; TestController device configuration file for Fluke 863, 865 and 867B Graphical Multimeters.
; Version 0.41 single
; Date 20-05-2023
; Written by Gertjan Miedema,  info at miedemageluid dot nl,  Username "Gertjan" at EEVblog.
; Tested with Fluke 867B and original Fluke PM9080 optical RS-232 interface cable.

; For use with TestController, software to control and log data: https://lygte-info.dk/project/TestControllerIntro%20UK.html

; Some  notes & tips:
; - This is the single display version of the Fluke 86x driver.
;   For logging both primary and secoundary read-outs use the Fluke86x dual display version of this driver.
;
; - Only the primary display is read out and logged.
;   In all cases the secondary reading can be switched to the primary display.
;
; - Advantage of single display read-out is faster logging (up to 0,2sec/interval).
;
; - This is not a fast meter. Calculations like RMS and Frequency are slowing the update rate down.
;
; - The default RS-232 parameters are: 1200 baud, 8 bits, No stop bit, 1 Parity bit, XON/XOFF handshake.
;   (But it will work with all baud rates up to 19200, if you set TestController and the Fluke 86x to the same baud rate.)
;
; - All function selection (DCV, ACV, Ohm etc.) is done on the meter itself.
;   Also set any further mode settings on the meter itself. 
;
; - It is best to use the Fluke 86x in manual ranging while logging, to avoid missing measurements due to slow auto-ranging.
;
; - Almost certainly this configuration file will also support the older Fluke 865 and 867 GMM's.
;   But I could not verify this... (Please contact me if you do!)
;
; - Overload indication ("OL") is translated to zero ("0").
;   This way OL can be handled as a normal number, and it is still easy recognized as an error.


; Known issues:
; - Auto ranging in slow on these meters. Auto range changing might take up to four seconds.
;   -> Solution: use manual ranging while logging...
;
; - This configuration file is meant for measurement data read out and logging.
;   Screen picture copy and waveform download is not supported.





; Meta definition for Fluke 867B Graphical Multimeter
#metadef
#idString Fluke,867
#name Fluke 867B
#handle Fluke867



; Meta definition to also support Fluke 863 Graphical Multimeter
#metadef
#idString Fluke,863
#name Fluke 863
#handle Fluke863

; Command to get a full id line and prevent connection to other devices
#verifyDevice "FLUKE 863" model?



; Meta definition to also support the older Fluke 865 Graphical Multimeter (not tested)
#metadef
#idString Fluke,865
#name Fluke 865
#handle Fluke865

; Command to get a full id line and prevent connection to other devices
#verifyDevice "FLUKE 865" model?



#meta
#idString Fluke,867
#name Fluke 867B
#handle Fluke867

#driver Ascii

; port can be com, comfixedbaud, comnobaud or a port number for network devices.
#port com

; The author statement is used for the listing in the About window.
#author Gertjan Miedema


#notes  Device configuration file for Fluke 863 and 867B Graphical DMM.

- This is the single display version of the fluke 86x driver.
  Only the primary display is read out and logged.
  For logging both primary and secoundary read-outs use the Fluke86x dual display version of this driver.

- The default RS-232 parameters are: 1200baud, 8N1, XON/XOFF.
  (But all baud rates up to 19200 will work. Set same baud rate in TC and meter.)

- All function selection (DCV, ACV, Ohm, ...) and mode settings are done on the meter itself.

- Use the Fluke 867B in manual ranging while logging.

- More info and known issues in the header of the definition file (Fluke86x.txt).


Configuration file version: 0.41 single display.



; This is delimiter for received blocks/lines, when not specified default is \r\n
#rxEol \r

