/* ************************************************************** */ /* * Module SR850 * This module contains I/O functions for the Stanford Research * SR850 lock-in amplifier. * * Zachary Wolf * 12/21/99 */ /* ************************************************************** */ /* INCLUDES */ #include #include #include #include #include "sr850.h" /* ************************************************************** */ /* PRIVATE FUNCTIONS */ int sr850_open_dev(int gpib_board_addr, int gpib_dev_addr); void sr850_close_dev(int dev_ID); int sr850_check_dev_open(int dev_ID); int sr850_out(int dev_ID, char* buf); int sr850_in(int dev_ID, char* buf); int sr850_spoll(int dev_ID, int* spoll); void sr850_wait_until_ready_for_command(int dev_ID); void sr850_wait_until_data_ready(int dev_ID); int sr850_get_errors(int dev_ID); void sr850_message(char* msg); void sr850_error(char* msg); /* ************************************************************** */ /* 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[SR850_MAX_NUM_DEV + 1]; static int dev_descr[SR850_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[SR850_MAX_CMD + 1]; static char msg[SR850_MAX_CMD + 1]; /* ************************************************************** */ /* PUBLIC FUNCTIONS */ /* ************************************************************** */ /* * sr850_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 * 12/21/99 */ void sr850_init(int gpib_board_addr, int gpib_dev_addr, int* ID) { /* Declare variables */ int dev_ID; int err; int i; /* Message */ sr850_message(""); sr850_message("Initializing the SR850..."); /* Check input parameters */ if (gpib_board_addr < 0 || gpib_board_addr > 10) { Fmt(msg, "%s 30) { Fmt(msg, "%s SR850_MAX_NUM_DEV) { Fmt(msg, "%s SR850_MAX_NUM_DEV) { Fmt(msg, "%s SR850_MAX_NUM_DEV) { Fmt(msg, "%s SR850_MAX_NUM_DEV) { Fmt(msg, "%s 19) { Fmt(msg, "%s