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: 

Continous Analog Out w/o Buffer-Need Example

Greetings
 
I'm using a USB6009 with the NIAQmx C interface.
 
At times I need to generate a 1.0 volt or 0.0 volt output (1 datapoint) on AO0 and just hold it there, until I tell it to change values.  I don't want to cycle in a loop feeding a buffer if possible.  Can someone point me to an example of how to do this?
 
Thanks,
Don Hess
0 Kudos
Message 1 of 5
(2,909 Views)

This code executes without error.  However when I go to measure ao0 on the USB6009 it still reads 0 volts.  All I want to do is lower or raise the output and hold it there on demand.  iWritten returns 1.

float64 f64Min

= 0.0; //0.0 min volts output

float64 f64Max

= 1.1; //1.1 max volts output

float64 fVal

= 1.0; //1.0 volts. What I want output to be

int32 iWritten

= 0;

DAQmxErrChk

(DAQmxCreateTask("AO", &m_hNIAOTask));

DAQmxErrChk

(DAQmxCreateAOVoltageChan(m_hNIAOTask,"Dev1/ao0",NULL,f64Min,f64Max,DAQmx_Val_Volts,NULL));

DAQmxErrChk

(DAQmxWriteAnalogF64(m_hNIAOTask, 1, TRUE, 10.0, DAQmx_Val_GroupByScanNumber, &fVal, &iWritten, NULL));

 

0 Kudos
Message 2 of 5
(2,873 Views)

Hi dthess,

Your code looks good except you never call the DAQmxStartTask function to start the output. This is probably why the output never leaves 0 volts. Once you start the task the output will hold to whatever value you set and not change unless you call the write function again. One thing to remember is that the output will hold the last value written to it even after you stop the task. So if you want the output to be zero volts after your program finishes make sure to write 0 volts to the output before stopping the task. I good example of static timed AO is the example program VoltUpdate. This can be found with the DAQmx ANSI C examples under “C:\Documents and Settings\All Users\Documents\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Analog Out\Generate Voltage\Volt Update”. Please let me know if you have any questions.

Thanks,

Nathan
NI Chief Hardware Engineer
0 Kudos
Message 3 of 5
(2,866 Views)
Just FYI, if you need to write just one single value, you can use the scalar version of the write function:
DAQmxWriteAnalogScalarF64()

Hope this helps.
LDP
Message 4 of 5
(2,839 Views)

Thanks for the feedback guys.  As always it's appreciated.

I found the problem.  I was measureing the voltage on non clamped down screw terminals on the block.  Apparently the circuit does not carry here.  Once I inserted my probe into the clamp port, I saw the voltage swing.

Again thanks,

Don

 

0 Kudos
Message 5 of 5
(2,837 Views)