
; TestController must be restarted before any changes in this file will be used.
; Manual is here: https://lygte-info.dk/project/TestControllerConfigDevice%20UK.html

;;;;;;;;;;;;;;;;;
; RuoShui Section

; UNTESTED
#metadef
#author TheDefpom_ http://www.TheDefpom.com
#idString ELEC,RuoShui 4090A
#name Ruoshui VC4090A
#handle RVC4090A
#removeline 15kHz 15000
#removeline 20kHz 20000
#removeline 40kHz 40000
#removeline 50kHz 50000
#removeline 80kHz 80000
#removeline 100kHz 100000
#removeline #cmdSetup number Frequency
#removeline VariableFrequency


; UNTESTED
#metadef
#author TheDefpom_ http://www.TheDefpom.com
#idString ELEC,RuoShui 4090B
#name Ruoshui VC4090B
#handle VC4090B
#removeline 40kHz 40000
#removeline 50kHz 50000
#removeline 80kHz 80000
#removeline 100kHz 100000
#removeline #cmdSetup number Frequency
#removeline VariableFrequency


#metadef
#author TheDefpom_ http://www.TheDefpom.com
#idString ELEC,RuoShui 4090C
#name Ruoshui VC4090C
#handle VC4090C
#removeline #cmdSetup number Frequency
#removeline VariableFrequency


; UNTESTED
#metadef
#author TheDefpom_ http://www.TheDefpom.com
#idString ELEC,RuoShui 4091A
#name Ruoshui VC4091A
#handle VC4091A
#removeline 100Hz 100
#removeline 120Hz 120
#removeline 200Hz 200
#removeline 400Hz 400
#removeline 800Hz 800
#removeline 1kHz 1000
#removeline 2kHz 2000
#removeline 4kHz 4000
#removeline 8kHz 8000
#removeline 10kHz 10000
#removeline 15kHz 15000
#removeline 20kHz 20000
#removeline 40kHz 40000
#removeline 50kHz 50000
#removeline 80kHz 80000
#removeline 100kHz 100000
#removeline #cmdSetup comboboxhot Frequency
#replaceText VariableFrequency Hz 10 10000


; UNTESTED
#metadef
#author TheDefpom_ http://www.TheDefpom.com
#idString ELEC,RuoShui 4091B
#name Ruoshui VC4091B
#handle VC4091B
#removeline 100Hz 100
#removeline 120Hz 120
#removeline 200Hz 200
#removeline 400Hz 400
#removeline 800Hz 800
#removeline 1kHz 1000
#removeline 2kHz 2000
#removeline 4kHz 4000
#removeline 8kHz 8000
#removeline 10kHz 10000
#removeline 15kHz 15000
#removeline 20kHz 20000
#removeline 40kHz 40000
#removeline 50kHz 50000
#removeline 80kHz 80000
#removeline 100kHz 100000
#removeline #cmdSetup comboboxhot Frequency
#replaceText VariableFrequency Hz 10 20000


; UNTESTED
#metadef
#author TheDefpom_ http://www.TheDefpom.com
#idString ELEC,RuoShui 4091C
#name Ruoshui VC4091C
#handle VC4091C
#removeline 100Hz 100
#removeline 120Hz 120
#removeline 200Hz 200
#removeline 400Hz 400
#removeline 800Hz 800
#removeline 1kHz 1000
#removeline 2kHz 2000
#removeline 4kHz 4000
#removeline 8kHz 8000
#removeline 10kHz 10000
#removeline 15kHz 15000
#removeline 20kHz 20000
#removeline 40kHz 40000
#removeline 50kHz 50000
#removeline 80kHz 80000
#removeline 100kHz 100000
#removeline #cmdSetup comboboxhot Frequency
#replaceText VariableFrequency Hz 10 100000

; End of Ruoshui Section
;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; East Tester Alternate Section

; UNTESTED ET4401 using RuoShui Definitions
#metadef
#author TheDefpom_ http://www.TheDefpom.com
#idString ZC,ET4401
#name East Tester ET4401 (Alt)
#handle ET4401Alt
#removeline 15kHz 15000
#removeline 20kHz 20000
#removeline 40kHz 40000
#removeline 50kHz 50000
#removeline 80kHz 80000
#removeline 100kHz 100000
#removeline #cmdSetup number Frequency
#removeline VariableFrequency


