LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

failure to synchronize timed loops

Hi there,
I wan to synchronise two time loops, one that generates an analogue signal at 20 kHz and the other which signals a TTL pulse to indicate the start of the generation of the analogue signal. Two achieve this, I used two timed loops (see attachment) and then connected their names to the synchronise sub-VI but I see that in 100 iteration of the same, it sync. for the first couple of iteration and then the TTL and analogue signal are not at the same time. Please advise as I am verz new to Labview and perhaps I am missing somethings.
Cheers,
Biswa
Message 1 of 7
(4,142 Views)
Hello Biswa,

LabVIEW tries to execute as much as possible in parallel. You should programmatically clarify that the synchronization happens before running the loops. Please keep in mind, that any element in your block diagramm only runs if all connected inputs contain valid values.
A simple and often used method to define a specific dataflow is to connect the error cluster and to have your elements stringed like a pearl necklet.
You have to be aware which parts of your program can be run parallel and what parts have to run in serial.
A second point is: You should use timing functions inside of your while loops because without them the loop takes all of your processor load, other processes can't be done.

I hope these remarks help.
National Instruments
District Sales Manager
0 Kudos
Message 2 of 7
(4,118 Views)
Hi there,

Many thanks for the message. I have timers inside the while loops such that they are timed well. My objective in this VI was to output a white noise trace at 20kHz for 10 seconds and then ellicit a TTL pulse on a digital line at the start of the white noise. I used the synchronize timed loop VI but I see that the TTL pulse is around 19-30 ms prior to that of the noise trace. I will certainly hook the error output of both the timed loops together such that they wait for each other. Is it likely that for equal prioroty timed loops with no offset, there is a jitter between the two, like the one that I observe. Your advice on this would be appreciated.

Cheers,
Biswa
0 Kudos
Message 3 of 7
(4,114 Views)
Hello Biswa,

you have to consider that there are running many processes in parallel on your system, e.g. your virus scanner is always running in the background. Every while loop that you use is running in single thread, so what can happen is that one thread (one loop) can start, but the other one hangs due to some background processes.
You can minimize the used while loop when you don't use express-vis. The functions contain a lot overhead that slows your system.

You have to connect the error output of the "Synchronize Timed Structure Starts" as an input to your while loops. This defines both loops to start running when the signal is present. This is the simplest possibility to minimize the jitter. Another possibility would be to stop all unnessessary background processes on your system, e.g. to deactivate your virus scanner.
National Instruments
District Sales Manager
0 Kudos
Message 4 of 7
(4,099 Views)
Hi there,

Thanks for the message and apologies for not being able to respond earlier. I changed the VI according to your advice (attached) but the delay seems to be considerable but certainly a bit lower than my original program. Your advice on this would be highly appreciated.

Also, when there are two synchronized time loops, how does the priority function in this scenario. Do I keep it the same for both the loops since they are to start at the same time or do you suggest some other alternative. According to what I read, if two loops have same priority, the one that has all the input data runs first? How does this hold for synchronized timed loops?

Thank you,

Biswa
0 Kudos
Message 5 of 7
(4,068 Views)
Hi Biswa,

I aplogize for my late response, but I haven't been at the office for some days.

How do you measure the differences between the starting of your loops?

Again, I strongly advise you not to use express-VIs. An example how to generate pulses can be found at

http://sine.ni.com/devzone/cda/epd/p/id/4487
http://digital.ni.com/public.nsf/websearch/A2DEBBA4C766363386256D1D0069D58F?OpenDocument

I think you have to simplify your LabVIEW code. There are many things that are defined to happen, so there is a lot to do at the background that slows down the execution of your program. This behaviour is also caused by express-VIs.

On the other hand, there is no chance to get better than the time that your operation system gives to the various threads.
You cannot determine what loops starts earlier when they are defined to be executed at the same time. The synchronized timed loops wait at each other.


National Instruments
District Sales Manager
0 Kudos
Message 6 of 7
(4,029 Views)


@Biswa wrote:
I wan to synchronise two time loops ...
Your timed loops run for exactly one iteration and you don't even use any synchronization code. Their relative start time is not deterministic as you notcied experimentally. Why even use a timed loop if you don't "loop"???
 
Your code needs a major cleanup, because you have large sections of duplicate code that can be consolidated.
 
It seems silly to place two individual timed loops in parallel and expect them to occur at the same time. Why not place all code of both loops into one timed loop instead?
 
Then you are writing to files in paralell to the DAQ code, further delaying things arbitrarily.
 
Suggestion: Place all DAQ parts in one tight timed sequence and do all the file writing, etc. at the end.
 
I don't have DAQ installed, so I cannot look at your configurations, but if this all should really occur at precise times, you should use hardware timing for the entire sequence of events.
Message 7 of 7
(4,022 Views)