!! INSTrument driver module for Agilent 34970A
END
SUB A34970_init
!! Used at First Start after 1st Loading of Driver
A34970_abort
SUBEND
SUB A34970_abort
!! Used to recover INSTrument dialog from unknown state
Bkhpib_instcde("A34970","ABORT")
A34970_reset
SUBEND
SUB A34970_reset
!! Used to inistialize INSTrument to known default state
Bkhpib_instout("A34970","*rst;*cls;*wai")
SUBEND
SUB A34970_err(OPTIONAL Ret_val$)
!! Used to retreive last error from INSTrument Error Queue
DIM Errt$[100],Err$[80]
INTEGER Err
Errt$=FNBkhpib_instq$("A34970","syst:err?")
ENTER Errt$ USING "#,K,K";Err,Err$
IF Err<>0 THEN
Bkinst_setstat("A34970","Error","ON")
Bksnd_erri(Errt$,"A34970")
ELSE
Bkinst_setstat("A34970","Error","OFF")
END IF
IF NPAR THEN
Ret_val$=TRIM$(VAL$(Err))
ELSE
Bksnd_result(TRIM$(VAL$(FNBkrwe_rcvtyp("SendInstCde")))&":"&Errt$)
END IF
SUBEND
SUB A34970_llo
!! Used to put INSTrument in Local Lockout Mode
Bkhpib_instcde("A34970","LLO")
SUBEND
SUB A34970_local
!! Used to put INSTrument in Local Mode
Bkhpib_instcde("A34970","LOCAL")
SUBEND
SUB A34970_test(OPTIONAL Ret_val$)
!! Used to perform INSTrument firmware Auto-Test
INTEGER Test
A34970_reset
Test=VAL(FNBkhpib_instq$("A34970","*TST?",30.))
IF NPAR THEN
Ret_val$=TRIM$(VAL$(Test))
ELSE
IF Test THEN
Bksnd_result(TRIM$(VAL$(FNBkrwe_rcvtyp("SendInstCde")))&":"&TRIM$(VAL$(Test))&",AUTOTEST_A34970=KO")
ELSE
Bksnd_result(TRIM$(VAL$(FNBkrwe_rcvtyp("SendInstCde")))&":"&TRIM$(VAL$(Test))&",AUTOTEST_A34970=OK")
END IF
END IF
SUBEND
DEF FNA34970_rev$
!! Used to get sw Revision of this INSTrument driver
DIM Ret_str$[100],Revision$[10]
REAL Timerev
Revision$="01"
Timerev=DATE("01 Mar 2004")+TIME("12:38:33")
Ret_str$="A34970_lib,"
Ret_str$=Ret_str$&Revision$&","&FNBktim_iso8601$(Timerev)
RETURN Ret_str$
FNEND
SUB A34970_set_conf(File$)
!! Used to send INSTrument configuration from disk file
DIM Channel$[80],Range$[80],Aperture$[80],Autozero$[80],Delay$[80],Vcc$[80]
! Retreive Parameters values from Config. File
Range$=FNBkreadini_get$(File$,"dvm","VoltRange","")
Aperture$=FNBkreadini_get$(File$,"dvm","Aperture","")
Autozero$=FNBkreadini_get$(File$,"dvm","Autozero","")
Channel$=FNBkreadini_get$(File$,"dvm","Channel","")
Delay$=FNBkreadini_get$(File$,"dvm","Delay","")
Vcc$=FNBkreadini_get$(File$,"vcc","Volt","")
! Cheks Voltage
IF VAL(Vcc$)<0 OR VAL(Vcc$)>5 THEN
Bkerr_a("VCC="&Vcc$&" Not Allowed. Must be >0 and <5")
END IF
! Puts INSTrument in 'known' state
A34970_reset
! Initialize Digital Output
A34970_digout(0)
! New parameters values are send to INSTrument
Bkhpib_instout("A34970","SOUR:VOLT "&Vcc$&",(@204);*WAI")
Bkhpib_instout("A34970","CONF:VOLT:DC (@"&Channel$&");*WAI")
Bkhpib_instout("A34970","ZERO:AUTO "&Autozero$&",(@"&Channel$&");*WAI")
Bkhpib_instout("A34970","VOLT:DC:RANG "&Range$&",(@"&Channel$&");*WAI")
Bkhpib_instout("A34970","VOLT:DC:APER "&Aperture$&",(@"&Channel$&");*WAI")
Bkhpib_instout("A34970","ROUT:SCAN (@"&Channel$&");*WAI")
Bkhpib_instout("A34970","ROUT:CHAN:DEL "&Delay$&",(@"&Channel$&");*WAI")
Bkhpib_instout("A34970","TRIG:SOUR EXT;*WAI")
! Checks if INSTrument doesn't generate error with parameters used
Bkinst_errqueue("A34970","chk")
SUBEND
SUB A34970_get_conf(File$)
!! Used to retreive INSTrument configuration to disk file
DIM Channel$[80],Range$[80],Aperture$[80],Autozero$[80],Delay$[80],Vcc$[80],Function$[80],Scansize$[80]
! Puts INSTrument in 'no error' state
Bkinst_errqueue("A34970","clr")
! Retreive parameters from current INSTrument state
Vcc$=FNBkhpib_instq$("A34970","SOUR:VOLT? (@204)")
Scansize$=FNBkhpib_instq$("A34970","ROUT:SCAN:SIZE?")
IF VAL(Scansize$)<>1 THEN
Bksnd_warning("There must be one and only one channel to scan (Actual="&Scansize$&")"&CHR$(10)&"Will Default to Channel 101 and use DCV default setings")
Channel$="101"
Range$="1"
Aperture$=".0004"
Autozero$="ONCE"
Delay$="0.001"
ELSE
Channel$=FNBkhpib_instq$("A34970","ROUT:SCAN?")
Channel$=Channel$[POS(Channel$,"@")+1,POS(Channel$,")")-1]
Function$=FNBkhpib_instq$("A34970","CONF? (@"&Channel$&")")
SELECT Function$[2,POS(Function$," ")-1]
CASE "VOLT"
Range$=FNBkhpib_instq$("A34970","VOLT:DC:RANG? (@"&Channel$&")")
Aperture$=FNBkhpib_instq$("A34970","VOLT:DC:APER? (@"&Channel$&")")
Autozero$=FNBkhpib_instq$("A34970","ZERO:AUTO? (@"&Channel$&")")
IF Autozero$="0" THEN ! Because 34970 Firmware
Autozero$="ONCE" ! is unable to tell if
ELSE ! OFF or ONCE
Autozero$="ON" ! ONCE is choosen because 'better' (ZERO don't wait INIT to be done)
END IF
Delay$=FNBkhpib_instq$("A34970","ROUT:CHAN:DEL? (@"&Channel$&")")
CASE ELSE
Bksnd_warning("Unsuported Function ["&Function$&"]"&CHR$(10)&"Will use DCV default setings")
Range$="1"
Aperture$=".0004"
Autozero$="ONCE"
Delay$="0.001"
END SELECT
END IF
! Checks if INSTrument doesn't generate error during retreive
Bkinst_errqueue("A34970","chk")
! Store Parameters values to Config. File
Bkfil_openewtxt(File$,@F)
OUTPUT @F;"[Dvm]"
OUTPUT @F;"VoltRange="&Range$
OUTPUT @F;"Aperture="&Aperture$
OUTPUT @F;"Autozero="&Autozero$
OUTPUT @F;"Channel="&Channel$
OUTPUT @F;"Delay="&Delay$
OUTPUT @F;"[Vcc]"
OUTPUT @F;"Volt="&Vcc$
ASSIGN @F TO *
SUBEND
SUB A34970_start
!! Used to Start a Measurement
Bkinst_errqueue("A34970","clr")
Bkhpib_instout("A34970","INIT")
SUBEND
DEF FNA34970_count
!! Used to retreive how many Measurement are stored in INSTrument
RETURN VAL(FNBkhpib_instq$("A34970","DATA:POIN?"))
FNEND
SUB A34970_getmeas(REAL M(*))
!! Used to retreive Measurement Results from INSTrument
Bkhpib_instout("A34970","FETC?")
Bkhpib_instina(M(*),"A34970","FETC?")
Bkinst_errqueue("A34970","chk")
SUBEND
SUB A34970_setcount(LONG Nb)
!! Used to reserve area to store data inside INSTrument
Bkhpib_instout("A34970","TRIG:COUN "&TRIM$(VAL$(Nb))&";*WAI")
Bkinst_errqueue("A34970","chk")
SUBEND
SUB A34970_digout(INTEGER Digval)
!! Used to Output a Digital Value and Output a Trigger Signal
Bkhpib_instout("A34970","SOUR:DIG:DATA:WORD "&TRIM$(VAL$(Digval))&",(@201)")
Bkhpib_instout("A34970","SOUR:DIG:DATA:WORD "&TRIM$(DVAL$((Digval+2^15),10))&",(@201)")
SUBEND