﻿; TestController configuration file for HP / Agilent 34401A Digital Multimeter
;
; Version history:
;
; 05-04-2020  maukka           Original author configuration file
;             WA               Added configuration for Measurement functions
; 23-01-2023  Hydron           Added enhanced version, and expanded Temperature setup page
; 30-09-2023  dl6lr            Expanded with either serial or GPIB
; 12-04-2024  the Chris        Fix trailing values, changed delays
; 10-11-2024  the Chris        Added "hidden" 10 mA ACI range
; 18-02-2025  jmurray          Minor corrections
; 01-11-2026  Gertjan Miedema  Separate, dedicated delays for GPIB and serial connection
;


#metadef
#name Agilent 34401A
#remove #cmdMode Temperature

#metadef
#name Hewlett-Packard 34401A
#remove #cmdMode Temperature

#metadef
#name Hewlett-Packard 34401A Enhanced
#handle HP34401A

#metadef
#name Agilent 34401A Enhanced
#handle HP34401A


#meta
#author maukka 
#idString HEWLETT-PACKARD,34401A,
#name HP/Agilent 34401A Enhanced
#handle HP34401A
#port com gpib
#baudrate 9600N82H
#driver SCPIx

#notes The baud rate setting must match the meters setting, this also include parity/bits: 
always two parity bits, DTR / DSR handshake.
WA: Added configuration for Measurement functions, correct baudrate setting: 2 stoppbits DTR / DSR handshake.
The meter must not be set at address 31, it has special meaning.
The "Enhanced" model are done by enabling hidden features of 34401A FW 07-xx-yy and later. See https://www.eevblog.com/forum/testgear/hp-agilent-34401a-hidden-menu/ for details

 
; A list of possible column name with unit and formatter (SI, Time, Int, D0..D6)
#value VoltageDC V D6 DC_Voltage,Diode
#value CurrentDC A SI DC_Current
#value VoltageAC V D6 AC_Voltage
#value CurrentAC A SI AC_Current
#value Resistance ohm SI 2W_Resistance,4W_Resistance,Continuity
#value Frequency Hz si Frequency
#value Ratio - D3 Ratio
#value Period s D6 Period
#value Temperature °C D3 Temperature
 
; How to poll for data, this is used for table and #values?
; a #askMode, #cmdMode and #prepareSample is used before this is string is used.
; This is a single line command
#askValues READ?
 
 
; When it gets extra measurements they will be put into the log window.
; It may be due to a timeout on reading the data or because it receives two lines of data.
; You can change the timeout with (Default is 1 second)
#readingDelay 10
#modeChangeDelay 10
  
; String to ask about actual meter mode,
; This is a single line command
#askMode FUNC?
 
 
; When one of these commands are used through the command interface a new configuration will be done before using #askMode
; Only one word for each #mayModifyMode
; Specify command without initial colon and in the shortest possible form
; #mayModifyMode

; Prepare the meter to response to #askValues
; #prepareSample


#interfaceType DMM BMM
#interface readValue 0


; ------------------  Initial commands & Final command  -------------

#scpiCmd SerialInit #pgm#
if (portType!="GPIB")
  deviceWrite(handle,"SYST:REM;[500]");
endif;

; Initial commands to meter when establishing connection
#initCmd SerialInit;*RST;[500]

#scpiCmd SerialExit #pgm#
if (portType!="GPIB")
  deviceWrite(handle,"system:local");
endif;

; Go to local for GPIB
#scpiCmd GoLocal tx [LOC]

; Final command to meter before breaking connection
#finalCmd *RST;GoLocal;SerialExit;[500];



; ==========  Mode (Function) menu  ==========


;Serial connection needs (much) more delay after a WRITE command then GPIB
; With GPIB delay is 20ms, but with serial connection delay is 500ms
#scpiCmd Delay #pgm#
if (portType=="GPIB")
    sleep(20)
else
    sleep(500)  
endif;

 
#cmdModeLayout 3 4
 
#cmdMode DC_Voltage VOLT
CONF:VOLT:DC;Delay

#cmdMode AC_Voltage VOLT:AC
CONF:VOLT:AC;Delay
 
