
#author SAS and WS
; WS adjusted the heading to match R&S
; and HKJ Ver. 0.7 - 21.04.2020
; 11-2020 HKJ Added interfaces, #outputoff, off on overload and automatic turn on with voltage radio buttons
; 20 Feb 2021 The device configuration file "R&SHMC8043.txt" by WA was used as a template for this file
; 17.03.2022 ROHDE&SCHWARZ variant of Hameg HMP2020

#idString ROHDE&SCHWARZ,HMP2020,
#name R&S HMP2020
#handle HMP2020
#port com

; A list of possible column name with unit and formatter (SI, Time, Int, D0..D6)
#value CH1_A A d5
#value CH1_V V d3

#value CH2_A A d5
#value CH2_V V d3

; 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 INST OUT1;MEAS:Curr?;:INST OUT1;MEAS:VOLT?; INST OUT2;MEAS:Curr?;:INST OUT2;MEAS:VOLT?

; List of commands for HMP2020:
; Measure output current and voltage for CH1:    INST OUT1;MEAS:Curr?;:INST OUT1;MEAS:VOLT?
; Measure output current and voltage for CH2:    INST OUT2;MEAS:Curr?;:INST OUT2;MEAS:VOLT?

#outputOff OUTP:GEN 0;INST OUT1;OUTP 0;INST OUT2;OUTP 0;
#initCmd SYST:REM
#finalCmd OUTP:GEN 0;SYST:LOC

#interfaceType PS P2:2
#interface setVoltage INST OUT(channel);VOLT (value)
#interface setCurrent INST OUT(channel);CURR (value)
#interface setOn INST OUT(channel);OUTP (value)

#interface getVoltage INST OUT(channel);VOLT?
#interface getCurrent INST OUT(channel);CURR?
#interface getOn INST OUT(channel);OUTP?


;**************************************************
#interface readCurrent 0 2 
#interface readVoltage 1 3 


#ScreenDump std
HCOPY:DATA? 
;**************************************************

; This popup stuff:
#cmdSetup radio Voltage Output_1
:read: INST OUT1;VOLT?
:write: INST OUT1;VOLT #;OUTP 1
:tip: Setup this voltage, turn output on
3.3V 3.3
5V 5.0
9V 9.0
12V 12.0
15V 15.0
17V 17.0
24V 24.0

#cmdSetup radio Current Output_1
:read: INST OUT1;CURR?
:write: INST OUT1;CURR
:tip: Output will current limit at this current
20mA 0.020
100mA 0.1
300mA 0.3
500mA 0.5
1A 1.0
2A 2.0
3A 3.0

;------------------------------------------------------------------------------------
#cmdSetup radio Voltage Output_2
:read: INST OUT2;VOLT?
:write: INST OUT2;VOLT #;OUTP 1
:tip: Setup this voltage, turn output on
3.3V 3.3
5V 5.0
9V 9.0
12V 12.0
15V 15.0
17V 17.0
24V 24.0

#cmdSetup radio Current Output_2
:read: INST OUT2;CURR?
:write: INST OUT2;CURR
:tip: Output will current limit at this current
20mA 0.020
100mA 0.1
300mA 0.3
500mA 0.5
1A 1.0
2A 2.0
3A 3.0
;------------------------------------------------------------------------------------

#cmdSetup radio Voltage Outputs_1/2
:read: INST OUT1;VOLT?
:write: INST OUT1;VOLT #;OUTP 1;INST OUT2;VOLT #;OUTP 1
:tip: Setup this voltage, turn output on
+/-3.3V 3.3
+/-5V 5.0
+/-9V 9.0
+/-12V 12.0
+/-15V 15.0
+/-17V 17.0
+/-24V 24.0

#cmdSetup radio Current Outputs_1/2
:read: INST OUT1;CURR?
:write: INST OUT1;CURR #;INST OUT2;CURR #
:tip: Output will current limit at this current
+/-20mA 0.020
+/-100mA 0.1
+/-300mA 0.3
+/-500mA 0.5
+/-1A 1.0
+/-2A 2.0
+/-3A 3.0
;------------------------------------------------------------------------------------
;------------------------------------------------------------------------------------

#cmdSetup color _ Output_1
(153,76,0)

