LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Controlling Pressure

Hello,
 
I am trying to control the pressure in my application. Initially user have to enter the set point  pressure and rate of pressurization...the pressure has to be controlled as per the rate of pressurization.
 
But the pressure input which I get from analog input channel of my card is very slow varying, so I am not able to get desired result....and how can I introduce auto PID in my VI.
 
The error data which I want to write to the analog output channel is not reflecting outside the while loop.
 
Regards
 

Message Edited by james p martin on 07-30-2006 12:18 PM

0 Kudos
Message 1 of 15
(4,484 Views)
The code you have outside the loop is only going to run once - when you first click the run button. If you want it to run continuously, put it inside the while loop. DO NOT use the run continuous button on the toolbar.
Message 2 of 15
(4,473 Views)
In addition to what Dennis said, there are a few other issues. You should really familiarize yourself with dataflow programming. Have a look at the examples that ship with LabVIEW.
  • LabVIEW does NOT execute left to right! In your code, there is no guarantee that the "data" local on the right is read before it even receives a reasonable value from inside the loop. You have a serious race condition.
  • If you use DAQ inside a loop for continuous acquisition and control, it is usually not recommended to "configure--acquire--close" with each loop iteration. Typically you would configure on the outside (left) of the loop, then continually acquire/control inside the loop and close the DAQ task only after the loop finishes, again outside (right) the loop.
  • It is not clear why you would need to read from the "pressure" local variable, the real terminal is right there in the same loop!
  • What exactly determines the loop timing?
  • As Dennis said, your AO belong inside the loop, where you can wire the "data" directly, without any need for local variables.
  • If you want sohisticated PID control options, have a look at the PID Toolkit.

Don't forget the debugging tools. Your problem would become immediately obvious if you would run your VI using execution highlighting. Try it! 😄

Message 3 of 15
(4,467 Views)

Thanks for the replies,

I have put the whole code into a while loop, and I have put the write function also within the loop, but as I have to compare the current pressure values with the rate (the ramp line which is being drawn according to the rate).... at every instant , I am not able to do that because as my rate line starts drawing.....the pressure input is vary slowly varying so the error increases all the time.

 

Could you please tell me that how to draw a ramp line without using any loop, so that I can take the ramp value at an instant and simultaneously compare with actual pressure.

Regards

0 Kudos
Message 4 of 15
(4,447 Views)
Hi James,
 
It looks like you're building the array piece by piece in that while loop. If you need access to it all at once, you could build it in a separate loop and pass it in as an array of values. That is, have one while loop create the ramp and quit. Take the ramp array and pass it through a tunnel to the loop that  you have now.
 
Just a thought,
 
Charlie S.

Visit ni.com/gettingstarted for step-by-step help in setting up your system
0 Kudos
Message 5 of 15
(4,412 Views)

Hi Charlie,

Thanks for your reply.....but I dont want the whole array to pass actually i want to compare the actual and current ramp input to calculate error.....can I do this with indexing enable coz what I think it will pass me whole array at the end of loop.......can I pass the current values from inside to outside the loop which I am not able to do coz I just get the last value after stopping the loop.

 

Thanks

 

Message Edited by james p martin on 08-03-2006 03:45 AM

0 Kudos
Message 6 of 15
(4,387 Views)
Hi James,
 
Once you've created your array of ramp values, you can use the array functions to index it as needed (for example, index array). In this way you can pull any value out of the array that you need.
 
I did have another idea, however. It looks like you're reading one point at a time, according to the .jpg that you posted a few days ago. If this is a slow varying signal, you should slow down the rate of your loop as well -- you don't have any timing in there at all as it is. Say, for example, your signal only changes values once a second. Time your loop such that it iterates only once per second. You can do this using the wait until nex ms multiple.
 
Hope this helps!
Charlie S.

Visit ni.com/gettingstarted for step-by-step help in setting up your system
0 Kudos
Message 7 of 15
(4,356 Views)

Thanks charlie..and others,

