LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

PID contol, I value maximum?

Solved!
Go to solution

I have defined PID values for different temperature values using Gain Schedule VI. Now, it picks up the appropriate values I want for tuning. 

 

Next step is improving the PID control so that my temperature stability (not accuracy) is maximum. Current program is already functional but not very practical and here you may find the details:

 

- Current PID program : checks the set temperature (Ts) and current temperature (Tc) if  abs(Ts-Tc)<0.01K stop the PID .

 

- Desired Program

1. checks if the abs(current temperature - set temperature)<2K

2. count 10 min when temperature change is continously <1% 

3. save the temperature value 

 

My plan is a for loop for step#1 and blinks an LED. Then, a second for loop for step#2 (a second LED), and a case structure that counts the time when LED is continously on. Save the temperature in a shift register?

 

Am I thinking in a too complex way ? 

0 Kudos
Message 21 of 26
(841 Views)

Why do you want to stop the PID when you reach temperature?  If the PID is properly tuned it will hold the setpoint continuously.  Also, I don't understand what you mean by "save the temperature value."  The temperature should be the setpoint (or close enough to it), right?  It's easy to check if the temperature is in range for a period of time.  Maintain two shift registers.  One contains a boolean; the other contains a timestamp.  Whenever the temperature is in range and the boolean is false, update the timestamp with the current time and set the boolean to true.  If (current time - saved time) >= desired time AND the boolean is true, you've achieved your goal.

 

I would do this all in one loop as a state machine.  The solid LED in step 2 is easy enough - just connect it directly to the shift register described above, inside the loop.  The blinking LED you can handle however you want.  If you want a really easy way to do it, use the "Blinking" property of an boolean indicator (either the same indicator as used for step 2, or a separate one).

0 Kudos
Message 22 of 26
(835 Views)
I wanna stop the pid cos the multimeter will be used for some other measurements at that time so I don't want to give interruptions since I don't have an instrument just for temperature readings . After the measurements it will jump up to the next temperature value and do the measurements after it is stable. All the measurement program is written pid is a sub vi for the measurement program .

Other info is very helpful, any suggestions on the time counter ? Thanks
0 Kudos
Message 23 of 26
(833 Views)

How will you know if you're maintaining temperature during the 10 minutes if you're not measuring the temperature?

 

I think I provided enough detail on my suggestion for the time counter, but I can throw together a quick VI if it's not clear.

Message 24 of 26
(829 Views)

I dont want to do the measurements in that 10 min time period. That 10 min helps me to make sure that the temperature is stable and I can stop the PID with the current input value and the temperature will remain constant (or almost constant) during those measurements.

 

I dont want the current temperature changing more than %2 for at least 10 min (while the current temperature value - set temperature value <2K). So it is not just a comparison between the setpoint but also a comparison between the collected current temperature values and diffrence between them.

 

As an example, I give the temperature to be 320K as a set point. But the system stabilizes at 318.5K and stays there for a long time ( more than 10 min ) with the same current value. Than, that is perfect for the stabilization and I no longer seek to be more close to 320K. But I need that value to be saved (believe me 320 and 318.5 gives me quite a bit of an error in the calculations so I wanna be accurate as I can).

 

I started to put together a state machine that will play role as a sub VI in my PID control VI. Set temperature and current temperature will be connected to related control wires. So I am not happy with the current VI I am sending you on the attachment. I tried to follow your ideas which were very helpful but I didnt find a way to compute the difference between current temperature levels. 

 

Thanks!

 

 

 

 

0 Kudos
Message 25 of 26
(817 Views)

You should look at the examples for state machines.  What you have there is not really a state machine and will not work as you want.  You should have an enumeration containing the states, stored in a shift register that tracks the current state.  You do not want to use the iterator terminal of the while loop as the input to the case structure because you may want to stay in the same state for multiple loop cycles.  If you have not gone through the LabVIEW basics, you may want to do that (if I'm not mistaken there are free online courses on the National Instruments site).  Your current logic is incomplete and makes no sense to me.

 

I think I may have misunderstood about your 10-minute period before.  Are you saying you will run the PID until the temperature has been stable for 10 minutes, then turn it off and do other measurements?  I'm still not convinced that you will maintain a stable temperature that way, but you can try it.  It would be a good idea to plot the controller output during that 10 minutes to see if it is also stable, or if it is varying constantly but maintaining temperature.  If the latter, your plan may not work well.

 

I've put together a quick image showing how you could check if the temperature is in range for a period of time.  This is a "snippet" - you can drag it directly to the block diagram of a LabVIEW 2009 or later VI.  You can run it and experiment with - change the setpoint and current temperature so it's in or out of range and see how it responds.  To convert this to a subVI you'd need to make a few changes: set the stop condition to a constant true, move the controls and indicators out of the loop, and remove the wait.  Then you could call this inside a loop and it would work.

In Range for Length of Time.png

Message 26 of 26
(797 Views)