Download LabMaster Ultima
Transcript
Remote Control Commands Example Program /*=============== FILE DESCRIPTION ======================== File: trend.c Description: This is a sample GPIB control program for the LabMaster Ultima. It uses the National Instruments GPIB drivers Ver. 2.1.1, which are included with the National Instruments GPIB-PCII board. It includes the file “decl.h”,and links with the object file “mcib.obj”, both of which are included with the National Instruments drivers. This file was compiled and linked using Microsoft C version 7.0. This sample program will setup the Ultima to collect 200 Trend data points on channel A. It will then download and display to the screen the first 10 of those 200 points. ============== HEADER INFORMATION =======================*/ /*============ INCLUDE FILES ============================*/ #include <stdio.h> #include <stdlib.h> #include <string.h> #include “decl.h” /* National Instruments header file */ /*=============== CONSTANTS ============================*/ /***** Bit 4 of the Status Byte is the Message Available bit. instruct the Ultima to generate a Service Request when Available, using the IEEE-488.2 command “*sre”. When we Request, we need to check if the Message Available bit is Byte, before we try to read data from the bus. We will need to it has a Message detect a Service set in the Status *****/ #define MAV (1<<4) /* Msg Available bit in Status Byte */ /*================= DATA ===============================*/ char out_buf[80]; /* buffer for outgoing messages */ char in_buf[20]; /* buffer for incoming messages */ /*============= FUNCTION PROTOTYPES =====================*/ int gpib_init(void); int gpib_write(int ud, char * str); void main(void); /*======================================================= Function: gpib_init() Input: none Returns: ud - unit descriptor referencing the GPIB device Description: Initialize the GPIB board by calling “ibfind” with the name of a device as setup in the GPIB driver via “ibconf.exe”. We are assuming the default name of “DEV1”. The GPIB board can support up to 16 devices, so the National Instruments functions must reference each device through a unit descriptor. This unit descriptor is returned by “ibfind”. We must then use this unit descriptor on all subsequent calls to National Instruments functions. 95