LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Extracting a variable from inside a case structure

Solved!
Go to solution

Hi! I am fairly new to the wonderful world of Labview. I started with watching most of the tutorials here and figured out some basics. However, I simply don't know how to solve my latest problem:

 

outgassing_help.PNG

This VI is reading pressure values from two different instruments (labeled TPG and DPG). The first one (TPG) is only read, the value from DPG is used to control the status of a vent within the vacuum system. The idea is, that the vent opens if the pressure get's too high (P>P_max): If that's the case the lower case structure is 'true' and the 'open vent' command is send ('[...]switchbox on'). The 'false' case is empty, so the vent stays open until the pressure get's too low (the upper case selection): if P<P_min the upper case is 'true' and the close command is send. Since the pressure rises due to outgassing of the vacuum tank this cycles repeats itself forever.

 

That's the part that works!

 

However: I want to get the time it takes from the 'close vent' command until the 'open vent' command (so from the lower case structure becoming 'true' until the upper structure is 'true') and want to log the elapsed time in a file. The problem is twofold:

1) Both 'true' cases are 'true' for more than one tick. it usually takes like 4-5 ticks until the open/closed vent leads to a pressure change which makes the condition 'false' again, so I get 4-5 timestamps each time one of the case structures is 'true'. What I would actually need is the equivalent of a 'latch when pressed' to initialize the timestamps so I only get one timestamp for the 'close' and one for the 'open' command for each cycle. This is also true for the command to close/open the vent: it really only needs to be sent ocne, not 4-5 times in a row, although it doesn't hurt the system.

2) I fail to actually get to use the timestamps to subtract them and hence get the time in between: I tunnel the timestamp of the upper structure into the the lower one (with 'use default if unwired') in order to subtract them but since the upper case is always 'false' when the lower is 'true' I always get a '0' from the upper case. I think the main question is: How can I extract a variable (the timestamp) from within a case structure to use it in the main while loop?

 

 

I would appreciate any advice I could get on this. I also realize that this is probably a very inelegant way to do this in labview, so if you have suggestions on do it 'better' I would be happy to implement those as well!

 

Thanks a lot!

0 Kudos
Message 1 of 3
(3,085 Views)
Solution
Accepted by topic author Schäfer

You need to keep the both Booleans of the cases in a shift register, that way you can compare the new and last value. If they're different you've got a signal change and can use Get millisecond (in a case) to register a start time. You can also combine the two booleans to an array and use array to number. That way you can have a case structure which differs between Raising flank, Falling flank, high and low, and get a start and finish time, calculate the difference and write to a log file in the appropriate cases.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 2 of 3
(3,076 Views)

Thank you, that worked perfectly!

0 Kudos
Message 3 of 3
(2,991 Views)