From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

sequential execution of two analog output tasks

Solved!
Go to solution

I am using a USB-6363 device and NI-DAQmx ANSI C. Is it possible to initialize two tasks, each associated with one independent hardware-timed analog output channel, ao0 and ao1, and run them sequentially without clearing and then re-initializing them every time? In other words, I would like to to do something like this (schematically):

 

CreateTask 0 (ao0, hardware clock)
CreateTask 1 (ao1, hardware clock)

StartTask 0 -> runTask 0 -> StopTask 0 -> StartTask 1 -> runTask 1 -> StopTask 1 -> ...

ClearTask 0
ClearTask 1

 

as opposed to:

 

CreateTask 0 - > StartTask 0 -> runTask 0 -> StopTask 0 -> ClearTask 0 - > CreateTask 1 - > StartTask 1 -> runTask 1 -> StopTask 1 -> ClearTask 1 -> ...

 

The latter method works, of course, but Creating and Clearing tasks takes a lot of time, while I would like to be able to execute my tasks very fast one after another. Is there any way to do that? Could you point me to a relevant example?

Thank you!

0 Kudos
Message 1 of 6
(3,113 Views)
Solution
Accepted by topic author svin

You definitely want to avoid creating and clearing tasks every time you need to send your signal.

 

It sounds like you want to do an Nchannel write. The "Voltage - Continuous Output.vi" in the LabVIEW Example Finder is capable of doing that. Essentially, you pick multiple channels when creating the task, and it would write to the channels in order as quick as possible. Does that sound like what you want to do?

 

Or, are you trying to use two different analog outputs each with their own clocks?

Bill B.
National Instruments
0 Kudos
Message 2 of 6
(3,072 Views)

Thank you very much, Bill!

What you suggest resonates closely with what I have been thinking as well: using two ao channels within one task. And yes, the clock for both channels is the same, so that should not be a problem.

Unfortunately, explaining the whole operation of the instrument will take too long, but if we were to use this two-channel approach, is it possible to write to these channels truly in parallel from two different buffers, as opposed to one channel after another or in the interleaved fashion? Is there a C example of such type of code?

Thank you again!
Sergei V.

0 Kudos
Message 3 of 6
(3,067 Views)
Solution
Accepted by topic author svin

No problem, Sergei.

 

I don't believe the 6363 is capable of truly simultaneous reads or writes. That said the multiplexing rate is usually fast enough that you won't notice it in most applications. Can you tell me why you need to have simultaneous writes? What rate are you trying to write at?

 

It may be that the channels switch fast enough that you don't notice it in your application.

 

As for the C example, what IDE are you working in LabWindows/CVI, Visual Studio, something else?

Bill B.
National Instruments
0 Kudos
Message 4 of 6
(3,045 Views)

Hi Bill,

Thank you!

The goal is to modulate two lasers diodes such that: (1) one (ao0) would generate a e.g. 10 microsecond-long light pulse, followed by e.g. 990 microseconds of inactivity (zeros in the buffer), during which the excited luminescnece would be measured, and then (2) the second laser (ao1) would produce a e.g. 40 microsecond-long pulse, followed by 960 microseconds of data collectiion. It is essential the (2) is performed right after (1), so that the total duration of the experiment is 2 milliseconds. 6363 can run easily at 1 MHz (which is not its maximal samplig rate), so that should not be a problem.

While waiting for your reply I went ahead and played with different arrangements of the channels in my Write task. What you suggest indeed works very well!! However, I noticed that when I do the experiment setting the parameter in the correspnding function as GroupByChannels and filling the 2000-points-long output buffer with values as described above (first values for ao0 and then for ao1), my lasers definitely light up at the same time... as opposed one after another. I can see that by an oscilloscope. So, it seems that the baord is running the two channels simultaneously, at least at the microsceond resolution. This is great, and I can figure out how to live with that.

>> As for the C example, what IDE are you working in LabWindows/CVI, Visual Studio, something else?
I use Qt, and it works with the NI-DAQmx very well.

Thanks again for your help!

Sergei

0 Kudos
Message 5 of 6
(3,041 Views)

Hi,

I'm facing a serous issue regarding this sequential operation of two analog output tasks. I'm using USB DAQ 6002 OEM. this has two analog outputs. For my operation, I,m generating square signal and i need the generated signal to be written on sequential basics. This is for my stepper motor control. At then start the signal must be written on the ao0 pin and after the completion of sequence 1 , next sequence must be executed. Here ta sequence 2 , ao0 must goes to "0" and an analog voltage is written on ao1 pin.

If i use two different DAQ assistant then it shows the error as "task is reserved". Help me to resolve this. 

0 Kudos
Message 6 of 6
(2,609 Views)