Question

I have been making a labview program for kids to moniter energy production from various types of power sources. I have a condition where if they are underproducing a warning will fire, and if they are overproducing by a certian threshold, another warning will fire. I would like to time how long throughout the activity, each type of warning is fired so each group will have a score at the end. This is just to simulate how the eventual program will behave. Currently I have a timer which can derrive the amount of time the warning is true, but it will overwrite itself each time the warning goes off and on again.

So basically I need to to sum up the total time that the value has been true, even when it has flitted between true and false.

enter image description here

Était-ce utile?

La solution

One method of tabulating the total time spent "True" would be exporting the Warning indicator from the While-loop using an indexed tunnel. If you also export from the loop a millisecond counter value of when the indicator was triggered, you can post process what will be an array of True/False values with the corresponding time at which the value transitioned.

The post processing could be a for-loop that keeps a running total of time spent true.

P.s. if you export your code as a VI snippet, others will be able to directly examine and modify the code without needing to remake it from scratch. See the NI webpage on the subject: http://www.ni.com/white-paper/9330/en/

Autres conseils

I would suggest going another way. Personally, I found the code you used confusing, since you subtract the tick count from the value in the shift register, which may work, but doesn't make any logical sense.

Instead, I would suggest turning this into a subVI which does the following:

  1. Keep the current boolean value, the running total and the last reset time in shift registers.
  2. Initialize these SRs on the first call using the first call primitive and a case structure.
  3. If the value changes from F to T (compare the input to the SR), update the start time.
  4. If it changes from T to F, subtract the start time from the current time and add that to the total.

I didn't actually code this now, so there may be holes there, but I'm leaving that as an exercise. Also, I would suggest making the VI reentrant. That way, you can simply call it a second time to get the same functionality for the second timer.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top