#cmdMode 2W_Resistance RES
CONF:RES;Delay

#cmdMode DC_Current CURR
CONF:CURR:DC;Delay
 
#cmdMode AC_Current CURR:AC
CONF:CURR:AC;Delay
 
#cmdMode 4W_Resistance FRES
CONF:FRES;Delay
 
#cmdMode Diode DIOD
CONF:DIOD;[20]
 
#cmdMode Continuity CONT
CONF:CONT;Delay
 
#cmdMode Frequency FREQ
CONF:FREQ;Delay
 
#cmdMode Period PER
CONF:PER;Delay

#cmdMode Ratio VOLT:RAT
CONF:VOLT:DC:RAT;Delay

#cmdMode Temperature TEMP
CONF:TEMP;Delay




; ========== Setup menu  ===========
 
;Mode--------------------------------------------------------------------------------------
#cmdSetup info Active_Mode
:read: FUNC?;[20]
:readmath: getElement("DC Voltage;AC Voltage;2W_Resistance;DC Current;AC Current;4W_Resistance;Diode;Continuity;Frequency;Period;Ratio;Temperature",listIndex(unQuote(value),"VOLT VOLT:AC RES CURR CURR:AC FRES DIOD CONT FREQ PER VOLT:RAT TEMP"," "),";")
:updatemodechange:
 
 ; --------------------- Volt DC ---------------------------------------------------------
#cmdSetup radio Range_Auto DC_Voltage
:write: VOLT:DC:RANG:AUTO #;Delay
:read: VOLT:DC:RANG:AUTO?;[20]
:updatedelayed: 0.5
:update: Range DC_Voltage
Auto 1
Manual 0
:updatemodechange:

#cmdSetup radio Range DC_Voltage
:write: VOLT:DC:RANG #;Delay
:read: VOLT:DC:RANG?;[20]
:updatedelayed: 0.5
:update: Range_Auto DC_Voltage
100mV 0.1
1V 1
10V 10
100V 100
1000V 1000
:updatemodechange:

#cmdSetup radio Auto_Zero DC_Voltage
:write: ZERO:AUTO #;Delay
:read: ZERO:AUTO?;[20]
:updatedelayed: 1
Off 0
On 1
Once ONCE
:updatemodechange:

#cmdSetup radio Input_impedance_Auto DC_Voltage
:write: INP:IMP:AUTO #;Delay
:read: INP:IMP:AUTO?;[20]
:tip: <html>With AUTO OFF (default), the input resistance is fixed at 10M for all ranges<br>With AUTO ON, the resistance is set to >10G for the 100mV, 1V, and 10V ranges
Off 0
On 1
:updatemodechange:

#cmdSetup radio NPLCycles DC_Voltage
:write: VOLT:DC:NPLC #;Delay
:read: VOLT:DC:NPLC?;[20]
100PLC 100
10PLC 10
1PLC 1
0.2PLC 0.2
0.02PLC 0.02
:updatemodechange:

; -------------------------------- Volt AC ----------------------------------------------
#cmdSetup radio Range_Auto AC_Voltage
:write: VOLT:AC:RANG:AUTO #;Delay
:read: VOLT:AC:RANG:AUTO?;[20]
:updatedelayed: 0.5
:update: Range AC_Voltage
Auto 1
Manual 0
:updatemodechange:

#cmdSetup radio Range AC_Voltage
:write: VOLT:AC:RANG #;Delay
:read: VOLT:AC:RANG?;[20]
:updatedelayed: 0.5
:update: Range_Auto AC_Voltage
100mV 0.1
1V 1
10V 10
100V 100
1000V 1000
:updatemodechange:

#cmdSetup radio AC_Filter AC_Voltage
:write: DET:BAND #;Delay
:read: DET:BAND?;[20]
>3Hz 3
>20Hz 20
>200Hz 200
:updatemodechange:

#cmdSetup radio Auto_Zero AC_Voltage
:write: ZERO:AUTO #;Delay
:read: ZERO:AUTO?;[20]
:updatedelayed: 1
Off 0
On 1
Once ONCE
:updatemodechange:

