Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Read the state of a DO line in C++ DaqMx Api?

How can I read the state of a digital out line in a digital out task using the C/C++ DAQmx API?  LabVIEW apparently has that capability: http://digital.ni.com/public.nsf/allkb/65A3DB0767ED26478625734C007271C8



However, when I try do do it in simulation mode I always get back an array of false/0.  I don't have immediate access to hardware to try this with a live multifunction DAQmx device. 

The application is that it would be very useful to know the initial state of the digital I/O lines prior to setting them in a DAQmx Digital Out task.

Thanks,


Dave Gladfelter

0 Kudos
Message 1 of 2
(2,884 Views)

Dave,

I have verified the use of the VI mentioned in the developer zone with an e-series card.  This method can be utilized to read the digital output at any point in the program.  The following functions in C can be utilized in the same architecture as the LabVIEW example. 

int32 DAQmxCreateDOChan (TaskHandle taskHandle, const char lines[], const char nameToAssignToLines[], int32 lineGrouping);

int32 DAQmxReadDigitalU8 (TaskHandle taskHandle, int32 numSampsPerChan, float64 timeout, bool32 fillMode, uInt8 readArray[], uInt32 arraySizeInSamps, int32 *sampsPerChanRead, bool32 *reserved);

I also verified that all values will be read as false when the hardware is simulated.  If you would like to know what the power up state of the digital lines are, keep in mind that this is hardwired in some cards while others can programmatically change this.  The power up state can be changed through Measurement and Automation Explorer by right clicking on the device and selecting properties>>power up states.  This information can be found in the manual of your device.      

0 Kudos
Message 2 of 2
(2,859 Views)