From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, 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: 

Synchronizing Timed Loops

Using LV2009 on a Win_XP machine.

 

I have a Main.vi that has a 10ms Timed Loop triggered by a Digital Edge(Counter) and within that Timed Loop acquire 8 analog channels and the array is fed to a Functional Global.

 

I have a 6 different Sub.vi's which are called one at a time and during that time, the Main.vi FP is closed. Each of the Sub.vi has a Timed loop which also is running at 10ms but using the 1kHz clock. The Timed Loop in the Main has a higher priority compared to the Timed Loop in Sub.vi.

 

The Sub.vi reads the analog values from the functional global for processing. As can be seen there is no synch between the Main and Sub Timed loop and which is what I want to bring in.

 

Though I do not want to achieve the timing synch. of a RT system, I still would atleast like to ensure that both timed loops are in synch. Any ideas to do this ?? (I have searched the forum but do not find any post on Synch between a Main and Sub.VI.).

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 1 of 10
(5,770 Views)
One good option is to have the main Timed Loop with the Counter timing source tick the slave Timed Loops after it populates the functional global. Use the Software-Triggered Timing Source to accomplish this instead of the 1kHz. Since the main loop is ticking the others, they have to be in sync.
Jarrod S.
National Instruments
0 Kudos
Message 2 of 10
(5,754 Views)

Hi Jarrod,

 

The idea to use a Software Triggering to maintain Synch looks OK. The problem is this : To use the "Fire software triggered Timing Source.vi" I first need to start up the "Create Timing Source.vi" and LV recommends that this VI should only be used with the 1kHz or 1MHz clocks. Whereas my primary timing ticks are hardware based. I am also not sure how to pass the timing info. between the Main and Sub?

 

I think I am not clear on how to implement your idea. A sample VI would help. Thanks.

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 3 of 10
(5,741 Views)

Here is an example of what I mean. The main loop ticks a software timing source that the slave loops listen to after it acquires the data and stores it into the functional global VI for processing.

 

 

TL.PNG

 

 

Jarrod S.
National Instruments
Message 4 of 10
(5,730 Views)

Hi Jarrod,

 

Thanks for your time.

 

But for the sample I am not sure I would have figured out the requirement to build the cluster and pass the Trigger Source name to the slave VIs.

 

Your example passes the Trigger source name to slave Timed Loops that reside on the same VI. Hence the one last point that I would like to get clarified is the methodology to pass the Trigger Source name ( string ) between the Main.vi and the Sub.vi ? ( It will atleast be two days since I will get back to my PC to test out the option)

 

Regards

Message Edited by Raghunathan on 11-16-2009 10:25 AM
Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 5 of 10
(5,705 Views)
You just need some top-level VI that calls the Main VI and all the subVIs. This top-level VI should create the timing source information and pass it as a subVI input to both the Main VI and all the subVIs.
Jarrod S.
National Instruments
0 Kudos
Message 6 of 10
(5,701 Views)

As of now my top level VI is just a user Login.vi.

 

How about using a FG to pass the Trigger Source name from main to sub ??

 

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 7 of 10
(5,699 Views)

Passing data by wire is best whenever possible, both functionally and for code readability.

 

A functional global might work, but could also introduce a race condition if the Main VI or one of the subVIs tries to access the timing source information before it's initialized. If you can control that that never happens, you should be fine.

Jarrod S.
National Instruments
0 Kudos
Message 8 of 10
(5,697 Views)

Agreed , when  it comes to passing data, the wire is the best. But I guess it is ruled out between a Main and Sub and we need to resort to other means.

 

And I always believed that FG is a fool proof way to prevent race conditions. Or am I missing something here ?

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 9 of 10
(5,689 Views)

Raghunathan wrote:

Agreed , when  it comes to passing data, the wire is the best. But I guess it is ruled out between a Main and Sub and we need to resort to other means.

 

And I always believed that FG is a fool proof way to prevent race conditions. Or am I missing something here ?


That caught my eye as well.

 

Any code construct can be implemented poorly. As long as you keep the "master" version of the data inside the AE and desgn/implement them such that you are asking for copies of the master data or making data change requests via the actions of the AE you should be OK. If your AE needs something specail done up-front concider using the First Call to make it happens at the first call.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 10 of 10
(5,676 Views)