LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Running multiple tasks on the Analog Output card NI-6738

I am having difficulty getting this card to do something that seems pretty simple to me.  All I want to do is have a couple tasks running independent of each other.  For instance I would like to start a "task1" to output a continuous sine wave say on AO1.  Then at some point down the road I would like to start "task2" to send a short pulse on say "AO15".  The channels make no difference to me but from my understanding they would have to be on different banks.  The only way I see that you can do multiple tasks at once is with the "On Demand" timing option.  This also makes it start outputting the task as soon as you write it to the channel instead of waiting for a "start" task.  This I can deal with but it is annoying.  The biggest issue is that in this mode it doesn't seem to do "continuous".  It seems to only do "finite" no matter what I set the mode to.  This makes the first part of what I want to do not possible.  Does anyone know of a way around this or am I doing something wrong?  I have attached an image of my test VI for reference.

0 Kudos
Message 1 of 7
(645 Views)

@BretRidgel42 wrote:

I am having difficulty getting this card to do something that seems pretty simple to me.  All I want to do is have a couple tasks running independent of each other.  For instance I would like to start a "task1" to output a continuous sine wave say on AO1.  Then at some point down the road I would like to start "task2" to send a short pulse on say "AO15".  The channels make no difference to me but from my understanding they would have to be on different banks.  The only way I see that you can do multiple tasks at once is with the "On Demand" timing option.  This also makes it start outputting the task as soon as you write it to the channel instead of waiting for a "start" task.  This I can deal with but it is annoying.  The biggest issue is that in this mode it doesn't seem to do "continuous".  It seems to only do "finite" no matter what I set the mode to.  This makes the first part of what I want to do not possible.  Does anyone know of a way around this or am I doing something wrong?  I have attached an image of my test VI for reference.


Hello, 

 

Your suspicions are correct, the code is not correct. The best thing to do in your case is to open labivew then go to Help -> Find Examples ... when you get the example finder window open search DAQmx and you will see many examples of how to setup and use DAQmx tasks with external hardware. Take one of these examples that suits you and modify it to do what you want. 

 

Jay14159265_0-1708034042876.png

 

______________________________________________________________
Have a pleasant day and be sure to learn Python for success and prosperity.
0 Kudos
Message 2 of 7
(604 Views)

I am looking through these examples and I do not see one that does multiple tasks or one that uses on-demand and continuous output.  The one on-demand example was a bit weird.  It never sets the mode, so maybe it defaults to on-demand?  Is there an example in particular you think goes into this issue?  There are a lot of them, but not really that many analog output ones.

0 Kudos
Message 3 of 7
(575 Views)

Hi Bret,

 


@BretRidgel42 wrote:

All I want to do is have a couple tasks running independent of each other.  For instance I would like to start a "task1" to output a continuous sine wave say on AO1.  Then at some point down the road I would like to start "task2" to send a short pulse on say "AO15".  The channels make no difference to me but from my understanding they would have to be on different banks.


  1. First step: Can you create a VI that creates a task to output a waveform continuously on one AO channel? (This should be possible using the example VIs from example finder.)
  2. Next step: duplicate the VI and create another task using a different channel (from a different bank to allow independent outputs). Can you run both VIs in parallel?
  3. Integrate the functionality into one VI (if needed)…

Do you get any errors when trying to run those VI(s)? If yes: which errors do you get?

 


@BretRidgel42 wrote:

This also makes it start outputting the task as soon as you write it to the channel instead of waiting for a "start" task.  This I can deal with but it is annoying.


Did you try any trigger option for the DAQmx task? I don't see this in your image!

DAQmx (usually) supports several kind of triggers…

 


@BretRidgel42 wrote:

I have attached an image of my test VI for reference.


An image is fine for a first impression, but did you know we cannot edit/debug/run images in LabVIEW?

Best regards,
GerdW


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

Your device only has 1 "timing engine" available for AO, so you can have no more than 1 hardware-clocked AO task running at a time.

 

As you've found, you could alternatively have 2 (or more) software-timed on-demand AO tasks running at the same time.

 

My vague memory that I don't really trust, and probably based on a much older generation of AO card like the 6733, is that no you also can't have one of each.  I carry around a conclusion that any hardware-clocked AO task must be the *only* AO task on a given device.  (It's possible this has changed with later generations of hardware and DAQmx driver, but I don't particularly expect that it has.)

 

About the only way around it with just a single device is to put both AO channels into a common task, and write 0V data to each channel during all the idle times you don't want to output anything.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy coming to an end (finally!). Permanent license pricing remains WIP. Tread carefully.
Message 5 of 7
(553 Views)

So I am ok with the on-demand to get multiple tasks to work.  And that work fines.  I can get two tasks to run on the card as long as they are from different banks.  So the big issue is why when using "on-demand" does the finite/continuous mode not work.  It is always finite.  I do not see anything in the documentation as to why this is.

0 Kudos
Message 6 of 7
(538 Views)

@BretRidgel42 wrote:

So I am ok with the on-demand to get multiple tasks to work.  And that work fines.  I can get two tasks to run on the card as long as they are from different banks.  So the big issue is why when using "on-demand" does the finite/continuous mode not work.  It is always finite.  I do not see anything in the documentation as to why this is.


On demand is a "software timed" event that runs intermittently and is probably best for use reading values instead of writing values. It ignores finite/continuous mode. From the docs:

 

  • On Demand—Every time the Read or Write function/VI executes, the device produces the requested samples as fast as possible. In this mode, the Sample Quantity attributes/properties are ignored. On-demand timing is a type of software timing.

https://www.ni.com/docs/en-US/bundle/daqhelp/page/smpletimingtype.html

 

It has been a few yeas since I used NI hardware but I remember having a single task/clock that put out different hardware timed waveforms on separate AO outputs. The trick was to update the waveform for the AO so if you wanted a pulse, your waveform would be 0v and then when you wanted the pulse you could update the waveform from 0v to the pulse waveform. You can also do tricks like looping your clock signal out and back in to a counter to generate other slower clocks. IMO LabView abstracts too much when it comes to DAQmx, it makes it more confusing than it should be.

______________________________________________________________
Have a pleasant day and be sure to learn Python for success and prosperity.
Message 7 of 7
(531 Views)