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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Changing AO during runtime while other AO continue to run

I had thought I knew how to do this... but it's a Monday.  Looked through the examples to no avail.

 

 

I have a PXI-6733 I am using to generate 4 AOs.  All AOs are in the same task as they should be.  I start the task with initially starting up the VI. 

 

1) Two of the AOs are used to write out continuous pressure data to another system and therefore run continuously and need to be uninterrupted. 

2) The other 2 are for sending out Analog command signals as configured by the user during runtime (sine's, ramps, sawtooths, etc.) to a couple controllers.  The user can change the output waveform parameters and then "say go".

 

 

I can successfully configure the buffer: set the size and finite samples for the user configured AOs during runtime.  But when I use the "DAQmx Write (Analog Wfm, 1 Chan Nsamp)" with the user waveforms, I get the -50103 Error (The specified resource is reserved....).  I am using the global virtual channels as the inputs to these blocks so I can get to these channels only. 

 

 

I don't want to "stop" the entire task (all of the channels) and then restart them when the user makes changes.  I just want to start writing the buffer on two of them.

 

Have I lost my mind?  Isn't there some way to do this?

0 Kudos
Message 1 of 8
(4,515 Views)

Hi bradh,

 

I would suggest to start with the AO Non-Regeneration example:

 

Help >> Find Examples... >>  Hardware Input and Output >> DAQmx >> Analog Generation >> Voltage >> Cont Gen Voltage Wf-Int Clk Non-Regeneration.vi

 

You will need to slightly modify the code to work with multiple channels.  It will end up looking something like this:

 

 

Multi_Update.PNG

 

The above would allow you to give an array of Sine/Square/Triangle/Sawtooth wave parameters for the different channels and update them on the fly based on user inputs.  Since your signals are all being defined differently, you might need to change up the code a little bit, but the idea is that you write all of the channels at once with new data to be generated.

 

 

Best Regards,

Message Edited by John P on 09-21-2009 05:37 PM
John Passiak
Message 2 of 8
(4,496 Views)

John,

 

Thanks, I understand what you are doing.  One question though - you are rewriting all of the channels in the task in your for loop.  Is it possible to write say only 2 of the 4 using two "Write Analog Wfm, 1 Channel, Nsamp"?  (All of 4 channels/wfms are at the same sample rate.)  I just need to change 2 of them without stopping the other 2 in the task?   

 

 

0 Kudos
Message 3 of 8
(4,478 Views)
I am also interested to know how to do this....
0 Kudos
Message 4 of 8
(4,465 Views)

Hi guys,

 

It isn't possible to only write to one of the channels at a time in a hardware-timed operation.  Since the analog output circuitry shares a single timing engine, all clocked analog output lines must be in the same task. What I was getting at in my last post is that you can continue to output any desired signal to your channels in this task.  This signal is defined in software, so if you want to only change a single channel it would certainly be possible to only adjust one channel in your array of data and continue to output the same data on the other lines.  This is what the code should do that I posted in my last post.

 

Also, you can put software-timed Analog Outputs in seperate tasks.  Software-timed Analog Outputs will only allow you to write a single value at a time (but you can write over and over based off of a software loop).

 

 

What exact signals do you need to generate?  For function generation (sine wave, sawtooth, etc.) you should probably use a hardware-timed, buffered operation mentioned in my first post.  The user could change the parameters of these signals on-the-fly since the data is constantly being streamed to the board.  The datatype being used in my last post is a 1D array of waveforms--every element is the waveform that will be written to a different channel in the task.  To turn a channel "off" just set this waveform to output 0s.

 

If you want the pressure data clocked off of the same AO clock as the function generation, you could simply build this data into your array that you are writing to the DAQ device.   If you don't need the data to be clocked (e.g. if it's a DC voltage level) then you can always put this into a seperate task that does not include any timing and run it in parallel with the hardware-timed task.

 

 

Best Regards,

John

John Passiak
0 Kudos
Message 5 of 8
(4,449 Views)

@

 

How did you build the cluster that gets unbundled in your example?

 

I tried to use an array but i couldn't get the Waveform Type:string inside it :-(, with cluster i can use only one (?) user Panel?

 

 

Can you please give some insight how to build the input cluster? Thank you!

0 Kudos
Message 6 of 8
(3,815 Views)

Two things here. FIrst this thread is from 2009. You should start a new qestion asking this.

 

THe second is you use a custer not an array. The cluster is located int he cluster palette.

Tim
GHSP
0 Kudos
Message 7 of 8
(3,809 Views)

Okay I know this is an old thread but it reminded me of a technique I used to accomplish this.  

 

So I had two AO in one task, both were PWMs at the same frequency, but different duty cycles.  I had a need to change the duty cycle of either AO while the program was running, but not stop the task, because I didn't want the other channel to stop.

 

The way I did this was I setup the continuous task and wrote my two arrays of set points and had it start.  Then when I wanted to update the values, I used a DAQmx Write property node and set the RelativeTo to 0.  This set my write point back at the start of the buffer.  I then generated a new duty cycle buffer for both channels, and wrote them.  What this did for me was replace the output setpoints I put on the hardware with a new set of points.  A limitation with this technique is the buffer size needs to be the same, and in my case they were because the frequency, and number of cycles in the buffer didn't change, just the duty cycle.

0 Kudos
Message 8 of 8
(3,776 Views)