LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Set time delay in different part in VI

Solved!
Go to solution

Hello, I wrote an laser scanning imaging code which includes the mirror scan settings and data sampling settings. When I click white arrow to start the program, the scan settings always 2~3 seconds delayed than the data sampling part. 

I don't know how to add a delay to data sampling at the start. I tried to add delay in for loop or while loop. They did not work or delay at each loop. 

I only need one 2~3 second delay for the data sampling to make sure it is synchronized with the mirror scan part. (VI attached)

Thank you

0 Kudos
Message 1 of 7
(1,954 Views)

Hi Rhapsody,

 

at first you should clean up the block diagram to make the VI readable…

 

How good do you need to sync both DAQ loops?

  • For simple approach you could use DataDependency to start both loops at (basically) the same time.
  • For better approach you should not use the DAQAssistent ExpressVI, but plain DAQmx function. Then try to use a syncing option in DAQmx to start AI and AO tasks at the very same time…
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 7
(1,943 Views)

Hi, GerdW, 

The VI I attached is mainly consisted of the scanning part and the AI part(AI part is directly from AI example in Labview). I used to tried not to use the DAQ assistant for scanning control, but I cannot complete the synchronization between AI and two channels AO (one channel for one mirror). 

Can you please send me a template of synchronization between AI and two AOs if you have one in hand. 

Thank you very much.

0 Kudos
Message 3 of 7
(1,935 Views)
Solution
Accepted by Rhapsody16

If you want to just pause between two subVIs that are wired together just insert a "stall data flow,vim" into that wire and wire the number of ms to wait into the stall.

 

Programming -> Timing -> Stall Data Flow.vim

 

If the two subVIs do not have any dependencies put the second one in a single frame flat sequence and wire some output of the first to the frame with a stall data flow between the first subVI and the frame.  The variable does not have yo be used in the frame, just be wired to it in order to manage the data flow.

 

PS next time save your program to V2012 so that everyone can open it,

0 Kudos
Message 4 of 7
(1,904 Views)

Hi, GerdW,

Please have a look at the previous version of VIs I attached. One is the 2 channel output only and the other is 2 output channel and 1 input AI channel which need to be synchronized.

In the output only vi, I add a channel in the code but it shows error of channel not matching. 

In the 2AO1AI vi, it says the error of specified resource is reserved. 

Can you please help me to modify them?

Thank you very much

 

0 Kudos
Message 5 of 7
(1,872 Views)

Hi, Tom,

Thank you for your suggestions. I have add the time delay in the code and it seems more synchronized than before and I think it is better to do it through DAQmx. 

I have tried to write some synchronized code for 2AO channel and 1 AI channel. but it shows error as attached. 

In the purpose of finding the problem, I wrote another 2 AO only code and still error. I need to set different AO frequencies and amplitudes separately but I found some errors happen.

Could you please help me to modify these codes?

Thank you very much

0 Kudos
Message 6 of 7
(1,868 Views)
Solution
Accepted by Rhapsody16

I only have time to drop some hints.

 

1. You should not branch the AO task wire and try to start it twice.  Both channels of data should be written to the one and only AO task before starting it.  Be sure you've defined the same # samples for both channels.

 

2. I've been in a lot of discussions about DAQmx hardware sync.  Couldn't find many examples quickly, but here's one that can act as a starting point.  You'd just substitute your AI task in place of the CTR edge-counting task in the example.  And of course you'd handle your AI data differently than the way the example handles the CTR data.  But the key concepts are described and illustrated nicely -- share a sample clock signal and start the master task last.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 7 of 7
(1,852 Views)