Showing results for 
Search instead for 
Did you mean: 

Creating cycles

First thing.....I am relatively new to LabVIEW!


Second thing.......this is what I want to do:


  1. Create a code that will generate On-Off cycles for a valve
  2. Run this code, possibly as a sub-VI
  3. On time and Off time will be provided by the user from FP
  4. Cycle the valve till the user stops the cycling

This is what I am going to use:

  1. LabVIEW 8.6 FDS
  2. cRIO 9074 with NI 9476 cards

I tried using the timer function blocks available in the RT module (two timers, after First is done, start second and after second is done restart first, PLC coding style!!). But this method doesnt seem to work!


So I used a 'FOR' loop with 2 iterations and the loop timing being adjusted using the On and Off times available from front panel entries.

Now when I use it as a sub VI, it is not working. If I connect another subVI to this code, it still doesnt work........


Where am I wrong?


Any help would be useful!


Thanks in advance...



0 Kudos
Message 1 of 4

There are a number of ways you could code this requirement, here is one suggestion (others will have other recommendations):


Use a while loop with a boolean stop control wired to the conditional terminal.

Inside the while loop, monitor time elapsed using the Time in ms function. Compare the current time in ms to that at the last value change, as stored in a shift register.

When the time elapsed is greater than the time required (high time or low time), switch the output from low to high (or high to low).

The loop will continue checking the time elapsed and alter the output accordingly, until the user selects Stop from the front panel.


The idea has the advantages of:

  • Adapting the high and low times to user front panel changes.
  • Allowing a user to stop the cycle at any time, not just at the end of a cycle.
Thoric (CLA, CLED, CTD and LabVIEW Champion)

0 Kudos
Message 2 of 4
use a while loop
Harold Timmis
*Kudos always welcome:)
0 Kudos
Message 3 of 4



The While Loop worked!



0 Kudos
Message 4 of 4