LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Monitor if Digital Input Doesn't Change State w/in Time Period

This program cycles a solenoid on and off for a user-defined period. I want to capture the time it takes for a digital input to turn ON and turn OFF, after a digital output comes ON or OFF (respectively).  In practice, I have a solenoid (digital output) that will be used to actuate a valve; a proximity sensor (digital input) will be used to verify stem travel.  I want to know:

   1. How long after the output turns on/off, that the input turns on/off, respectively.

   2. If the input never changes states during the cycle. 

 

I am able to follow the digital output and report the time it takes for the digital input to come on or turn off (following the output).  Two things I can't accommodate: reporting a value if the input never changes during the cycle and resetting the timers at the end of the cycle.

 

0 Kudos
Message 1 of 3
(2,479 Views)

At any instant in time, you are in a certain "State" (i.e. the Solenoid is On or Off, your Timer is in some State or other).  Depending on the "State", when you check the Digital Input, you will do a "State-dependent" action, and will possibly pass to another "State".  This idea can be modelled as a While Loop surrounding a Case Statement, where the Case Selector is the name of the "State" (it could be a String or, my preference, an Enum).

 

This is called a "State Machine", and vastly simplifies the (somewhat confusing and obscure) logic exemplified by your code.  There are Examples and Tutorials in LabVIEW about State Machines, and there is even a Project/Template for building one, the "JKI State Machine" (Google it, or look it up in the LabVIEW Tools Network which you can access by running the VI Package Manager, which you should have installed when you installed LabVIEW).

 

Try rewriting your Project using the State Machine model -- I think you will be able to solve your problem yourself.

 

Bob Schor

0 Kudos
Message 2 of 3
(2,432 Views)

Thanks Bob!  I'll give it a shot.

0 Kudos
Message 3 of 3
(2,405 Views)