
#author WA 
; 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
#idString Rohde&Schwarz,HMC8043,
#name R&S HMC8043
#handle HMC8043
#port 5025

; 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 CH1_W W d1

#value CH2_A A d5
#value CH2_V V d3
#value CH2_W W d5

#value CH3_A A d5
#value CH3_V V d3
#value CH3_W W d1

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

; List of commands for HMC 8043:
; Measure output current, voltage and power for CH1:    INST OUT1;MEAS:Curr?;:INST OUT1;MEAS:VOLT?;:INST OUT1;MEAS:POW?
; Measure output current, voltage and power for CH2:    INST OUT2;MEAS:Curr?;:INST OUT2;MEAS:VOLT?;:INST OUT2;MEAS:POW?
; Measure output current, voltage and power for CH3:    INST OUT3;MEAS:Curr?;:INST OUT3;MEAS:VOLT?;:INST OUT3;MEAS:POW?

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

#interfaceType PS P2:2 PS:3
#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 3 6
#interface readVoltage 1 4 7
#interface readPower 2 5 8

#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 Output_3
:read: INST OUT3;VOLT?
:write: INST OUT3;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_3
:read: INST OUT3;CURR?
:write: INST OUT3;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:MAST?
: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.0005 3
;------------------------------------------------------------------------------------

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

#cmdSetup buttonsOn Output Output_2
:read: INST OUT2;OUTP?;OUTP:MAST?
: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.0005 3
;------------------------------------------------------------------------------------

#cmdSetup color _ Output_3
(255,102,0)

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

#cmdSetup checkbox Overload Output_3
:read: INST OUT3;FUSE?
:write: INST OUT3;FUSE:UNLINK 1;unlink 2;FUSE
Turn_off 0 1

#cmdSetup checkbox Overload Output_3
:read: INST OUT3;FUSE:DELAY?
:write: INST OUT3;FUSE:DELAY #
:enable: Output_3.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_3
:read: INST OUT3;VOLT?
:write: INST OUT3;VOLT
:tip: Setup this voltage, do not turn output on/off
Volt 0 32.050

#cmdSetup number Current Output_3
:read: INST OUT3;CURR?
:write: INST OUT3;CURR
:tip: Setup this current, do not turn output on/off
Amps 0.0005 3
;**************************************************************************

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

#cmdSetup buttonsOn Output Outputs_1/2
:read: INST OUT1;OUTP?;INST OUT2;OUTP?;OUTP:MAST?
: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.0005 3
;**************************************************************************
; Prepare the meter to response to #askValues
#prepareSample
abort
sample:count 1
trig:source imm
trig:count inf
init
