06-06-2019 02:28 AM
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 🙂
06-06-2019 07:23 AM
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.
06-06-2019 10:19 AM
I have attached a VI that counts the time a bolean is high.
Try this!
06-06-2019 10:55 AM - edited 06-06-2019 10:57 AM
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.
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. 😉
06-06-2019 12:10 PM
@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?
06-07-2019 11:13 AM
I'm sorry about that!
It should be placed inside a while loop 😉