﻿
#author Mark Wilson
#idString OWON,XDM3041,
#name Owon XDM3041
#handle XDM3041
#port com  
#baudrate 115200

#notes Com port driver.  Temperature in deg C only.  No dual mode.  No stats.  Double-check that manually entered offsets work correctly.


;Driver locked to only use temperature in deg C.  Changing the unit of a value isn't clear in the documentation.
;entering offset values for relative measurement doesn't always seem to work correctly
;does not handle dual readings right now


; A list of possible column name with unit and formatter (SI, Time, Int, D0..D6)
#value VoltageDC V si DC_Voltage,Diode
#value CurrentDC A si DC_Current
#value VoltageAC V si AC_Voltage
#value CurrentAC A si AC_Current
#value Resistance ohm si 2W_Resistance,4W_Resistance,Continuity
#value Capacitance F si Capacitance
#value Temperature °C si Temperature
#value Frequency Hz si Frequency
#value Period s si Period

; 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 MEAS?

; Format of answer: f=float, u=remove trailing letters, x=skip, *=Zero upper case values if this value is 0
#askValuesReadFormat f

; Accept this delay when reading values (seconds)
#readingDelay 3

; Mode change have a longer delay on reading values (seconds)
#modeChangeDelay 5

; Switch meter to this mode during start, leave empty to avoid any switching
#initialMode 

; String to ask about actual meter mode, 
; This is a single line command
#askMode SENS:FUNC?
; Remove spaces from returned result: "VOLT AC" and "CURR AC" to "VOLTAC" and "CURRAC"
#askModeMathFormat unQuote(replace(replace(value,"VOLT AC","VOLTAC"),"CURR AC","CURRAC"))



; 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
#mayModifyMode conf
;#mayModifyMode meas
;#mayModifyMode abor
;#mayModifyMode trig 

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

; Initial commands to meter when establishing connection
#initCmd SYST:REM; TEMP:RTD:UNIT C

; Final command to meter before breaking connection
#finalCmd *cls; SYST:LOC

#interfaceType DMM
#interface readValue 0

; Strings to configure device in different modes
; First parameter must match a #value (4 parameter) and second parameter must match what #askMode returns
; First parameter is also used in shortcut menu
;#cmdMode

#cmdModeLayout 3 4

#cmdMode DC_Voltage VOLT
FUNC "VOLT:DC";[1000]

#cmdMode AC_Voltage VOLTAC
FUNC "VOLT:AC";[1000]

#cmdMode 2W_Resistance RES
FUNC "RES";[1000]

#cmdMode DC_Current CURR
FUNC "CURR:DC";[1000]

#cmdMode AC_Current CURRAC
FUNC "CURR:AC";[1000]

#cmdMode 4W_Resistance FRES
FUNC "FRES";[1000]

#cmdMode Diode DIOD
FUNC "DIOD";[1000]

#cmdMode Continuity CONT
FUNC "CONT";[1000]

#cmdMode Temperature TEMP
FUNC "TEMP";TEMP:RTD:UNIT C;[1000]

#cmdMode Capacitance CAP
FUNC "CAP";[1000]

#cmdMode Frequency FREQ
FUNC "FREQ";[1000]

#cmdMode Period PER
FUNC "PER";[1000]

; Setup menu functions
; The parameters on the first line is: type name page 
; Settings on the following lines are:
; read: SCPI to read value from device, is used to synchronize when opening setup page or setting equal named fields. Not always used
; readformat: Parse read value.
; write: Send the value to device, this field is used in combination with data fields in the details to send updates to device.
; tip: Add this tip to all components for this input field.

;Mode-------------------------------------------------------------------------------------------
#cmdSetup info Active_Mode
:read: FUNC?
:readmath: getElement("Diode;DC Voltage;AC Voltage;DC Current;AC Current;Temperture;Capacitance;2W Resistance;4W Resistance;Frequency;Period;Continuity",listIndex(unQuote(replace(replace(value,"VOLT AC","VOLTAC"),"CURR AC","CURRAC")),"DIOD,VOLT,VOLTAC,CURR,CURRAC,TEMP,CAP,RES,FRES,FREQ,PER,CONT",","),";")
:updatemodechange:

;DC_Current-------------------------------------------------------------------------------------
#cmdSetup radio Range DC_Current
:write: CURR:DC:RANGE:AUTO
:read: CURR:DC:RANGE:AUTO?
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
AUTO ON
Manual OFF
:updatemodechange:

