07-08-2010 12:03 PM
Hi all,
I have just started using LabView, and couldn't see the answer to this in the threads that are already up.
I have a delay for my overall program (100ms) in an overall while loop for my program, which dictates the rate at which my data points are taken and saved to a file.
Yet i also have another time delayed case loop, within the original while loop, which controls the the rate at which a load value increases, until it reaches a certian set point.
The problem is that once the case loop has been activated, the time delay within the the case loop (As this is generally larger than the While loop delay), becomes the controlling delay of the whole program and my save file only saves data points at the rate of the case loop delay.
Is there any way to have these two timing delays, yet have the case loop delay only effect the the loop in which it is situated.
Sorry if my termanology is poor, like I say, i've only just started using LabView. Any help is extremely welcome. I have attached a picture of the offending case loop.
Thanks,
Oli
07-08-2010 12:13 PM
I don't see a single loop in your picture. The subject line reads two time loops interfere, yet I don't see any timed loops. Maybe you should attach the entire VI.
07-08-2010 12:32 PM
"Load Applied" and "Loop Number" have race conditions.
Ben
07-09-2010 03:12 AM
tBob, i have attached the actual VI. Sorry the picture wasn't that comprehensive, as it didn't catch the whole VI.
Some of the sub VI's have been construted by the firm which produced the load unit.
Thanks.
07-09-2010 03:27 AM
Sorry Ben, I'm unsure what a race condition is.
The setup, is so that as the case loop iterates, it increases the load value for an IV curve, and the value, is set at a particluar load for a set amount of time. The problem is that i want the data to log every 100ms, independent of the IV Curve (Case Loop) application.
Thanks.
07-09-2010 07:08 AM
@Clubber wrote:
I have a delay for my overall program (100ms) in an overall while loop for my program, which dictates the rate at which my data points are taken and saved to a file.
Yet i also have another time delayed case loop, within the original while loop, which controls the the rate at which a load value increases, until it reaches a certian set point.
The problem is that once the case loop has been activated, the time delay within the the case loop (As this is generally larger than the While loop delay), becomes the controlling delay of the whole program and my save file only saves data points at the rate of the case loop delay.
The loop isn't complete until all commands have executed, if that involves several waits the longest wait will determine the speed.
In this case you can get the time in the case and see if enough time has passed to make it execute.
/Y
07-09-2010 09:47 AM - edited 07-09-2010 09:49 AM
If the IV Apply boolean is True, the case structure will execute. The delay in the True case will cause the entire loop to wait until that delay is over before it will iterate again. You will not be able to write to the file every 100mS. But why write every 100mS? Why not just collect the data every 100mS to an array, and write at the end of the code. Also you have two writes, Conbine them into one by concatenating the strings. File write uses the OS and takes a long time. Just do it once. As for the long delay in the True case, try putting this case structure in a separate loop in parallel to the main loop so it doesn't slow down the main loop;
As for Race conditions, how do you know which value will be in Load Applied local that goes into the selector. Is it the Load Applied value from the last loop iteration? Is it the Load Applied value from the True case after the add function? Or is it the Load Applied value that is loaded inside the flat sequence structure, which would be 0? There is no telling since these functions operate in parallel. This is a race condition. Use wires instead of locals. Then the wires will control the execution flow and Load Applied will be consistent every loop iteration.
I don't see a race condtion with Loop Number because the increment function is between the local and the indicator. The data flow will always read from the local before writing to the indicator. However, a shift register would be a better choice. In fact, you don't even need a Loop Number local or the add function. Just use the i terminal of the loop. It contains the loop number.
Why do all newcomers have to have such huge block diagrams with lots of space that takes up more than one monitor screen. I don't like scrolling all over to view the entire code.