LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Switch between triggered and untriggered AO: need to clear task each time?

Solved!
Go to solution

Hello,

 

I use the AO to produce a sinusoidal array of values sent out multiple times using Allow Regeneration, with Finite Samples, which is initiated by a trigger. Call this one group.

 

A single test involves hundreds of groups. But, there are gaps between them where other devices are doing things. In that gap, I also change the sinusoidal array values and then restart (waiting for trigger). I would like to use just the Stop Task and Start Task vis for this.

 

The complication is I want the AO to be a specific value in the gap between groups, which might not be the last value of the array. I want a way to say: after the task is done, make the AO sit at X until you hit the next start trigger. Since I'm using regeneration, I can't just put the value on the end of the normal output array.

 

Is there a way to do this without clearing the triggered task, creating a new untriggered task, setting the value, then clearing again, creating a new triggered task, ect., hundreds of times as it goes around the loop?

 

thanks,

Isaac

0 Kudos
Message 1 of 6
(4,071 Views)

can you post a sample of the code where you are doing this (image would be ok)?

--------------------------------------------------------------------------------------------------------------------------------------------------------------------

Wisdom is the principal thing; therefore get wisdom: and with all thy getting get understanding. Proverbs 4:7
0 Kudos
Message 2 of 6
(4,047 Views)
You can create two tasks at the start of your program, but do not start them. This way the tasks can both reference the same output channel. As long as you are careful to stop one task before starting the other you will be OK. You can start and stop the tasks without having to clear/create each time. This will be much quicker and more stable. There may well be other ways of achieving what you need but I think this method is valid. Michael.
0 Kudos
Message 3 of 6
(4,029 Views)

@iBrow1000 wrote:

Hello,

 

 

Is there a way to do this without clearing the triggered task, creating a new untriggered task, setting the value, then clearing again, creating a new triggered task, ect., hundreds of times as it goes around the loop?

 

thanks,

Isaac


Your approach is just a bit off--- but the question is a nice little headwarmer.  It sounds like you need 1 Task outputting a waveform streamed to the device.  Luckilly I went into the Example finder:

Capture1.PNG

That is "C:\Program Files (x86)\National Instruments\LabVIEW 2014\examples\DAQmx\Analog Output\Voltage (non-regeneration) - Continuous Output.vi

 

Some mods would need to be made:

  • Your going to loose hardware triggering and use that trigger source to change the generated waveform parameters. (Probably via queue into the generation loop)
  • remember a sine wave of 0 amplidude and offset of x is a DC waveform at x Volts

The tricky part will be adjusting the granularity of the wafeform length to meet your trigger timing constraints but, you can easilly generate DC wafeforms at very short lengths (Oh, Say 1 sample long) and longer wafeforms while in the "Triggered" mode.

 

Have fun!


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 6
(4,016 Views)

Thanks for the answers all.

 

hmarcano: I'm not going to post code right now, since I'd need to unpick the relevant parts, and I already have some suggestions to work with.

 

Michael78: I was under the impression that you could not send in a different task to Start without Clearing the old one. But, if you're right that than this is what I want to do. Using Stop Task each time doesn't bother me, I just didn't want to re-create the task each time.

 

Jeff: thanks for the different approach idea, but it sounds more complicated than having two alternating tasks and start and stop, assuming I can get that to work.

0 Kudos
Message 5 of 6
(4,006 Views)
Solution
Accepted by topic author iBrow1000

In case anyone else wants to try something similar, you cannot actually transition between two tasks using the same resources (lines) just by using the DAQmx Stop Task VI, because the resources are still reserved.

 

Instead, I replaced Stop Task with the DAQmx Control Task VI, with the action set as 'unreserve'. I can unreserve one task, then start a different one, and in that way go back and forth without needing to Clear or Create the tasks each time (same idea could be used for any number of tasks on the same lines, though I have just two).

 

I tested this by meassuring the analog output and it seems to work, no errors reported in the code.

0 Kudos
Message 6 of 6
(3,955 Views)