; UNTESTED ET4402 using RuoShui Definitions
#metadef
#author TheDefpom_ http://www.TheDefpom.com
#idString ZC,ET4402
#name East Tester ET4402 (Alt)
#handle ET4402Alt
#removeline 40kHz 40000
#removeline 50kHz 50000
#removeline 80kHz 80000
#removeline 100kHz 100000
#removeline #cmdSetup number Frequency
#removeline VariableFrequency


; TESTED ET4410 FW V6.00.2136.018 using Ruoshui Definitions
#metadef
#author TheDefpom_ http://www.TheDefpom.com
#idString ZC,ET4410
#name East Tester ET4410 (Alt)
#handle ET4410Alt
#removeline #cmdSetup number Frequency
#removeline VariableFrequency


; UNTESTED ET4501 using RuoShui Definitions
#metadef
#author TheDefpom_ http://www.TheDefpom.com
#idString ZC,ET4501
#name East Tester ET4501 (Alt)
#handle ET4501Alt
#removeline 100Hz 100
#removeline 120Hz 120
#removeline 200Hz 200
#removeline 400Hz 400
#removeline 800Hz 800
#removeline 1kHz 1000
#removeline 2kHz 2000
#removeline 4kHz 4000
#removeline 8kHz 8000
#removeline 10kHz 10000
#removeline 15kHz 15000
#removeline 20kHz 20000
#removeline 40kHz 40000
#removeline 50kHz 50000
#removeline 80kHz 80000
#removeline 100kHz 100000
#removeline #cmdSetup comboboxhot Frequency
#replaceText VariableFrequency Hz 10 10000


; UNTESTED ET4502 using RuoShui Definitions
#metadef
#author TheDefpom_ http://www.TheDefpom.com
#idString ZC,ET4502
#name East Tester ET4502 (Alt)
#handle ET4502Alt
#removeline 100Hz 100
#removeline 120Hz 120
#removeline 200Hz 200
#removeline 400Hz 400
#removeline 800Hz 800
#removeline 1kHz 1000
#removeline 2kHz 2000
#removeline 4kHz 4000
#removeline 8kHz 8000
#removeline 10kHz 10000
#removeline 15kHz 15000
#removeline 20kHz 20000
#removeline 40kHz 40000
#removeline 50kHz 50000
#removeline 80kHz 80000
#removeline 100kHz 100000
#removeline #cmdSetup comboboxhot Frequency
#replaceText VariableFrequency Hz 10 20000


; UNTESTED ET4510 using RuoShui Definitions
#metadef
#author TheDefpom_ http://www.TheDefpom.com
#idString ZC,ET4510
#name East Tester ET4510 (Alt)
#handle ET4510Alt
#removeline 100Hz 100
#removeline 120Hz 120
#removeline 200Hz 200
#removeline 400Hz 400
#removeline 800Hz 800
#removeline 1kHz 1000
#removeline 2kHz 2000
#removeline 4kHz 4000
#removeline 8kHz 8000
#removeline 10kHz 10000
#removeline 15kHz 15000
#removeline 20kHz 20000
#removeline 40kHz 40000
#removeline 50kHz 50000
#removeline 80kHz 80000
#removeline 100kHz 100000
#removeline #cmdSetup comboboxhot Frequency
#replaceText VariableFrequency Hz 10 100000

; End of East Tester Section
;;;;;;;;;;;;;;;;;;;;;;;;;;;;


#meta
#author TheDefpom http://www.TheDefpom.com
#idString ELEC,RuoShui 4090x
#name Ruoshui 4090x
#handle VC4090x
#port comfixedbaud
#baudrate 115200
#driver SCPIx

#charset ISO-8859-1



