LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

PID Cascade control

Hi, 

 

I've only started working with labview this year and I'm really struggling to write a cascade control loop to control both flow rate and pressure together. I have written a loop to control flow rate and pressure separately, and one to also control them manually, but when I try to write the loop I'm going wrong somewhere... or in multiple places. 

 

If anyone can offer advice or guidance, I would greatly appreciate it! I've attached the cascade attempt, and the other two control loops if that helps. 

 

Many thanks

0 Kudos
Message 1 of 6
(1,229 Views)

Hi jk,

 


@jk1274 wrote:

I've only started working with labview this year and I'm really struggling to write a cascade control loop to control both flow rate and pressure together. I have written a loop to control flow rate and pressure separately, and one to also control them manually, but when I try to write the loop I'm going wrong somewhere... or in multiple places. 

 

If anyone can offer advice or guidance, I would greatly appreciate it! I've attached the cascade attempt, and the other two control loops if that helps. 


Why don't you cleanup that code? It really would help to understand the code easier:

 

  • Why do you compare the flow control output with those pressure range settings? (Doesn't make sense to me to compare a flow value with some pressure limits…)
  • Why do you subtract the current flow value from your pressure control output? Doesn't make sense to me as those are two different physical units…
  • Why do you add the Flow sp to your current flow value?
  • Does the pressure PID really use the same gains as the flow PID?
  • What's the meaning of those linearity constants?
  • Why do you use a 500ms wait function when you could easily determine the loop iteration rate by requesting a fixed number of samples from DAQmxRead!?
  • Why do you fiddle with buffer size at DAQmxTiming in "continuous" sampling mode? Did you read the help for that function?
  • Do you really need a 4kS/s samplerate for determining a DC offset? Why that DC offset and not just a simple mean function?
  • Why do you need a formula node when there is a math function to calculate a polynomial expression?
  • Did you know the InRangeAndCoerce function?

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(1,222 Views)

Hi GerdW, 

  • Why do you compare the flow control output with those pressure range settings? (Doesn't make sense to me to compare a flow value with some pressure limits…)
  • Why do you subtract the current flow value from your pressure control output? Doesn't make sense to me as those are two different physical units…
  • Why do you add the Flow sp to your current flow value?

These are good points - I was trying to follow the structure of a simple cascade loop that one might write on paper rather than in a DAQ labview script and I think it's gone very wrong... I've attached an old version of the script that I wrote without doing this. But does it still make sense to put the output of the pressure PID into the setpoint of the flow PID? This is what I've seen others cascade loops do... but I don't quite understand it. 

  • Does the pressure PID really use the same gains as the flow PID?

No, but the calculated PID gains for pressure don't seem to work (used both reaction curve method & oscillation method). When I used the gains for flow, they just happened to also work for pressure

  • What's the meaning of those linearity constants?

0.1 indicates a nonlinear process, 1 indicates a linear process.

  • Why do you use a 500ms wait function when you could easily determine the loop iteration rate by requesting a fixed number of samples from DAQmxRead!?
  • Why do you fiddle with buffer size at DAQmxTiming in "continuous" sampling mode? Did you read the help for that function?
  • Do you really need a 4kS/s samplerate for determining a DC offset? Why that DC offset and not just a simple mean function?

These three points were requested / done previously by my boss (my dissertation is in conjunction with my work) but are they not necessary / helpful?  

  • Why do you need a formula node when there is a math function to calculate a polynomial expression?

This is the only way I knew how to do it... I didn't know how to use the math function you're talking about. 

  • Did you know the InRangeAndCoerce function?

I've never heard of this, but I'm looking it up now. Would you suggest I use this for this application?

 

I can't express how thankful I am for your response - it's been more helpful than my supervisor's comments for this entire project. 

 

Best, 

 

jk1274

0 Kudos
Message 3 of 6
(1,201 Views)

Attaching the updated labview files as i think they didn't attach again. 

0 Kudos
Message 4 of 6
(1,196 Views)

Hi jk,

 


@jk1274 wrote:

I'm really struggling to write a cascade control loop to control both flow rate and pressure together. I have written a loop to control flow rate and pressure separately, and one to also control them manually, but when I try to write the loop I'm going wrong somewhere... or in multiple places.


Can you describe/picture that cascade control approach?

You want to control a pressure AND a flow rate by the very same actuator? How should that work?

 

(I also had testbenches with combined pressure and flow control, but usually I had two actuators to manipulate them (mostly) independently from each other…)

 


@jk1274 wrote:
  • Why do you use a 500ms wait function when you could easily determine the loop iteration rate by requesting a fixed number of samples from DAQmxRead!?
  • Why do you fiddle with buffer size at DAQmxTiming in "continuous" sampling mode? Did you read the help for that function?
  • Do you really need a 4kS/s samplerate for determining a DC offset? Why that DC offset and not just a simple mean function?

These three points were requested / done previously by my boss (my dissertation is in conjunction with my work) but are they not necessary / helpful?  


  • Usually it doesn't make sense to place a wait function next to DAQmxRead: by requesting a number of samples for a given samplerate you already can define the loop iteration rate!
  • Usually DAQmx is better than you in guessing the needed (internal) buffer size, so first read the LabVIEW help and then don't fiddle with buffer size!
  • What kind of signal do you measure? Does the flow rate really change so fast so you need to read samples at 4kHz? (Again: what is your control system?) And why do you use the DC/RMS function instead of a plain mean function?
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 6
(1,195 Views)

Can you describe/picture that cascade control approach?

You want to control a pressure AND a flow rate by the very same actuator? How should that work?

 

(I also had testbenches with combined pressure and flow control, but usually I had two actuators to manipulate them (mostly) independently from each other…)

 

  • Yes, they are controlled by the same actuator - I assumed that this would be okay because I used that same valve actuator when controlling the valves individually, and when flow rate is changed, pressure also changes. 
  • The cascade control approach was preferred for this project because the change in flow rate is at least 3x faster than the change in pressure, and the two affect each other directly. Is this incorrect logic / not appropriate for this application? 
  • When you controlled combined pressure and flow in your testbenches, where was the second actuator? At the outlet or at the same input side? For this system, a vacuum is pulling air out of the system. I have a second actuator, but when I placed it at the outlet, it mostly just changed the settling rates of pressure and flow.

 

  • Usually it doesn't make sense to place a wait function next to DAQmxRead: by requesting a number of samples for a given samplerate you already can define the loop iteration rate!
  • Usually DAQmx is better than you in guessing the needed (internal) buffer size, so first read the LabVIEW help and then don't fiddle with buffer size!
  • What kind of signal do you measure? Does the flow rate really change so fast so you need to read samples at 4kHz? (Again: what is your control system?) And why do you use the DC/RMS function instead of a plain mean function?

I will update these in the system based on your feedback! I paid little attention to these as it was just asked of by my boss, but if they are unnecessary, then that's understandable. The flow rate change based on the valve position is very fast but you're right in that samples may not need to be read at 4kHz. 

 

Best, 

 

jk1274

 

0 Kudos
Message 6 of 6
(1,155 Views)