Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

AO_VWrite -> DAQmxWriteBinaryU16 but parameters?

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));
 


  
I'm converting DAQ to DAQmx..from Parkoz.com
0 Kudos
Message 1 of 4
(3,361 Views)
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,
Daniel S.
National Instruments
0 Kudos
Message 2 of 4
(3,340 Views)
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,

I'm converting DAQ to DAQmx..from Parkoz.com
0 Kudos
Message 3 of 4
(3,334 Views)
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,
Daniel S.
National Instruments
0 Kudos
Message 4 of 4
(3,315 Views)