;***********************************************************************************
; Rev 1.0.4 Release 12th December 2022
; Written by Scott - TheDefpom
;  
; Website: http://www.TheDefpom.com 
; Electronics Repair Videos: https://www.youtube.com/TheDefpom
;***********************************************************************************
; Please add any notes about 3rd party changes or future definition updates below:
;
; 1.0.1 added mode detection
; 1.0.2 added VC4091 series and tidied up definition file a bit
; 1.0.3 fixes for display of Current values in AUTO, ECAP and Z modes
;       renamed Dissipation to Dissipation_Factor, and changed unit from % to none
; 1.0.4 added East Tester section as newer East Tester devices are using the same
;       response format as RouShui e.g. ET4410 FW V6.00.2136.018
;
;
;
;
;***********************************************************************************


#notes 
Rev 1.0.4 Release 12th December 2022
Tested by C.J.S. & NPAudio
East Tester Section added by NPAudio (Using the metadefs from TheDefpom)
Written by Scott - TheDefpom
Website: http://www.TheDefpom.com 
Electronics Repair Videos: https://www.youtube.com/TheDefpom

Untested definition for RuoShui 4090A, 4090, and 4091A, 4091B, 4091C.

This definition is based on the East Tester ET4xxx however the response format is different.

(NPAudio December 2022)
However on a new East Tester ET4410 FW V6.00.2136.018 it required the RouShui reponse format.

Untested definition for other newer Firmware East Tester ET4401, ET4402 and ET4501, ET4502, ET4510.


; A list of possible column name with unit and formatter (SI, Time, Int, D0..D6) 
; Format: #value ColumnName Unit Format {Selector}
; Selector is only used when column layout varies with mode, this often require the use of #cmdMode
;
; the #value 2nd is to catch the 2nd function where it does not currently flag up with a mode,
; once that is corrected it wont be needed anymore.
; Primary functions are AUTO, C, ECAP, L, Z, R, DCR
; 2nd functions are ESR, X, D, Q, THR (Angle)

#value Unknown _ SI AUTO
#value Capacitance F SI C,ECAP
#value Inductance H SI L
#value Impedance Ohm SI Z
#value Resistance Ohm SI R
#value DC_Resistance Ohm SI DCR
#value ESR Ohm SI ESR
#value Reactance Ohm SI X
#value Dissipation_Factor _ SI D
#value Quality_Factor _ D4 Q
#value Angle Deg D2 THR
;#value Primary _ SI
;#value 2nd _ SI


#scpiCmd *idn? txrx? *idn?
:readmath: getElement(value,0)+","+getElement(value,1)+","+getElement(value,4)+","+getElement(value,2)+" "+getElement(value,3)

; 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.
; Number of returned values must match number of columns defined with #value (allowing for selector use)
; This is a single line command
#askValues :FUNC:IMP:A?; :FUNC:IMP:B?; :FETC?

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


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

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


; String to ask about actual meter mode, it is mostly used for DMM's
; This is a single line command
#askMode :FUNC:IMP:A?; :FUNC:IMP:B?
#askModeMathFormat getElement(value,0,"[ ]")+";"+getElement(value,1,"[ ]");
#modeFromValue getElement(value,0,"[ ]")+";"+getElement(value,1,"[ ]");


; Initial commands to meter when establishing connection, used to disable local control
; commented out as turning this on locks the front panel controls, and we don't need to use it !
;#initCmd  SYST:REM

; Final command to meter before breaking connection, used to restore local control
#finalCmd SYST:LOC



; This type will specify the handle name for the first device with this type
; This makes it possible to easy get generic handle names for a setup, that will work with a script
;#interfaceType DMM BMM
#interfaceType LCR
#interface readValue 1




;********************************************************
; Handle column type tracking
; This is only being used to display the active mode in the setup window
;********************************************************
; Hack to determine and track what mode the instrument is in as there are two parallel modes.
; :FUNC:IMP:A - Primary functions - AUTO,L,C,Z,DCR,ECAP,R
; :FUNC:IMP:B - 2nd functions - ESR, X, D, Q, Angle
; :FUNC:IMP:EQU - Series/Parallel mode
;********************************************************
#scpiCmd ModeAUTO none?
:setvar: myMode="AUTO"

#scpiCmd ModeL none?
:setvar: myMode="L"

#scpiCmd ModeC none?
:setvar: myMode="C"

