LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

PID or PWM for Servo?

I have a Moog Servo.  Attached is a synchro for feedback voltage to my circuit that is proportional ( PID?) to a wing position attached to the servo.  The servo is fully on when commanded (threw a DAQ 6229 Analog out) to an angle/position or off  once its at the commanded position ( PWM?) .  Everything I've read indicates this ..to me..is a hybrid PID/PWM controller.   ON_OFF_ON..etc.. would be the PWM and a PID to determine when it got to the commanded position.  The problem w the PID is it looks like it keeps looking at the process variable ( my synchro ) compares it to my setpoint ( my commanded angle) and tries to set the output to a voltage to get the wing position to its commanded position.  In my case I want to give the servo say 10 vdc and by measuring the synchro voltage take away servo voltage when the two are equal..

This is a "general" example but this is graphically what I envision..

The 2nd plot is what I think the PID does..it outputs a voltage or whatever constantly after you have adj the P, I and D.

 

Thanks..

Download All
0 Kudos
Message 1 of 9
(2,481 Views)

I'm not clear on what specifically the problem is. You're correct that a PID controller will vary its output to try to drive the process variable to the desired setpoint, which is what you say it's doing. Are you saying that it's not tuned properly, so it significantly overshoots, undershoots, or oscillates? Or that it's configured improperly, so it drives the output in the wrong direction?

0 Kudos
Message 2 of 9
(2,458 Views)

If you want to set to 10V (not exactly how PWM works) and go until you reach your desired setpoint, you don't need PID.  You can eliminate that piece all together.

 

But, why do you want to?  The purpose of the PID is to move to your setpoint and then maintain that point.  Yes, there are little oscillations.  But, that's likely preferable to the alternative.  Is your motor supporting any weight?  If so, turning it off is likely to send it back towards the starting point.  Do you have code in place to move it back if it overshoots your setpoint or will it just stay at the further point?

0 Kudos
Message 3 of 9
(2,442 Views)

So I did up this plot to help better understand if I need a PID Controller or not as most of the NI explanations and the Web use a graph of some sort.

This is just a general graph of my situation.  I am using a NI DAQ board to generate and read the analog voltages.  The example in he whitepapers  #3782 was used.

The user sets the setpoint (SP)  to the desired angle that they want the fins to go to..say 80 degrees.  Time zero in my graph.  Because the process variable (PV) is measured in volts the SP is converted to voltage thru a formula.  In this case 8 vdc.  The PV is measured via a synchro which is also measure and converted to a DC voltage.  When the system is turned on the daq AI looks at the voltage (PV) and compares it to the SP.  If they are not equal it applies 10 vdc..say.. to an AO which is connected to a servo. This "DO WHILE" loops continues until the PV=SP at which time the 10 vdc is removed from the output.  Time =9 in my graph.  My question is does this sound like a good use for a PID??  I'm trying to relate this to a temperature control that is given in a lot of examples for PIDs .  But once I remove the 10 vdc the fin stops moving..not immediately but nothing like a heating element where you remove the voltage and it still has residual heat on it that affects the other parameters in the PID..does it?  I'm trying to figure out how to implement the output of the PID.  Put it in a case statement.  If the PV=SP then the output=0 otherwise = 10 vdc?  I guess I'm a little confused on what the value actually is on the output of the PID.  No currently I hadn't thought of moving it back..till your post..if it overshot SP.

 

Thanks..

0 Kudos
Message 4 of 9
(2,429 Views)

Honestly, it sounds like you haven't grasped some key concepts about feedback control and dynamic systems that PID algorithms are meant to help solve.

 

It starts with your error signal, defined as (SP - PV) expressed in the same units.  Then the amount of control effort you exert in a PID algorithm depends on:

P - a Proportional part that's based on the actual error size

I - an Integral part that's based on an accumulation of error over time

D - a Derivative part that's based on the rate at which the error is changing

 

The type of control you're proposing was called "Bang Bang" control in my coursework.  It guarantees that you will oscillate about your setpoint forever.

 

PWM stands for "Pulse Width Modulation".  It's common for motor drives to use fast switching digital electronics as a *mechanism* for delivering the "control effort" voltage to the motor.  PWM often operates just above human hearing range (20 kHz+), and the effective voltage delivered to the motor depends on the duty cycle of the PWM waveform.  

 