#cmdSetup comboboxHot Range DC_Current
:write: CURR:DC:RANGE
:read: CURR:DC:RANGE?
:readformat: f
600uA +6.00000000E-04
6mA +6.00000000E-03
60mA +6.00000000E-02
600mA +6.00000000E-01
6A +6.00000000E+00
10A +1.00000000E+01
:updatemodechange:

#cmdSetup comboboxHot Speed DC_Current
:write: RATE
:read: RATE?
:readformat: f
Fast F
Middle M
Slow S
:updatemodechange:

#cmdSetup radio Filter DC_Current
:write: CURR:DC:FILTER:STAT
:read: CURR:DC:FILTER:STAT?
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
On ON
Off OFF
:updatemodechange:

#cmdSetup radio Null DC_Current
:write: CURR:DC:NULL
:read: CURR:DC:NULL?
:update: Null_Value
:updatedelayed: 0.1
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
On ON
Off OFF
:updatemodechange:

#cmdSetup number Null_Value DC_Current
:read: CALC:NULL:OFFS?
:write: CALC:NULL:OFFS
:buttontext: Set
Amps -10 +10
:updatemodechange:

;DC_Voltage-------------------------------------------------------------------------------------
#cmdSetup radio Range DC_Voltage
:read: VOLT:DC:RANGE:AUTO?
:write: VOLT:DC:RANGE:AUTO
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
AUTO ON
Manual OFF
:updatemodechange:

#cmdSetup comboboxHot Range DC_Voltage
:write: VOLT:DC:RANGE
:read: VOLT:DC:RANGE?
600mV +6.00000000E-01
6V +6.00000000E+00
60V +6.00000000E+01
600V +6.00000000E+02
1000V +1.00000000E+03
:updatemodechange:

#cmdSetup comboboxHot Speed DC_Voltage
:write: RATE
:read: RATE?
Fast F
Middle M
Slow S
:updatemodechange:

#cmdSetup radio Filter DC_Voltage
:write: VOLT:DC:FILTER:STAT
:read: VOLT:DC:FILTER:STAT?
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
On ON
Off OFF
:updatemodechange:

#cmdSetup radio Impedance DC_Voltage
:write: VOLT:DC:IMP:AUTO
:read: VOLT:DC:IMP:AUTO?
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
10M OFF
10Gand10M ON
:updatemodechange:

#cmdSetup radio Null DC_Voltage
:write: VOLT:DC:NULL
:read: VOLT:DC:NULL?
:update: Null_Value
:updatedelayed: 0.1
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
On ON
Off OFF
:updatemodechange:

#cmdSetup number Null_Value DC_Voltage
:read: CALC:NULL:OFFS?
:write: CALC:NULL:OFFS
:buttontext: Set
Volts -1000 +1000
:updatemodechange:

;Diode------------------------------------------------------------------------------------------
#cmdSetup radio Beeper Diode
:write: SYST:BEEP:STAT
:read: SYST:BEEP:STAT?
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
On ON
Off OFF
:updatemodechange:

;Frequency--------------------------------------------------------------------------------------
#cmdSetup radio Range Frequency
:write: FREQ:VOLT:RANGE:AUTO
:read: FREQ:VOLT:RANGE:AUTO?
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
AUTO ON
Manual OFF
:updatemodechange:

#cmdSetup comboboxHot Range Frequency
:write: FREQ:VOLT:RANGE
:read: FREQ:VOLT:RANGE?
600mV +6.00000000E-01
6V +6.00000000E+00
60V +6.00000000E+01
600V +6.00000000E+02
750V +7.50000000E+02
:updatemodechange:

#cmdSetup radio Null Frequency
:write: FREQ:NULL
:read: FREQ:NULL?
:update: Null_Value
:updatedelayed: 0.1
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
On ON
Off OFF
:updatemodechange:

#cmdSetup number Null_Value Frequency
:read: CALC:NULL:OFFS?
:write: CALC:NULL:OFFS
:buttontext: Set
Hz 0 1000000
:updatemodechange:

;Period-----------------------------------------------------------------------------------------
#cmdSetup radio Range Period
:write: PER:VOLT:RANGE:AUTO
:read: PER:VOLT:RANGE:AUTO?
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
AUTO ON
Manual OFF
:updatemodechange:

