$debug$ $modcal$ $sysprog on$ $partial_eval$ $search '~jpl/tools/viewmod','/lib/local/numex','mt'$ Module MMMT; IMPORT {K196_con,} {library for AC voltmeter} newasm, mt, viewmod; EXPORT Procedure MT_MM_MAIN(action:MT_action); IMPLEMENT TYPE state_of_MM = RECORD exists:boolean; {is one connected to HPIB} resolution:v_paramptr; {# of digits - 3/4/5/6 legal values} range:v_paramptr; {range 0=autorange, 1--7 legal values} mode1, {mode1: V(volts),A(amps),R(ohms)} mode2:v_paramptr; {mode2: A(AC),D(DC),B(db)} filter:v_paramptr; {0 = no filter, 1-99 number of samples averages} output:v_paramptr; {real number output of meter} End; VAR MM:state_of_MM; {*****************************************************************************} {*****************************************************************************} {*****************************************************************************} { MT Library for K196 Multimeter } {*****************************************************************************} {*****************************************************************************} {*****************************************************************************} {HPIB library commands for K196 FUNCTION K196_Error : BOOLEAN; PROCEDURE trigger_K196; PROCEDURE Init_K196;}{call at beginning}{ PROCEDURE Set_k196_Res (res : integer);}{3,4,5,6 digits}{ PROCEDURE Set_k196_Range (range : integer);}{0 auto, 1--7}{ PROCEDURE Set_k196_Mode (M,T : CHAR);} {"M" 'V' ==> Voltmeter 'A' ==> Ammeter 'R' ==> Ohmmeter {"T" 'A' ==> AC 'D' ==> DC 'B' ==> dB} {PROCEDURE Set_k196_Filter(filter: integer);} {Sets filter function to off if filter = 0 Number of readings averaged if filter = 1-99} {FUNCTION Read_k196: REAL;} { Reads Keithley 196 DVM } {PROCEDURE Reset_k196;} {put 196 into continous trigger and local mode} {*****************************************************************************} { 'this variable has been changed - here's the string ' } Procedure MT_MM_chproc(pp : v_paramptr; var val : na_str255); {*****************************************************************************} Var testreal:real; testint:integer; Begin If MM.exists Then Begin With MM Do If (pp = mode1) Then Begin val :=strupper(val); If (val='VOLT') Or (val='VOLTS') Or (val='VOLTMETER') Or (val='V') Then pp^.val.c[0]:='V' Else If (val='AMP') Or (val='AMPS') Or (val='AMMETER') Or (val='A') Then pp^.val.c[0]:='A' Else If (val='OHM') Or (val='OHMS') Or (val='OHMMETER') Or (val='R') Or (val='O') Then pp^.val.c[0]:='R' Else v_failmsg('Do not understand ' + val); {Set_k196_Mode (mode1^.val.c[0], mode2^.val.c[0]);} End Else If (pp = mode2) Then Begin val :=strupper(val); If (val='AC') Or (val='A') Then pp^.val.c[0]:='A' Else If (val='DC') Or (val='D') Then pp^.val.c[0]:='D' Else If (val='DB') Or (val='B') Then pp^.val.c[0]:='B' Else v_failmsg('Do not understand ' + val); {Set_k196_Mode (mode1^.val.c[0], mode2^.val.c[0]);} End Else If (pp = resolution) Then Begin If v_parseinteger(val,testint) and (Testint>2) And (Testint<7) Then pp^.val.i1:=testint Else v_failmsg('Incorrect value ' + val); {Set_K196_Res(pp^.val.i1);} End Else If (pp = range) Then Begin If v_parseinteger(val,testint) and (Testint>-1) And (Testint<8) Then pp^.val.i1:=testint Else Begin val :=strupper(val); If (val='AUTO') or (val='A') Then pp^.val.i1:=0 Else v_failmsg('Incorrect value ' + val); End; {Set_K196_Range(pp^.val.i1);} End Else If (pp = filter) Then Begin If v_parseinteger(val,testint) and (Testint>-1) And (Testint<100) Then pp^.val.i1:=testint Else Begin val :=strupper(val); If (val='OFF') or (val='O') Then pp^.val.i1:=0 Else v_failmsg('Incorrect value ' + val); End; {Set_K196_Filter(pp^.val.i1);} End Else If (pp = output) Then v_failmsg('Writing attempted to a read-only parameter') Else v_failmsg('MT system error') End End; {*****************************************************************************} { 'give me the value of this variable in string form' } Procedure MT_MM_fmtproc(pp : v_paramptr; var val : na_str255); {*****************************************************************************} Begin If MM.exists Then Begin With MM Do If (pp = mode1) Then val := strchar(pp^.val.c[0]) Else If (pp = mode2) Then Case pp^.val.c[0] of 'A':val :='AC'; 'B':val :='dB'; 'D':val :='DC'; Otherwise; End Else If (pp = resolution) Then val := strint(pp^.val.i1) Else If (pp = range) Then Begin If (pp^.val.i1=0) Then val := 'AUTO' Else val := strint(pp^.val.i1) End Else If (pp = filter) Then Begin If (pp^.val.i1=0) Then val := 'OFF' Else val := strint(pp^.val.i1) End Else If (pp = output) Then Begin {pp^.val.r := Read_k196;} val := strreal(pp^.val.r) End Else v_failmsg('MT system error') End End; {*****************************************************************************} { 'this variable has been changed - here's the number ' } Procedure MT_MM_nchproc(pp : v_paramptr; var val : real); {*****************************************************************************} begin end; {*****************************************************************************} { 'give me the value of this variable in number form' } procedure MT_MM_nfmtproc(pp : v_paramptr; var val : real); {*****************************************************************************} begin end; {*****************************************************************************} { Main procedures of MM } Procedure MT_MM_MAIN(action:MT_action); {*****************************************************************************} {*****************************************************************************} { initializes library of MM } Procedure MT_MM_init; {*****************************************************************************} Begin Try Begin MM.exists:=false; {Init_K196;} MM.exists:=true; MM.output^.val.r:=0; {meter output} End Recover Writeln('K196 multimeter not found - continuing initialization'); End; {*****************************************************************************} { uninitializes library of MM } Procedure MT_MM_uninit; {*****************************************************************************} Begin MM.exists:=false; End; {*****************************************************************************} { updates state of MM } Procedure MT_MM_update; {*****************************************************************************} Begin If MM.exists Then With MM Do Begin {Set_k196_Range(range^.val.i1);} {Set_k196_Mode (mode1^.val.c[0],mode2^.val.c[0]);} {Set_k196_Res (resolution^.val.i1);} {Set_k196_Filter(filter^.val.i1);} End End; {*****************************************************************************} { resets MM state to sane values } Procedure MT_MM_reset; {*****************************************************************************} Begin If MM.exists Then With MM Do Begin resolution^.val.i1:=6; {six digits resolution} range^.val.i1:=0; {autoranging} mode1^.val.c[0]:='V'; {volts} mode2^.val.c[0]:='A'; {AC} filter^.val.i1:=4; {average over 4+1 readings} End; End; {*****************************************************************************} { makes parameters for MM } Procedure MT_MM_makeparam; {*****************************************************************************} Var dummykind : v_paramkindptr; {parameter kind placeholder} Begin v_addparamkind(dummykind, v_pk_other); dummykind^.chproc := MT_MM_chproc; dummykind^.nchproc := MT_MM_nchproc; dummykind^.fmtproc := MT_MM_fmtproc; dummykind^.nfmtproc := MT_MM_nfmtproc; v_addparam('MM_DIGITS', MM.resolution, dummykind); v_addparam('MM_RANGE', MM.range, dummykind); v_addparam('MM_V_A_R', MM.mode1, dummykind); v_addparam('MM_AC_DC_DB', MM.mode2, dummykind); v_addparam('MM_AVERAGE', MM.filter, dummykind); v_addparam('MM_OUTPUT', MM.output, dummykind); MM.exists:=false; End; { main procedure for MM } Begin case action of MT_reset:MT_MM_reset; MT_init:MT_MM_init; MT_uninit:MT_MM_uninit; MT_update:MT_MM_update; MT_makeparam:MT_MM_makeparam; Otherwise; End; End; End.