So summing up, SP and PV lead to an Error signal.  The PID algorithm turns Error into "control effort".  PWM is a cost-effective method for delivering that control effort using digital electronics instead of analog.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW?

(Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).



0 Kudos
Message 5 of 9
(2,417 Views)

Then I guess I need more education in control theory before I ask anymore questions..

0 Kudos
Message 6 of 9
(2,413 Views)

It'll be worthwhile to get some grounding, but it's a deep, deep rabbit hole that you shouldn't wander too far into all at once.

 

First try using only Proportional control.  The control effort will be proportional to how far away you are from the setpoint.  You can do hand calcs based on your motor & drive specs to get a reasonable starting point for your Proportional control gain value.

 

An implication of PID control is that you only exert effort when there's an error signal, i.e., when you are *not* exactly at your setpoint.  If your setpoint for desired speed requires 8 Volts, then you're going to end up at a place where Kp * (SP - PV) must give you a result of 8 volts.  Therefore, you *must* inevitably have a non-zero error.  The larger you make your proportional gain Kp, the smaller the error will be.  However, in a dynamic system a large value of Kp may also make you unstable.  With a big actuator, you could be violently unstable and cause damage, so be careful.   Start small with Kp, and increase gradually.

 

Typically Integral gain Ki is added next.  It adds in some extra control effort based on the integral of the error.  A small error for a long time integrates to be appreciable, so the Integral gain works to drive the system to a 0 steady-state error.  Again, the system can easily become unstable if you make Ki too large, so start small and change slowly.

   Many times, it can be helpful to use something known as "gain scheduling" to decide if and when to apply Integral control.  It can often be easier to get a good and stable response if the Integral control only "kicks in" when the error is small-ish.  That way you don't accumulate error during the very beginning of a large step response.

 

The final component is Kd, the Derivative gain.  It acts on the derivative of the error.  It'll end up *subtracting* control effort when the error is decreasing, i.e., when you are getting closer to the setpoint.  It tends to add back some of the stability that Kp and Ki threaten.

   I've seen many real-world systems perform adequately with Derivative gain of Kd=0.  Not optimally, but adequately.

 

 

-Kevin P

 

 

P.S.  PID control isn't the only method and often isn't really the best method.  Better methods tend to depend on a good mathematical model of the system's dynamic behavior.  PID is popular because it's an effective general-purpose method for implementing feedback control of a system without a good mathematical model.

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW?

(Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).



0 Kudos
Message 7 of 9
(2,403 Views)

@Kevin_Price wrote:

An implication of PID control is that you only exert effort when there's an error signal, i.e., when you are *not* exactly at your setpoint.  If your setpoint for desired speed requires 8 Volts, then you're going to end up at a place where Kp * (SP - PV) must give you a result of 8 volts.  Therefore, you *must* inevitably have a non-zero error.  The larger you make your proportional gain Kp, the smaller the error will be.


This is true if instead of "PID control" you meant "proportional control", because in PID control of course the integral term will provide continuous output if necessary, even when the error is zero. It's essential in things like temperature controllers, where some continuous heater output is required to make up for heat leaking out of the system and keep the error at zero.

 

Aaron T.

Message 8 of 9
(2,399 Views)

@arteitle wrote:

@Kevin_Price wrote:

An implication of PID control is that you only exert effort when there's an error signal, i.e., when you are *not* exactly at your setpoint.  If your setpoint for desired speed requires 8 Volts, then you're going to end up at a place where Kp * (SP - PV) must give you a result of 8 volts.  Therefore, you *must* inevitably have a non-zero error.  The larger you make your proportional gain Kp, the smaller the error will be.


This is true if instead of "PID control" you meant "proportional control", because in PID control of course the integral term will provide continuous output if necessary, even when the error is zero. It's essential in things like temperature controllers, where some continuous heater output is required to make up for heat leaking out of the system and keep the error at zero.

 

Aaron T.


Absolutely right, thanks for the correction!  In my mind I was still in the context of proportional-only, but I had a "brain-o"* and typed PID.

 

 

-Kevin P

 

* a "brain-o" is like a typo, but it's a carelessness of the brain instead of the fingers

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW?

(Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).



0 Kudos
Message 9 of 9
(2,396 Views)