Shop OBEX P1 Docs P2 Docs Learn Events
PWM for motor speed control — Parallax Forums

PWM for motor speed control

BaldyBaldy Posts: 3
edited 2006-06-28 21:23 in Propeller 1
I am new to Parallax products so have no previous knowledge of basic stamp·techniques let alone propeller ones! I think propeller would suit the application I have in mind which is to vary the speed of a motor using a fixed frequency PWM signal and varying·duty cycles, the speed·being determined by a varied analogue input voltage.·I know a lot of products would do that very easily but I want to alter the relationship between the input voltage and the output pulse in many ways and determined by other analogue inputs and switches. This relationship will need·floating point arithmatic.
Problem is I am stumbling at the first hurdle as I can't see the way to generate the PWM pulses I need, can anyone point me in the right direction please?

Comments

  • SawmillerSawmiller Posts: 276
    edited 2006-06-28 20:01
    the chapter 4 spin referance talks about using the cogs counters to do a PWM signal, also in the objects that you can download there is a BS2 object that mimics the basic stamps pwm command...
    dan
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2006-06-28 20:33
    As pure hardware peripherals, the counters are probably too fast to use for motor PWM control. The reason is that you would need to use the duty cycle output to drive the gate of a MOSFET which, in turn would drive the motor winding. But MOSFET gates have high capacitance and, driven at very high frequencies, will spend most of their time in the linear region, causing them to overheat. Because of the motor windings' inductance, you don't need such high-speed switching for smooth current flow.

    Now, having said that, it's possible to use a combined hardware/software approach with the counters' NCO mode and switching frequencies between the high and low output states. That way you can get nearly any combination of frequency and duty cycle you want — even current regulation via comparator feedback. But, so far as I can tell from the scant information I have, software intervention would be required.

    -Phil
  • BaldyBaldy Posts: 3
    edited 2006-06-28 20:41
    Hi Sawmiller,

    Thanks for the quick response, I did see both of those items. I don't know enough about BS2 to know if the object would do what I want, I will ckeck out the BS2 PWM command and see if it will work for me. It would be nice to try to code it myself but the biggest problem I have is that even though the reference says that the counters can be used for PWM it doesn't go into any detail about how to about it.
  • edited 2006-06-28 20:43
    Here is a·pwm object and·example program·that generates 4 pwm signals ranging from 10 kHz to 40 kHz.· Two signals are held at 50% while the other two are swept in opposite directions.· One·sweeps from 0 to 100% as the other sweeps from 100 to 0%.

    The pwm.spin object·has more horsepower than is strictly necessary for motor PWM.· While the test program specifies the duty cycles in·terms·of percent,·signal high and cycle times can actually be specified in terms of clock ticks.··A motor pwm object will likely appear that sends multiple PWM signals with a single cog (as opposed to the 1 pwm per cog that this one does).

    <<<Note, the file that was attached to this post turned out to be an interim·archive that only worked up to a point.· The link now points to a file attached a couple posts down, and that·example program and object work as advertised>>>


    Post Edited (Andy Lindsay (Parallax)) : 6/28/2006 9:50:03 PM GMT
  • BaldyBaldy Posts: 3
    edited 2006-06-28 21:10
    Andy,

    Thanks, I will have a good look at those objects and try to get my head around it.
  • edited 2006-06-28 21:23
    Aach!!!

    Sorry, that was an old version I posted.·

    Attached is the one that works as advertized.

    Post Edited (Andy Lindsay (Parallax)) : 6/28/2006 9:47:20 PM GMT
Sign In or Register to comment.