SCPI Commander - Command Reference


© 2018-2020 Michael Augustsson Contact Me
Command Reference


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.


NOP

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


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

argument
volt
"also one argument"
@volt




Connection Commands

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
connection view.

Example

Open 10.0.1.1 5025
Open 10.1.1.1
Open


OPENF [favorite]

Open connection to the favorite [favorite] saved in the connection view. can be between 1 and last favorite.

Example

Openf 1


CLOSE

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.

Example

Close


BUFFSIZE [size]
BUFFSIZE

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)




Variable Commands

Variables can be named anything (exception see below), UPPER and lowercase is different.

To get the variables content begin variable name with @.

Reserved variables:

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

Example

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]

Example

int a @a


& [variable] [string] [string] ...

Appends the [string] (strings) to the variable contents

Example

set a 56
& a " kilo" "grams"
? a
-> 56 kilograms


SAVEBIN [variable] [filename]

Saves the binary block contained in [variable] to [filename]

Example

SaveBIN @data "values.bin"



Flow Control

SPEED [ms]

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.

Example

Speed 10
Speed


STOP

Stops the execution of the script.

Example

Stop


ONERROR

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.

Example

ONERROR
? "Error occurred"


ERROR

Triggers a user generated error and will jump to the ONERROR routine if it exists, otherwise the script will stop with an error,

Example

Error


PAUSE
*BR


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


WAIT [ms]

Pauses the execution .
If no argument default to 500 ms

Example

Wait 1000


LABEL [labelName]
LBL [labelName]


Defines label in the script where it's possible to jump to.

Example

Label JumpHere


JMP [rows]
JMP [label]
GOTO [rows]
GOTO [label]


Jump/Goto to row . Positive number jumps forward, negative backwards.
Jumo/Goto label. See label.

Example

Jmp 3
Jmp -4
Jmp @a
Jmp label1
Jmp NextNum



Loop Commands

LOOP [end value] [step value]

Initiates a loop that will loop from 0 to using step


NEXT

Execute the next loop iteration

Example

Loop 10 1
? @index
Next



Display Commands

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.

Examples

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.

Example:

?bin 255 8 -> 11111
?bin 7 8 -> 00000111
?bin 255 4 -> 1111


DISPBB [variable] [rows]
DISPBB [variable]
?B [variable] [rows]
?B [variable]


Displays information about a binary block stored in [variable]. On each row 8 bytes is displayed as hex-values and ascii-characters:

Example

DispB @data 20



Compare Commands

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.

Example

set a 10
set b 10
IF= @a @b 3
disp "Not Equal"
jmp 2
disp "Equal"
if< @a @b lessThan


Math Commands

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]

Example

add @a 45
- @a 10
% @a -50


INT [variable] [value]
INT [variable]


Stores the integer value [value] into variable [variable]

Example

int a @a
int b


ROUND [variable] [value]
ROUND [variable]


Round the [value] to 2 significant digits and store into [variable]
Round the value stored in [variable] to 2 significant digits.

Example

round a @a
round b


RND [variable]

Stores a random float number between 0 and 1 into variable.



BIT Commands

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.

Example

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.

Example

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

Example

ANDBIT a 170
XOR a 85


NOTBIN8 [variable]
NOT8 [variable]
NOTBIN16 [variable]
NOT16 [variable]

Inverts all bits (8 or 16) of the variable content.

Example

NOTBIN8 a
NOT16 b


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.

Example

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.

Example

out "*idn?"
out "*rst"
out ":meas:volt:chan @" @a


IN [variable]

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.

Example

in a
disp @a


INF [variable]

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.

Example

inf a
disp @a


INI [variable]

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.

Example

in a
disp @a


INB [variable]

Read back the response from the instrument, expecting it to be a binary block

Example

inb data


TIMEOUT [ms]
TIMEOUT

Changes the timeout value to [ms]. If no argument defaults to 10000 ( 10s )




CSV COMMANDS

NEWCSV [file]

Creates a new CSV file. If the previous is not closed by CLOSECSV it will be erased.

Example

NewCSV voltlog.cvs


ADDCSV [arg1] [arg2] ... [argn]

Adds all arguments to the csv file comma separated

Example

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.

Example

AddNLCSV @time @volt



ADDVARCSV [variable]

Adds the contents of the [variable], removes binary block header if present.

Example:

speed 10
open 10.2.1.61
”:wav:form ascii”
”:wav:poin 10”
:wav:data?
in b
newcsv data.csv
Addvarcsv @b



CLOSECSV

Close the csv file and save it.

Example

CloseCSV


SAVECSV [fileName] [csvVariable]

Saves the csvVariable to file fileName.

Example

SaveCSV measurement @logvar


