/*---------------------------------------------------------------------- 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 All NI-DAQ C functions can run under the Ch Standard Edition, this program has plot function which require the Ch Professional/Student Edition. -----------------------------------------------------------------------*/ #include <windows.h> /* needed for NIDAQ */ #include <nidaq.h> /* NIDAQ functions */ #include <stdio.h> /* input/output functions */ #include <chplot.h> /* ploting functions */ #include <numeric.h> /* use linspace() */ #define COUNT 500 /* # of data points */ #define NUM_OF_SEC 3 /* amount of time to take data */ int main() { 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 */ time[COUNT], /* buffer to hold time stamp */ VoltBuffer[COUNT]; /* buffer to hold converted data */ CPlot plot; /* instantiate a plot class */ /****** print a header to the screen ******/ printf ("This program will acquire %d points from channel %d.\n", InCount, 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); } /****** plot the data ******/ linspace(time, 0, NUM_OF_SEC); plotxy(time, VoltBuffer,"Data acquired through NIDAQ","time (sec)", "Voltage (volts)",&plot); plot.grid(PLOT_ON); plot.plotting(); } /* End of Program */