anarkie
2008-07-30 14:10:11 UTC
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 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));