GETCSVVALUE [variable] [position] [csvstring]
#CSV [variable] [position] [csvstring]


Get the value at certain position in a CSV-string

Example

GetCSVValue Yorig 0 @csvvar



PICTURE COMMANDS

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.

Example

Open 10.2.1.61
":DISP:DATA? PNG, COLOR"
Wait 5000 // wait for instrument to finish
Inb pic
SavePic @pic "test.png"



SHOWPIC [variable] [heading]
SHOWPIC [variable]


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.

Example:

speed 10
open 10.2.1.61
*idn?
in idn
":HARD:INK OFF"
":DISP:DATA? PNG, COLOR"
wait 3000
inb b
?b @b 100
showpic @b @idn


CLOSEPIC

Closes the show picture view if it's open

Example:

ClosePic


NEWPICLABEL [label]
NEWPICLABEL


Updates the label text in the show picture view to [label], if no argument clears the label

Example

NewPicLabel "A new label"




ALERT COMMANDS

ALERTOK [header[ [message]


Displays a alert with message and header, and a OK Button. All arguments following message are combined into one message,.

Example

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,.

Example

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,.

Example

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,.

Duration:

S = Short 2s
A = Average 4s
L = Long 8s

Type:

S = Success green color
E = Error red color
W = Warning yellöow color
I = Info blue color


Examples

banner s s "Everthingh went ok"
banner success short "Everthingh went ok""



MISC COMMANDS

BEEP
VBR


Vibrates the phone


MANUF [idnstring]
MODEL [idnstring]
SERIAL [idnstring]
FW [idnstring]


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"


CLEAR

Clears the log.


#BYTES [variable] [binbuff]

Stores the number of bytes into variable that the binbuff consist of,

Example

#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:

OUTP ON,(@1,2)

The scrip engine will try to parse this and replace variables with their value etc, so the string actual send is:

OUTPON,(@1,2)

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:

"OUTP ON,(@1,2)"


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)

OUTP ON,(@1,2)



STATISTICAL COMMANDS

STATINIT


Initiates the statistical array for new sample. Note the statistical array is not cleared between executions.

Example

StatInit


STATADD [value]
STAT+ [value]


Adds a value to the statistical array

Example

StatAdd @a
Stat+ 5.7


AVERAGE [variable]
AVG [variable]
MEAN [variable]
MAX [variable]
MIN [variable]
STAT# [variable]
MEDIAN [variable]
MED [variable]
STDDEV [variable]


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)

Example

Mean a
Stddev b


STATSORT+
STATSORT-


Sort the statistical array from high to low (STATSORT+) or low to high (STARTSORT-)

Example

StartSort+
StatSort-


GETSTAT [variable] [index]

Get the statistical value at index into variable

Example

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.

Example

Savestat mystat.csv



PLOT AND GRAPH COMMANDS

PLOTSTATBAR [label]
PLOTSTATLINE [label]


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.

Example

PlotStatBar "Temperature Bra Graph"
PlotStatLine


PLOTCSVBIN [binblock] [label]

Plots the binary block where the data is comma separated ascii values (CSV). The label is optional.

Example

PlotCSVBin @binblock "Sinus"
PlotCSVBin @binblock


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:

”:wav:pre?”
in s

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.

Example

ByteOrder LSBF'


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

Example

Xaxis# @xori @xinc @xref 1000000


XSCALE [ON | OFF]

Turns ON or OFF the scaling of the X-axis

Example

XScale Off


BARCOLOR [color | et]

Change to either one color for all bars or set with different color for each bar

One color:

Darkgreen
Green
Darkred
Red
Darkblue
Blue

Sets:

Set1
Set2
Set3
Set4
Set5

Example:

BarColor Blue
BarColor Set4


LINECOLOR [color]

Set the color lines will be drawn wither in statistical line graph or binary plot.

Darkgreen
Green
Darkred
Red
Darkblue
Blue

Example:

LineColor blue


PLOTCSV [csvString] [label]

Plots the CSV values in thecsvString

Example:

plotcsv @measuredCsv
plotcsv @measuredCsv "Measured Data"


CLOSEPLOT
CLOSECHART


Closes the plot/chart view if it's open

Example

CloseChart


OPENPLOT
OPENCHART


Opens the plot/chart view

Example

OpenChart


CLEARPLOT
CLEARCHART


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.

Example

ClearChart



----------------------------------



APPENDIX A

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

Error Command

200 - User Generated Error



APPENDIX B

X- and Y- axis scaling
Stacks Image 264

improve your online experience. Take a look at the Cookie Privacy to learn more and also my Privacy Policy. By pressing Dismiss I assume you are happy to allow the use of these cookies.

RapidWeaver Icon

Made in RapidWeaver