/* This program exercises the Dataq Instruments DI194RS ADC module */ #include #include #include #include #include #include "DI194RS.h" int main(void) { dataqsdk DI194; int ChannelList[MAXCHANNELS] = { 0, 1, 2, 3 }; int MethodList[MAXCHANNELS] = { 0, 0, 0, 0 }; short int offsets[MAXCHANNELS]; short int samplebuf[MAXCHANNELS]; float scalefactors[MAXCHANNELS]; bool status; long int count; int i, j; /* Display startup banner */ printf("Dataq Instruments DI194RS DMM Test\n"); /* Set calibration data */ GetCalibration(offsets, scalefactors); /* Set up for the data acquisition */ DI194.ProductName(PRODUCTNAME); SDKerror(&DI194, "ProductName", TRUE); DI194.DeviceFile(SERIALPORT); SDKerror(&DI194, "DeviceFile", TRUE); DI194.ADChannelCount(4); SDKerror(&DI194, "ADChannelCount", TRUE); DI194.ADChannelList(ChannelList); SDKerror(&DI194, "ADChannelList", TRUE); DI194.ADMethodList(MethodList); SDKerror(&DI194, "ADMethodList", TRUE); DI194.SampleRate(1.0); SDKerror(&DI194, "SampleRate", TRUE); DI194.EventPoint(1); SDKerror(&DI194, "EventPoint", TRUE); DI194.SampleRate(3.0); SDKerror(&DI194, "SampleRate", TRUE); DI194.Start(); SDKerror(&DI194, "Start", TRUE); /* Display voltages at all the analog inputs */ for (;;) { status = DI194.NewData(count); SDKerror(&DI194, "NewData", TRUE); if (status) for (i = 0; i < count; i++) { DI194.GetDataEx(samplebuf, MAXCHANNELS); SDKerror(&DI194, "GetDataEx", TRUE); for (j = 0; j < MAXCHANNELS; j++) printf("%10.2f V ", (samplebuf[j] - offsets[j])*scalefactors[j]); putchar('\r'); fflush(stdout); } } }