Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Start a synchronized analog input acquisition over multiple task with a single digital trigger event

Hello,

 

I would like to know if it is possible to set up a data acquisition script with the nidaqmx python package that is able to trigger 3 seperate analog input tasks with a single digital trigger. I need 3 seperate tasks because each has to acquire data with a different sampling rate. A synchronization of all 3 tasks would be desired. Right now, my code looks something like this:

 

task_1 = ni.Task()
task_1.ai_channels.add_ai_voltage_chan(channel parameters)
task_1.timing.cfg_samp_clk_timing(acquisition parameters)
task_1.triggers.start_trigger.cfg_dig_edge_start_trig("/cDAQ1Mod1/PFI7", trigger_edge=ni.constants.Edge.RISING)
 
task_2 = ni.Task()
task_2.ai_channels.add_ai_voltage_chan(channel parameters)
task_2.timing.cfg_samp_clk_timing(acquisition parameters)
task_2.triggers.start_trigger.cfg_dig_edge_start_trig("/cDAQ1Mod1/PFI7", trigger_edge=ni.constants.Edge.RISING)
 
task_3 = ni.Task()
task_3.ai_channels.add_ai_voltage_chan(channel parameters)
task_3.timing.cfg_samp_clk_timing(acquisition parameters)
task_3.triggers.start_trigger.cfg_dig_edge_start_trig("/cDAQ1Mod1/PFI7", trigger_edge=ni.constants.Edge.RISING)
 
value_card_1 = task_1.read()
value_card_2 = task_2.read()
value_card_3 = task_3.read()

 

The problem with that seems to be that the program seems to wait 3 times for the trigger happening until the acquisition starts. (I cant verify from the data if the acquisition starts 3 seperate times or if only one acquisition is executed after the third time the trigger event happens)

 

I have trouble understanding the documentation of nidaqmx. So if you could guide me to the function able to synchronize those trigger events, that would be very helpful.

 

For the hardware in use: Im working with a NI cDAQ-9178 chassis and a NI 9222, 9223 and 9775 card respectively. The Trigger is excecuted over a NI 9421 card.

 

Thank you in advance

0 Kudos
Message 1 of 4
(355 Views)

@Turukmakto98 wrote:

Hello,

 

I would like to know if it is possible to set up a data acquisition script with the nidaqmx python package that is able to trigger 3 seperate analog input tasks with a single digital trigger. I need 3 seperate tasks because each has to acquire data with a different sampling rate. A synchronization of all 3 tasks would be desired. Right now, my code looks something like this:

 

task_1 = ni.Task()
task_1.ai_channels.add_ai_voltage_chan(channel parameters)
task_1.timing.cfg_samp_clk_timing(acquisition parameters)
task_1.triggers.start_trigger.cfg_dig_edge_start_trig("/cDAQ1Mod1/PFI7", trigger_edge=ni.constants.Edge.RISING)
 
task_2 = ni.Task()
task_2.ai_channels.add_ai_voltage_chan(channel parameters)
task_2.timing.cfg_samp_clk_timing(acquisition parameters)
task_2.triggers.start_trigger.cfg_dig_edge_start_trig("/cDAQ1Mod1/PFI7", trigger_edge=ni.constants.Edge.RISING)
 
task_3 = ni.Task()
task_3.ai_channels.add_ai_voltage_chan(channel parameters)
task_3.timing.cfg_samp_clk_timing(acquisition parameters)
task_3.triggers.start_trigger.cfg_dig_edge_start_trig("/cDAQ1Mod1/PFI7", trigger_edge=ni.constants.Edge.RISING)
 
value_card_1 = task_1.read()
value_card_2 = task_2.read()
value_card_3 = task_3.read()

 

The problem with that seems to be that the program seems to wait 3 times for the trigger happening until the acquisition starts. (I cant verify from the data if the acquisition starts 3 seperate times or if only one acquisition is executed after the third time the trigger event happens)

 

I have trouble understanding the documentation of nidaqmx. So if you could guide me to the function able to synchronize those trigger events, that would be very helpful.

 

For the hardware in use: Im working with a NI cDAQ-9178 chassis and a NI 9222, 9223 and 9775 card respectively. The Trigger is excecuted over a NI 9421 card.

 

Thank you in advance


I don't see any reason why all tasks won't be triggered by a single signal. What would happen if you send only single pulse? Only one task is triggered?

-------------------------------------------------------
Control Lead | Intelline Inc
0 Kudos
Message 2 of 4
(315 Views)

I noticed that it always takes 3 consecutive trigger events for the script to finish. when i tried to only adress two cards with the same script it takes two and with one only one. So it seems like each trigger is only executing one task. When I define the trigger for only one of those cards and leave the others without it looks like the data acquisition is triggered at the right time for the task where a trigger was defined. The other two cards seem to start acquiring data as soon as the task are defined.

 

The problem lies not with the trigger event since when I look at the test panel in NI MAX the edges are count correctly by the PFI channel.

0 Kudos
Message 3 of 4
(302 Views)

Several issues:

 

1. I'm only moderately knowledgeable about cDAQ, but as a general rule any given AI module can only support 1 sample rate at a time.  Do you have distinct AI modules for each of your 3 channels?

 

2.  You never explicitly start your tasks so when you call your read function, each task will be started implicitly at that time.

 

3. Though you haven't shown us what your 'acquisition parameters' are,  it would appear that each is set up to do Finite Sampling.  Thus, the simple 'read()' call will wait for the finite task to accumulate *all* its samples, then return them.  Having done that, it's free to move on and implicitly start, wait, read from the next task.

 

4. But again, even if you explicitly start all the tasks before doing any reads, you're then liable to run into problem #1 above (unless you do indeed have 1 dedicated module per AI channel of interested).

 

5. You'll likely need to end up making a single task for all 3 channels, sampling at the highest rate needed, then running a simple downsampling algorithm in software for the channels where you want a lower apparent sample rate.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy coming to an end (finally!). Permanent license pricing remains WIP. Tread carefully.
0 Kudos
Message 4 of 4
(288 Views)