LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

time a boolean value

I am reading the status of 10 lamps from a serial string. My VI returns a boolean value according to the status of the lamp. Now I need to time the on time of each lamp. As soon as a lamp turns off it should save the time and start adding the time again once the lamp comes on again. Once the VI is closed and reopend the on time should appear in the VI for each lamp. And once a lamp comes on it should start adding to that time. I should also be able to reset the time and I should also be able to enter a number of hours that a lamp has been on already. Any suggestions ? Thanks
0 Kudos
Message 1 of 2
(2,541 Views)
Use a while loop with an uninitialized shift register for each lamp. Inside the while loop have a case structure with cases for No Change, Lamp Came On, Lamp Went Off, Initialize, and Reset. Inside the Lamp Came On and Lamp Went Off cases, read the Get Date/Time or Tick Count function (depending on the desired timing resolution) and add/subtract to get the elapsed time for each lamp. You might need two shift registers for each lamp: one to hold the most recent Lamp Came On time and one for the total elapsed time (or one shift register with a cluster holding the two elements).If the VI is to run continuously, put a wait in the loop so that other parts of the program will have opportunities to execute. If it is only to be called when a change takes place, set t
he loop to execute only once for each call to the VI.

Lynn
0 Kudos
Message 2 of 2
(2,541 Views)