LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to log Elasped Time?

Hi All, I have been spending too much time on this subVI of mine. In all it is very simple, it's a boolean control that gets sent to my DAQ. Switch on, water turns on, switch off, water turns off. The thing is that I need to log how long I had it on for so later I can calculate water consumption later. I thought using a simple case structure (True/False) and the Elasped Time Express VI would be best. I am having a problem actually logging the last time due to the fact that as soon as I hit the switch and give it a false, the elasped time value resets to zero. Is there some way to hold that last time value to write to a file before clearing? I attached my VI.....
 
Thanks
 
Gerald
0 Kudos
Message 1 of 10
(3,354 Views)
You didn't get the attachment on. Sometimes this happens if you preview before you post.
Now Using LabVIEW 2019SP1 and TestStand 2019
0 Kudos
Message 2 of 10
(3,341 Views)
Hi Thunderhead,

I'm not sure what your attempt looked like, but this is how I would do it.  I tend to do things the old fashioned way rather than resort to express VIs, myself. 

I attached a picture since I'm not sure which version of LabVIEW you're using.

Jim
0 Kudos
Message 3 of 10
(3,330 Views)
Sorry Guys for the missing, VI. Here is what I am working with.


Gerald
0 Kudos
Message 4 of 10
(3,318 Views)
You need to wire the feeback node/shift register through the false case. As soon as your Water On switches to false, the output of the case statement is zero. You have nothing wired in the false case and have selected use default if unwired. The default is zero.
Message 5 of 10
(3,309 Views)
You are absolutely right. I thought of this before but it didn't work. With your help this time, it did. Thanks alot DenisKnight!!!!


Gerald
0 Kudos
Message 6 of 10
(3,297 Views)
You also have some other problems.

1.  Look at your CPU usage.  You need to add some time delays or move to an event structure (The event structure would remove your continuous DAQ writes).  Sitting idle, your VI runs at 50% CPU on my system, and then shoots up to 75% when I turn the water on.

2.  Your logic is also assuming the user never turns the water back on after turning it off.  If you turn it off, wait 10s, then turn it back on, you'll notice your elapsed timer jumps 10s because it was never reset, so your final number will be inaccurate.
Message 7 of 10
(3,293 Views)
Thanks Matthew, I know about these other two problems. I had to work out this big thing first. I will be adding a wait time for sure (Or my LabVIEW Basics teacher would kill me hahaha), I'm controlling a solid state relay and it won't even flicker to a little wait time. I will also be adding a reset to the the Elasped time VI so that it does reset. This will take a little thinking, maybe set aside the values before the resetting and adding them later and write the sum to file.....I appreciate the input, Thx


Gerald

0 Kudos
Message 8 of 10
(3,276 Views)
Gerald,

I have used several variations on the Elapsed Time VI which I have attached. Typically it is used in a state machine. In that usage the While loop is removed and the shift registers are part of the state machine loop. This stand alone VI demonstrates the concepts. The radio buttons may be states or commands to the state machine and the local variables would not be needed because the state selection logic would manage this.

Lynn
Message 9 of 10
(3,263 Views)
I swear this little section has become more difficult than the login system I made for it. As Matthew brought up yes there will be a problem to log multiple on states. It's not important for me to have the actual sum logged, only every on time would be fine. I have to find a way to maybe compare it to last value and if not equal to log that new value. As it is now, It will log every value as long as the switch is off. If I put it outside the while loop it will take the last measurement but the VI will stop. Is there some easy way to just take the on elasped time and log it for every time??? I'm sure I'm looking to deep into this cause my ears are starting to hurt.......hehehe


Gerald



0 Kudos
Message 10 of 10
(3,252 Views)