Hello,
I tried to write a definition-file for a Prema 6048. This is a non-scpi Device, but with GPIB. I use a ar488-GPIB adapter. The problem is, that the Prema replies to a ++read with the full measurement value and the status in one single line only after the integration time is finished. The integration time can be very long: up to 80sec, in this time the device doesn´t answers to any ++read and there is no possibility to ask for the status or the last measurement value of the device. Thats why I tried the following approach:
buffer the output to a variable and when a rx-timeout occurs, then use this buffer, but I need help for that. What I have so far (and it doesn´t work completely):
#author meandeev
#idString PREMA 6048
#name Prema_6048
#handle P6048
#port comfixedbaud
; using a AR488 so the DTR has to be set correctly:
#baudrate 115200N81Rd
#driver Ascii
; A list of possible column name with unit and formatter (SI, Time, Int, D0..D6)
#value VoltageDC V X9 DC_Voltage
; Simulated SCPI command definitions for the Prema 6048
; Function
#scpiCmd VD tx VD
; Synthetic Commands
#scpiCmd READ:DATA? txrx? ++read
:readmath: (strlen(value)==0)? oldvar : value
:setvar: oldvar=(strlen(value)==0)?oldvar:value
#cmdMode DC_Voltage VD
VD
; String to ask about actual meter mode,
; This is a single line command
#askMode READ:DATA?
#askModeMathFormat substring(value,16,18)
; How to poll for data, this is used for table and #values?
; a #askMode, #cmdMode and #prepareSample is used before this string is used.
; This is a single line command
#askValues READ:DATA?
#readingDelay 3
#askValuesMathFormat substring(value,0,14)
#initCmd
:setvar: oldvar=""
#finalCmd tx ++loc
; Setup menu functions
;Mode-------------------------------------------------------------------------------------------
#cmdSetup info Active_Mode
:read: READ:DATA?
:readmath: substring(value,16,18)
:updatemodechange:
;DC_Voltage-------------------------------------------------------------------------------------
#cmdSetup checkbox AutoRange DC_Voltage
:write: (getElement("A0 A1",value))
:read: READ:DATA?
:readmath: substring(value,22,23)
On 0 1
:updatemodechange:
but when I set the integration time to 4s and the rate of TC to 1s I get this:
;; 22:50:39.022 P6048: Tx <READ:DATA?>
;; 22:50:39.022 P6048: Tx <txrx? ++read>
;; 22:50:39.039 COM23: Tx: <++read.> 2B 2B 72 65 61 64 0A
;; 22:50:39.039 COM23: Rx: <+007.497929E+0MRVDP00A1R3F1T7D0S0Q1M02B06> 2B 30 30 37 2E 34 39 37 39 32 39 45 2B 30 4D 52 56 44 50 30 30 41 31 52 33 46 31 54 37 44 30 53 30 51 31 4D 30 32 42 30 36
;; 22:50:39.046 P6048: Rx <+007.497929E+0MRVDP00A1R3F1T7D0S0Q1M02B06>
;; 22:50:39.048 P6048: Rx after :readmath: substring(value,0,14) <+007.497929E+0>
;; 22:50:39.048 P6048: Rx as numbers <7.497929>
;; 22:50:40.022 P6048: Tx <READ:DATA?>
;; 22:50:40.022 P6048: Tx <txrx? ++read>
;; 22:50:40.024 COM23: Tx: <++read.> 2B 2B 72 65 61 64 0A
;; 22:50:41.027 COM23: Rx: timeout
;; 22:50:41.027 P6048: Rx <null>
;; 22:50:41.027 P6048: Rx after :readmath: substring(value,0,14) <null>
;; 22:50:41.027 P6048: Rx as numbers <NaN>
;; 22:50:41.027 P6048: Tx <READ:DATA?>
;; 22:50:41.027 P6048: Tx <txrx? ++read>
;; 22:50:41.030 COM23: Tx: <++read.> 2B 2B 72 65 61 64 0A
;; 22:50:41.164 COM23: Rx: <+007.497929E+0MRVDP00A1R3F1T7D0S0Q1M02B00> 2B 30 30 37 2E 34 39 37 39 32 39 45 2B 30 4D 52 56 44 50 30 30 41 31 52 33 46 31 54 37 44 30 53 30 51 31 4D 30 32 42 30 30
;; 22:50:41.180 P6048: Rx <+007.497929E+0MRVDP00A1R3F1T7D0S0Q1M02B00>
;; 22:50:41.180 P6048: Rx after :readmath: substring(value,0,14) <+007.497929E+0>
;; 22:50:41.180 P6048: Rx as numbers <7.497929>
;; 22:50:42.035 P6048: Tx <READ:DATA?>
;; 22:50:42.035 P6048: Tx <txrx? ++read>
;; 22:50:42.038 COM23: Tx: <++read.> 2B 2B 72 65 61 64 0A
;; 22:50:43.050 COM23: Rx: timeout
;; 22:50:43.050 P6048: Rx <null>
;; 22:50:43.050 P6048: Rx after :readmath: substring(value,0,14) <null>
;; 22:50:43.050 P6048: Rx as numbers <NaN>
;; 22:50:43.050 P6048: Tx <READ:DATA?>
;; 22:50:43.050 P6048: Tx <txrx? ++read>
;; 22:50:43.055 COM23: Tx: <++read.> 2B 2B 72 65 61 64 0A
;; 22:50:44.065 COM23: Rx: timeout
;; 22:50:44.065 P6048: Rx <null>
;; 22:50:44.065 P6048: Rx after :readmath: substring(value,0,14) <null>
;; 22:50:44.065 P6048: Rx as numbers <NaN>
;; 22:50:44.065 P6048: Tx <READ:DATA?>
;; 22:50:44.065 P6048: Tx <txrx? ++read>
;; 22:50:44.071 COM23: Tx: <++read.> 2B 2B 72 65 61 64 0A
;; 22:50:45.090 COM23: Rx: timeout
;; 22:50:45.090 P6048: Rx <null>
;; 22:50:45.090 P6048: Rx after :readmath: substring(value,0,14) <null>
;; 22:50:45.090 P6048: Rx as numbers <NaN>
;; 22:50:45.090 P6048: Tx <READ:DATA?>
;; 22:50:45.090 P6048: Tx <txrx? ++read>
;; 22:50:45.096 COM23: Tx: <++read.> 2B 2B 72 65 61 64 0A
;; 22:50:45.174 COM23: Rx: <+007.497929E+0MRVDP00A1R3F1T7D0S0Q1M02B00> 2B 30 30 37 2E 34 39 37 39 32 39 45 2B 30 4D 52 56 44 50 30 30 41 31 52 33 46 31 54 37 44 30 53 30 51 31 4D 30 32 42 30 30
;; 22:50:45.174 P6048: Rx <+007.497929E+0MRVDP00A1R3F1T7D0S0Q1M02B00>
;; 22:50:45.174 P6048: Rx after :readmath: substring(value,0,14) <+007.497929E+0>
;; 22:50:45.174 P6048: Rx as numbers <7.497929>
;; 22:50:46.023 P6048: Tx <READ:DATA?>
;; 22:50:46.023 P6048: Tx <txrx? ++read>
;; 22:50:46.027 COM23: Tx: <++read.> 2B 2B 72 65 61 64 0A
;; 22:50:47.041 COM23: Rx: timeout
;; 22:50:47.041 P6048: Rx <null>
;; 22:50:47.041 P6048: Rx after :readmath: substring(value,0,14) <null>
;; 22:50:47.041 P6048: Rx as numbers <NaN>
;; 22:50:47.041 P6048: Tx <READ:DATA?>
;; 22:50:47.041 P6048: Tx <txrx? ++read>
;; 22:50:47.046 COM23: Tx: <++read.> 2B 2B 72 65 61 64 0A
;; 22:50:48.060 COM23: Rx: timeout
;; 22:50:48.060 P6048: Rx <null>
;; 22:50:48.060 P6048: Rx after :readmath: substring(value,0,14) <null>
;; 22:50:48.060 P6048: Rx as numbers <NaN>
So after the rx timeout the substitution with the oldvar doesn´t occur. Why? I´m lost ...
Can somebody help me with this? Thanks!