Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: Webbot on April 05, 2008, 08:57:47 PM

Title: Motor control: Servo vs H-Bridge overview L293D, Orangutan, PWM
Post by: Webbot on April 05, 2008, 08:57:47 PM
I'm going to repeat some stuff covered by various other posts over a long period. Sorry 'bout this but was hard to find a relevant 'starting post' and I guess this more to do with 'thinking aloud' rather than I cry for help.


I'm trying to come up with a good motor driver guide for general low voltage servos or DC motors eg from Tamiya and their dual geabox.

Servo:- Admin has given lots of code examples for the $50 robot onwards. But my preference, I now think, would be to use the PWM solution http://www.societyofrobots.com/robotforum/index.php?topic=1827.msg12082#msg12082 (http://www.societyofrobots.com/robotforum/index.php?topic=1827.msg12082#msg12082) as this all goes on in the background and doesn't rely on timing of your main loop. Adding interrupt driven timers for delays/compares also seems to make sense - ie 'I am a sonar so only resample every 100ms to prevent ghost echoes'. So with an ATMega8 then we can only control 2 motors this way. (NB additional motors/servos can stlll be controlled directly via the OUT port as per admin $50 robot).


DC motor:- So you now require some kind of H-Bridge to control the motor. My two thoughts are:-
1) L293D - cost about $5. A 16pin package that allows Left/Right/Forwards/Stop. Needs 3xpins from the mcu per motor. Probably (?) also needs some of these pins to come via PWM to control the speed info so that its not just full fwd/reverse etc. Given that the ATMega8 has limited pins then this seems like a good answer if you only have 2 motors.

2) something like the Pololu Dual Serial Motor Controller - approx $35. This allows you to daisy chain lots of 'them' together and control approx a max of 60 motors (each with a speed of 0 to 127 in forward or backward mode) via one serial line. Previous posts (including from Admin) have said that the problem is that it uses, for the ATMega8, the one-and-only precious serial port. So no more talking to LCDs/Hyperterminal etc. However, if you are trying to control a biped with umpteen degrees of freedom then the fact you can control 60ish motors over one serial line may be a bonus. It does all the PWM stuff for you.


Have also looked at creating an H Bridge from discrete components - which is fine and you can find links from Wikipedia - but, unless you are going to make many of them, then the cost appears higher than examples above.

Finallly - some of the Orangutan boards seem like good value for money (not a plug). Given they are based on Atmel AVR chips - with an ISP programmer, a two motor HBridge, ATMega 168, various switches/LEDS/Pots for £16 (say $30). May well be a good intro for newbies - as they could make stuff with no (?) soldering.

As mentioned at the start. This is 'brain in progress'. So any thoughts/comments/criticisms and particularly alternatives are welcome.


Title: Re: Motor control: Servo vs H-Bridge overview L293D, Orangutan, PWM
Post by: brijesh on April 07, 2008, 10:04:56 PM
Needs 3xpins from the mcu per motor. Probably (?) also needs some of these pins to come via PWM to control the speed info so that its not just full fwd/reverse etc. Given that the ATMega8 has limited pins then this seems like a good answer if you only have 2 motors.


If you use Locked Antiphase mode to drive the H-Bridge then you can control a motor with just 1 pin. One pin for both direction and speed.

Here is more info
http://www.barello.net/Papers/Motion_Control/index.htm

I am using Baby Orangutan Board, they are good. But I do have one gripe about them. The kind of H-bridge they have on the board forces one to use 3 interrupts and software control to do PWM on 2 motors, ie. one is unable to use the built in PWM feature of the ATMega chips.

