/* ************************************************************** */ /* * Module DAQCARD516 * This module contains I/O functions for the National Instruments * DaqCard 516. * * Zachary Wolf * 3/23/99 */ /* ************************************************************** */ /* INCLUDES */ #include #include #include #include #include #include "daqcard516.h" /* ************************************************************** */ /* PRIVATE FUNCTIONS */ void daqcard516_message(char* msg); void daqcard516_error(char* msg); /* ************************************************************** */ /* PRIVATE GLOBAL VARIABLES */ static char cmd[DAQCARD516_MAX_CMD + 1]; static char msg[DAQCARD516_MAX_CMD + 1]; /* ************************************************************** */ /* PUBLIC FUNCTIONS */ /* ************************************************************** */ /* * daqcard516_init * This function opens the device, queries for ID, and * initializes the device to a known state. * * Output: * ID, identifier for future references to the device * * Zachary Wolf * 3/23/99 */ void daqcard516_init(int* ID) { /* Declare variables */ int dev_ID; int err; /* Message */ //daqcard516_message(""); //daqcard516_message("Initializing the DaqCard 516..."); /* Initialize the card */ /* Done */ return; } /* ************************************************************** */ /* * daqcard516_get_chan_v * This function gets a voltage from the specified analog input * channel of the daqcard. * * Input: * chan, channel number (0 to 7) * * Output: * v, channel voltage (V) * * Zachary Wolf * 3/29/99 */ void daqcard516_get_chan_v(int chan, double* v) { /* Declare variables */ char chan_str[2]; /* Check the channel number */ if (chan < 0 || chan > 7) { daqcard516_error("Improper channel number"); *v = 0.; return; } /* Exit here if testing without hardware */ #ifdef DUMMY_DEVICES *v = 1.; return; #endif /* Format the channel specification */ Fmt(chan_str, "%s<%i", chan); /* Get the voltage */ AISampleChannel (1, chan_str, DAQCARD516_ABS_VAL_MAX_VOLTAGE, -DAQCARD516_ABS_VAL_MAX_VOLTAGE, v); /* Done */ return; } /* ************************************************************** */ /* * daqcard516_scan_v * This function gets the voltages from a range of analog input * channels of the daqcard. * * Input: * hi_chan, channel number to start the scan from, scans from hi_chan to 0 (0 to 7) * * Output: * v[hi_chan + 1], channel voltages (V) * * Zachary Wolf * 3/29/99 */ void daqcard516_scan_v(int hi_chan, double v[]) { /* Declare variables */ char chan_str[20]; int i; /* Check the channel number */ if (hi_chan < 0 || hi_chan > 7) { daqcard516_error("Improper channel number"); return; } /* Exit here if testing without hardware */ #ifdef DUMMY_DEVICES for (i = 0; i <= hi_chan; i++) v[i] = -1. - 0.01 * (double)rand() / RAND_MAX; return; #endif /* Format the channel specification */ Fmt(chan_str, "%s<%i:0", hi_chan); /* Get the voltage */ AISampleChannels (1, chan_str, DAQCARD516_ABS_VAL_MAX_VOLTAGE, -DAQCARD516_ABS_VAL_MAX_VOLTAGE, v); /* Done */ return; } /* ************************************************************** */ /* PRIVATE FUNCTIONS */ /* ************************************************************** */ /* * daqcard516_message * This function handles messages about the DaqCard516. * * Input: * message, string to display in standard I/O * * Zachary Wolf * 3/23/99 */ void daqcard516_message(char* message) { /* Print the message */ printf("%s\n", message); /* Done */ return; } /* ************************************************************** */ /* * daqcard516_error * This function handles error messages for the DaqCard 516. * * Input: * message, string to display in standard I/O * * Zachary Wolf * 3/23/99 */ void daqcard516_error(char* message) { /* Declare variables */ char buf[80]; /* Notify the operator of the error */ printf("\nDAQCARD516 ERROR: %s\n", message); Beep(); Delay(.5); Beep(); /* Terminate the program if the operator desires */ printf("Press 0 ENTER to continue, anything else to terminate program: "); scanf("%s", buf); if (buf[0] == '0') return; else exit(0); }