;2W_Resistance--------------------------------------------------------------------------------
#cmdSetup radio Range 2W_Resistance
:write: RES:RANG:AUTO #;Delay
:read: RES:RANG:AUTO?;[20]
:updatedelayed: 0.5
:update: Range 2W_Resistance
AUTO 1
Manual 0
:updatemodechange:

#cmdSetup radio Range 2W_Resistance
:write: RES:RANGE #;Delay
:read: RES:RANGE?;[20]
:updatedelayed: 0.5
:update: Range_Auto 2W_Resistance
100Ohm 100
1kOhm 1000
10kOhm 10000
100kOhm 100000
1MOhm 1000000
10MOhm 10000000
100MOhm 100000000
:updatemodechange:

#cmdSetup radio Auto_Zero 2W_Resistance
:write: ZERO:AUTO #;Delay
:read: ZERO:AUTO?;[20]
Off 0
On 1
Once ONCE
:updatemodechange:

#cmdSetup radio NPLCycles 2W_Resistance
:write: RES:NPLC #;Delay
:read: RES:NPLC?;[20]
100PLC 100
10PLC 10
1PLC 1
0.2PLC 0.2
0.02PLC 0.02
:updatemodechange:

;4W_Resistance----------------------------------------------------------------------------------
#cmdSetup radio Range 4W_Resistance
:write: FRES:RANG:AUTO #;Delay
:read: FRES:RANG:AUTO?;[20]
:updatedelayed: 0.5
:update: Range 4W_Resistance
AUTO 1
Manual 0
:updatemodechange:

#cmdSetup radio Range 4W_Resistance
:write: FRES:RANGE #;Delay
:read: FRES:RANGE?;[20]
:updatedelayed: 0.5
:update: Range_Auto 4W_Resistance
100Ohm 100
1kOhm 1000
10kOhm 10000
100kOhm 100000
1MOhm 1000000
10MOhm 10000000
100MOhm 100000000
:updatemodechange:

#cmdSetup radio Auto_Zero 4W_Resistance
:write: ZERO:AUTO #;Delay
:read: ZERO:AUTO?;[20]
Off 0
On 1
Once ONCE
:updatemodechange:

#cmdSetup radio NPLCycles 4W_Resistance
:write: FRES:NPLC #;Delay
:read: FRES:NPLC?;[20]
100PLC 100
10PLC 10
1PLC 1
0.2PLC 0.2
0.02PLC 0.02
:updatemodechange:

;DC_Current-------------------------------------------------------------------------------------
#cmdSetup radio Range DC_Current
:write: CURR:DC:RANG:AUTO #;Delay
:read: CURR:DC:RANG:AUTO?;[20]
:updatedelayed: 0.5
:update: Range DC_Current
AUTO 1
Manual 0
:updatemodechange:

#cmdSetup radio Range DC_Current
:write: CURR:DC:RANG #;Delay
:read: CURR:DC:RANG?;[20]
:updatedelayed: 0.5
:update: Range_Auto DC_Current
10mA 0.01
100mA 0.1
1A 1
3A 3
:updatemodechange:

#cmdSetup radio Auto_Zero DC_Current
:write: ZERO:AUTO #;Delay
:read: ZERO:AUTO?;[20]
Off 0
On 1
Once ONCE
:updatemodechange:

#cmdSetup radio NPLCycles DC_Current
:write: CURR:DC:NPLC #;Delay
:read: CURR:DC:NPLC?;[20]
100PLC 100
10PLC 10
1PLC 1
0.2PLC 0.2
0.02PLC 0.02
:updatemodechange:

;AC_Current-------------------------------------------------------------------------------------
#cmdSetup radio Range AC_Current
:write: CURR:AC:RANG:AUTO #;Delay
:read: CURR:AC:RANG:AUTO?;[20]
:updatedelayed: 0.5
:update: Range AC_Current
AUTO 1
Manual 0
:updatemodechange:

#cmdSetup radio Range AC_Current
:write: CURR:AC:RANG #;Delay
:read: CURR:AC:RANG?;[20]
:updatedelayed: 0.5
:update: Range_Auto AC_Current
1A 1
3A 3
:updatemodechange:


; Extra "hidden" AC curent range
; Only for use with firmware 07-05-02 and later
; Beware: this command is writing to (=changing) an EPROM in your 34401A!
; To use, un-remarkt (remove ;) and use at your own risk!
;
; #cmdSetup radio Range AC_Current
; :write: (getElement("DIAG:POKE 25,0,1_CURR:AC:RANG 1_CURR:AC:RANG 3",(value==0.01?0:(value==1.0?1:2)),"[_]+"));Delay
; :read: CURR:AC:RANG?;[20]
; :updatedelayed: 0.5
; :update: Range_Auto AC_Current
; 10mA 0.01
; 1A 1
; 3A 3
; :updatemodechange:


#cmdSetup radio AC_Filter AC_Current
:write: DET:BAND #;Delay
:read: DET:BAND?;[20]
:readFormat: u
>3Hz 3
>20Hz 20
>200Hz 200
:updatemodechange:

#cmdSetup radio Auto_Zero AC_Current
:write: ZERO:AUTO #;Delay
:read: ZERO:AUTO?;[20]
Off 0
On 1
Once ONCE
:updatemodechange:

;Continuity-------------------------------------------------------------------------------------
#cmdSetup radio Beeper Continuity
:write: SYST:BEEP:STAT #;Delay
:read: SYST:BEEP:STAT?;[20]
Off 0
On 1
:updatemodechange:

;Frequency--------------------------------------------------------------------------------------
#cmdSetup radio Range Frequency
:write: FREQ:VOLT:RANG:AUTO #;Delay
:read: FREQ:VOLT:RANG:AUTO?;[20]
:updatedelayed: 0.5
:update: Range Frequency
AUTO 1
Manual 0
:updatemodechange:

#cmdSetup radio Range Frequency
:write: FREQ:VOLT:RANG #;Delay
:read: FREQ:VOLT:RANG?;[20]
:updatedelayed: 0.5
:update: Range_Auto Frequency
100mV 0.1
1V 1
10V 10
100V 100
1000V 1000
:updatemodechange:

#cmdSetup radio Aperture Frequency
:write: FREQ:APER #;Delay
:read: FREQ:APER?;[20]
0.01 0.01
0.1 0.1
1 1
:updatemodechange:

;Period-----------------------------------------------------------------------------------------
#cmdSetup radio Range Period
:write: PER:VOLT:RANG:AUTO #;Delay
:read: PER:VOLT:RANG:AUTO?;[20]
:updatedelayed: 0.5
:update: Range Period
AUTO 1
Manual 0
:updatemodechange:

#cmdSetup radio Range Period
:write: PER:VOLT:RANG #;Delay
:read: PER:VOLT:RANG?;[20]
:updatedelayed: 0.5
:update: Range_Auto Period
100mV 0.1
1V 1
10V 10
100V 100
1000V 1000
:updatemodechange:

#cmdSetup radio Aperture Period
:write: PER:APER #;Delay
:read: PER:APER?;[20]
0.01 0.01
0.1 0.1
1 1
:updatemodechange:

;Ratio-------------------------------------------------------------------------------------
#cmdSetup radio Range_Auto Ratio
:write: VOLT:DC:RANG:AUTO #;Delay
:read: VOLT:DC:RANG:AUTO?;[20]
:updatedelayed: 0.5
:update: Range Ratio
Auto 1
Manual 0
:updatemodechange:

#cmdSetup radio Range Ratio
:write: VOLT:DC:RANG #;Delay
:read: VOLT:DC:RANG?;[20]
:updatedelayed: 0.5
:update: Range_Auto Ratio
100mV 0.1
1V 1
10V 10
100V 100
1000V 1000
:updatemodechange:

#cmdSetup radio Auto_Zero Ratio
:write: ZERO:AUTO #;Delay
:read: ZERO:AUTO?;[20]
:updatedelayed: 1
Off 0
On 1
Once ONCE
:updatemodechange:

#cmdSetup radio Input_impedance_Auto Ratio
:write: INP:IMP:AUTO #;Delay
:read: INP:IMP:AUTO?;[20]
Off 0
On 1
:updatemodechange:

