6-1
6 PROGRAMMING EXAMPLE
This section provides a basic example of controlling the electronic load via GPIB. The
GPIB used here is made by
National Instruments
.
#include “dec1.h”
#include <stdio.h>
#include <stdlib.h>
#include <sring.h>
#include <iostream.h>
#include <time.h>
static int MTA,
MLA;
static int bd;
const char LA = 0x20,
TA = 0x40;
static void setNi( int pad, char *cardName )
{
MTA = TA + pad;
MLA = LA + pad;
if ( (bd = ibfind ( cardName ) ) < 0 ) {
puts ( “GPIB Card Found Error” );
exit ( 1 );
}
if ( ibpad ( bd, pad ) & ERR ) {
puts ( “GPIB Card Address Assignment Error” );
exit ( 3 );
}
ibtmo ( bd, 10 );
ibsic ( bd );
ibsre ( bd, 1 );
}
static void Niwrite( int pad, char *cmdStr )
{
char cmd[4];
cmd[0] = UNL;
cmd[1] = UNT;
cmd[2] = MTA;
cmd[3] = LA + pad;
//
ibcmd( bd, cmd, 4 );
ibwrt ( bd, cmdStr, _fstrlen( cmdStr ) );
ibcmd( bd, cmd, 2 );
Artisan Scientific - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisan-scientific.com
Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com