beautypg.com

Gpib programming example, Appendix a – AMETEK SLM-1 User Manual

Page 57

background image

APPENDIX A

GPIB PROGRAMMING EXAMPLE

Example Program in C


/* Link this program with appropriate *cib*.obj. */

/* This application program is written in TURBO C 2.0 for the IBM PC-AT compatible. The
National Instruments Cooperation (NIC) Model PC-2A board provides the interface between
the PC-AT and a Sorensen brand Electronic Load. The appropriate *cib*.obj file is required in
each program to properly link the NIC board to C LANGUAGE and include the
HEADER FILE to C LANGUAGE. */

#include
#include
#include
#include "decl.h"

/* NI GPIB CARD HEADER FILE */


main()
{
char ouster[20],rdbuf[15],spec[10];
int i,ch,load;
/* Assign unique identifier to the device "dev5" and store in variable load. check for error.
ibfind error = negative value returned. */
if((load = ibfind("dev5")) < 0)

/* Device variable name is load */

{

/* GPIB address is 5 */

printf("\r*** INTERFACE ERROR ! ***\a\n");
printf("\r\nError routine to notify that ibfind failed.\n");
printf("\r\nCheck software configuration.\n");
exit(1);
}
/* Clear the device */
if((ibclr(load)) & ERR);
{
printf("INTERFACE ERROR ! \a");
exit(1);
}
clrscr();
/* Clear load error register */
for(i=1,ch=0;i<=4;i++,ch++)
{
outstr=chan[ch];
ibwrt(load,outstr,6);
ibwrt(load,"CLER",4);
}
ibwrt( load,"NAME?",5);

/* Get the SL-series module load specification */

strset(rdbuf,'\0');

/* Clear rdbuf string buffer */

strset(spec,'\0');

/* Clear spec string buffer */

M540070-01 Rev B

A-1