From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Newbie: ON-delay and OFF-delay timers

I'm trying to create sub VI's for ON-delay and OFF-delay timers similar to those in PLC logic.  This is proving to be more difficult than expected; I must be missing something obvious.

I want the sub VI to have three terminals:
A boolean input for the signal that activates the timer
A numeric input for the delay in msec
A boolean output that goes TRUE after the ON-delay (or FALSE after the OFF-delay)

I would appreciate a nudge in the right direction.
0 Kudos
Message 1 of 8
(5,583 Views)
Hi,
I made two examples of Timers, a synchronous and asynchronous variant. The Logic of On-Delay and Off-Delay can be made outside the SubVIs. I made only frames around the code which can be in SubVIs so it's all in one VI.
Greets, Dave
Greets, Dave
Message 2 of 8
(5,555 Views)
Thanks Dave.  Your example helps alot.

If you're willing to help more, I need it work function a little differently: The timers I'm trying to emulate require the input to stay true in order for the counter to accumulate.  If the input goes false before the timer finishes, it starts over at zero.  I have attached a VI that shows the functionality I'm after.  The problem with my approach is that it doesn't seem to lend itself to the creation of a sub VI.

I can't seem to get there with your example because subsequent input tansitions are ignored by the while loop.

Dave Cleveland
Timberline Automation
0 Kudos
Message 3 of 8
(5,539 Views)
Hi Dave,
sorry for the late answer. I'm on monday at work again, then I will write back.
Greets, dave
Greets, Dave
0 Kudos
Message 4 of 8
(5,481 Views)
There's probably no need to write back.  I've been taking a great ride up the steep part of the learning curve.  Once I got a few basic concepts to push aside 20 years of PLC programming, things started clicking faster.  It was your example code plus those of many other veterans on this forum that provided the breakthroughs I needed.

Thanks.
0 Kudos
Message 5 of 8
(5,479 Views)
This is really great to read Smiley Very Happy Ride on...
Greets, Dave
Greets, Dave
0 Kudos
Message 6 of 8
(5,453 Views)

I am trying to create sub VI's for operating three things simultaneously (current, pressure and temperature), with varying time parameters to keep the three things ON for a specified time.

 

The default for all the things should be OFF. Only after a Boolean input is called for all three actions should be:

 

The current should remain ON for say 0.5 sec.

The pressure should remain ON for say 2 sec.

The temperature should remain ON for say 3 sec.

 

After the specified time all the three parameters goes to OFF position, unless it is called for again through the same Boolean input. This simple logic seems to be more difficult than, I expected, can some one please help / suggest in the right direction.

 

THANKS

0 Kudos
Message 7 of 8
(5,416 Views)
Warning: Newbie answering question; take it for what it's worth.

I am using a state machine to do that kind of timing.

Each case of a Case structure is a state that can present the next case via a shift register.  It's very easy to advance through a timed sequence with this design, plus you can respond to inputs to terminate early, repeat a step, skip a step, etc.






0 Kudos
Message 8 of 8
(5,333 Views)