I have made few changes also in my program and what I am doing in my code is that as I have to increase the pressure at a desired rate , which is "Rate(Kgf/Sec)" specified in the code which I am calculating at every 10msec. point by increasing a counter...and comparing it with current pressure value to calculate error for PID loop...but now I have some issues....

  • The value "dT" I m taking in PID loop is 10mSec. because I am calculating desired pressure at 10mSec....is this correct???or what should I take ???
  • As the user can change the Rate so my desired pressure slope changes according to that and the points which I will be getting corresponding to that wud change....e.g. if I my " Rate(Kgf/Sec)" becomes 1 so in 1 sec. the desired should reach at 1 and at t= 2sec it should become 2....and if if set Rate to 0.5 Kgf/Sec so at t=1sec. it should become 0.5..and so on.....but it is not happening..the rate does not have any relationship with timing which is missing in the code...so how can I get  my timing right???
  • Is there anything to do with the samping rate at which I am acquiring the pressure.
  • Also How can I reset the counter value to 0 ....even when I make reinitialise to default it starts with previous value.
  • How Can I better my PID control response...shown in fig. attached.

I got some response regarding to this problem but it could not solve the problem

Regards

Download All
0 Kudos
Message 8 of 15
(4,324 Views)

Hi James,

I'll try to answer as many of your questions as I can, though, I am not an expert in PID control...

The value "dT" I m taking in PID loop is 10mSec. because I am calculating desired pressure at 10mSec....is this correct???or what should I take ???

If your loop rate is maintained a 10ms, then I would assume that dT=10ms should work fine.

As the user can change the Rate so my desired pressure slope changes according to that and the points which I will be getting corresponding to that wud change....e.g. if I my " Rate(Kgf/Sec)" becomes 1 so in 1 sec. the desired should reach at 1 and at t= 2sec it should become 2....and if if set Rate to 0.5 Kgf/Sec so at t=1sec. it should become 0.5..and so on.....but it is not happening..the rate does not have any relationship with timing which is missing in the code...so how can I get  my timing right???

In order for your loop rate to reflect what the user inputs on the front panel, you will have to modify the value you pass to the ms timer in your loop. In other words, don't wire a constant value of 10 to it; rather, whatever you calculate based on user input. (same for the elapsed time)

Is there anything to do with the samping rate at which I am acquiring the pressure.

The larger while loop will run as fast as it can with everything inside of it, since it has no explicit timing of its own. If the DAQ Asst takes longer to execute than the 10 ms in your inner while loop, that will control the timing. Since it is likely that the DAQ Asst does not take this long to execute in your app, it's safe to say it's not controlling the timing of your overall application.

Also How can I reset the counter value to 0 ....even when I make reinitialise to default it starts with previous value.

The value being displayed in your counter indicator is being fed by a feedback node -- this what's actually sotring the value (it's that orange arrow on your block diagram).

I hope this helps -- at least a little!

Charlie S.

Visit ni.com/gettingstarted for step-by-step help in setting up your system
0 Kudos
Message 9 of 15
(4,296 Views)

Thanks Charlie,

You wrote "In order for your loop rate to reflect what the user inputs on the front panel, you will have to modify the value you pass to the ms timer in your loop. In other words, don't wire a constant value of 10 to it; rather, whatever you calculate based on user input. (same for the elapsed time"

I have tried this but as I have given the values to the elapsed time as per the calculated value (i.e. Rate) my chart is updating after that much time interval....which is not right......what I want is that I should calculate the values per 10mSec. using a counter and then updating the chart as per the Rate(kgf/Sec)  (which is slope).

Anyways.....now I have changed the controller card for Valves and the response is also linear so I am just using open loop and I am able to control as per the desired rate but the problem is that the desired pressure is not changing as per rate enterd by input......now the file which I am attaching is ..I have removed all the time delays .....and there is another thing that when I give time elapsed a value of 10/100msec. it always show time elapsed TRUE all the time.

............Now I am giving it a new start....my aim is to calculate the desired pressure points which I am doing with the concept that every 10msec. I am running a counter(C)  then I multiply that with Rate and divide by 100.....which gives me desired point at 10msec point and so on....so what I am doing is right or not???or you could suggest me some other method to calculate my desired pressure points as per the rate defined by user so my main focus is this to update the chart as per the specified rate ....controlling thing is now I am able to control.

 

Regards

0 Kudos
Message 10 of 15
(4,278 Views)