/********************************************************************* * * Example program: * DAQOp.c * * Description: * Read a waveform from one analog input channel using internal * timing (uses high-level NI-DAQ functions) * * Example Category: * AI * * Example Task Types: * BUF, 1CH, BURST, IMMED, SYNC, INTTRIG * * List of key parameters: * lTimeout, dSampRate * * [Since variables are hardcoded, there is no guarantee that this * program will work for your setup. This example is simply * presented as a code snippet of how you can use NI-DAQ functions * to perform a task.] * * List of NI-DAQ Functions used in this example: * Timeout_Config, NIDAQErrorHandler, DAQ_Op, DAQ_VScale * * [NOTE: For further details on each NI-DAQ function, please refer * to the NI-DAQ On-Line Help (NIDAQPC.HLP).] * * Pin Connection Information: * Connect your analog signal to AI channel 1. The default analog * input mode for the DAQ device will be used. * * [For further I/O connection details, please refer to your hardware * User Manual.] * * [For further details on how to run this example, please refer to * the NI-DAQ Examples On-Line Help (NIDAQEx.HLP).] * *********************************************************************/ /* * Includes: */ #include "nidaqex.h" /* * Main: */ void main(void) { /* * Local Variable Declarations: */ i16 iStatus = 0; i16 j = 0; i16 iRetVal = 0; i16 iDevice = 1; i32 lTimeout = 180; i16 iChan = 2; i16 iGain = 1; f64 dSampRate = 1000.0; u32 ulCount = 100; f64 dGainAdjust = 1.0; f64 dOffset = 0.0; static i16 piBuffer[100] = {0}; static f64 pdVoltBuffer[100] = {0.0}; i16 iIgnoreWarning = 0; /* This sets a timeout limit (#Sec * 18ticks/Sec) so that if there is something wrong, the program won't hang on the DAQ_Op call. */ iStatus = Timeout_Config(iDevice, lTimeout); iRetVal = NIDAQErrorHandler(iStatus, "Timeout_Config", iIgnoreWarning); /* Acquire data from a single channel. */ /* HINT: You can easily replace this with the SCAN_Op function. */ iStatus = DAQ_Op(iDevice, iChan, iGain, piBuffer, ulCount, dSampRate); iRetVal = NIDAQErrorHandler(iStatus, "DAQ_Op", iIgnoreWarning); iStatus = DAQ_VScale(iDevice, iChan, iGain, dGainAdjust, dOffset, ulCount, piBuffer, pdVoltBuffer); iRetVal = NIDAQErrorHandler(iStatus, "DAQ_VScale", iIgnoreWarning); printf(" The data is available in 'pdVoltBuffer'.\n"); for (j = 0; j < 100 ; j = j + 5) { printf ("\n%f %f %f ",pdVoltBuffer[j],pdVoltBuffer[j+1],pdVoltBuffer[j+2]); printf ("%f %f",pdVoltBuffer[j+3],pdVoltBuffer[j+4]); } } /* End of program */