#cmdSetup buttonsOn Output Output_1
:read: INST OUT1;OUTP?;OUTP:GEN?
:readmath: match(value,"1.*1");
:write: INST OUT1;OUTP
:tip: Turn output on or off
:updatealloff:
Off 0
On 1

#cmdSetup checkbox Overload Output_1
:read: INST OUT1;FUSE?
:write: INST OUT1;FUSE:UNLINK 2;FUSE:UNLINK 3;FUSE
Turn_off 0 1

#cmdSetup checkbox Overload Output_1
:read: INST OUT1;FUSE:DELAY?
:write: INST OUT1;FUSE:DELAY #
:tip: When fuse it active it will first trip after a short delay in CC mode
:enable: Output_1.Overload.Turn_off
1s_Trip_delay 0 1


#cmdSetup number Voltage Output_1
:read: INST OUT1;VOLT?
:write: INST OUT1;VOLT
:tip: Setup this voltage, do not turn output on/off
Volt 0 32.050

#cmdSetup number Current Output_1
:read: INST OUT1;CURR?
:write: INST OUT1;CURR
:tip: Setup this current, do not turn output on/off
Amps 0.000 10
;------------------------------------------------------------------------------------

#cmdSetup color _ Output_2
(255,0,0)

#cmdSetup buttonsOn Output Output_2
:read: INST OUT2;OUTP?;OUTP:GEN?
:readmath: match(value,"1.*1");
:write: INST OUT2;OUTP
:tip: Turn output on or off
:updatealloff:
Off 0
On 1

#cmdSetup checkbox Overload Output_2
:read: INST OUT2;FUSE?
:write: INST OUT2;FUSE:UNLINK 1;FUSE:UNLINK 3;FUSE
Turn_off 0 1

#cmdSetup checkbox Overload Output_2
:read: INST OUT2;FUSE:DELAY?
:write: INST OUT2;FUSE:DELAY #
:enable: Output_2.Overload.Turn_off
:tip: When fuse it active it will first trip after a short delay in CC mode
1s_Trip_delay 0 1


#cmdSetup number Voltage Output_2
:read: INST OUT2;VOLT?
:write: INST OUT2;VOLT
:tip: Setup this voltage, do not turn output on/off
Volt 0 32.050

#cmdSetup number Current Output_2
:read: INST OUT2;CURR?
:write: INST OUT2;CURR
:tip: Setup this current, do not turn output on/off
Amps 0.000 5.01
;------------------------------------------------------------------------------------

;**************************************************************************

#cmdSetup color _ Outputs_1/2
(255,255,0)

#cmdSetup buttonsOn Output Outputs_1/2
:read: INST OUT1;OUTP?;INST OUT2;OUTP?;OUTP:GEN?
:readmath: match(value,"1.*1.*1");
:write: INST OUT1;OUTP #;INST OUT2;OUTP #;
:tip: Turn output on or off
:updatealloff:
Off 0
On 1

#cmdSetup checkbox Overload Outputs_1/2
:read: INST OUT1;FUSE?;FUSE:LINK? 2;INST OUT2;FUSE?;FUSE:LINK? 1
:readmath: match(value,"1.*1.*1.*1")
:write: INST OUT1;FUSE #;INST OUT2;FUSE #;FUSE:LINK 1;FUSE:UNLINK 3;INST OUT1;FUSE:LINK 2;FUSE:UNLINK 3;
Turn_off 0 1

#cmdSetup checkbox Overload Outputs_1/2
:read: INST OUT1;FUSE:DELAY?
:write: INST OUT1;FUSE:DELAY #;INST OUT2;FUSE:DELAY #
:enable: getVar("Outputs_1/2.Overload.Turn_off");
:tip: When fuse it active it will first trip after a short delay in CC mode
1s_Trip_delay 0 1

#cmdSetup number Voltage Outputs_1/2
:read: INST OUT1;VOLT?
:write: INST OUT1;VOLT #;INST OUT2;VOLT #
:tip: Setup this voltage, do not turn output on/off
+/-Volt 0 32.050

#cmdSetup number Current Outputs_1/2
:read: INST OUT1;CURR?
:write: INST OUT1;CURR #;INST OUT2;CURR #
:tip: Setup this current, do not turn output on/off
+/-Amps 0.000 5.01
;**************************************************************************
; Prepare the meter to response to #askValues
#prepareSample
abort
sample:count 1
trig:source imm
trig:count inf
init


