06-20-2018 04:04 PM
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
06-20-2018 11:35 PM - edited 06-20-2018 11:35 PM
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.
06-21-2018 11:00 AM
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.
06-21-2018 11:09 AM
(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.
06-21-2018 12:41 PM
Sorry about the subvi.
06-21-2018 02:22 PM - edited 06-21-2018 02:45 PM
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.
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.
06-21-2018 02:31 PM
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.
06-21-2018 03:43 PM
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!
06-21-2018 03:54 PM
@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?
06-22-2018 01:04 AM
No I can't take credit the subvi was not mine .