Searching \ for '[PIC] PWM motor control' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/ios.htm?key=motor
Search entire site for: 'PWM motor control'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] PWM motor control'
2001\02\19@064158 by brah

flavicon
face
       Has anyone done anything with "hunting" I think the term is.

       Say I have a variable control number (adjustable externally) 24 bits or
so, which represents the "RPM" I want a PWM controlled motor to run at.
       The motor has a variable load (uncontrolled) which changes the RPM of
the motor due to loading.
       I pick up some pulses off the motor shaft, and compare the period with
my control number. (Fiddling with period scales to get numbers in the
same ball park!)
       So, how do I change the PWM value so the motor "hunts" up or down until
the control number and the motor period number match.
       The motor is very slow revving - 10 to 200 RPM (it's actually an
electric PWM valve over a hydraulic motor)  so the time taken to get a
period number off the shaft is quite long, which means that several
turns might be necessary before a match can be made, making the "hunt"
time long too - perhaps too long.
       One thought I had was to determine if the motor period number was more
or less than the control number - flag which way (more or less) - add or
subtract (depending on the flag) a large number to the PWM - wait and
get a motor period number and see it the additon or subtraction drove
the motor "past" the match point by comparing with the flag.  If not
past, then add or subtract the same large number again, wait and get a
new period number etc. When the motor period number goes "past" the
match, subtract or add a smaller number and repeat till it matches.
       Sort of like a sorting routine.  Trouble is the darn motor might have
the indecency to change RPM itself due to loading, after my gadget has
decided which way to force the motor, and it's already done so.
(Hmmmm... not too sure of the ramifications here, but it's sure to be
bothersome.)
       Anyone done something like this?  Admittedly the actual thing will be
more complex, but I have an F876 controlling the motor directly with PWM
now, just that there's no feedback from the motor.

Regards to all
Howard.

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spam_OUTlistservTakeThisOuTspammitvma.mit.edu with SET PICList DIGEST in the body


2001\02\19@074301 by Mark Hull

flavicon
face
It seems like you're talking about a PID control application.
Look at  http://www.piclist.com/techref/io/motors.htm, scroll down to PID, and look at the links, or look at  http://www.jkerr.com for complete solutions, or look at Microchip's app notes "Intelligent remote positioner" runs on a 16C54 !

Good luck
Mark

-------------------------------------------------------------------
Mark Hull
Engineering/Technical
EMS (Africa) (Pty) Ltd
PO Box 1026, Melville, 2109, South Africa
Ph +27 11 482 4470 Fax +27 11 726 2552

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email .....listservKILLspamspam@spam@mitvma.mit.edu with SET PICList DIGEST in the body


2001\02\19@093446 by Mark Hull

flavicon
face
Hi Howard

Sorry, the earlier message was a bit brief.
Basically PID is a control 'filter' , which helps you get to a goal setpoint as fast as possible without overshoot or oscillation. The technique is siple realy:
1. Find the 'error' ie the difference between where the system is, and where it needs to be.
Multipl this error by a gain value known as Kp. This is the proportional component of the output.
2. Find the difference between the last error and the current error and multiply by another gain known as Kd.
This is the differential component of the output. It is responsible for accelerating the motor if the error is large.
3. Find the running average of errors, and multiply by another gain value known as Ki. This term is responsible for damping the system to prevent overshoot and oscillation.
4. Add the proportional, differential and integral terms together and scale the result down to 255 max, and use this value as a PWM value.

The algorithim gives more power to the motor when it's further from the target, and less power when it's close to the target.

By choosing the Kp, Kd and Ki terms properly you can 'tune' the filter to respond smoothly and rapidly to any position demand without overshooting.

The tutorials on the piclist page should help explain the tuning.

Cheers
Mark


-------------------------------------------------------------------
Mark Hull
Engineering/Technical
EMS (Africa) (Pty) Ltd
PO Box 1026, Melville, 2109, South Africa
Ph +27 11 482 4470 Fax +27 11 726 2552

   {Original Message removed}

2001\02\20@035429 by JP.BROWN

flavicon
face
Thank's Mark for your description of a PID controller, I have been looking
for years for a good verbal description of this function. The descriptions
I have seen in text books have all left me clueless but I always suspected
that there wasn't too much to it if only someone could explain it clearly.

Cheers John

         -----  John P. Brown      J.P.BrownspamKILLspambradford.ac.uk ----
          \            --- Witty remark goes here ---         /
           --------------------------------------------------

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam.....mitvma.mit.edu


2001\02\20@073523 by Michael Rigby-Jones

