Author Topic: Motor control: Servo vs H-Bridge overview L293D, Orangutan, PWM  (Read 8252 times)

0 Members and 1 Guest are viewing this topic.

Offline WebbotTopic starter

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
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 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.


Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline brijesh

  • Full Member
  • ***
  • Posts: 55
  • Helpful? 0
Re: Motor control: Servo vs H-Bridge overview L293D, Orangutan, PWM
« Reply #1 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.


Offline Ro-Bot-X

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,431
  • Helpful? 25
  • Store: RoBotXDesigns.ca
    • Ro-Bot-X Designs
Re: Motor control: Servo vs H-Bridge overview L293D, Orangutan, PWM
« Reply #2 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)...
Check out the uBotino robot controller!

Offline WebbotTopic starter

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: Motor control: Servo vs H-Bridge overview L293D, Orangutan, PWM
« Reply #3 on: April 08, 2008, 06:02:25 AM »
Thanks for the comments.
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Motor control: Servo vs H-Bridge overview L293D, Orangutan, PWM
« Reply #4 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.

Offline bens

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 335
  • Helpful? 3
Re: Motor control: Servo vs H-Bridge overview L293D, Orangutan, PWM
« Reply #5 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 were designed to be pin-compatible with the original Orangutan 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 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

Offline ALZ

  • Full Member
  • ***
  • Posts: 75
  • Helpful? 1
Re: Motor control: Servo vs H-Bridge overview L293D, Orangutan, PWM
« Reply #6 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.

Offline WebbotTopic starter

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: Motor control: Servo vs H-Bridge overview L293D, Orangutan, PWM
« Reply #7 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?

  • Well the 9 pin single in line package does all of the H-Bridge and PWM stuff for you and one package controls two motors (at 1 Amp each) or 1 motor (at 2 amps).
  • The pin outs are great for breadboarding as you can use a standard servo 3 lead wire to provide ground, +5v, and serial in
  • This also means that if you have more than 2 motors you can very easily use stripboard to connect all of the common pins like: motor supply, ground, logic supply, reset, serial in so the only differences per chip are the motor output pins
  • Incredibly easy solution for any number of motors from 1 to around 60 all via one serial transmit (UART)
  • Small footprint for an H-Bridge controlling 2 motors
  • Leaves other microcontroller PWM pins available
  • Doesn't eat into all of the precious pins on your standard DIP processor package
  • Physical size is smaller than you could make an H-Bridge from discrete components
  • Works with - and auto-senses - a large range of baud rates

So whats the downside?
  • Cost? I say '?' because its simplicity, small footprint, easy of scalability may well offset this for beginners with 2 motors or for folk wanting to control lots'a motors
  • It requires one UART - so if your mcu only has one - then kiss goodbye to serial LCDs etc. But since each packet sent to the chips specifies which device it is for then it would be interesting to write something to strip out these packets and for other device types to act as normal. ie its potentially possible to multiplex the UART so that each packet says what kind'a device the output should go to. Alternatively there are other posts on the forum to simulate a UART on a standard I/O pin
  • Latency? To set the speed of a motor you have to send a serial command - which takes time - even at 19200 baud. May not be a problem as motors have other physical latencies anyway

Anyone else want to share any experience of using this Pololu Dual Serial Controller.
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline WebbotTopic starter

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: Motor control: Servo vs H-Bridge overview L293D, Orangutan, PWM
« Reply #8 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?
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline brijesh

  • Full Member
  • ***
  • Posts: 55
  • Helpful? 0
Re: Motor control: Servo vs H-Bridge overview L293D, Orangutan, PWM
« Reply #9 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.

 


Get Your Ad Here

data_list