Title: Re: Motor control: Servo vs H-Bridge overview L293D, Orangutan, PWM
Post by: Ro-Bot-X on April 08, 2008, 12:43:23 AM
I agree with brijesh. I have looked at Orangutans and liked the features but not the implementation. I would have made the board different. Perhaps other people would have made it different than mine, so a configurable board would have been perfect. I was even thinking at how I would use a ATmega168, add some H-bridges, a LCD, etc. and made it user configurable by the use of jumpers. Maybe not wire jumpers but small dip switches. Having all parts SMD form would even make the board smaller. There are many things that may be user configurable, for instance the use of the LCD or the use of the H-bridge. But in the end I migrated for a modular way, some sort of Lego like building style, where you just plug in different modules in whatever configuration you need them. This sort of building makes things easier for the user that is not electronically inclined, but takes away the (mostly pain...) joy of building everything by your hands. I am still experimenting (I don't have the time to do it fast)...
Title: Re: Motor control: Servo vs H-Bridge overview L293D, Orangutan, PWM
Post by: Webbot on April 08, 2008, 06:02:25 AM
Thanks for the comments.
Title: Re: Motor control: Servo vs H-Bridge overview L293D, Orangutan, PWM
Post by: Admin on April 14, 2008, 06:42:08 PM
After a quick glance through the datasheet, it appears the ATmega8 can only do up to four PWM channels, so that will limit you to using just four servos. If you need the timers for something else, then thats even fewer.

Anyway, AVRlib has pwm software thats really easy to use. Just add the header files and call the correct functions, and its all done for you.
Title: Re: Motor control: Servo vs H-Bridge overview L293D, Orangutan, PWM
Post by: bens on May 16, 2008, 03:16:04 AM
I am using Baby Orangutan Board, they are good. But I do have one gripe about them. The kind of H-bridge they have on the board forces one to use 3 interrupts and software control to do PWM on 2 motors, ie. one is unable to use the built in PWM feature of the ATMega chips.

As a brief explanation, the original Baby Orangutans (http://www.pololu.com/catalog/product/216) were designed to be pin-compatible with the original Orangutan (http://www.pololu.com/catalog/product/125) robot controller, which initially featured an ATmega8.  The microcontroller was replaced with an ATmega48/168, but no revision was made to the board to take advantage of the extra PWMs the new AVRs offered.  The new Baby Orangutan B (http://www.pololu.com/catalog/product/1216) robot controllers use the four 8-bit PWM outputs for motor control (timer0 PWMs control motor 1 and timer2 PWMs control motor 2), making motor control much simpler.

- Ben
Title: Re: Motor control: Servo vs H-Bridge overview L293D, Orangutan, PWM
Post by: ALZ on May 17, 2008, 02:06:01 AM
Since you can get a "VEX" Transmitter and Receiver on Ebay for less than $20 that is what I have been working with. I have programmed a PIC "P16F887" to decode the pulses from the receiver so that the PIC  uses 3 pins per motor output (2 for forward, backward and one for PWM). The PIC can control up to 8 motors and 1 high low output.  The VEX  Transmitter has 6 channels ( 4 chs for the two joysticks and 2 chs for the 4 buttons). I use two buttons to control 1 joystick so that it can control 6 motors. I used the other 2 buttons to lock in the high low output. The PIC can also take a 3 byte command from another PIC or CPU to control the motors. I built 3 H-Bridges from MosFet and relays.  I did the first real test today and the bridge diodes got too hot. I put them on a heat sink and have to test again. So their are low cost ways to build things that could cost many hundreds of dollars to buy.
Title: Re: Motor control: Servo vs H-Bridge overview L293D, Orangutan, PWM
Post by: Webbot on May 19, 2008, 01:50:15 PM
My initial post mentioned
Quote
something like the Pololu Dual Serial Motor Controller

I've now got this working in my C++ library and it will be in the next release of my C++ library in the member forums - but thought I'd just talk about my experiences.

It took me a couple of minutes to get this going by using a breadboard and a Tamiya dual gearbox with dc motors.

What are the benefits?


So whats the downside?

Anyone else want to share any experience of using this Pololu Dual Serial Controller.
Title: Re: Motor control: Servo vs H-Bridge overview L293D, Orangutan, PWM
Post by: Webbot on May 26, 2008, 08:12:26 AM
If you use Locked Antiphase mode to drive the H-Bridge then you can control a motor with just 1 pin. One pin for both direction and speed.

Here is more info
http://www.barello.net/Papers/Motion_Control/index.htm


From the article then 'enable' is always turned on and we can control both sides of the L293D bridge from 1 PWM line.

I assume that this will mean that the PWM will need to connect to Input 1 and then via a logic invertor to Input 2. Is this correct - ie that I will need to add the invertor?
Title: Re: Motor control: Servo vs H-Bridge overview L293D, Orangutan, PWM
Post by: brijesh on May 26, 2008, 12:14:33 PM

From the article then 'enable' is always turned on and we can control both sides of the L293D bridge from 1 PWM line.

I assume that this will mean that the PWM will need to connect to Input 1 and then via a logic invertor to Input 2. Is this correct - ie that I will need to add the invertor?

Yes, you will need the inverter.