Shop OBEX P1 Docs P2 Docs Learn Events
DC Motor Control — Parallax Forums

DC Motor Control

WhitWhit Posts: 4,191
edited 2007-05-13 11:25 in Robotics
Hi Guys,

What are my options using the BOE and BS2 to control a DC motor (forward, reverse and speed). The motor is from an 7.2 volt electric drill. I·like to run it a a lower voltage to slow it down (3.1 is fast and 1.5 is just right or should I do this with the motor control). Have been reading up on H bridges and was wondering whether to try to build one or buy something. Are there places to find examples of how to program the stamp to work with the H Bridge?· Can this motor control be done directly by the stamp? Any suggestions would be appreciated. This my first attemp at making a bot from scratch.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Whit+

Post Edited (Whit) : 4/5/2007 5:10:41 PM GMT

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-04-05 17:00
    Look at some of the motor controllers that Parallax sells: www.parallax.com/html_pages/products/motorcontrol/motor_control.asp. The Pololu unit looks about right for what you're doing. The Wikipedia has good information on H-Bridges. Do a websearch on "wiki h-bridge".

    The Parallax tutorials on Process Control and Robotics are also good starting places (www.parallax.com/html_pages/downloads/siccurriculum/documentation_sic_curriculum.asp).
  • WhitWhit Posts: 4,191
    edited 2007-04-05 17:04
    Thanks Mike! I had downloaded the info on the Pololu the other day. I thought it might work. I will try the wiki search and Parallax tutorials too.

    The learning curve is steep, but I am having so much fun and learning so much.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Whit+

    Post Edited (Whit) : 4/5/2007 5:10:09 PM GMT
  • edited 2007-04-06 05:15
    Hi Whit..

    My recommendation goes for the H-Bridge IC.... I am currently using the National Semiconductors LM18201 IC with great results... this is a single chip that can drive dc motors at up to 3 amps... the logic of the IC is adaptable... it has a "Brake Pin"... "Direction Pin" and "PWM Pin"... but.... it also has a feature that allows you to control the Speed and Direction with a single pin... for that to work you will have to drive this pin with a Pulse Width Modulated PWM type of signal.... so... a signal with a 50% duty cycle means no movement.. but variations of the dyte cycle percentage means movement in one direction or another (lets say 49% or less is forward and 51% or more is reverse) so.. the lower or the higher the Duty Cycle percentage goes.. the slower or faster the motor moves... it is important to mention that this pulse is not servo type of pulse.... you will have to play with your code in order to obtain the correct frecuency and duty cycles..... I love this feature because simplifies the connections, the number of microcontroller pins used for controlling the motors... and it also simplifies the code... I am using it to control a couple gearhead motors and in 50% duty cycle it actually serves as a brake... so... it looks like you can control speed, direction and braking with one pin.. neat...

    Another nice feature of the LM18201 is the fact that if you need to drive a motor over 3 amps... you can actually connect two or more in parallel to double or triple the Amp rating, but you need to follow certain simple rules in the PCB design, here is more info about this possibly less known feature of the LM18200/LM18201 IC:

    http://search.national.com/iphrase/query?query=lm18201 parallel

    If your power needs are above this... you should consider Parallax's HB-25, but I do not believe a 7.2 Drill Motor needs that much power, I am driving a pittman gearhead motor with a single LM18201 with no issues, and this motor is more power hungry than a drill motor... especially since I believe the 7.2 Volts drills are not that big at all.. ??


    ... also.. in its most simple configuration it actually requires only a ceramic capacitor for Vcc bypassing (very important) that's it.. no sense resistors, no charge pump capacitors and diodes (well, only if you are planning to switch the motor at frecuencies above 1Khz... but even then it is just a couple ceramic capacitors for the charge pump, no diodes required).... the LM18201 doesn't provide a easy way to measure Amps through a sense resistor... if you require this option you should use the LM18200 instead...

    I hope this helps.. Happy Roboting!!
  • WhitWhit Posts: 4,191
    edited 2007-04-06 13:22
    Thanks Joe "Bot" Red,

    Looks really good. Price is good too. I found a the data sheet pdf and have downloaded it and will read up on it some more.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Whit+

    Post Edited (Whit) : 4/6/2007 9:36:12 PM GMT
  • WhitWhit Posts: 4,191
    edited 2007-04-06 13:24
    Shoot-through protection is nice too!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Whit+
  • edited 2007-04-06 18:50
    ohh!!!... I just thought of some potential issue.... the minimum rated VCC voltage for the LM18201 is 12 Volts... and the internal resistance of this chip is around .33 Ohms (so the voltage drop on the IC itself is minimal) ... and your motors are rated at 7.5 volts, of course, I know a motor is an analog device, and you will be able to feed it with more than 7.5 Volts, but, to what extent?? 12 volts maybe?.. so I wonder about two things:

    1.- Is it possible to feed the LM18201 with less than 12 Volts?? the datasheet states a VCC range of 12 - 42 Volts

    2.- Will your motors survive a continuous voltage around 12 Volts?? of course, your code will be modulating the power fed to the motor through a PWM signal so your motors won't be getting full power all the time, but what if your code at some point provides continuous power at 12 Volts in one direction for a long period of time???.. will the motor go down in flames???

    Uhm... I am probably going to try to feed the LM12801 with less than 12 Vots and see what happens... I will let you know...
  • WhitWhit Posts: 4,191
    edited 2007-04-06 21:36
    Thanks Joe "Bot" Red. I had not seen that on the data sheet. I'm glad to know about this chip even if I can't use it now. It has so many great features.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Whit+
  • T ChapT Chap Posts: 4,223
    edited 2007-04-06 22:02
    It probably has undervoltage shutdown below 12V. What about some relays for direction and simple PWM and n channel mosfets? Rado shack parts would have it up and running in not time. You could make an external PWM circuit, ot buy any number of I2C ICs for PWMing LEDs that will allow the Stamp to set motor speed and not be bogged down with the PWM task.

    Post Edited (TChapman) : 4/8/2007 5:31:40 PM GMT
  • edited 2007-04-06 22:24
    TChapman... thanks for the info.... I read somehere online that VCC below 12 Volts will cause strange behavior of the LM18201.... hey Whit... what if you give it a try to running the motor at 12 volts directly????... if the drill was a 7.2 Volts type.... that means there is a certain tolerance for the motor, I wouldn't believe the motor can only run at 7.2 volts or below... I'll bet you that motor you have can easily run at 12 Volts.....
  • WhitWhit Posts: 4,191
    edited 2007-04-07 01:57
    TChapman and Joe "Bot" Red,

    Thanks for the great suggestions. I will do a little experimenting. I don't mind building or buying/trying 2 or 3 ideas. After all, I'm trying to learn what works well and how. Thanks for taking the time to respond.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Whit+
  • D FaustD Faust Posts: 608
    edited 2007-05-06 23:48
    I noticed that the pololu dual serial motor contoller says that it is contolled through a serial line. Does this mean that it requires on of the two serial pins on the stamp or will any I/O pin work? If it runs on a serial pin how would that work with the BOE?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    D Faust
  • LarryLarry Posts: 212
    edited 2007-05-07 00:15
    Any output pin will work. The serial is TTL

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • D FaustD Faust Posts: 608
    edited 2007-05-07 23:46
    Are there any alternatives to the Motor Mind B, Pololu Micro Motor contoller, and the HB-25 for contolling 1 amp motors up to 5 VDC? Can a motor be contolled by a BS2 using a digital to analog converter, a relay with 8 pins (two sets of threes and the coil), and a MOSFET? I mean this by sending a sending a signal to the converter and allowing it to control the MOSFET, while the relay controls the polarity of of the signal.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    D Faust
  • edited 2007-05-09 16:08
    Hey D Faust... question.... I see you mentioned "up to 5VDC" why is that limitation??... I mean... the LM18201 is very simple to use... and probably cheaper compared to a MOSFET + Relay + optoisolators idea.. just a thought... smile.gif the only limitation is that the LM18201 requires 12 VDC minimum... that is the reason of my original question about the 5 VDC
  • D FaustD Faust Posts: 608
    edited 2007-05-09 21:16
    Joe "Bot" Red,
    The reason that I said up to 5VDC is because I would like to buld a small robot about eight inches wide and I would like to use small motors. I would rather not have a large battery pack for this. Can 12 VDC be apllied to the logic and only 5 VDC for the motors themselves? Where can I get one of these? In case you were wonderind the kind of motor that I had in mind, it is the RE 260 Mabuchi motor with a gear box. Thanks for the advice, even if it doesn't work woith this project it might work on future ones.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    D Faust
  • AA Posts: 22
    edited 2007-05-10 16:12
    Another way is similiar to what you mentioned but with no relays.· two NPN power tansistors and two matched PNP transistors can make your H-bridge.· You can pick the transistors based on your power requiremnts.· A serial DAC and some opamps can give you programmable PWM.· THe opamps make a square wave and integrate it to get a triangle wave.· The voltage from the DAC and the trianlge wave are fed into a comparator.· THis gives speed control from the stamp and uses three pins.· A set of comparators·can be used with one pin from the stamp to control direction.· The comparators controll what power transistors are on.· I·attached some schematics.· This is for a smaller dc motor at·9.6V the particular transistors can handle 7 amps.
    580 x 403 - 37K
    580 x 325 - 22K
  • D FaustD Faust Posts: 608
    edited 2007-05-10 21:16
    Thanks for the suggestion, I will keep it in mind, but I would like to stick with something a little simpler especially because I want to do this with two motors. This seems to be a little·over my head. What is so bad about a relay? Also, how do you make schematics? Is there special software?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    D Faust
  • LSBLSB Posts: 175
    edited 2007-05-10 23:26
    I'm sure there are forum members tired of hearing my favorite answer... the SN774410 (or L293). It’s a “quad driver” chip that accepts 4.5 - 36 volts in and drives two 600 mA motors forward and reverse without any additional components. If you need more amps... drive each motor with a separate chip (1 amp per motor) or “piggyback” one chip on top another (2 amps per motor). They’re small (16P DIP), easy to wire, and have thermal and diode protection built in (verify on the datasheet). You can drive both motors with 6 outputs, or at a $.40 cent inverter chip and use only 4 pins (1 DIR, 1 PWM/ motor).

    PWM is a trial for the stamp, but PWMPAL (easier to interface) or “A’s” answer may be suitable to your needs and skill level.

    For the platform you describe, I’d use 6V to drive the H-bridges, regulated to 5V for the Stamp—should motor over flat carpet and bare floor at satisfactory speeds driven by one chip powering each motor. Total cost, around $50—including PWMPAL. Rock solid answer at a reasonable price. If you ever want to upgrade, soldier a second chip over the first, connect a 12V battery, and chase cats up trees...
  • D FaustD Faust Posts: 608
    edited 2007-05-11 01:28
    Why would you have to use a DAC when the stamp has a PWM command that can generate an analog voltage by pulsing on and off? (see:·[url=Why would you have to use a DAC when the stamp has a PWM command that can generate an analog voltage by pulsing on and off (see: http://www.parallax.com/dl/docs/prod/stamps/web-BSM-v2.2.pdf )]Stamp manual·[/url])

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    D Faust
  • edited 2007-05-11 17:13
    Hey D Faust... I see your interest on relays.... so.. I played before with H-Bridge type Relays, this one in particular:

    http://www.mouser.com/search/ProductDetail.aspx?R=EN2-1N1Svirtualkey55100000virtualkey551-EN2-1N1S
    It is cheap.. but it requires around 95 miliamps and around 12 volts to excite the coil..... the good thing about it is that you only require one relay per motor, and only one control signal per motor (of course... in order to stop the motor you will need to control power to it, probably with another simple relay... just an idea...

    About the LMD18201 .... I actually obtained a couple samples directly from National Semiconductors ( at no cost at all... they are so kind they even pay for the shipment smile.gif of course, you will need a company email account in order to be able to request samples, personal accounts like hotmail or yahoo are not valid... feel free to IM me if you need more details... or anybody who is reading this smile.gif ( is that Whit requesting
    samples??? smile.gif

    I hope this helps....
  • AA Posts: 22
    edited 2007-05-11 17:52
    I use the dac so that the PWM can be set and left.· This releives the stamp from having to constantly refresh the voltage when using pulse out.· More time to do other things in the code.· Relays are not so bad but in general they where out, are bulky, and not very fast. The particular DAC I'm using is a Maxim522 (i think) it could be used to drive another PWM circuit allowing for controlling two motors.· I draw my schematics several ways,· Pspice(free), Visio,Autocad,PCBExpress(also free)
  • D FaustD Faust Posts: 608
    edited 2007-05-13 11:25
    I thought about using the PWM command to control a MOSFET which can then control the power to the motor, and then a relay to control the direction of the power. Would this work? How about an optoisolator instead of a relay. Do they do the same thing? Thanks!!!!! (especially for the advice on how to make schematics, I will try to post one of my idea soon.)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    D Faust
Sign In or Register to comment.