/* ************************************************************** */ /* * Module SR830 * This module contains I/O functions for the Stanford Research * SR830 lock-in amplifier. * * Zachary Wolf * 7/2/04 */ /* ************************************************************** */ /* INCLUDES */ #include #include #include #include #include "sr830.h" /* ************************************************************** */ /* PRIVATE FUNCTIONS */ int sr830_open_dev(int gpib_board_addr, int gpib_dev_addr); void sr830_close_dev(int dev_ID); int sr830_check_dev_open(int dev_ID); int sr830_out(int dev_ID, char* buf); int sr830_in(int dev_ID, char* buf); int sr830_spoll(int dev_ID, int* spoll); void sr830_wait_until_ready_for_command(int dev_ID); void sr830_wait_until_data_ready(int dev_ID); void sr830_message(char* msg); void sr830_error(char* msg); void sr830_try_to_fix_errors(int dev_ID); int sr830_get_errors(int dev_ID); /* ************************************************************** */ /* PRIVATE DEVICE TABLE */ /* * This table allows several devices of the same type to be * used in the system. * dev_addr, contains the GPIB addresses of opened devices * dev_descr, contains the device descriptors of opened devices * dev_count, contains the number of devices open of this type */ static int dev_addr[SR830_MAX_NUM_DEV + 1]; static int dev_descr[SR830_MAX_NUM_DEV + 1]; static int dev_count; /* ************************************************************** */ /* PRIVATE GLOBAL VARIABLES */ /* * cmd, buffer for GPIB I/O strings * msg, buffer for message strings to Standard I/O */ static char cmd[SR830_MAX_CMD + 1]; static char msg[SR830_MAX_CMD + 1]; /* ************************************************************** */ /* PUBLIC FUNCTIONS */ /* ************************************************************** */ /* * sr830_init * This function opens the device, queries for ID, and * initializes the device to a known state. * * Input: * gpib_board_addr, address of the GPIB board the device is connected to (0, 1, ...) * gpib_dev_addr, GPIB address of the device (1 to 30, 0 is reserved) * * Output: * dev_ID, identifier for future references to the device * * Zachary Wolf * 7/2/04 */ void sr830_init(int gpib_board_addr, int gpib_dev_addr, int* ID) { /* Declare variables */ int dev_ID; int err; int i; /* Message */ sr830_message(""); sr830_message("Initializing the SR830..."); /* Check input parameters */ if (gpib_board_addr < 0 || gpib_board_addr > 10) { Fmt(msg, "%s 30) { Fmt(msg, "%s SR830_MAX_NUM_DEV) { Fmt(msg, "%s SR830_MAX_NUM_DEV) { Fmt(msg, "%s SR830_MAX_NUM_DEV) { Fmt(msg, "%s SR830_MAX_NUM_DEV) { Fmt(msg, "%s 19) { Fmt(msg, "%s