Shop OBEX P1 Docs P2 Docs Learn Events
Motor speed control with PWMPAL — Parallax Forums

Motor speed control with PWMPAL

Reagent XReagent X Posts: 9
edited 2010-10-23 18:31 in BASIC Stamp
Hi,

I am using a BS2pe and a PWMPAL to control a 12VDC gearmotor (http://www.jameco.com/webapp/wcs/stores/servlet/Product_10001_10001_155821_-1?CID=PDF). My goal is to control the speed over as wide a range of RPM's as possible. I have the motor working, and I am using the output of the PWMPAL to control the "enable" input of an L293D motor controller (H-bridge IC).

I am wondering how to optimize the ability to lower the speed as much as possible, while avoiding risk of stalling the motor or otherwise jerky or unreproducible performance. Currently, I can lower the speed to about 40% of max, but not any lower. I am using the same code as in the PWMPAL docs. The motor makes humming noises, but the shaft doesn’t turn. Seems I should be able to go down lower, like to 25% as in the PWMPAL documentation. Any suggestions on how I can get a bigger range of speeds? Thanks!

-Ron
East Bay, CA

Edit: oops - I meant L293d. corrected above.

Comments

  • Reagent XReagent X Posts: 9
    edited 2010-10-21 00:03
    I found this example for controlling the speed of a small fan using PWM: http://pcbheaven.com/circuitpages/PWM_Fan_controller_using_a_555/

    Looks intriguing and quite simple. Can anyone please point me toward so more examples to get a wide range of speeds out of a DC motor? There is so much information about motor control, but I can't find any guidance on what kind of dynamic range one can expect or how to go about optimizing a circuit. Anyone have any ideas?
  • CampeckCampeck Posts: 111
    edited 2010-10-21 08:45
    I used the BS2 to control a digipot(ad5220) which controlled the duty cycle of a 555. however by changing the duty cycle the frequency would also change. This circuit here solves that.

    Change R2 to 1k
    make R5 a digipot controlled by the BS2, and make R4 and R6 adjustable to dial in 0-100% PWM
    Feed the output of the 339 into the enable of the motor driver. (you can ditch the transistor and LED) Keep the 10k pullup though.

    attachment.php?attachmentid=74592&d=1287675930
  • ercoerco Posts: 20,256
    edited 2010-10-21 09:32
    I've experimented with many speed controllers (incl the L293) and many robots, and the best one is on my Heathkit Hero 2000 robot. Torquey & slow, a stump puller, very good for slow cautious navigation on that ~70-lb robot.

    Many speed controls have the dreaded "dead zone" you mention: when the motor is hopelessly, torquelessly stalled at an intermediate speed. That's no better performance than you can get with a 1930's rheostat. With PWM, you should have full control down to zero speed. I don't understand what passes for motor controllers these days. Most show a sizeable voltage drop. And personally I think their multi-kHz pulse rate is too high by a factor of 500.

    One of my very first electronics projects WAY back in 1983 was a homegrown motor speed controller using a 556 dual timer. Forest Mimms' yellow Radio Shack book saved me there. It worked great, sending slow (~4-5 hz) PWM signals to a transistor switch. I could dial the speed down to zero, it would rotate a small toy motor about 1/8 turn per pulse with 100% torque. It looked like a stepper motor; you could easily see the motor shaft turning forcefully in small steps. I'll try to dig that up and post a circuit.

    You can experiment on your own with a Stamp, a switching transistor, and your motor. Send a string a pulses to the transistor at various frequencies and duty cycles to see what works. Simple code: "high, pause, low, pause, loop" kind of code. Within 10 minutes, you'll achieve better results than your PWMPAL and L293 can deliver. Once you find your preferred frequency, you could make a 556 circuit controlled by a digipot to PWM your motor.
  • CampeckCampeck Posts: 111
    edited 2010-10-21 10:25
    erco wrote: »
    you could make a 556 circuit controlled by a digipot to PWM your motor.

    Which I also have a schematic for here.
    Change R1 to 2.2k or you will burn the pot up.
    change the digipot to a 100k version
    and change the timing cap to .01uF

    that should net around 2-98%
    also this circuit will suffer from frequency change. I also couldn't use this circuit with the parallax PING sensor because as I changed speed there was harmonic noise coming from somewhere that would change with duty cycle because the hz was changing also. And it would cause the PING to false detect.

    The cool thing about the first circuit I posted is it's frequency stability and 0-100% duty cycle and one 555 for multiple channels. 4 channels of PWM with the LM339 (or CMOS version)


    attachment.php?attachmentid=74603&stc=1&d=1287681919
    973 x 708 - 36K
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-10-22 17:17
    I used the attached program when I demo'd it --
    http://www.youtube.com/watch?v=GcWttdSQ-jM

    That's a pretty cool little motor and it performs the same with both a 2N3904 (npn) and a 2N7000 (mos).
  • Reagent XReagent X Posts: 9
    edited 2010-10-22 20:20
    Thanks for the help folks!

    I was reading some basic info on motor speed control in the book "Practical Electronics for Inventors" by Paul Scherz. In the book they say that motors tend to stall when they applied voltage drops to about 50% of the specified operating voltage. They also say you can safely run a motor at a voltage about 30% higher than the operating voltage.

    This seems to support my observation that my motor stalls when the duty cycle of my PWM signal drops below 40%.

    Here's a question: what advantage do these other circuits have over the PWMPAL? The PWMPAL may not be the cheapest solution, but isn't the output signal as good as you can get? Shouldn't it be flexible to meet my needs?
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-10-22 20:38
    I wasn't making a case against it. Party on. Seen the HB-25? That's a solid way to go.
  • Reagent XReagent X Posts: 9
    edited 2010-10-23 18:31
    This guy talks about how it is hard to drive a gearmotor below about a 50% duty cycle, due to the internal inertia. He suggests using a power supply at a higher voltage than the rated voltage to get extra range in the speed.

    http://www.robotroom.com/PWM5.html
Sign In or Register to comment.