Discussion:
AO_VWrite -> DAQmxWriteBinaryU16 but parameters?
(too old to reply)
anarkie
2008-07-30 14:10:11 UTC
Permalink
Hello?
 
I tried to find conversion from AO_VWrite to DAQmxWriteBinaryU16, but there was nothing special. So I add this one here.
 
As you know, AO_VWrite accepts a float parameter then converts it into a binary code. This binary is to be written to the port.
 
But!!! DAQmxWriteBinaryU16 accepts an unsigned integer array, not a float.
 
Questions
1. Is this code right conversion? I want to write a floating point voltage to the port.
2. Is actually DAQmxWriteBinaryU16 converting it and writing a binary to the port? There is no explanation in NI-DAQmx C help file.
 
 
 TaskHandle   AO_handle=0; int32             error=0; char              errBuff[2048]={'\0'}; uInt16       iCurrentVoltValue = (uInt16)(fCurrentVoltValue + 0.5f); int32             sampsPerChanWritten = 1000; int32             numSampsPerChan=1000; 
 DAQmxErrChk(DAQmxCreateTask("",&AO_handle));
 DAQmxErrChk(DAQmxCreateAOVoltageChan(AO_handle, csChannelName,"",0,10,DAQmx_Val_Volts,NULL));    DAQmxErrChk(DAQmxWriteBinaryU16(AO_handle, numSampsPerChan, TRUE, 10.0, DAQmx_Val_GroupByChannel,           &iCurrentVoltValue, //this is an array.          &sampsPerChanWritten, NULL));  //Because the voltage can be unsigned value, we need the DAQmxWriteBinaryU16.  DAQmxErrChk(DAQmxStartTask(AO_handle));   
dansch
2008-07-31 23:10:09 UTC
Permalink
Hi anarkie,In the case that you are trying to write a floating-point value, you would want to use the DAQmxWriteAnalogF64 function. According to the DAQmx C Reference Help, this function "writes multiple floating-point samples to a task that contains one
or more analog output channels." Therefore, the function will accept a floating-point value and convert it to binary automatically. The DAQmxWriteBinaryU16 only accepts unsigned 16-bit integers directly, and thus there is no conversion which takes place. Hope this helps,
anarkie
2008-08-01 02:40:18 UTC
Permalink
Oh, thanks a lot!Then in case of digital
output, can I use the same function (DAQmxWriteBinary..) after creating
a digital output with DAQmxCreateDOChan()?Regards,
dansch
2008-08-01 14:40:22 UTC
Permalink
Hi anarkie,For a digital write, you will want to use the "DAQmxWriteDigital..." functions. With these functions, you have the choice of a single 32-bit integer or an array of 8-,16-, or 32-bit unsigned integers. You can see a quick description of each of the DAQmx Write functions in the NI-DAQmx C Reference Help under NI-DAQmx C Functions ยป Write Functions. Hope this helps,
Loading...