/*------------------------------------------------------------------------------------- This program will acquire data from channel 2 of the AT-MIO-16E-10 board. All settings are made in the program itself, there are not any inputs for the user. The current settings are: # data points 500 - set with the COUNT Device -------------------------------------------------------------------------------------*/ #include <windows.h> /* needed for NIDAQ */ #include <nidaq.h> /* NIDAQ functions */ #include <stdio.h> /* input/output functions */ #define COUNT 500 /* # of data points */ #define NUM_OF_SEC 3 /* amount of time to take data */ int main() { int j = 0; /* counter */ short InDevice = 1, /* device number of A/D card set in NIDAQ */ InChannel = 2, /* channel to read from */ InGain = 1, /* gain to apply to the reading */ InBuffer[COUNT] = {0}, /* buffer to hold data from A/D card */ InStatus; /* return value of NIDAQ functions for error check */ long InTimeOut = 360; /* # of timer ticks to wait for data to be acquired before assume error */ unsigned long InCount = COUNT; /* # of data points to take */ double InRate = COUNT/NUM_OF_SEC, /* frequency of data acquisition */ GainAdjust = 1, /* factor to adjust the gain in binary to value conversion */ Offset = 0, /* binary offset needed in binary to value conversions */ VoltBuffer[COUNT] = {0.0}; /* buffer to hold converted data */ char *FileName = "data.txt"; /* name of file to save data in */ /****** print a header to the screen ******/ printf ("This program will aquire %d points", InCount); printf (" from channel %d.\n", InChannel); /****** set time for timeout and error check ******/ if ((InStatus = Timeout_Config(InDevice, InTimeOut)) != 0) { printf ("Timeout_Config error %d\n",InStatus); exit(InStatus); } /****** acquire data and error check ******/ if ((InStatus = DAQ_Op(InDevice, InChannel, InGain, InBuffer, InCount, InRate)) != 0) { printf ("DAQ_Op error %d\n",InStatus); exit(InStatus); } /****** convert binary data to input data type and error check ******/ if ((InStatus = DAQ_VScale(InDevice, InChannel, InGain, GainAdjust, Offset, InCount, InBuffer, VoltBuffer)) != 0) { printf ("DAQ_VScale error %d\n",InStatus); exit(InStatus); } /****** output the data ******/ /* output to screen is commented out */ for (j = 0; j < InCount; j = j + 5) { printf ("\n%10f %10f %10f ",VoltBuffer[j],VoltBuffer[j+1],VoltBuffer[j+2]); printf ("%10f %10f",VoltBuffer[j+3],VoltBuffer[j+4]); } printf("\n\n"); return 0; } /* END OF PROGRAM */