#cmdSetup comboboxHot Range Period
:write: PER:VOLT:RANGE
:read: PER:VOLT:RANGE?
600mV +6.00000000E-01
6V +6.00000000E+00
60V +6.00000000E+01
600V +6.00000000E+02
750V +7.50000000E+02
:updatemodechange:

#cmdSetup radio Null Period
:write: PER:NULL:STAT
:read: PER:NULL:STAT?
:update: Null_Value
:updatedelayed: 0.1
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
On ON
Off OFF
:updatemodechange:

#cmdSetup number Null_Value Period
:read: CALC:NULL?
:write: CALC:NULL
:buttontext: Set
Sec 0.000001 0.05
:updatemodechange:



;Temperature------------------------------------------------------------------------------------

#cmdSetup combobox SENSORTYPE Temperature
:write: TEMP:RTD:TYP
:read: TEMP:RTD:TYP?
THR_BITS90 BITS90
THR_EITS90 EITS90
THR_JITS90 JITS90
THR_KITS90 KITS90
THR_NITS90 NITS90
THR_RITS90 RITS90
THR_SITS90 SITS90
THR_TITS90 TITS90
THR_W5_26 W5_26
THR_W3_25 W3_25
RTD_PT100 PT100
RTD_PT10 PT10
RTD_Cu100 Cu100
RTD_Cu50 Cu50
:updatemodechange:

;Don't allow changing unti because it is unclear how to change the unit on a value
;#cmdSetup combobox TEMPUNIT Temperature
;:write: TEMP:RTD:UNIT
;:read: TEMP:RTD:UNIT?
;:string:
;Celsius C
;Fahrenheiht F
;Kelvin K
;:updatemodechange:


#cmdSetup radio Null Temperature
:write: TEMP:RTD:NULL
:read: TEMP:RTD:NULL?
:update: Null_Value
:updatedelayed: 0.1
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
On ON
Off OFF
:updatemodechange:

#cmdSetup number Null_Value Temperature
:read: CALC:NULL:OFFS?
:write: CALC:NULL:OFFS
:buttontext: Set
°C -270 +1820
:updatemodechange:



;2W_Resistance----------------------------------------------------------------------------------
#cmdSetup radio Range 2W_Resistance
:read: RES:RANGE:AUTO?
:write: RES:RANGE:AUTO
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
AUTO ON
Manual OFF
:updatemodechange:

#cmdSetup comboboxHot Range 2W_Resistance
:write: RES:RANGE
:read: RES:RANGE?
600Ω +6.00000000E+02
6kΩ +6.00000000E+03
60kΩ +6.00000000E+04
600kΩ +6.00000000E+05
6MΩ +6.00000000E+06
60MΩ +6.00000000E+07
100MΩ +1.00000000E+08
:updatemodechange:

#cmdSetup comboboxHot Speed 2W_Resistance
:write: RATE
:read: RATE?
Fast F
Middle M
Slow L
:updatemodechange:

#cmdSetup radio Null 2W_Resistance
:write: RES:NULL
:read: RES:NULL?
:update: Null_Value
:updatedelayed: 0.1
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
On ON
Off OFF
:updatemodechange:

#cmdSetup number Null_Value 2W_Resistance
:read: CALC:NULL:OFFS?
:write: CALC:NULL:OFFS
:buttontext: Set
Ω -60000000 +60000000
:updatemodechange:

;4W_Resistance----------------------------------------------------------------------------------
#cmdSetup radio Range 4W_Resistance
:read: FRES:RANGE:AUTO?
:write: FRES:RANGE:AUTO
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
AUTO ON
Manual OFF
:updatemodechange:

#cmdSetup comboboxHot Range 4W_Resistance
:write: FRES:RANGE
:read: FRES:RANGE?
600Ω +6.00000000E+02
6kΩ +6.00000000E+03
60kΩ +6.00000000E+04
600kΩ +6.00000000E+05
6MΩ +6.00000000E+06
60MΩ +6.00000000E+07
100MΩ +1.00000000E+08
:updatemodechange:

#cmdSetup comboboxHot Speed 4W_Resistance
:write: RATE
:read: RATE?
Fast F
Middle M
Slow L
:updatemodechange:

#cmdSetup radio Null 4W_Resistance
:write: FRES:NULL
:read: FRES:NULL?
:update: Null_Value
:updatedelayed: 0.1
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
On ON
Off OFF
:updatemodechange:

#cmdSetup number Null_Value 4W_Resistance
:read: CALC:NULL:OFFS?
:write: CALC:NULL:OFFS
:buttontext: Set
Ω -60000000 +60000000
:updatemodechange:

