LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

timing in parallel while loops

Hi,

 

I'm having some issues with timing of while loops when two loops execute in parallel.

 

I have one loop which writes to a GPIB device every x ms to produce a regular signal, and another that reads from another device continuously (no delay time) to produce a trigger when it recieves a specific output.

 

Both of these loops work fine alone, but together they screw up the timing. I can't simply add a delay to the second loop, since the trigger signal must be read and executed straight away, even 1ms delay might cause me to miss the effect I'm looking for...

 

Thanks for any help!

0 Kudos
Message 1 of 4
(3,231 Views)

Bob75,

 

Are you running in a real-time OS? No desktop OS can give you reliable 1 ms response timing.

 

To get two parallel loop to share CPU resources with minimal delay put a Wait (ms) function in each loop. Wire a value of zero to the Wait in the fast loop. A wait of zero will cause LabVIEW's internal scheduler to switch loops without adding significant delay.

 

Lynn

Message 2 of 4
(3,222 Views)

Thanks Lynn,

 

I'm the same person who posted this question as bob75... Slight mix up with accounts...

Anyway, I have found that my code seems to run faster overall when I merge the two parallel while loops into one. The only problem is that the code in the faster loop is now slowed. Is this an inherent thing when you run parallel while loops, or could there be a way around it?

 

Also, I am using LabVIEW in windows, no RT software. Do you have any idea of the response times of LabVIEW to an external trigger with and without the RT software?

I'd like some figures in terms of milliseconds delay, to determine whether it's worth buying.

 

Thanks,

Steve

0 Kudos
Message 3 of 4
(3,188 Views)

Did you even try Lynn's suggestion of placing a "0ms" wait in the fast loop? Did it work? The problem you are seeing is due to the fact that a loop without any wait will hog the CPU for many iterations, thus potentially stalling the other loop for extended times (see also).

 

Depending on your hardware, the two loops can also run on mutliple cores.

 

How are you detecting the signal in the fast loop. Can you show us some code?

 

I also agree that you need LabVIEW RT or FPGA to implement this in a robust way. Do you need to react to the trigger in a predictable way or do you simply need to ensure that it is not missed?

0 Kudos
Message 4 of 4
(3,184 Views)