A Quick Introduction to NI-DAQ
Status Codes
  • Each NI-DAQ C function is of the following form:
    status = Function_Name(parameter 1, parameter 2, ..., parameter n);
  • Each function returns a value in the status variable that indicates the success or failure of the function as shown below.

    Status Result
    Negative Function did not execute because of an error.
    Zero Function completed successfully.
    Positive Function Executed but with a potentially serious side-effect.
Primary Data Types
  • NI-DAQ data types

    Type Name Description C Type
    U8 8-bit ASCII character char
    I16 16-bit signed integer short
    U16 16-bit unsigned integer unsigned short
    I32 32-bit signed integer int
    U32 32-bit unsigned integer unsigned int
    F32 32-bit single-precision floating point float
    F64 64-bit double-precision floating point double
    STR BASIC or Pascal character string char *
    HDL HI_DAQ_Mem or DSP Memory handle long
Basic Functions
  • i16 Timeout_config(i16 deviceNumber, i32 timeout);
    Function Timeout_config() is used to establish a timeout limit that is used by the synchronous functions to ensure that these functions will eventually return control to the software application.
    • deviceNumber refers to the number that the computer assigns to the data acquisition board as a label.
    • timeout is the number of timer ticks. The duration of a tick is 55 ms, and there is approximately 18 ticks/s.
  • i16 DAQ_Op(i16 deviceNumber, i16 chan, i16 gain, i16 buffer, u32 count, f64 sampleRate);
    This function performs a synchronous, single-channle DAQ operation in order to acquire A/D conversion samples and stores them in a buffer.
    • deviceNumber refers to the number that the computer assigns to the data acquisition board as a label.
    • chan refers to the analog input channel number.
    • gain is the gain setting to be used for the specified channel.
    • buffer is an integer array or an NI_DAQ_MEM array.
    • count is the number of samples to be acquired.
    • sampleRate is the desired sample rate in units of pts/s.
    • DAQ_Op() does not return control to the application until NI-DAQ acquires all the required sample or until an acquisition error occurs.
  • i16 DAQ_VScale(i16 deviceNumber, i16 chan, i16 gain, f64 gainAdjust, f64 offset, u32 count, i16 *binArray, f64 *voltArray);
    Function DAQ_VScale() converts the values of an array of acquired binary data and the gain setting for that data to actual input voltages measured.
    • deviceNumber refers to the number that the computer assigns to the data acquisition board as a label.
    • chan is the on-board channel or AMUX channel on which the binary data was acquired.
    • gain is the gain setting at which NI-DAQ acquired the data in binArray
    • gainAdjust is the multiplying factor to adjust the gain.
    • offset is the binary offset that needs to be subtracted from the readingo.
  • nidaqExtRetType NIDAQErrorHandler(i16 iStatus, char *strFuncName, i16 iIgnoreWarning);
    Function NIDAQErrorHandler() displays an error message when an error occurs in the NI-DAQ application.
    • iStatus is the error code of the particular error that occurred.
    • strFuncName is the name of the function that caused the error.
    • iIgnoreWarning is a flag for ignoring a warning message.