piclist 2001\02\22\120606a >
Thread: PWM motor control
www.piclist.com/techref/microchip/ios.htm?key=motor
flavicon
face BY : Mike Mansheim email (remove spam text)



>What about if, say, the PWM 'setting' is 1000.  The 'actual' motor
>speed 900.
>Derived from a speed sensor of immaterial description)  Subtract the
>'actual' from the 'setting', and, if a negative result, add to the
>result to the PWM register, or if a positive result, subtract it from
>the PWM register.  (In either case, leave the 'setting' unchanged, and
>just add to the PWM register, so the next comparison will be made with
>the 'setting' figure, not the actual PWM register)
>So, in example, 1000 - 900 = 100. Add to PWM register, which becomes
>1100.  The motor speeds up, perhaps miraculously to 1000.  Then, at next
>comparison, 1000 minus 1000 = 0.  Add 0 to the PWM register and nothing
>changes, motor continues to run at 1000! Change the setting, or the
>motor changes, and it will compensate.

The simplest control system for something like this is:

if      (speed < desired speed) increase pwm output
else if (speed > desired speed) decrease pwm output

This will oscillate around the desired speed, which often is perfectly
acceptable.  How much it oscillates depends, among many other things, on
how much you change the pwm output each time.  In your example, you make
the change in pwm output "proportional" to the difference between the
actual speed and the desired speed, which can be a useful enhancement -
although it will still always oscillate around the desired speed.
But it is not a "classical" proportional control, where the pwm output
each time this calculation is done is a function *only* of the difference
between the speed and the desired speed, and has no "memory" - i.e. it is
completely unrelated to the previous pwm output.  The integral term is
what adds this memory.
A couple of practical notes if you use this approach:

- it can be useful to add a hysteresis term to create a window in which
 no change is made to the pwm.  e.g.:

 if      (speed < (desired speed - hysteresis)) increase pwm output
 else if (speed > (desired speed + hysteresis)) decrease pwm output

- I realize you were probably picking numbers out of the air for your
 example, but just in case, don't feed 1100 to a 10 bit pwm register.
 It will max out at 1023, if you've set the pwm frequency correctly
 relative to the clock; less otherwise.

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


<OF16186CB1.09787FC2-ON862569FB.0059F647@graco.com>

See also: www.piclist.com/techref/microchip/ios.htm?key=motor
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) PWM motor control

month overview.

new search...