LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Time the length of a boolean value then write that value to a file then reset the timer ready for the next time

I have a VI where I need to time the value of a boolean which I use a tick counter in ms which is fine.  So when the value is 'true', the timer starts and when the value is 'false' the timer stops and using an indicator I can see in (ms) the duration which the boolean was true.  not a problem (see attached).

 

 

But what I need is that duration time to be recorded to file, txt doc or what ever/spreadsheet not fussed at the min.  but it needs to be stored!

 

Once it has successfully stored the time, I want the timer to reset to 0 ready to time the next value and recored it, but not write over the previuosly stored time.

 

Hope someone can please help.  thanks (the labview expert) nooorrrrrwwwwt

 

 

0 Kudos
Message 1 of 11
(3,893 Views)

Hi hawk,

 

but it needs to be stored!

I don't see any file function in your image…

 

what I need is that duration time

Duration typically is the difference of two timestamps. I don't see this in your image…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 11
(3,881 Views)

Thats right Gerd,  

 

I am not sure how to get it to write to a file.

 

For my duration count, the operation I am using if fine, its simple but does what I need it to do,  using two counters adds complexity which is not required.  (not for this particular instance anyway)

 

 

0 Kudos
Message 3 of 11
(3,868 Views)

true_VI_BD.pngfalse_VI_BD.png

 

*take special note of the mechanical action of the bool switch

Message 4 of 11
(3,835 Views)

I always learn something new 🙂 I was not aware of the existance of the "Boolean crossing Pt by Pt" VI 🙂 Very handy tool!

0 Kudos
Message 5 of 11
(3,814 Views)

Is that photo the entire VI?  If so......

Tick Count is not a timing duration tool.  I'm not entirely sure, someone can correct me on this, but it either pulls the ms counter from your PC or it's its own internal counter that starts the second you opened LabVIEW.  Like I said, someone with more knowledge answer that.  Either way, the minute you push run, you're going to get an incredibly ridiculous value that will not make any sense.  It'll say something like 54789283 then the next time 64298430.  You need a time stamp of when you started subtracted from a time stamp of when you ended.

0 Kudos
Message 6 of 11
(3,805 Views)

DailyDose wrote:  Tick Count is not a timing duration tool....

That's why you subtract the curent from the previous.  That will give you the duration you are looking for.  It is accurate to the ms.  So if that is all the resolution you need, it works wonderfully.  If you need more accurate, then use the High Resolution Relative Seconds instead.  If your time length is more than seconds, then start looking at using the system timestamp.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 7 of 11
(3,791 Views)

well said cross......

Example_VI_BD.png

 

just incase anyone is interested where:   \vi.lib\Utility\High Resolution Relative Seconds.vi

0 Kudos
Message 8 of 11
(3,783 Views)

DailyDose wrote: ...  You need a time stamp of when you started subtracted from a time stamp of when you ended.

^^

Yes, you can use Tick count as a time stamp.  Never said you couldn't.  Just that the code provided is simply a case structure that gets a Tick Count value.  Not going to do anything more than that.  So I felt the need to explain that Tick Count is not a timing tool unless made to be used as one which apok showed.

0 Kudos
Message 9 of 11
(3,775 Views)

 

ojk, I have now sorted somewhat, thanks.   just need to get it to autostop so it writes the file automatically - at the minute it only writes the values when i press the stop loop button can this be automatically done?

0 Kudos
Message 10 of 11
(3,757 Views)