flavicon
face
> -----Original Message-----
> From: JP.BROWN [SMTP:EraseMEJ.P.Brownspam_OUTspamTakeThisOuTBRADFORD.AC.UK]
> Sent: Tuesday, February 20, 2001 9:03 AM
> To:   PICLISTspamspam_OUTMITVMA.MIT.EDU
> Subject:      Re: [PIC] PWM motor control
>
> Thank's Mark for your description of a PID controller, I have been looking
> for years for a good verbal description of this function. The descriptions
> I have seen in text books have all left me clueless but I always suspected
> that there wasn't too much to it if only someone could explain it clearly.
>
> Cheers John
>
>           -----  John P. Brown      @spam@J.P.BrownKILLspamspambradford.ac.uk ----
>            \            --- Witty remark goes here ---         /
>             --------------------------------------------------
>
The PID controller may be relatively simple in concept, but actually coding
one and optimising the loop parameters for the best control loop response
can be pretty tricky.  There are all sorts of "Rules of thumb" and the
control system can be modeled to get theoretical values, but (IMHO) at the
end of the day tweaking the values to get the desired response from the
system is the only way to get good results, and it can be very time
consuming.

Mike

--
http://www.piclist.com hint: To leave the PICList
KILLspampiclist-unsubscribe-requestKILLspamspammitvma.mit.edu


2001\02\20@080433 by Bob Ammerman

picon face
> The PID controller may be relatively simple in concept, but actually
coding
> one and optimising the loop parameters for the best control loop response
> can be pretty tricky.  There are all sorts of "Rules of thumb" and the
> control system can be modeled to get theoretical values, but (IMHO) at the
> end of the day tweaking the values to get the desired response from the
> system is the only way to get good results, and it can be very time
> consuming.
>
> Mike

And if you really want a challenge, try creating a 'self-tuning' PID
controller. Such an algorithm adjusts its own tuning (ie: coefficients)
based on the observed response of the system over time.

And life gets messier the more non-linear the response of the controlled
device to the control signal.

Generally one tries to tune a PID controller for the fastest possible
response without appreciable overshoot.  But, like Mike says, this can be
quite difficult.

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu


2001\02\20@103002 by JP.BROWN

flavicon
face
Just as an aside I guess that the humble r/c servo has PID controller
inside it?, it behaves like one, it moves fast if the distance to travel
is long and slow it the distance is short also they never overshoot
(or not the ones I have seen).

--- John

On Tue, 20 Feb 2001, Bob Ammerman wrote:

{Quote hidden}

         -----  John P. Brown      TakeThisOuTJ.P.BrownEraseMEspamspam_OUTbradford.ac.uk ----
          \            --- Witty remark goes here ---         /
           --------------------------------------------------

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestspamTakeThisOuTmitvma.mit.edu


2001\02\20@105322 by Ed Koffeman

flavicon
face
> Just as an aside I guess that the humble r/c servo has PID controller
> inside it?, it behaves like one, it moves fast if the distance to travel
> is long and slow it the distance is short also they never overshoot
> (or not the ones I have seen).

I think the cheap ones are just P because if you force them off of the desired position, the force stays the same over time.

Some of the expensive analog ones might be PID, but I've seen them overshoot a lot (I think they tune them to get good specs for
initial travel, on paper, at the cost of accuracy). JR was advertising tight (at least PI) servos that I think were analog.

The newer digital ($100+) ones hopefully do full PID, but I don't have any of those.

Ed Koffeman

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestEraseMEspam.....mitvma.mit.edu


2001\02\20@120113 by Roman Black

flavicon
face
Bob Ammerman wrote:
{Quote hidden}

Interesting that I had never heard the term PID until
seeing it on this piclist. About 20 years ago I did
industrial electronics training, some very large
closed loop DC motors and generally a lot of analogue
systems. I remember whole bays full of plug-in circuit
boards each with maybe 5 to 10 transistors on a board
about 6x4 inches. Talk about low-density hardware!!

Basically in closed loop training we learned two simple
"rules of thumb"

1. Negative feedback;
* too much causes hunting and instability
* too little makes it too slow to respond to change

2. Damping;
* too much causes slow to respond plus slows hunting
* too little causes too fast to respond plus speeds
hunting

(obviously these are over simplified)
A lot of the analogue equipment we saw actually had two
trimpots, one for neg feedback and one for damping.
Actually having the motor in front of you and turning
the trimpots was a good lesson.

In the years since I have designed and built a number
of high perf closed loop systems and they have all
worked very well just understanding the two main
factors. After reading the simple PID example it
seems like using a lot of math for something a
transistor can do... :o)

So, for the PID experts, do you really need divide/
mult math to get this performance or can you use
other simpler software means to do this?? Don't you
just need to check how far it is from the correct value
and adjust the rate of change, etc, to suit?
ie; bigger error = more power to change, smaller
error = less power to change? I've successfully done
this in numerous ways using hardware and software
and never needed a 24bit divide...
-Roman

--
http://www.piclist.com hint: To leave the PICList
EraseMEpiclist-unsubscribe-requestspammitvma.mit.edu


2001\02\20@121808 by Bob Ammerman

