Comments starts by:
Everything after // is treated as comment and will be ignored.
If a // is the only command on a row it still will take time to process (defined by the speed).
The commands can be written with any case you want (upper, lower or mixed).
If it's an unknown command it will be sent to the connected instrument. Se the chapter "send to instrument" for important information abut formatting the string to send to instrument.
Don't do anything expect pause the time as set by speed
Floating point numbers
NOTE! All floating point handling is done using dot "." as decimal separator since this is the format used by the instruments.›
Arguments to all the commands are separated with space, if you want to include space in the argument use double quote. To use a variables value precede the argument with @.Examples
"also one argument"
OPEN [address] [port]
Open connection to instrument at using
If is not specified default to 5025
If no arguments are supplied it will open
connection to the instrument opened in
Open 10.0.1.1 5025
Open connection to the favorite [favorite] saved in the connection view. can be between 1 and last favorite.
Closes the current connection.
This command is not necessary to use since the script engine takes care of closing open connection automatically. It's only included for completeness.
Changes the read buffer size to [size] for the next open. If non argument the defaults t0 4096.
Min: 1024 (1 Kilobyte)
Max: 1073841824 ( 1 Gigabyte)
Default: 4096 (4 Kilobytes)
Variables can be named anything (exception see below), UPPER and lowercase is different.
To get the variables content begin variable name with @.
average# - Average of statistics
avg# - Average of statistics
buffsize - Current buffer size
buildnr - Returns the SCPI-Commande buildnr
currentrow - Current executing row
date - Current date in local short form
errormsg - The last error message, empty then no error
errorno - Last error number, see appendix
errorrow - Row number of the last error, -1 no error
index - Current loop index value
max# - Maximum value of statistics
mean# - Average of statistics
median# - Median of statistics
med# - Median of statistics
min# - Minimum values of statistics
scriptname - Name of current script.
- ”(not saved)” if not saved
speed - Returns the current speed
stat# - Number of statistical values
stddev# - Standard deviation
time - Current time hh:mm:ss
timems - Current time hh:mm:ss:mmm (with millisecond)
timestamp - Returns the number of seconds since jan 1 2001 00:00:00
timeout - Current Time out in ms
version - Retuns the SCPI-Commander version
SET [variable] [value]
Creates and store value
Set a 10
Set a @b Set a to the same value as b
INT [variable] [value]
Stores the integer value [value] into variable [variable]
int a @a
& [variable] [string] [string] ...
Appends the [string] (strings) to the variable contents
set a 56
& a " kilo" "grams"
-> 56 kilograms
SAVEBIN [variable] [filename]
Saves the binary block contained in [variable] to [filename]
SaveBIN @data "values.bin"
Changes the execution speed of the script. Each command will be execute with minimum ms delay. If no arguments it will default to 100 ms. The value can be between 0 and 5000 ms.
Stops the execution of the script.
All code following ONERROR will be executed whenever an error occurs in the main script. ONERROR routine must be the last routine in the script. Any error in the ONERROR routine will stop the script.
? "Error occurred"
Triggers a user generated error and will jump to the ONERROR routine if it exists, otherwise the script will stop with an error,
Pauses the script and shows "Break Point". You can now step through the script row by row. Continue the script by pressing RUN or stop by pressing STOP
Pauses the execution .
If no argument default to 500 ms
Defines label in the script where it's possible to jump to.
Jump/Goto to row
. Positive number jumps forward, negative backwards.
Jumo/Goto label. See label.
LOOP [end value] [step value]
Initiates a loop that will loop from 0 to using step
Execute the next loop iteration
Loop 10 1
DISP [arg1] [arg2] [argN]
? [arg1] [arg2] [argN]
DISP- [arg1] [arg2] [argN]
?- [arg1] [arg2] [argN]
Display the arguments separated with a space. Variables will be replaced with the value. If no argument is supplied an empty row will be displayed. If the command ends with - (minus sign) a new line is not printed at the end.
If you want to have newline in the middle of a string you can type \n.
Disp "This is just one argument"
? This is several arguments
Disp- "Measured volt " @volt " V"
?- Measured current is @current " A"
? "Row 1\nRow 2\Row 3"
DISPBIN [number] [bits]
?BIN [number] [bits]
DISPBIN- [number] [bits]
?BIN- [number] [bits]
Display the [number] in binary format with [bits] bits. If the command ends with - (minus sign) a new line is not printed at the end.
?bin 255 8 -> 11111
?bin 7 8 -> 00000111
?bin 255 4 -> 1111
DISPBB [variable] [rows]
?B [variable] [rows]
Displays information about a binary block stored in [variable]. On each row 8 bytes is displayed as hex-values and ascii-characters:
DispB @data 20
IF= [value1] [value2] [rows | label]
IF!= [value1] [value2] [rows | label]
IF< [value1] [value2] [rows | label]
IF> [value1] [value2] [rows | label]
IF<= [value1] [value2] [rows | label]
IF>= [value1] [value2] [rows | label]
= [value1] [value2] [rows | label]
!= [value1] [value2] [rows | label]
<> [value1] [value2] [rows | label]
< [value1] [value2] [rows | label]
> [value1] [value2] [rows | label]
<= [value1] [value2] [rows | label]
>= [value1] [value2] [rows | label]
Compares value1 with value2 and if it's true jumps rows [rows] or to label. Only compares numbers, not strings. See label.
set a 10
set b 10
IF= @a @b 3
disp "Not Equal"
if< @a @b lessThan
ADD [variable] [value]
SUB [variable] [value]
MUL [variable] [value]
DIV [variable] [value]
MOD [variable] [value]
PER [variable] [value]
+ [variable] [value]
- [variable] [value]
* [variable] [value]
/ [variable] [value]
% [variable] [value]
Execute the math function on variable [variable] with value [value]
Percentage add or removes percentage [value]
add @a 45
- @a 10
% @a -50
INT [variable] [value]
Stores the integer value [value] into variable [variable]
int a @a
ROUND [variable] [value]
Round the [value] to 2 significant digits and store into [variable]
Round the value stored in [variable] to 2 significant digits.
round a @a
Stores a random float number between 0 and 1 into variable.
BITSET? [variable] [bitnr] [jump]
BS? [variable] [bitnr] [jump]
BITCLR? [variable] [bitnr] [jump]
BC? [variable] [butnr] [jump]
Test to see if a bit is set (BITSET, BS) or cleared (BITCLR?, BC?) and jumps if true.
BitSet? @a 4 BitSet
BC? @a 1 BitClr
SETBIT [variable] [bitnr]
SB [variable] [bitnr]
CLRBIT [variable] [bitnr]
CBN [variable] [bitnr]
Sets (SETBIT or SB) or clears (CLRBIT or CB) a bit of the value in variable.
SETBIT a 5
CB a 3
ANDBIT [variable] [value]
AND [variable] [value]
ORBIT [variable] [value]
OR [variable] [value]
XORBIT [variable] [value]
XOR [variable] [value]
Perform the bitwise operation with value on the content of variable
ANDBIT a 170
XOR a 85
Inverts all bits (8 or 16) of the variable content.
SHIFTR8 [variable] [shifts]
SR8 [variable] [shifts]
SHIFTR16 [variable] [shifts]
SR16 [variable] [shifts]
SHIFTL8 [variable] [shifts]
SL8 [variable] [shifts]
SHIFTL16 [variable] [shifts]
SL16 [variable] [shifts]
Shifts the bit in the variable to left or right, and shift 8 or 16 bits.
ShifL8 a 2
SR16 a 3
Read and Write to instrument Commands
OUT [arg1] ... [argN]
Combines all argument into a string where each argument is added after each other with no space between and send it to the connected instrument.
out ":meas:volt:chan @" @a
Read back the response from the connected instrument. If there is no response a time-out error will be throw after the set time out value has passed.
Read back the response from the connected instrument and try to convert to float.. If there is no response a time-out error will be throw after the set time out value has passed.
Read back the response from the connected instrument and try to convert to integer. If there is no response a time-out error will be throw after the set time out value has passed.
Read back the response from the instrument, expecting it to be a binary block
Changes the timeout value to [ms]. If no argument defaults to 10000 ( 10s )
Creates a new CSV file. If the previous is not closed by CLOSECSV it will be erased.
ADDCSV [arg1] [arg2] ... [argn]
Adds all arguments to the csv file comma separated
AddCSV @time @volt
ADDNLCSV [arg1] [arg2] ... [argn]
Adds all arguments to the csv file comma separated followed by new line.
If no arguments then a new line is added.
AddNLCSV @time @volt
Adds the contents of the [variable], removes binary block header if present.
Close the csv file and save it.
SAVECSV [fileName] [csvVariable]
Saves the csvVariable to file fileName.
SaveCSV measurement @logvar
GETCSVVALUE [variable] [position] [csvstring]
#CSV [variable] [position] [csvstring]
Get the value at certain position in a CSV-string
GetCSVValue Yorig 0 @csvvar
SAVEPIC [variable] [filename]
Saves the binary block as picture (format depends on instrument) to [filename]. The binary block header is removed before saving, assuming the rest is picture data.
":DISP:DATA? PNG, COLOR"
Wait 5000 // wait for instrument to finish
SavePic @pic "test.png"
SHOWPIC [variable] [heading]
Open a view and shows the picture stored in [variable] and print [heading] above. The picture shown can be copied to the camera roll or be printed.
":DISP:DATA? PNG, COLOR"
?b @b 100
showpic @b @idn
Closes the show picture view if it's open
Updates the label text in the show picture view to [label], if no argument clears the label
NewPicLabel "A new label"
ALERTOK [header[ [message]
Displays a alert with message and header, and a OK Button. All arguments following message are combined into one message,.
AlertOk "A header" "A little message
ALERTOKCANCEL [variable] [header] [question]
Displays an alert with a question and header, with an OK and a CANCEL button. If ok is pressed "1" is stored in variable, otherwise "0". All arguments following question are combined into one message,.
AlertOkCancel answer "A question" "Is the value correct?"
ALERTASK [variable] [header] [message]
Displays an alert with a field where the user can type a responds. The response is stored in the variable. All arguments following message are combined into one message,.
AlertAsk ans "Your Answer" "Enter a Number"
BANNER [duration = S | A | L] [type = S | E | W ı I] [message]
Displays a banner for a duration and a certain type with message. All arguments following message are combined into one message,.
S = Short 2s
A = Average 4s
L = Long 8s
S = Success green color
E = Error red color
W = Warning yellöow color
I = Info blue color
banner s s "Everthingh went ok"
banner success short "Everthingh went ok""
Vibrates the phone
Get the component from the idn string [idnstring], manufacturer, model, serial and firmware version if they exist. It assumes the idn string has components in the following order "manufacturer,model,serial,fw"
Clears the log.
#BYTES [variable] [binbuff]
Stores the number of bytes into variable that the binbuff consist of,
#Bytes a binfuf
SEND TO INSTRUMENT
Any commands not recognized by the script engine will be sent to the connected instrument.
If you for example have the following row:
The scrip engine will try to parse this and replace variables with their value etc, so the string actual send is:
the space is considered a command separator and is removed (this is by designs as you will se later) and this will not be understood by the instrument. You should instead write it like this:
This is designed like this so you can construct the string that will be send by using variables. Maybe you want calculate what channel will be used in the command. Like this:
set a 1
set b 2
"OUTP ON,(@" @a , @b )
This will create the following string (a and b is substituted with their actual value)
Initiates the statistical array for new sample. Note the statistical array is not cleared between executions.
Adds a value to the statistical array
Calculates the statistical function: Mean value (AVERAGE,AVG or MEAN), Max Value, Min Value, Number of values (STAT#), Median value (MEDIAN or MED) or Standard deviation (STDDEV)
Sort the statistical array from high to low (STATSORT+) or low to high (STARTSORT-)
GETSTAT [variable] [index]
Get the statistical value at index into variable
GetStat a 4
SAVESTAT [filename] [type]
Save the statistical values into a csv-file. type 0 = raw unsorted, 1 = raw sorted, 2 = sorted and frequency.
PLOT AND GRAPH COMMANDS
Plots a graph using the statistical data collected using the statistical commands. It will plot either a Bar graph (PlotStatBar) or Line Graph (PlotStatLine). The label is optional.
PlotStatBar "Temperature Bra Graph"
PLOTCSVBIN [binblock] [label]
Plots the binary block where the data is comma separated ascii values (CSV). The label is optional.
PlotCSVBin @binblock "Sinus"
PLOTBIN [binblock] [label] [Yorigin] [Yincrement] [Yreference] [datasize]
Plots the binary block where the data is either byte or word size. The label optional (See Appendix B)
Yorigin - The original start of the Y-axis
Yincrement - The increment of the Y-axis
Yreference - The reference value used to convert from byte or word to floating value
datasize - 0 = byte, 1 = Word
The values for Yoriginal, Yincrement, Yreference and datasize is values read from the instrument.
Example: For the Keysight Infiniivision oscilloscope the following command sequence gets the required info:
GetCSVvalue yinc 7 @s
GetCSVvalue yori 8 @s
GetCSVvalue yref 9 @s
GetCSVvalue datasize 0 @s
PlotBin @binblock ”Binblock Plot” @yori @yinc @yref @datasize
BYTEORDER [MSBF | LSBF]
Defines the sequence of bytes in binary block where datasize is word:
LSBF - Least Significant Byte First
MSBF - Most Significan Byte first
The default is MSBF and will be reset each time the script is executed, since this is the default.
If no arguments is given, it defaults to MSBF.
XAXIS# [Xorigin] [Xincrement] [Xreference] [Sacelfactor]
Set the values to be used for the X-Axis ( See Appendix B)
Xorigin - The original start of the X-axis
Xincrement - The increment of the X-axis
Xreference - The X-reference value
Scalefactor - The factor to scale the X-axis, ex. 1000000 gives micro-seconds
Xaxis# @xori @xinc @xref 1000000
XSCALE [ON | OFF]
Turns ON or OFF the scaling of the X-axis
BARCOLOR [color | et]
Change to either one color for all bars or set with different color for each bar
Set the color lines will be drawn wither in statistical line graph or binary plot.
PLOTCSV [csvString] [label]
Plots the CSV values in thecsvString
plotcsv @measuredCsv "Measured Data"
Closes the plot/chart view if it's open
Opens the plot/chart view
If the plot/chart view is open, the chart is cleared immediately.
If the plot/chart view is not opened, the chart is cleared when is opened.
Error messages and the error No
0 - Ok
1 - To Few Arguments
2 - Time Out
3 - Variable Not Found
4 - Next without Loop
5 - Division by Zero
6 - No Instrument Connected
7 - Not a Number
8 - Not a Valid Variable
9 - Invalid Argument
10 - File Error
11 - Undefined label
12 - Stat array not initialized
13 - No values to calculate statistics
14 -Invalid binary buffer
Visa Specific Error
101 - Could Not Connect
102 - Not Connected
103 - Could not Read from Instrument
104 - Time Out Occurred
105 - Could not Write to Instrument
106 - No String Received from Instrument
200 - User Generated Error
X- and Y- axis scaling