LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

how to start two or more tasks at the same time?

Hi all,

  I have few tasks setup to send analog and digital output to different channel with buffer and given sampling rate. I need to precisely control the timing of samples output to each channel. But if I start the task in labwindows

 

    DAQmxStartTask(taskHandle1)

    DAQmxStartTask(taskHandle2)

    DAQmxStartTask(taskHandle3)

 

they actually not start at the same time since they are exectued in sequence. I wonder how much time delay will be if I start each task in sequence. Also, is it possible to have 2 or more tasks started at the same time?

 

p.s. I think it will be easier if I could bind different channels to a single virtual channel but I don't think it is possible to create a signle virtual channel with analog channel and digitial channel.

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

I had success in doing something similar on the input side by sharing the same sample clock across the tasks with:

DAQmxCfgSampClkTiming (DigitalTaskHandle, "/Dev1/ai/SampleClock", 1000, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, 1000);

In my application I had the power to have the same acquisition speed on all tasks, so that the sample clock could be same on all of them.

 

The conceptual framework is this one (pay attention to the step order):

  1. Setup your AO task
  2. Setup your DO task
  3. Set the DO task to share the AO sample clock with the instruction given above
  4. Start the DO task (IMPORTANT: it must precede the AO task start, so that DO task is started but does not generate samples)
  5. Start the AO task

If you have different sample speed on the tasks, I suppose an alternative is to use a start trigger sharing some digital signal among them. I have seen examples that use a separate counter output as a start trigger.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 3
(4,254 Views)

@RobertoBozzolo wrote:

I had success in doing something similar on the input side by sharing the same sample clock across the tasks with:

DAQmxCfgSampClkTiming (DigitalTaskHandle, "/Dev1/ai/SampleClock", 1000, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, 1000);

In my application I had the power to have the same acquisition speed on all tasks, so that the sample clock could be same on all of them.

 

The conceptual framework is this one (pay attention to the step order):

  1. Setup your AO task
  2. Setup your DO task
  3. Set the DO task to share the AO sample clock with the instruction given above
  4. Start the DO task (IMPORTANT: it must precede the AO task start, so that DO task is started but does not generate samples)
  5. Start the AO task

If you have different sample speed on the tasks, I suppose an alternative is to use a start trigger sharing some digital signal among them. I have seen examples that use a separate counter output as a start trigger.


Thanks a lot. It gives me a good information, I think that will help. I am encountering another sitution, if task1 is analog output with continuous samples with rate 100000 samples/second and task2 and task3 are a single digital sample (i.e. write only 1 sample to one digital line). In task1, I write continuous samples and there will be a spike (of 2.2V) at the time 1.2ms after the task started. And I want to write to the digital channels (task2 and task3) at 0.2ms before the spike was set in task1. In this case, there is only one sample written to DO task, so how does it work to use the sample clock source?

 

In your last suggestion, we could use tirgger but how does it help? Is there any example I can follow? Thanks.

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