#scpiCmd ModeR none?
:setvar: myMode="R"

#scpiCmd ModeZ none?
:setvar: myMode="Z"

#scpiCmd ModeDCR none?
:setvar: myMode="DCR"

#scpiCmd ModeECAP none?
:setvar: myMode="ECAP"


#scpiCmd ModeX none?
:setvar: myMode2="X"

#scpiCmd ModeD none?
:setvar: myMode2="D"

#scpiCmd ModeQ none?
:setvar: myMode2="Q"

#scpiCmd ModeTHR none?
:setvar: myMode2="THR"

#scpiCmd ModeESR none?
:setvar: myMode2="ESR"


#scpiCmd ModeSERial none?
:setvar: myMode3="SERial"

#scpiCmd ModePALlel none?
:setvar: myMode3="PALlel"


; handle the myMode query, killing it, and returning the value
#scpiCmd myMode? none?
:readmath: myMode

; handle the myMode2 query, killing it, and returning the value
#scpiCmd myMode2? none?
:readmath: myMode2

; handle the myMode3 query, killing it, and returning the value
#scpiCmd myMode3? none?
:readmath: myMode3






;*************************************************************
; Mode Window
;*************************************************************

; Strings to configure device in different modes, using these forces a mode check/change
; When used to select mode, first parameter must match a #value (4 parameter) and second parameter must match what #askMode returns
; It can also be used for just checking the mode, then the #value (4 parameter) must match what #askMode returns
; First parameter is also used in shortcut menu

#cmdModeLayout 6 2


#cmdMode ECAP ECAP
:FUNC:IMP:A ECAP;ModeECAP;[400];

#cmdMode C C
:FUNC:IMP:A C;ModeC;[400];

#cmdMode L L
:FUNC:IMP:A L;ModeL;[400];

#cmdMode Z Z
:FUNC:IMP:A Z;ModeZ;[400];

#cmdMode R R
:FUNC:IMP:A R;ModeR;[400];

#cmdMode DCR DCR
:FUNC:IMP:A DCR;ModeDCR;[400];



#cmdMode ESR ESR
:FUNC:IMP:B ESR;ModeESR;[400];

#cmdMode D D
:FUNC:IMP:B D;ModeD;[400];

#cmdMode X X
:FUNC:IMP:B X;ModeX;[400];

#cmdMode Q Q
:FUNC:IMP:B Q;ModeQ;[400];


#cmdMode Angle Deg
:FUNC:IMP:B THR;ModeTHR;[400];

#cmdMode AUTO AUTO
:FUNC:IMP:A AUTO;ModeAUTO;[400];

; blank spacers
;#cmdMode







;*************************************************************
; Setup Window
;*************************************************************


#cmdSetup info Active_Mode Info
:read: myMode?
:readmath: getElement("AUTO;Electrolytic Capacitance;Capacitance;Inductance;Impedance;Resistance;DC Resistance",listIndex(unQuote(value),"AUTO ECAP C L Z R DCR"," "),";")
:updatemodechange:
:layout:



; *** commented out as it does not change modes in the Mode window, which means the "Current Values" tab doesn't show the correct mode ***
;#cmdSetup comboboxhot Mode
;:read: :FUNC:IMP:A?;
;:write: :FUNC:IMP:A #;[400];Mode#
;:readmath: trim(value)
;:updatemodechange:
;:update: Selector
;AUTO AUTO
;Inductance L
;Capacitance C
;Elecrolytic_Capacitance ECAP
;AC_Resistance R
;DC_Resistance DCR
;Impedance Z
;************



;********
; allows for the VC4090x and VC4091x, only difference is fixed steps vs variable freq.
#cmdSetup number Frequency
#cmdSetup comboboxhot Frequency
:read: :FREQ?;
:write: :FREQ #;[400]
:readmath: trim(value)
:string:
100Hz 100
120Hz 120
200Hz 200
400Hz 400
800Hz 800
1kHz 1000
2kHz 2000
4kHz 4000
8kHz 8000
10kHz 10000
15kHz 15000
20kHz 20000
40kHz 40000
50kHz 50000
80kHz 80000
100kHz 100000
VariableFrequency
;********



