LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

PID Control - analog input, digital outputs

Hello everyone,

 

I am trying to use the PID toolkit to convert my existing feedback control system to one using PID or just PI whatever works best. Problem is that the tutorials out there discuss in detail about obtaining Analog inputs and using the PID output to control an analog output. Are there any tutorials that show how I can control my process variable which is an analog input by using the PID output to generate digital outputs?

 

Basically, what I am doing is controlling the incline of my device with two digital outputs that control two solenoid valves. The angle is calculated from a calibration curve that plots distance sensor voltage with Angle. Any help would be immensely apprecitated. I want to try this out on my own before I post some vi's. Thanks!

 

V

I may not be perfect, but I'm all I got!
0 Kudos
Message 1 of 54
(9,975 Views)

It's not useful to connect a PID to a digital output, because the PID produces a continuous (versus discrete) signal.  You need some way to make that continuous output relevant to the valve.  This is most commonly done with PWM - pulse width modulation - in which the output is turned on for a varying length of time depending on the PID output.  However, some solenoid valves don't like being switched on and off quickly, so you may need to limit the rate at which the valve switches (by running the control loop at a low frequency).  The most reliable way to generate a PWM signal is with a counter/timer output, but if you don't have one available, you can do it in software as shown here.  It will be slower and less accurate than a hardware-timed output but may be sufficient for you.

0 Kudos
Message 2 of 54
(9,970 Views)

Thank you Nathan. Here is some information regarding my requirements.

 

I do not require quick ON/OFF. A low control loop, even as low as 200-300ms is desirable. I discovered this value by raising my device to the max position and using the lower valve to step down by varying the DO signal ON time and discovered that for values less than 150ms ON time for the valve, the device barely lowers.

 

And my incline is controlled by two digital output channels. For example, if I want the device to get to a certain set point, based on the error in position voltage, valves trigger. If it is lower than desired, raise valve triggers and if it is high, lower valve triggers. Problem I am facing is related to achieving steady state. There seems to be oscillations around the target. Hence, I hope PID would help smooth that out.

 

I will try your vi and see if it works for my application. Thanks!

 

V

I may not be perfect, but I'm all I got!
0 Kudos
Message 3 of 54
(9,966 Views)

VeeJay wrote:

And my incline is controlled by two digital output channels. For example, if I want the device to get to a certain set point, based on the error in position voltage, valves trigger. If it is lower than desired, raise valve triggers and if it is high, lower valve triggers. Problem I am facing is related to achieving steady state. There seems to be oscillations around the target. Hence, I hope PID would help smooth that out.


If you're getting noise around the setpoint but are otherwise reaching the desired position, you may simply want to widen the setpoint range, so that you only turn on the valve when you at least some minimum number of units away from the setpoint rather than needing to hit the setpoint exactly.  Or, introduce some hysteresis, so that the valves trigger at slightly different positions going in one direction versus the other.  For example if you have one valve to raise the device, you would leave the valve on until you are slightly higher than the setpoint, and keep it off until you are slightly lower than the setpoint, rather than switching it the moment you reach the setpoint.  This will probably be better for eliminating noise around the setpoint than introducing a PID controller.

0 Kudos
Message 4 of 54
(9,963 Views)

That is exactly what I am doing currently. I have error bands specified around the target to make sure that it doesn't oscillate. But, under load conditions such as pulsed load conditions, the device goes out of bounds and the values trigger to correct for it. But, what I need is seemless or atleast seemless correction. Currently what I see is sudden adjustments to the incline. Please find attached what I am currently using. I am trying to get a more finer solution if at all possible.

 

Note: Within 5% of the target = NO action

          Between 5% and 15% = Pulsed ACtion ( DO On for Pulse width time)

          Greater than 15% = continuous action until it reaches Pulse band

I may not be perfect, but I'm all I got!
Download All
0 Kudos
Message 5 of 54
(9,960 Views)

I also want to know the nature of the PID output when PV is in voltage. Is my understanding correct here? Guide me here.

 

My PV is in volts based on a position. A new setpoint indicates that error = PV-SP = negative. What will be the output here? Is there a way to use this value to set the ON time on PWN to raise?

 

I think what I am doing is either setting the ON time to max or a predetermined value of 150 ms. What I want to do is bring the ON time from a max value and taper it down until it reaches the target. For ex. ON time from max loop time(say 300ms) down to 250ms down to 200ms down to 150 etc. until the device reaches the target band.

I may not be perfect, but I'm all I got!
0 Kudos
Message 6 of 54
(9,958 Views)

Would this be an approach? Just a trial. Not completed.

 

V

I may not be perfect, but I'm all I got!
0 Kudos
Message 7 of 54
(9,955 Views)

I highly recommend that you disconnect the DAQ functions, put some controls and indicators on the front panel so that you can simulate your system by typing in values, and see what happens.  At the least, you need to check the sign of the PID output and drive only the appropriate valve depending on whether you're going up or down.

0 Kudos
Message 8 of 54
(9,953 Views)

Hi Nathan,

 

Would you mind taking a look at the earlier two vis I attached to get a better idea of what I am trying to do. Thanks!

 

V

I may not be perfect, but I'm all I got!
0 Kudos
Message 9 of 54
(9,939 Views)

I am a little confused as to what the duty cycle is a percentage of? Is it a percentage of the loop time? Also, I want duty cycle to be higher if the error is higher and get lower as the PV approaches SP or crosses a threshold of 5% within SP.

I may not be perfect, but I'm all I got!
0 Kudos
Message 10 of 54
(9,934 Views)