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: 

Timer vi

Hello

 

I am trying to run multiple timers together but they are in sync. I want to run them individually, is this possible? Many thanks

 

0 Kudos
Message 1 of 10
(3,434 Views)

Hello Fatmat,

 

Your timer subvi is missing.

 

But you can have multiple timer vi as many you wants (ref. attached image)

as your timer vi contains shift register only one timer is valid for that vi, you can not use fgv vi as re-entrent vi to achieve individual timer, as each new instance of the timer vi on block diagram create another independent resource for the vi and you fgv will be no longer in your control. 

CLD
Message 2 of 10
(3,392 Views)

We really need to see what you are doing with that missing subVI in order to give some real advice.

 

If you want multiple loops to be able to read the same timer value, then you could add in some intelligence into your FGV.  Use Variant Attributes to hold the values for the timer and you can use a string input to write/read the values to/from the values in the shift register.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 10
(3,366 Views)

(Please don't maximize the fp and diagram to the screen, that's annoying.)

 

If the timer subVI should have several independent instances, it needs to be reentrant.

0 Kudos
Message 4 of 10
(3,362 Views)
0 Kudos
Message 5 of 10
(3,351 Views)

Your timer has 32 timer slots. If you want the two loops to use independent times, you need to wire a different "timer number". Since you don't have that input connected, they both use the same timer (0).

 

I don't understand the need for the non reentrant subVI wrapper. seems completely pointless. Just use the timer subVI directly in your code. (it is already non-renetrant).

 

Here's how it could look like.

 

timers.png

 

In terms or architecture, your two event structures are just plain silly. Once they have fired once, they are no longer reachable by dataflow, so if you keep pressing these buttons, you'll queue up an infinite amount of events that can never execute. Seems pointless. All you need in each loop is a clean state machine.

I am sure you don't need nanosecond resolution consuming all CPU spinning the loop as fast as the computer allows, so put a small wait in each loop.

 

 

Message 6 of 10
(3,342 Views)

I assume that this timer is not your code. Where did you get it?

 

If the author is still around, there are some changes that would be good. For example I would use high resolution relative seconds because the output only cares about differences. Also, the terminals for "reset", "time target" and "auto-reset" belong on the toplevel diagram. They should not be buried deep inside inner structures (details). Otherwise, the code is pretty clean.

0 Kudos
Message 7 of 10
(3,339 Views)

Thanks altenbach I sorted the problem by wiring a different timer number for each. The code is a mixture of a timer and an alarm by me, Thanks again!

0 Kudos
Message 8 of 10
(3,321 Views)

@fatmat wrote:

The code is a mixture of a timer and an alarm by me, Thanks again!


So, did you write the timer or not?

0 Kudos
Message 9 of 10
(3,317 Views)

No I can't take credit the subvi was not mine .

0 Kudos
Message 10 of 10
(3,304 Views)