#cmdSetup radio Function
:read: :FUNC:IMP:B?;
:write: :FUNC:IMP:B #;[400];Mode#
:readmath: trim(value)
:updatemodechange:
:string:
ESR ESR
Dissipation_Factor D
Reactance X
Quality_Factor Q
Angle THR




#cmdSetup radio Type
:read: :FUNC:IMP:EQU?;
:write: :FUNC:IMP:EQU #;[400];Mode#
:readmath: trim(value)
:updatemodechange:
:string:
Series SERial
Parallel PALlel



;***************
; this refuses to work... can read the value but wont write it !
;#cmdSetup number Bias_Voltage
;:read: :BIAS:VOLT:LEV?;
;:write: :BIAS:VOLT:LEV #;[400]
;:updatemodechange:
;:readmath: trim(value)
;:string:
;:format: int
;mV 0 1500

; Strangely this one works fine !
#cmdSetup comboboxhot Bias_Voltage
:read: :BIAS:VOLT:LEV?;
:write: :BIAS:VOLT:LEV #;[400]
:updatemodechange:
:readmath: trim(value)
:string:
0mV 0
5mV 5
10mV 10
25mV 25
50mV 50
75mV 75
100mV 100
250mV 250
500mV 500
750mV 750
1V 1000
1.25V 1250
1.5V 1500
;*****************




#cmdSetup radio Speed
:read: :APER?;
:write: :APER #;[400]
:readmath: trim(value)
:updatemodechange:
:string:
Fast FAST
Medium MEDium
Slow SLOW




;#cmdSetup checkbox Impedance_Auto_Range
;:read: :FUNC:IMP:RANG:AUTO?;
;:write: :FUNC:IMP:RANG:AUTO #;[400]
;:readmath: trim(value)
;:update: ZSelector
;:string:
;On OFF ON




; not working, cant seem to figure out correct SCPI command, the one in the manual does not work?
;#cmdSetup comboboxhot Impedance
;:read: :FUNC:IMP:RANG:VAL?;
;:write: :FUNC:IMP:RANG:VAL #;[400]
;:updatemodechange:
;:string:
;30_Ohms 30
;100_Ohms 100
;300_Ohms 300
;1k_Ohms 1000
;3_kOhms 3000
;10_kOhms 10000
;30_kOhms 30000
;100_kOhms 100000




#cmdSetup checkbox Beeper
:read: :SYST:BEEP:STAT?;
:write: :SYST:BEEP:STAT #;[400]
:readmath: trim(value)
:string:
On OFF ON




#cmdSetup checkbox Relative_Measurement
:read: :FUNC:DEV:MODE?;
:write: :FUNC:DEV:MODE #;[400]
:readmath: trim(value)
:updatemodechange:
:string:
On OFF ON



#cmdSetup selector Selector
:read: :FUNC:IMP:A?;
:readmath: trim(value)
:updatemodechange:
:layout:
AUTO Frequency Speed Bias_Voltage Impedance_Range Beeper Relative_Measurement
L Frequency Function Type Speed Bias_Voltage Impedance_Range Beeper Relative_Measurement
C Frequency Function Type Speed Bias_Voltage Impedance_Rangee Beeper Relative_Measurement
ECAP Frequency Function Type Speed Impedance_Range Beeper Relative_Measurement
R Frequency Function Type Speed Bias_Voltage Impedance_Range Beeper Relative_Measurement
DCR Type Speed Bias_Voltage Impedance_Range Beeper Relative_Measurement
Z Frequency Function Type Speed Bias_Voltage Impedance_Range Beeper Relative_Measurement



;#cmdSetup selector Selector2
;:read: :FUNC:IMP:B?;
;:readmath: trim(value)
;:updatemodechange:
;ESR ESRmode
;D Dmode
;X Xmode
;Q Qmode
;THR Anglemode

; Angle may need renaming.



;#cmdSetup selector ZSelector
;:read: :FUNC:IMP:RANG:AUTO?;
;:readmath: trim(value)
;:updatemodechange:
;:layout:
;ON Impedance_Auto_Range
;OFF Impedance_Auto_Range Impedance



