11-15-2009 10:26 AM
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.).
11-15-2009 05:16 PM
11-15-2009 08:19 PM
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.
11-15-2009 11:48 PM
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.
11-16-2009 10:20 AM - edited 11-16-2009 10:25 AM
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
11-16-2009 10:24 AM
11-16-2009 10:29 AM
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 ??
11-16-2009 10:32 AM
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.
11-16-2009 10:41 AM
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 ?
11-16-2009 10:55 AM
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