Asking for help: PID controller for a DC Motor

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Hi, I'm looking for some theoretical help on a PID controller
for speed in a DC Motor. It is a small 9V DC motor from Radio Shack,
and I've been told of the type known as "Sensorless DC Motor" (?).

My restrictions in this project are as follows:

1. I am not using a dedicated DC motor controller type, but a small
   "general purpose" RISC microcontroller

2. Use the microcontroller to generate a PWM that will be applied
   to the driver of the motor.  (This is no problem, already tested
   as an open loop case, operator controlled through buttons).

3. Introduce a closed loop from the motor, sensing the sepeed, back to
   the microcontroller.

From the algorithmic (software) point of view, I think that I have
envisioned the subroutines and major points which I must be aware of.
I also have most of the hardware idea, except for the point 3 above.
Of course, everything can be changed if convenient.


As a dummy in the field of DC motors, and close to dummy in PID control,
I will appreciate any help in the following big problems I have here:

a)  How do I sense the speed so as to send the signal to the controller?
    I first thought that the voltage at the DC motor would be fine; those
    experts in DC motors will surely know already I was wrong. I tried
    then measuring the current, but I am not sure of the results and
    I have not been able to make a connection, if there is any.

b)  How can I derive a good circuit model for the DC that could be of
    some help?  It seems the best would be an RLC series subcircuit,
    together with a voltage source. But there has been some contradiction
    among the people I've consulted (and who could not help me with
    the first question completely).

c)  How should I proceed to tune the PID coefficients?  At first, I
    thought of looking at the motor, but I have serious doubts, since
    what I am controlling is the timer for the pwm signal really.....
    unless there is something wrong with this concept.

I thank you in advance.

Rogelio

Re: Asking for help: PID controller for a DC Motor
On 12 Jul 2003 16:03:11 -0700, the renowned

Quoted text here. Click to load it

Presumably you're not going to be introducing a tachometer (hence the
sensorless). That leaves you with three possible ways that I can think
of of compensating for load variations:

IR compensation
brush noise to measure RPM
motor back EMF to measure RPM

Each has disadvantages and advantages.

Quoted text here. Click to load it

You need to increase motor voltage slightly as current increases to
compensate for losses in the motor, in order to maintain the speed
constant.

Quoted text here. Click to load it

Different answers- static and dynamic models etc. You'd have to
measure most of the characteristics. You could check this out:

Johan Scholliers, Timo Yli-Pietila, The Modeling of Motion Control
Systems With An Analog Circuit Simulator, 16th Intl. PCIM, 1995

Quoted text here. Click to load it

Empirically is how it is usually done. See any of the many books on
PID at any technical library. For your controller design, just make
sure your sample rate is fast enough and is periodic.  

The PWM frequency should be high enough that it does not matter; what
you will be controlling is the PWM *duty cycle* as the controller
output, and that should behave much like an analog controller output
would- from 0 to 100%. If you want to get a bit fancy, you can look at
feedforward on supply changes.

Quoted text here. Click to load it

Best regards,
Spehro Pefhany
--
"it's the network..."                          "The Journey is the reward"
snipped-for-privacy@interlog.com             Info for manufacturers: http://www.trexon.com
We've slightly trimmed the long signature. Click to see the full one.
Re: Asking for help: PID controller for a DC Motor
Ideally use an encoder or tacho to measure the actual speed.

If this is not possible, you can make a reasonable estimate of the speed
using the standard DC motor equation :

V = Flux * Speed + I * R + L. dI/dt
Te = Flux * I

Flux is often referred to as voltage constant or torque constant

The L. dI/dt term can usually be ignored except in highly dynamic
applications.

So if you know R (the armature resistance of the machine) and measure I & V
(actually you control V so you could estimate it from your supply and PWM
modulation index) you make a pretty good estimation of the speed.

Pitfalls here are :
- The value of R can vary by around 50% across typical operating
temperatures for a machine
- The motor equation assumes constant field current (or permanent magnet
excitation)
- The speed is in effect unobservable at and around zero speed, so if you
need high quality control of zero speed you'll really need to measure the
speed directly.

