From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

PID control with sensors and actuator

Hi,

I am doing a project which has been mechanically set up such that when a linear actuator moves up, the force exerted on the sensor increases, and when it moves down, the sensor reading decreases.

I have a VI that takes data readings from sensors (PV) and compares it with a desired value (SP).

Based on that, my PID control is supposed to send a command to the linear actuator to move up or down such that it reaches the SP and maintains it. 

I am unable to figure out how to convey information between the PID output and the linear actuator input (i.e. if I probe the PID output, it shows a value of 100 when the error is 0.7N; but how is the actuator supposed to know what 100 means?)

I am new to controls and LabVIEW, but am I missing something subtle here?

Please let me know.

Regards

0 Kudos
Message 1 of 5
(3,241 Views)

Honestly, you're missing a *lot* and I don't think it could be considered subtle.

 

This is understandable considering that you're new to both controls and LabVIEW.  Expect to spend some time learning about each.  In the meantime, here's an important question for you to consider before plunging in:

- if one were to accidentally command the actuator to its extremes (perhaps this is max speed toward max displacement in either direction), is there a risk of harming people or equipment?

 

There's a very real chance that your initial attempts at PID control using LabVIEW, when both are currently unfamiliar, will result in exactly that kind of extreme command.  Unless the consequences of uncontrolled motion are already benign, find a way to make them benign while doing your tinkering.

 

 

-Kevin P

 

P.S.  It won't be the actuator that "knows" how to scale between voltage and real-world units.  It'll need to be your LabVIEW software.

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 2 of 5
(3,229 Views)

Hi,

My controller is a precision motion control stage, so if it gets the instruction to move beyond a distance prescribed in its range, it just does not move, with no harm to the stage or anyone around.

I guess my problem is more about how LabVIEW uses the PID, but I can make it cleared by sending a pictorial representation of what exactly my doubt is. 

Until then, I will try to elaborate my VI.

1. I get a force output from my force sensors (PV).

2. I compare it with the desired force (SP).

3. I compute the error from 1 and 2, and the PID gives me an output (which I do not understand signifies what).

4. Depending on 3, I want the stage to move to a particular position (the stage=plant can only take positional inputs) relative to its previous position (up, if PV is less than SP; down, if PV is greater than SP)

 

So, here are my doubts:

  • In most feedback systems, the loop is as follows (left to right and in a cycle): SP-error-controller-plant-sensor(feedback)-PV. However, in my case, the plant (stage) does not send any data/instructions to the sensor-the sensor just continually measures data. Is it possible to incorporate that in the PID?
  • I have a model for my plant. In one of the PID examples, it shows to define plant parameters (I know them) in a Plant.VI, is it necessary to incorporate that in between the controller and the stage?

Please let me know if you need any further clarification.

0 Kudos
Message 3 of 5
(3,216 Views)

Hi PER,

 

However, in my case, the plant (stage) does not send any data/instructions to the sensor-the sensor just continually measures data. Is it possible to incorporate that in the PID?

In all my PID control loops the plants don't "send instructions to the sensor": the sensor always measures the current plant state!

 

3. I compute the error from 1 and 2, and the PID gives me an output (which I do not understand signifies what).

The PID output depends on the allowed output range (an input of the PID function). And of course it depends on the PID gains.

You can have an output range of ±100 [%] and scale that percentage to your engineering units (like ±10V output signal). Or you can set the output range to match the input of your plant (like the ±10V signal) and additionally adapt the PID gains to fit that other PID output range.

On PID gains:

P gain is the relation between error and proportional output signal change. (Like temperature is 10K too low, so increase the heater power by 5%: that gives a P gain of 5%/10K.)

I gain is the time it takes to output the very same amount of PID output change due to integrational part as the proportional part does instantanously for the same error.

 

4. Depending on 3, I want the stage to move to a particular position (the stage=plant can only take positional inputs) relative to its previous position (up, if PV is less than SP; down, if PV is greater than SP)

The default output range for PID is set to [0, 100]: you need to change this to allow also negative output signals!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 5
(3,210 Views)

I'll answer what I can, but I would consider myself a PID "dabbler".  There are others around here who are more proficient, so don't take my answers as a final word on things.  Just an attempt to help.

 

1. Always think about your units!   Always!  Really!

    The first place this comes into play is your error term (SP - PV).  Be sure that SP and PV are expressed in the same units before you do the subtraction.

 

2. The output of the PID calculation is a "control effort".   It will vary with both your instantaneous error (the Proportional term) and different aspects of your error *history* (the Integral and Derivative terms).   You may need to further scale or transform this number into the right form / units for your actuator.

    In your system, you'll have an error term in units of force.  The "control effort" you want to give to your actuator will be in terms of "incremental displacement".  A larger force error will require a larger adjustment in incremental position.  

    Note: many real-world systems can be controlled with just PI.  Not all need the D term.

 

3. It's actually normal, not unusual, that the feedback sensor is distinct from the actuator or "plant" and just keeps measuring no matter what the plant is doing.  Part of the beauty of a feedback loop is that once set up correctly, it keeps automatically making the right thing happen.

 

4. A dynamic model of your plant would be vital if you wanted to *simulate* the behavior of your control system.  But you should *not* insert that model into your PID calculations when you're controlling the real system.

    Two notes.  One, the plant model can be useful to PID wizards (I'm not one), who can derive near-optimal PID gains using that knowledge.  Two, there are *other* control methods (such as feed-forward, state space control, probably others) that *would* insert the plant model knowledge into the calculations.  But for regular, "simple" PID control, leave it out.

   Actually here's a third note.  It *can* be helpful to use your knowledge of the relationship between force and incremental displacement (for example, a scaling factor like 2.0 cm/N).  It'll give you a rough order of magnitude of where to start with your P gain as you start tuning your parameters.  Again, I'm not a PID wizard, but I might start with P value that's somewhere around 1/4 of that or less.  Specifically, if you had an instantaneous error of 1.0 N, the 2.0 cm/N relationship might seem to suggest you'd want to apply a "control effort" of 2 cm incremental motion.  I'd be inclined to start with a P value more like 0.5 cm/N or less.

 

5. All this discussion so far has conveniently ignored an important factor -- the likely latency between delivering a command to the motion stage and the time it takes to finish obeying that command and producing the corresponding force feedback.  Simple PID can have trouble with time delays, though I expect yours won't be so severe as to prevent you from getting decent behavior with "mere" PID.

   A simple strategy that could help you is to reduce the rate of your control loop.  You'll probably reduce your difficulties if the loop interval is a little but not an awful lot faster than your actuator response time.  (For example, if response time is ~250 msec for modest incremental motions, a 50 msec loop rate is probably more appropriate than a 5 msec loop rate.)

 

 

-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 5
(3,205 Views)