LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

check for how many ms the condition is true/false

Hi LabView community!

I was wondering if there is an easy way to get the ms timer which would count, for how many ms the condition in CASE selector was true or false. I'm pretty new to LabView programming, working on a project for my classes, therefore i made a simple VI to show what my problem is. 

Can I get some hints on how to do it? Right know my timer counts time in ms since the VI started.

Any help would be appreciated, many thanks 🙂

 

0 Kudos
Message 1 of 6
(2,348 Views)

I would recommend looking at the online LabVIEW tutorials
LabVIEW Introduction Course - Three Hours
Learn LabVIEW

 

Look up shift registers.  If you place into the shift register the value of the millisecond timer when you change from False to True, then the millisecond timer subtraction will tell you how much time has passed since then.

0 Kudos
Message 2 of 6
(2,320 Views)

I have attached a VI that counts the time a bolean is high.

Try this!

0 Kudos
Message 3 of 6
(2,294 Views)

Well, you need to reset the reference time whenever the boolean changes. A != (or XOR, but less readable ;)) of current and previous boolean will do that for you 

 

Here's a quick example, showing the current and previous time in an array (you can delete all that if you don't need it) and the time since last boolean change.

 

OffOnTime.png

 

If you want the time in seconds, use "high resolution relative second" instead.

 

Note that your case structure was completely unnecessary, but please put it back if you need more code in the various cases. Also don't forget to place a reasonable wait in the loop. No need to strain the CPU. 😉

0 Kudos
Message 4 of 6
(2,278 Views)

@fcappon wrote:

I have attached a VI that counts the time a boolean is high.

Try this!


Your code doesn't have a loop!

 

How exactly are you supposed to use it?

0 Kudos
Message 5 of 6
(2,265 Views)

I'm sorry about that!

It should be placed inside a while loop 😉

0 Kudos
Message 6 of 6
(2,238 Views)