Hi,
I have an issue with digital acquisition I am using the DAQmxReadRaw function and change detection mode, When I try to test my acquisition using a 5volts power suplly all leds indicators connected to this raw turn red (0 value) instead of turning green only the input I passed the 5volts onto.
Here the the code used to make this acquisition:
main file
int32 CVICALLBACK DigitalInputsAcquisition(TaskHandle taskHandle, int32 signalID, void *callbackData)
{
int PowerFailureByte;
int EngineFailureByte;
int TemperatureFailureByte;
int BrakeResistorFailureByte;
int OilLevelHighByte;
int OilLevelLowByte;
double OilTankVal=0;
//DAQmxReadDigitalU16(DigitalInputsTask, DigitalSamplesPerChan, 10, DAQmx_Val_GroupByChannel, DigitalInputsArray, 8, &SamplesPerChannelRead, 0);
DAQmxReadRaw(DigitalInputsTask, DigitalSamplesPerChan, 10, DigitalInputsArray, 8, &DigitalSamplesPerChan, &BytesPerSamples, 0);
//DAQmxReadDigitalLines(DigitalInputsTask, -1, 10, DAQmx_Val_GroupByScanNumber, DigitalInputsArray, 8, &DigitalSamplesPerChan, &BytesPerSamples, 0);
PowerFailureByte = DigitalInputsArray[0];
EngineFailureByte = DigitalInputsArray[1];
TemperatureFailureByte = DigitalInputsArray[2];
BrakeResistorFailureByte = DigitalInputsArray[3];
OilLevelHighByte = DigitalInputsArray[4];
OilLevelLowByte = DigitalInputsArray[5];
SetCtrlVal(dvdxt, DVDXT_Tension_LED,PowerFailureByte);
SetCtrlVal(dvdxt, DVDXT_Moteur_LED,EngineFailureByte);
SetCtrlVal(dvdxt, DVDXT_Temperature_LED,TemperatureFailureByte);
SetCtrlVal(dvdxt, DVDXT_Resistance_LED,BrakeResistorFailureByte);
SetCtrlVal(dvdxt, DVDXT_Oil_LED,OilLevelLowByte);
SetCtrlVal(dvdxt, DVDXT_Oil_LED,OilLevelLowByte);
if(OilLevelHighByte==1)
{
OilTankVal= 50;
}
else if (OilLevelLowByte==1) OilTankVal = 25;
SetCtrlVal(dvdxt, DVDXT_Tank_Oil_Level, OilTankVal);
return 0;
}
digitalIO.c file
#include <NIDAQmx.h>
TaskHandle DigitalInputsTask;
//****************************************************
//Digital inputs task
//****************************************************
int32 DigitalInputsAcquisition(TaskHandle taskHandle, int32 signalID, void *callbackData);
void CVICALLBACK AcquireDigitalInputs(TaskHandle taskHandle)
{
DAQmxLoadTask("DigitalInputs", &DigitalInputsTask);
DAQmxRegisterSignalEvent(DigitalInputsTask, DAQmx_Val_ChangeDetectionEvent, 0, DigitalInputsAcquisition, 0);
DAQmxStartTask(DigitalInputsTask);
return ;
}
May I use another acquisition function , to get digital inputs one by one?
any suggestions?
Thanks
Olivier