#cmdSetup radio NPLCycles Ratio
:write: VOLT:DC:NPLC #;Delay
:read: VOLT:DC:NPLC?;[20]
100PLC 100
10PLC 10
1PLC 1
0.2PLC 0.2
0.02PLC 0.02
:updatemodechange:

;Temperature----------------------------------------------------------------------------------
#cmdSetup radio Transducer_Type Temperature
:write: TEMP:TRAN:TYPE #;Delay
:read: TEMP:TRAN:TYPE?;[20]
:update: Temperature_Settings
:string:
Thermocouple TC
2W_RTD RTD
4W_RTD FRTD
Thermistor THER
:updatemodechange:

#cmdSetup selector Temperature_Settings Temperature
:read: TEMP:TRAN:TYPE?;[20]
:update: Transducer_Type
:updatedelayed: 0.2
:updatemodechange:
RTD Temperature2.Transducer_Type Temperature2.RTD_R0 Temperature2.RTD_Type Temperature2.NPLCycles Temperature2.Auto_Zero
FRTD Temperature2.Transducer_Type Temperature2.RTD_R0 Temperature2.RTD_Type Temperature2.NPLCycles Temperature2.Auto_Zero
THER Temperature2.Transducer_Type Temperature2.Thermistor_Type Temperature2.NPLCycles  Temperature2.Auto_Zero
TC Temperature2.Transducer_Type Temperature2.Thermocouple_Type Temperature2.Reference_Junction Temperature2.NPLCycles Temperature2.Auto_Zero

#cmdSetup radio Auto_Zero Temperature2
:write: ZERO:AUTO #;Delay
:read: ZERO:AUTO?;[20]
Off 0
On 1
Once ONCE
:updatemodechange:

#cmdSetup radio NPLCycles Temperature2
:write: TEMP:NPLC #;Delay
:read: TEMP:NPLC?;[20]
100PLC 100
10PLC 10
1PLC 1
0.2PLC 0.2
0.02PLC 0.02
:updatemodechange:

#cmdSetup comboboxHot Thermocouple_Type Temperature2
:write: TEMP:TRAN:TC:TYPE #;Delay
:read: TEMP:TRAN:TC:TYPE?;[20]
:update: Active_Type
B B
E E
J J
K K
N N
R R
S S
T T
:updatemodechange:

#cmdSetup number Reference_Junction Temperature2
:write: TEMP:TRAN:TC:RJUN #;Delay
:read: TEMP:TRAN:TC:RJUN?;[20]
:buttontext: Set
°C -1 +55
:updatemodechange:

#cmdSetup radio Thermistor_Type Temperature2
:write: TEMP:TRAN:THER:TYPE #;Delay
:read: TEMP:TRAN:THER:TYPE?;[20]
2.2kOhm +2200
5kOhm +5000
10kOhm +10000
:updatemodechange:

#cmdSetup number RTD_R0 Temperature2
:write: TEMP:TRAN:RTD:RES:REF #;Delay
:read: TEMP:TRAN:RTD:RES:REF?;[20]
:buttontext: Set
Ω 4.9 2100
:updatemodechange:

#cmdSetup radio RTD_Type Temperature2
:write: TEMP:TRAN:RTD:TYPE #;Delay
:read: TEMP:TRAN:RTD:TYPE?;[20]
alpha_=_0.00385 85
alpha_=_0.00391 91
:updatemodechange:

; ----------------------------------------------------------------------------------------------

#cmdSetup selector Mode_settings 
:read: FUNC?
:readmath: unQuote(value)
:updatemodechange:
VOLT DC_Voltage.
VOLT:AC AC_Voltage.
CURR DC_Current.
CURR:AC AC_Current.
DIOD Diode.
FREQ Frequency.
RES 2W_Resistance.
FRES 4W_Resistance.
CONT Continuity.
PER Period.
VOLT:RAT Ratio.
TEMP Temperature.

; --------------------------------------------------------------------------------------------

#cmdSetup buttonsOn Display
:write: DISP (value);Delay
:read: DISP?;Delay
:updatedelayed: 0.2
Off 0
On 1
