LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Synchronize Movement & Write to file actions in loops

Hello,

Can someone please look at my attached vi and advise me.

I am trying to move a motor for (simplicity) 10 steps with 2seconds wait time while recording the spectrum right after reaching each step.

I tried adjusting the time on wait for millisec function but it keeps just increasing/decreasing the number of written to file spectra which is not correct.

How do I link the write to file to end of each movement correctly (to save 10 spectra only in this case).

Thank you,

0 Kudos
Message 1 of 2
(2,664 Views)

It looks like the lower part of your block diagram is processing motor controls, with a loop that moves some distance containing a wait node, then moves again. I guess this is the Wait you're talking about?

 

Meanwhile, the top part of the block diagram writes data gathered from some sort of optical device measuring a series of spectra. However, there is no link to the bottom part of your graph.

 

To synchronise two processes like you have here, you should place some dataflow dependency between them. As an example, you can put them all in the same loop, and have the spectrum measurement take place after the movement finishes. When the spectrum finishes, you can either write the file inside the loop, or build a multi-dimensional array of measurements and write them all at the end.

 

How fast does this need to be? If time is not very limited, you should just move, stop, measure, repeat. At the moment, you have no link between the two elements and so the chance of reliable measurements is very low.

 

As additional comments, your flat sequence structures can be removed using dataflow dependency also, and the Build XY Graph Express node is unnecessary - using Bundle on the two inputs (X and Y) will allow you to pass a cluster of two arrays to a XY Graph.


GCentral
0 Kudos
Message 2 of 2
(2,633 Views)