There are a number of ways to control the machine :

1. Use a PID (actually the D term is rarely used) whose demand is required
speed, whose feedback is estimated speed (from the above equation) and whose
effort is motor volts. This is simple, but you have no control over the
current and you'll have to ramp the demand carefully.

2. Use an inner current loop - the effort from the speed loop is the demand
for  another PI loop, whose feedback is motor current and whose effort is
volts. You can then impose limits on the current demand between the speed
and current loops. Typically the current loop will execute at the same
frequency as the PWM with speed loop being able to run somewhat slower.

Tuning of the loops is often done by experiment. If you want to do it
analytically, you have to consider the load model for each loop :

Current loop is based on the dynamic equations : dI/dt =
(1/L)(V-I.R-Speed*Flux). If you assume the current loop bandwidth is much
higher than the rate at which the speed can change (i.e. you can assume the
Speed * Flux term is slowly changing) you are basically controlling current
in a L-R series circuit. Another common technique is to feed-forward the
Speed * Flux term.

Speed loop is based on dW/dt = (1/J)(Flux*I - Tload(W))
W = speed
J = total moment of inertia
Tload(W) is the load torque as a function of speed (e.g. k0 + k1.W + k2. W^2
etc)

Sorry to be so non-specific, hope this helps.

Gary

Quoted text here. Click to load it



Re: Asking for help: PID controller for a DC Motor
Hello Gary - please can you help me out with your terminology. When
people talk to me about PID loops, I understand things like PV, SP and
OP (OP sometimes called MV). You mention things like:
Demand
Effort

<snip>
Quoted text here. Click to load it

How do these relate?

Thanks & regards,
Pete Fowler
<snip>

Re: Asking for help: PID controller for a DC Motor
By effort I mean the output from the controller
By demand I mean the setpoint, reference i.e. the input
By feedback I mean the measured quantity of what is being controlled (e.g.
measured speed)

i.e. Error = (Demand - Feedback)

     Effort = Kp * Error + Ki * INTEGRAL(Error) + Kd * (Derivative of Error)

Note : This isn't a very good way to implement PID control.

A better way is :

PTerm = Kp * Error
ITerm  = ITerm_on_last_iteration + Ki' * Error   (Ki' is scaled and based on
sample period)
DTerm = Kd * (Error - Error_on_last_iteration)

Effort = PTerm + ITerm + DTerm

If Effort is > maximum Value, Effort = Maximum Effort & don't update storage
of ITerm (avoids "integral wind-up")

There are other more CPU efficient implementations (FIR filter) :

Yn =  A0 En + A1 En-1 + B1 Yn-1

Where En, En-1 are error this time and error last time and Yn-1 is output
last time.

I generally find that the first implementation is better in low resolution
(16-bit) implementations since the FIR approach can give problems with
resolution and range of individual gains.




Quoted text here. Click to load it
required
whose



Re: Asking for help: PID controller for a DC Motor
The PID parameters are tuned, not calculated.  This is a toughie for a
student to understand, but you do NOT pre-calculate them.  The reason is
that they are the final point at which all errors in calculations,
measurement and linearity are collected and compensated.  There are a number
of tuning procedures to chose from, including the original Nickols and
Ziegler to be found at www.driedger.ca, but there is one major pitfall:  You
have to know the particular algorithm your controller is using.  They seldom
use for form you are taught at school.

Walter.

Quoted text here. Click to load it



Re: Asking for help: PID controller for a DC Motor

Quoted text here. Click to load it
To obtain the motor equation (Ist order) you can do a o/l step input to
obtain the Time Constant  (T when RPM i= 66%RPMmax) the other motor
constants factors can be worked out by Turn on accelleration RPM = 0.
(exstrapolated) Bung all  these figures into a modelling packege like
Mathcad and you can tune your loop to give desired performance.

Hugh



Site Timeline