;AC_Current-------------------------------------------------------------------------------------
#cmdSetup radio Range AC_Current
:write: CURR:AC:RANGE:AUTO
:read: CURR:AC:RANGE:AUTO?
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
AUTO ON
Manual OFF
:updatemodechange:

#cmdSetup comboboxHot Range AC_Current
:write: CURR:AC:RANGE
:read: CURR:AC:RANGE?
60mA +6.00000000E-02
600mA +6.00000000E-01
6A +6.00000000E+00
10A +1.00000000E+01
:updatemodechange:

#cmdSetup radio Speed AC_Current
:write: RATE
:read: RATE?
Fast F
Middle M
Slow S
:updatemodechange:


#cmdSetup radio Null AC_Current
:write: CURR:AC:NULL
:read: CURR:AC:NULL?
:update: Null_Value
:updatedelayed: 0.1
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
On ON
Off OFF
:updatemodechange:

#cmdSetup number Null_Value AC_Current
:read: CALC:NULL:OFFS?
:write: CALC:NULL:OFFS
:buttontext: Set
Amps -10 +10
:updatemodechange:

;AC_Voltage-------------------------------------------------------------------------------------
#cmdSetup radio Range AC_Voltage
:write: VOLT:AC:RANGE:AUTO
:read: VOLT:AC:RANGE:AUTO?
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
AUTO ON
Manual OFF
:updatemodechange:

#cmdSetup comboboxHot Range AC_Voltage
:write: VOLT:AC:RANGE
:read: VOLT:AC:RANGE?
600mV +6.00000000E-01
6V +6.00000000E+00
60V +6.00000000E+01
600V +6.00000000E+02
750V +7.50000000E+02
:updatemodechange:

#cmdSetup radio Speed AC_Voltage
:write: RATE
:read: RATE?
Fast F
Middle M
Slow S
:updatemodechange:


#cmdSetup radio Null AC_Voltage
:write: VOLT:AC:NULL
:read: VOLT:AC:NULL?
:update: Null_Value
:updatedelayed: 0.1
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
On ON
Off OFF
:updatemodechange:

#cmdSetup number Null_Value AC_Voltage
:read: CALC:NULL:OFFS?
:write: CALC:NULL:OFFS
:buttontext: Set
Volts -750 +750
:updatemodechange:

;Capacitance------------------------------------------------------------------------------------
#cmdSetup radio Range Capacitance
:write: Cap:RANGE:AUTO
:read: Cap:RANGE:AUTO?
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
AUTO ON
Manual OFF
:updatemodechange:

#cmdSetup comboboxHot Range Capacitance
:write: Cap:RANGE
:read: Cap:RANGE?
2nF +2.00000000E-08
20nF +2.00000000E-07
200nF +2.00000000E-06
2uF +2.00000000E-05
20uF +2.00000000E-04
200uF +2.00000000E-03
10000uf +1.00000000E-02
:updatemodechange:

#cmdSetup radio Null Capacitance
:write: Cap:NULL
:read: Cap:NULL?
:update: Null_Value
:updatedelayed: 0.1
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
On ON
Off OFF
:updatemodechange:

#cmdSetup number Null_Value Capacitance
:read: CALC:NULL:OFFS?
:write: CALC:NULL:OFFS
:buttontext: Set
mF -10 +10
:updatemodechange:

;Continuity------------------------------------------------------------------------------------------
#cmdSetup radio Beeper Continuity
:write: SYST:BEEP:STAT
:read: SYST:BEEP:STAT?
:readmath: replace(replace(value,"0","OFF"),"1","ON")
:string:
On ON
Off OFF
:updatemodechange:

#cmdSetup number Threshold Continuity
:read: CONT:THRE?
:write: CONT:THRE
:buttontext: Set
Ohms 1 1100
:updatemodechange:


;Mod sel-------------------------------------------------------------------------------------------
#cmdSetup selector Mode_settings
:read: FUNC?
:readmath: unQuote(replace(replace(value,"VOLT AC","VOLTAC"),"CURR AC","CURRAC"))

:updatemodechange:
VOLT DC_Voltage.
VOLTAC AC_Voltage.
CURR DC_Current.
CURRAC AC_Current.
DIOD Diode.
FREQ Frequency.
TEMP Temperature.
RES 2W_Resistance.
FRES 4W_Resistance.
CAP Capacitance.
CONT Continuity.
PER Period.