; Adds this string to all transmitted commands (Except #poll), when not specified default is \r\n
#eol \r




; ================= Original Fluke 860 commands to SCPI/TestController commands translations  ======================

; There must be a line for each of the original device commands that will be used, converting it to a similar SCPI command



; -----  command to init & exit  ------

; DS    Default Setup
;         After DS wait for at least 4 seconds to let the GMM settle itself before you send the next command.
; RI    Resets all instrument registers to factory settings, except communications parameters, printer type, and calibration constants.
;         After RI wait for at least 5 seconds, to let the GMM settle itself before you send the next command.
; Command to initialize the meter
#scpiCmd init txrx DS


; Final command to meter before breaking connection, used to restore local control
; DS    Default Setup
#scpiCmd reset txrx DS


; -----  Instrument identification    -----

; ID  IDentification query. (Answer string: "0<lf>FLUKE 867,V1.4,7140240  ")
; Recall the model number
#scpiCmd model? txrx2? ID
:readmath: getElement(value,1,"[\n,]");

; Recall the firmware version
#scpiCmd getDeviceSW? txrx2? ID
:readmath: getElement(value,2,"[\n,]");

; Recall the serial number
#scpiCmd getDeviceSN? txrx2? ID
:readmath: getElement(value,3,"[\n,]");


; -----  data & mode read out  -----

; Commands to read current value or values.
; It is possible to define value1?, value2?, etc. and then use them all with a ; between in the #askValues statement.
; In some modes (Ohm,F,S) the Fluke 86x sends a two line answer, in all other  Modes it sends a three line answer. 


; Command to read primary display value from 2 line answer (for modes without secondary display)
; QM  Query Measurement
#scpiCmd read2? txrx2? QM
:readmath: replace(getElement(value,1,"[\n]"),"OL","0");


; Command to read both primary and secondary display values from 3 line answer
; QM  Query Measurement
#scpiCmd read3? txrxn? 3 QM
:readmath: replace(getElement(value,1,"[\n]"),"OL","0");




; =================================  End command conversion Fluke 860 -> TestController SCPI  ===========================



;----------------------- Data read out  ------------------

; A list of possible column name with unit and formatter (SI, Time, Int, D0..D6)
; code: #value name unit format {selector}

#value Volt_DC VDC SI mVDC,VDC

#value Volt_AC VAC SI mVAC,VAC

#value deciBel dB D2 dB

#value Ohm Ohm SI Ohms,kOhms,MOhms

#value Amp_DC ADC SI uADC,mADC,ADC

#value Amp_AC AAC SI AAC,uAAC,mAAC

#value Frequency Hz SI Hz,kHz,MHz

#value Conductance S SI nS

#value Capacitance F SI pF,uF

#value Duty_Cycle % D1 %

#value Period s SI us,ms

; Extra function to catch OverLoad and errors (mainly during slow mode auto ranging and mode switching)
#value Unknown NaN D1 Unknown,OL,NaN


; Prepare the meter to response to #askValues
; Take a measurement in advance, to read out the current Modes
#prepareSample #askValues;[100]


; This is a single line command
; The input string is split into segments on all spaces, commas and semicolons and each segment is assumed to be a value.
; Use read command read3?, but for 2-line answers (Ohm, S or F) use read2?
#askValues [mode:Ohms,kOhms,MOhms,nS,pF,uF]read2?;
[mode:mVDC,VDC,mVAC,VAC,dB,uADC,mADC,ADC,AAC,uAAC,mAAC,Hz,kHz,MHz,%,us,ms,Unknown,OL,NaN]read3?;

#askValuesMathFormat replace(parseSI(replace(value," ","")),"NaN","0");

#askMode read3?
#askModeMathFormat getElement(value,1,"[ ]+");
#modeFromValue getElement(value,1,"[ ]+")



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

; Give the device time to change mode, a value of 10 (seconds) will usual be fine
#modeChangeDelay 5




;------------------  Initial commands & final command  --------------

; Commands to get a full id line and prevent connection to other devices
#verifyDevice "FLUKE 867" model?


; Initial commands to meter when establishing connection
;#initCmd init;[1000];

; Final command to meter before breaking connection
; Wait for at least 4 seconds to let the GMM settle itself before you send the next command.
;#finalCmd reset;[4000] 



; ==================  Menu  ==================

; No menu.....
; All function switching and mode selection is done on the meter itself.
; The actual mode is decoded from #askValues
 
