LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Configuring a synchronized time to plot. 7.1

In the attached app you can see I have two while loops each with various inputs. I want to make a plot from data in both of these loops but it gets a bit complicated for my skills.(it could take me forever to figure this out but I know it is simple). The problem is that the lower loop is usually delayed at the start so the time (x data on its graph)drags about 3 seconds behind the other loop. I could graph all this data in excel and then synch all the data by subtracting the lag but this would be a pain to do every time. I want to take the temperature data from the upper loop input and graph it against the lower loop input. Knowing that the latter drags behind the first means that I have to first synchronize the time scales to each other. I suppose this means pulling the time out of both individual plots and then applying a subtraction function and then regraphing. I dont know how to go about this exactly. Any help would save me so much time. I am new to this...and am lucky to come as far as I have. Thanks
Jim
0 Kudos
Message 1 of 5
(2,663 Views)
0 Kudos
Message 2 of 5
(2,635 Views)
Hi Tim,

There are 2 While loops in your program and there are no wires to indicate that the timing with these loops. To make sure that these loops run in parallel, I would suggest passing a wire from the DAQ VIs above as an input terminal to the bottom wire loop. In LabVIEW, no code is executed until all the input wires have values passed to them. This is essentially dataflow programming. Even though the bottom loop does not need any input from the DAQ VIs above, I would use the branch the error cluster wire to the bottom loop to indicate to that loop that the two while loops are to be executed in parallel.

The other point to mention, is that there is no wait in either of your while loops. NI suggests that you ALWAYS include a Wait in your while loops just so the CPU can allow other processes to run, even briefly. In particular, even a Wait of 0 ms will cause the CPU to pause for such a brief split second of time that other processes will execute. This will enhance the overall performance of your program and I would suggest placing Wait functions in both while loops.

Hope this gives you a couple ideas. Good luck!

Kileen
0 Kudos
Message 3 of 5
(2,616 Views)
thanks for the tip on the wait function! As far as what you said before I think I understand what you are saying, but I think their might be a problem. The lower loop talks to a mass spec through a serial port and if operations do not run fast enough to retrieve data from it then it could get bufferd within the mass spec and mess up data synchronization in real time. I made two loops in hopes that they could run independently of each other and not mess with each others timing yet still be made to combine data in time for graphing. If the top loop slows too much it errors (kind of a problem) and the lower loop can cause this so it seems if they are seperate all things are better. A wait function could be the answer however for the time being, because a lot of the differences in the timing in the two loops is caused by the initalization of the mass spec in the lower loop. Maybe I should find a way to trigger the top loop when the lower loop begin data retreival. Thanks
Tim
0 Kudos
Message 4 of 5
(2,612 Views)
Hi Tim,

Since you have LabVIEW 7.1, you can consider using Timed Loops, introduced in LabVIEW 7.1. There is an excellent shipping example that can be found: LabVIEW 7.1\examples\general\timedloop.llb\Multi-rate timed loop preemption.vi. I’ve also attached a timed-loop example with a real-time chart below. Additionally, to learn more about timed loops:

NIDZ Tutorial: Using the Timed Loop to Write Multirate Applications in LabVIEW

Also, for communication between parallel while loops, you can consider using the Producer/Consumer with Events:
NIDZ Tutorial: Changing the Face of Design Patterns with LabVIEW 7 Express Event Structure

Best of luck!

KIleen
0 Kudos
Message 5 of 5
(2,596 Views)