Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

NI-DAQmx VisualStudio C++ 6 Single point analog output

Specs: NI-DAQmx 7, VisualStudio C++ 6.0,  PCI-6722,8channel AO
 
We have a very simple application: set a voltage (actually 6 channels) and keep it until we want it changed again, perform the change very quickly in response to an image capturing algorithm. So I don't need any waveforms or buffering.
 
In this forum post http://forums.ni.com/ni/board/message?board.id=231&message.id=3283&query.id=18094 you talk about an AOOnePoint example, but I get an error that the NI-DAQ driver does not support my device.
 
I may need to use NI-DAQmx, but how? I would like to use something like AO_VWrite(,,), maybe for 6 channels in one call. But I can't find it in NI-DAQmx. It seems I need to setup buffers and frequencies. I have a working sample, but it seems a slow and certainly overkill of this simple application:
 
// Link with \DAQmx ANSI C Dev\lib\msvc\NIDAQmx.lib
#include "NIDAQmx.h"
double[2] data;
int taskHandleAnalog;
int written;
void Init()
{
    DAQmxErrChk (DAQmxCreateTask("",&taskHandleAnalog));
    DAQmxErrChk (DAQmxCreateAOVoltageChan(taskHandleAnalog,"Device and Channel Info","",0,10,DAQmx_Val_Volts,NULL));
    DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandleAnalog,"",1000,DAQmx_Val_Rising,DAQmx_Val_ContSamps,NUMBER_OF_AO_SAAMPLES));
    DAQmxErrChk (DAQmxWriteAnalogF64(taskHandleAnalog,NUMBER_OF_AO_SAAMPLES,0,1.0,DAQmx_Val_GroupByChannel,data,&written,NULL));
    DAQmxErrChk (DAQmxStartTask(taskHandleAnalog));
}
 
void SetVoltage( double voltage )
{
    data[0] = voltage;
    data[1] = voltage;
    DAQmxStopTask(taskHandleAnalog);
    DAQmxErrChk (DAQmxWriteAnalogF64(taskHandleAnalog,NUMBER_OF_AO_SAAMPLES,true,10.0,DAQmx_Val_GroupByChannel,data,&written,NULL));
}
0 Kudos
Message 1 of 2
(4,142 Views)
Hi,
 
It looks like you simply wants to output voltages on the analog output channels, but only wants one update at a time with no waveforms or buffering in DAQmx.
 
As I'm sure you know there are really just 3 types of measurements.  Single Point, Finite, and Continuous.  Since you want a single value at a time it's just a Single Point operation.
 
You can find DAQmx examples for single point operations in this path:
C:\Program Files\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Analog Out\Generate Voltage\Volt Update
 
Simply place the DAQmx Write Code within a loop and you will be updating one value at a time, but multiple times when "we want it changed again".
-----------------------------------------------------
Dennis Morini
District Sales Manager
National Instruments Denmark
http://www.ni.com/ask
Message 2 of 2
(4,110 Views)