LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

PID Control - analog input, digital outputs


@Ravens Fan wrote:

I've seen that situation withe the integral windup.  I wonder why the PID algorhithms or the toolkit doesn't already do something to handle that situation automatically.  It seems to me that the integrated error should be automatically reset anytime the setpoint value changes.


If your system depends on some integrated error in order to maintain steady state (again I'm thinking of a heater), resetting the integrated error every time the setpoint changes will result in poor performance.  For example I'm working with a very small heater system right now in which we run a ramp up the temperature by steadily increasing the setpoint every 1ms.  If the integrated error reset to zero on every setpoint change, the ramp performance would be terrible.  Conversely, I do reset the integral error whenever the PID output is negative, since I can't set the output any lower than zero.  This helps avoid windup when the temperature is decreasing.  PID is a fantastic generic algorithm but often you need to tailor it slightly to your system.

0 Kudos
Message 41 of 54
(2,178 Views)

@VeeJay wrote:

Thanks Nathan! I guess I am over complicating things. I have read all these material over the last few days and it has propped up so many questions in my head. My mind is getting all these stupid ideas. That's all 🙂 I will read them again, maybe some repetition will trigger some better understanding. I have a solution in mind. I will implement it and post the vi. Maybe you can take a look at it. Thanks!

 

V


Just wondering... did you get your system to work?

0 Kudos
Message 42 of 54
(2,153 Views)

Hi Nathan,

 

Sorry it took long for me to reply. Please don't take it the wrong way. I have been really busy with work and classes and it has been crazy.

 

Good news and thanks to you, I have strong command on PID and using PID toolkit. Please find attached my control vi and a screen shot of my graphs. It still needs fine tuning and I would probably need help with that.

 

In my system, I am using ON/OFF controller during raise because of the 120VAC motor which I do not wish to pulse.

Lower valve is pulsed using PWM. Here, again, there are small issues I am facing with respect to what the frequency of the square waveform is and what the output range is. But, overall there is good control.

 

In my system for the lower valve, the minimum pulse time to see a physical effect on lowering is atleast 120-130ms ON time. Hence, I am currently using a 4Hz square wave with output range (-60%- -80%) because any ON time less than 60% has no effect and anything over 80% has excessive effect.

 

And, I have deadband set to 0.2 degrees within which I reset PID output.

 

One question though. My program is running at 10ms per iteration which has actually helped a lot in terms of averaging and the square wave generation. But, What I still see (If I may direct you to the lower valve chart on the screenshot) is that few pulses combine and it leads to a continuous open which leads to undershoot.

 

Thanks for your help Nathan! PID is incredible if you get to understand it and with you help I have. Please review code and let me know of any logical inconsistencies (VI is not well formated though).

 

Regards,

V

 

P.S. In the screenshot, please ignore PID gain 2, output range2 controls and many others. I took the screenshot before I edited the vi.

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

Glad to hear you're getting close.

 

It's difficult to understand the data in your graphs since there are so many of them without labels on the legends and I don't know your system.  It will be easier to comment on your code once you finish cleaning it up - right now you have functions with nothing wired to the output, and wires going all over the place.  There is no need for the sequence structure (for some reason all new LabVIEW users think they're necessary).  You have two different timing structures in your loop - the event timeout, and wait for next ms multiple.  There's probably a better way to keep track of the previous Desired Angle value, using a shift register in place of the property node and removing the event structure.  You might find it simpler to chain a single error wire through all your DAQ functions, instead of a separate one for each DAQ item.  I can't check through all your logic.

 

Removing the "Wait for next ms multiple" and using either the event structure, or a simple Wait, may help your timing.  Wait for next ms multiple can introduce additional delays because if you miss the 10ms cycle, it will wait another 10ms.  With a wait, if you miss the 10ms cycle it will execute as soon as possible after that.  The best solution for accurate PWM generation is, of course, in hardware.  Does your card have a timer output?  If so, take advantage of it.

Message 44 of 54
(2,111 Views)
Hi, I'm trying to stabilize a laser with a PI and I would like to know how can I adjust its parameters without knowing its transfer function? I saw in another page something on the method of ziegler nichols, but the thing is that the response of the system is not periodic, so I don't know how to obtain the critical gain Kc. Further more, if the input of the PI is a voltage and I'm stabilizing a device by stabilizing its current. Do I have to put a conversion ratio between the output of the PI and the input of the device or not? if yes, how can I determine it? Thank you in advance.
0 Kudos
Message 45 of 54
(1,673 Views)

@Yasmine90 wrote:
Hi, I'm trying to stabilize a laser with a PI and I would like to know how can I adjust its parameters without knowing its transfer function? I saw in another page something on the method of ziegler nichols, but the thing is that the response of the system is not periodic, so I don't know how to obtain the critical gain Kc. Further more, if the input of the PI is a voltage and I'm stabilizing a device by stabilizing its current. Do I have to put a conversion ratio between the output of the PI and the input of the device or not? if yes, how can I determine it? Thank you in advance.

Hi Yasmine,

 

You can use the PID control kit available in LabVIEW. Setpoint will be your target, Process Variable will be your feedback. You set a desired output range and PID parameters to control. That's the basics.

 

 

Now, to determine the P, I, D parameters without a transfer function is time consuming,  but can be done. I had to do a lot of trial and errors to get desirable parameters. You start with setting I, D as zeros and determine a gain that would result in the feedback oscillating around the target. Ideally, you would graph the output and calculate rise time and all that. But, for trial and error, keep trying values for P to find a number that would make your feedback oscillate about the target. Once you have determined that, try introducing Ki values. Note that in LabVIEW, the units are minutes and no seconds for integral time. We can introduce D later if required.

 

More information from you would help. What are your channels you are controlling? An example vi or a snapshot would help. I did not get what you mean by input is a voltage and stabilizing the current?

 

Your PID function will calculate an Output based on SP, PV, Output range and PID paramters. You have to interpret that output to control the device. For eg. If you are controlling the duty cycle of a square waveform, then if output range is set between 40% and 100%, Your PID function will output starting from 40 through 100 based on your parameters. If you want the PID output to be (1-5)V, then you would set that in your output range and the direct output can be used to control the device.

 

Please provide more information and I can try and help you out.

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

Thank you for your reply 🙂

Here is my VI as well as the PID that I did by myself cause I don't need something really complicated that I don't even know how it works.

I don't know if you're familiar with lasers. I' not 😛 but in this project what I have to do, is to stabilize the current of a laser on Labview via GPIB.

To this laser I have to connect a lock-in amplifier which will play the role of a frequency discriminator and will take off the noise as well.

Appearently, to stabilize the laser to the bottom of the transmission curve, and so to fix it to a certain current, It's easier to work on the lock-in amplifier and make its signal stuck in 0.

So, like I explained on the VI, the inputs of the PID are PV= output of the lock-in amplifier and SP=0.

The output of the PID, goes to the laser to stabilize its current after a small conversion of which I'm not sure by the way.

Like I told you, I don't have a periodic signal or normal oscillation, that's why I don't know how to set the parameters of the PID.

I don't even know if I have to cncentrate of the signal that I get from the laser or the lock-in amplifier to get the correction parameters, what do you think?

 

0 Kudos
Message 47 of 54
(1,665 Views)

I would like to generate a step voltage via GPIB as well. Do you have an idea of how I can do that? Maybe it will allow me to obtain the step response of the laser so as to calculate the parameters of the PID. 

Thank you for your help 🙂

0 Kudos
Message 48 of 54
(1,657 Views)

Here's a schematic which may better help you understand my setup.

0 Kudos
Message 49 of 54
(1,649 Views)

When you say "the response of the system is not periodic" - you won't get a periodic response until you introduce the proportional control. You induce a fluctuating response in the system by slowly increasing the proportional gain.

 

I don't have LabVIEW 2013 at the moment so I can't look at your VI, but why would you try to write your own PID (which might contain errors) when there is a well-tested and documented version available? Do you not have access to the PID toolkit?

 

You'll have to consult the documentation for your device to figure out which command to send over GPIB. Without knowing anything about the device you're using, there's no way we can tell you how to generate a step output.

 

It's normal for the process variable and the output to be different units (for example, measuing temperature in degrees, and an ouptut in voltage). No conversion is necessary; the proportional gain takes care of that for you. You can think of the proportional gain as the change in output that will cause a corresponding change in input, so it's essentially a conversion factor.

0 Kudos
Message 50 of 54
(1,643 Views)