From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

pressure based timer

I have spend two days and still breaking my head. I would really appreciate some help. I am trying to develop a labview application to monitor pressure and vaccum on my instrument. I have 30pressure sensors and 30vacuum sensors and I need to monitor 30 ports on my instrument. I have attached an image just to show how each port is connected to sensor by T off's. When the instrument starts, one port at a time will pressurize upto 32psi(monitor pressure sensor, even no AI channels) and reaches-16psi(monitor vacuum sensor, odd no AI channels). And the issue is the pressure sensor can read vacuum upto -3psi and vacuum sensor can read pressure upto 3psi.

 

The problem I have right now is check threshold state. I have to monitor all the AI channels and when the pressure reaches 5psi start a timer and when it reaches 30psi stop the timer to calculate the flow rate. But when I energize to vacuum the system will drop from 32psi to -16psi and I should start my timer at 0psi and stop at -16psi on vaccum sensor (and not at 5psi and 30psi). On my check threshold state i used elapsed timer.vi and I thought having 10ms wait in the while loop will suspend the thread and the sequence will move to scan state and acquire new data from DAQ. By using breakpoint I realized that when the pressure reaches 5PSI I enter my while loop and I never exit.

 

Before I make any further changes I want to know whether I am on right track. I am thinking of adding DAQ read inside the while loop(in check threshold state) to get the latest reading and run timer based on that. But still I am little confused on how to start and stop timer for my requirements. 

 

Please need some help. Thanks.

 

 

Download All
0 Kudos
Message 1 of 7
(2,691 Views)
Any help please.:mansad:
0 Kudos
Message 2 of 7
(2,662 Views)

You have a major problem in the inner while loop of your check threshold state.

 

You are doing some comparisons with value.  That will either stop the while loop or allow it to continue to run.  The problem is the value comes into the while loop through a tunnel.  Once the while loop runs, there is no way to ever get a different value on that wire.  It will continue to do its evaluations on the same data.  So if that loop runs more than once because the value is not in a range that will cause the loop to stop, it will run forever because that value will never change.

 

Also, don't use the Exit LabVIEW function when you are working on code in the development environment.  I don't want to have to restart LabVIEW everytime I run then stop your code.  If you need to use that function, don't add it until the very end of your development, or wrap it in a case structure that it only executes based on the App.Kind property node.

Message Edited by Ravens Fan on 04-02-2010 11:22 PM
0 Kudos
Message 3 of 7
(2,655 Views)

Thanks for your reply. I modified the program in a quick and dirty way to calculate the elapsed time. I somehow think timed loop is the way I have to approach but I am not able to implement the same logic. Please provide your feedback on how to fix this. At the current vi when the instrument goes from pressure to vacuum I see the drop in pressure from 32psi to -16psi and to calculate the vacuum flow rate I have to start timer at 0psi and stop at -16. But now when the pressure drops it changes the start and end time. I also can't wait forever for the system to get to 32psi. I have to timeout if it doesn't  and move to next port.

 

Please need some help.

 

Thanks

0 Kudos
Message 4 of 7
(2,651 Views)

Now you have some local variable abuse causing race conditions in that check threshold state.

 

Does a value get written to Numeric before or after it gets read?  No way to tell or control it.

 

Likewise with start time and end time.

 

 

Remember to be careful testing double representation values for equality.  They may never be equal to 5 or 15 or 20.  In your previous VI, it looked like you were using some Express VI's to help take care of that, but I'm not sure because I avoid most Express VI's.

 

Since you want to use a timer mechanism, there is one good Express VI that does that.  Look at Elaspsed Time in the Timing palette.  That will let you start, reset, auto reset, and do a number of things in a convenient little package.

 

And GET RID OF THAT EXIT LABVIEW FUNCTION!

0 Kudos
Message 5 of 7
(2,648 Views)

Thanks for the reply. Regarding the start and end local variables I thought those are accessed only when the case statement are satisified. When the pressure is 5psi(I rounded the double)I write start variable and when its 15psi I write end and when the pressure reaches maximum I calculate flow rate inside an another case by using start and end time. Would there be a race condition? And regardin numeric indicator yes I am sure there is some race condition. I need to find the index of the scaled data array for a specified port when there is a change in pressure and I thought threadshold_peak_detect.vi would do the trick. I am sure there will be so many ways we can do this and I would really appreciate if I could get some pointers to implement this in better way. May be using timing_sequence struct. For the final version I will building an exe. So how will I close my application without using exit labview. Is there any other way to close the app? Please let me know.


Thanks

0 Kudos
Message 6 of 7
(2,626 Views)

Yes, since only one of those 3 True cases in those case structures can execute at one time based on the conditions, there is no race condition on those values.  However you still have an issue of comparing a double value to be equal to another value.

 

Your blue numeric local variables are a race condition.  The way you solve it is to wire directly from one function to the other.

 

For your exit LabVIEW, don't put it in your code at all until you are ready to make your executable.  Then you won't annoy anyone running your code in the development environment exit LabVIEW on them.  How are you dealing with it now?  Isn't it forcing LabVIEW to close on you anytime you run your own VI?

 

If you want to leave it in there, do what I told you to do earlier which is look at the app.kind property node.  Nothing is in the default case.

Message Edited by Ravens Fan on 04-03-2010 11:54 PM
0 Kudos
Message 7 of 7
(2,623 Views)