picon face
> Interesting that I had never heard the term PID until
> seeing it on this piclist. About 20 years ago I did
> industrial electronics training, some very large
> closed loop DC motors and generally a lot of analogue
> systems. I remember whole bays full of plug-in circuit
> boards each with maybe 5 to 10 transistors on a board
> about 6x4 inches. Talk about low-density hardware!!
>
> Basically in closed loop training we learned two simple
> "rules of thumb"
>
> 1. Negative feedback;
> * too much causes hunting and instability
> * too little makes it too slow to respond to change

This would be 'proportional control'

> 2. Damping;
> * too much causes slow to respond plus slows hunting
> * too little causes too fast to respond plus speeds
> hunting

This is 'integral' control

{Quote hidden}

Again, this is basically P (proportional) control

>I've successfully done
> this in numerous ways using hardware and software
> and never needed a 24bit divide...
> -Roman


Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestEraseMEspamEraseMEmitvma.mit.edu


2001\02\20@132924 by Simon Nield

flavicon
face
roman:
>error = less power to change? I've successfully done
>this in numerous ways using hardware and software
>and never needed a 24bit divide...

Multiplication is handy for a control system as it lets you tweak the coefficients. You could just
have hard coded multipliers of course and just add.
Can't see why you would need a divide though... the PID controller code I have doesn't use a divide
at all (that I remember) unless you count the staturated shift at the end, which I guess is a kind
of divide by 2^something.

error = wanted - actual

diff = error - old_error

if (drive not saturated){
 integral += error
 }

old_error = error

p = kp * error
i = ki * integral
d = kd * diff

drive = (saturated ls bits of) (p+i+d)


For the applications I have put it too I have generally found the integral term to be of little
use... depends on what you are doing of course.


Regards,
Simon

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestspam_OUTspamKILLspammitvma.mit.edu


2001\02\21@025220 by Michael Rigby-Jones

flavicon
face
> -----Original Message-----
> From: Roman Black [SMTP:RemoveMEfastvidTakeThisOuTspamspamEZY.NET.AU]
> Sent: Tuesday, February 20, 2001 5:03 PM
> To:   EraseMEPICLISTspamspamspamBeGoneMITVMA.MIT.EDU
> Subject:      Re: [PIC] PWM motor control
>
> So, for the PID experts, do you really need divide/
> mult math to get this performance or can you use
> other simpler software means to do this?? Don't you
> just need to check how far it is from the correct value
> and adjust the rate of change, etc, to suit?
> ie; bigger error = more power to change, smaller
> error = less power to change? I've successfully done
> this in numerous ways using hardware and software
> and never needed a 24bit divide...
> -Roman
>
The scheme you have just described is a simple "Proportional" system, where
the output of the control is simply proportional to the error term.  This
works ok in some situations, but it has the inherent problem that there must
be an error term in order to get an output from the system.  This implies
that there will always have be an error for the system to work.  The error
can be reduced by increasing gain up toa point, but too much gain =
instability as you commnted previously.

Adding in integral term, which is a sum of all previous error terms, works
to reduce the final error to zero.  Because of it's nature, the integral
term will be larger (and therefore require more bits to store) than the
output range of the controller.  Typically a controller with an 10 bit
output range might need a 24 bit integral term.  This is where the 24 bit
divide could come in handy!

Mike

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\02\21@173533 by Mike Mansheim

flavicon
face
> error = wanted - actual
> diff = error - old_error
> if (drive not saturated){integral += error}
> old_error = error

> p = kp * error
> i = ki * integral
> d = kd * diff

> drive = (saturated ls bits of) (p+i+d)

> For the applications I have put it too I have generally found the
integral
> term to be of little use... depends on what you are doing of course.

This is an excellent illustration of how simple it is in concept to
implement a pwm control - until you start have to start tweaking
kp, ki, and kd to make your system behave properly!
However:  a "typical" control system must have an integral term.  For
example, if the output is a pwm signal to drive a motor, if you actually
got to the desired speed, error = 0 and your output would also = 0, and
you would stop driving the motor.  The integral builds over time and
creates a "baseline" output that allows the error to go to zero.  The
other terms modify this baseline to react quickly to changes; by it's
nature, the integral reacts slowly to changes.  One of the things that
can complicate the above simple representation is saving/restoring the
integral under certain conditions - if, for instance, your motor
routinely needs to be stopped temporarily, and you don't want the
integral to have to build all the way back up each time.
Note that since ki is multiplied by the integral, it is very often = 1.
Anything larger quickly makes for very large integral terms.
I think it is more typical to have a PI only system - and only use the
derivative term when absolutely necessary.  It is simply a means to let
the control system react to the rate of change of the error, and often
isn't needed.
Finally, going way back to the original post on this, they said that it
can take a while to get a speed reading.  I just wanted to mention that you
must pay attention to how often the pid calculation is done.  You
absolutely do not want to update the output faster than the system can
respond - you will not be in control.  That's not quite the case here -
you just won't know how the system responded - but you still don't want
to update based on old data.  Probably better to figure out how to get
the speed quicker.
Wow, this is much longer than I intended - I got rambling - sorry for the
length.

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


More... (looser matching)
- Last day of these posts
- In 2001 , 2002 only
- Today
- New search...