\documentclass[a4paper,11pt]{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} % LY1 also works \usepackage[margin=1in]{geometry} %% Font settings suggested by fbb documentation. \usepackage{textcomp} % to get the right copyright, etc. \usepackage[lining,tabular]{fbb} % so math uses tabular lining figures \usepackage[scaled=.95,type1]{cabin} % sans serif in style of Gill Sans \usepackage[varqu,varl]{zi4}% inconsolata typewriter \useosf % change normal text to use proportional oldstyle figures %\usetosf would provide tabular oldstyle figures in text \usepackage{microtype} \usepackage{siunitx} \DeclareSIUnit{\belmilliwatt}{Bm} \DeclareSIUnit{\dBm}{\deci\belmilliwatt} \sisetup{range-phrase=--, range-units=single, binary-units = true} \usepackage{graphicx} \usepackage{tikz} \usepackage{svg} %\usepackage{hyperref} \usetikzlibrary{arrows, shadows} \tikzset{% cascaded/.style = {% general shadow = {% shadow scale = 1, shadow xshift = -1ex, shadow yshift = 1ex, draw, thick, fill = white}, general shadow = {% shadow scale = 1, shadow xshift = -.5ex, shadow yshift = .5ex, draw, thick, fill = white}, fill = white, draw, thick, minimum width = 1.5cm, minimum height = 2cm}} \usepackage{enumitem} \usepackage{longtable} \setitemize{noitemsep,topsep=0pt,parsep=0pt,partopsep=0pt} \setlist{leftmargin=*} \usepackage{listings} \definecolor{darkgreen}{RGB}{0,140,0} \lstset{ basicstyle=\ttfamily, frame=single, breaklines=true, morecomment=[l][\color{darkgreen}]{\#}, } \lstnewenvironment{example}{\lstset{ ,frame=single ,xleftmargin=2em ,xrightmargin=2em % ,backgroundcolor=\color{lightgray} ,title=Example }}{} \usepackage[os=win]{menukeys} \renewmenumacro{\keys}[+]{shadowedroundedkeys} \usepackage{booktabs,caption} \usepackage[flushleft]{threeparttable} \newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}} \newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}} \newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}} \usepackage{tabularx} \usepackage{stackengine} \usepackage{scalerel} \usepackage{xcolor,mdframed} \newcommand\danger[1][5ex]{% \renewcommand\stacktype{L}% \scaleto{\stackon[1.3pt]{\color{red}$\triangle$}{\tiny !}}{#1}% } \newenvironment{important}[1][]{% \begin{mdframed}[% backgroundcolor={red!15}, hidealllines=true, skipabove=0.7\baselineskip, skipbelow=0.7\baselineskip, splitbottomskip=2pt, splittopskip=4pt, #1]% \makebox[0pt]{% ignore the withd of ! \smash{% ignor the height of ! %\fontsize{32pt}{32pt}\selectfont% make the ! bigger \hspace*{-45pt}% move ! to the left \raisebox{-5pt}{% move ! up a little {\danger}% type the bold red ! }% }% }% }{\end{mdframed}} \newcommand\info[1][5ex]{% \renewcommand\stacktype{L}% \scaleto{\stackon[1.2pt]{\color{blue}$\bigcirc$}{\raisebox{-1.5pt}{\small i}}}{#1}% } \newenvironment{information}[1][]{% \begin{mdframed}[% backgroundcolor={blue!15}, hidealllines=true, skipabove=0.7\baselineskip, skipbelow=0.7\baselineskip, splitbottomskip=2pt, splittopskip=4pt, #1]% \makebox[0pt]{% ignore the withd of ! \smash{% ignor the height of ! %\fontsize{32pt}{32pt}\selectfont% make the ! bigger \hspace*{-45pt}% move ! to the left \raisebox{-5pt}{% move ! up a little {\info}% type the bold red ! }% }% }% }{\end{mdframed}} \usepackage{makecell} \usepackage{hyperref} \usepackage{xifthen} \newcommand{\vna}{LibreVNA} \newcommand{\gui}{\vna{}-GUI} \newcommand{\subsubsubsection}[1]{\paragraph{#1}\mbox{}\\\\} \newcommand{\screenshot}[2]{\begin{center} \includegraphics[width=#1\textwidth]{Screenshots/#2} \end{center}} \newcommand{\event}[3]{ \noindent\textbf{Event:} \begin{longtable}{p{.15\textwidth} | p{.80\textwidth} } \hline \textbf{Effect:} & #1 \\ \hline \textbf{Syntax:} & #2 \\ \hline \textbf{Parameters:} & \makecell[Xl]{#3} \\ \hline \end{longtable} } \newcommand{\query}[4]{ \noindent\textbf{Query:} \begin{longtable}{p{.15\textwidth} | p{.80\textwidth} } \hline \textbf{Effect:} & #1 \\ \hline \textbf{Syntax:} & #2 \\ \hline \textbf{Parameters:} & \makecell[tl]{#3} \\ \hline \textbf{Return value:} & \makecell[tl]{#4} \\ \hline \end{longtable} } \title{\vna{} SCPI Programming Guide} \begin{document} \maketitle \setcounter{tocdepth}{4} \setcounter{secnumdepth}{4} \tableofcontents \clearpage \section{Introduction} The \gui{} contains a TCP server that can be used to control the \vna{} with SCPI commands. \section{SCPI Server Configuration} The server is configurable in the preferences: \menu[,]{Window,Preferences,General} \screenshot{0.3}{serverconfig.png} If enabled, it will accept any TCP connection at the configured port. Once the connection is established, it can be used to send SCPI commands and receive replies. Only one connection at a time is possible, if a second connection is created, the first one will be closed by the \gui{}. Alternatively, a port can be manually configured by setting the ``port'' argument: \begin{lstlisting} ./LibreVNA-GUI --port 1234 \end{lstlisting} This enables the SCPI server at the specified port, regardless of what is configured in the preferences (useful for starting multiple instances at different ports at the same time). If no graphical user interface is required, the \gui{} can be hidden: \begin{lstlisting} ./LibreVNA-GUI --port 1234 --no-gui \end{lstlisting} \section{General Syntax} The syntax follows the usual SCPI rules: \begin{itemize} \item All commands are case insensitive (implicitly converted to uppercase before evaluated) \item The command tree is organized in branches, separated by a colon: \begin{lstlisting} VNA:TRACE:LIST? \end{lstlisting} \item Multiple commands can be concatenated in one line using a semicolon: \begin{lstlisting} DEVice:CONNECT;:DEVice:INFo:FWRevision? \end{lstlisting} \item If a subsequent command starts with a colon it is evaluated from the root branch, otherwise the last used branch is assumed: \begin{lstlisting} VNA:FREQuency:START 1000000;STOP 2000000 #No colon, VNA:FREQuency branch was used before \end{lstlisting} \item Branches and commands can be abbreviated by using only the uppercase part of their name, the following commands are identical: \begin{lstlisting} DEVice:INFo:LIMits:MINFrequency? DEV:INF:LIM:MINF? \end{lstlisting} \item Every query generates a response, terminated with a newline character (exceptions exist for a few queries which return more than one line) \item Some commands require additional arguments that have to be passed after the command (separated by spaces): \begin{lstlisting} DEV:REF:OUT 10 \end{lstlisting} \item Two types of commands are available: \begin{itemize} \item \textbf{Events} change a setting or trigger an action. They have no response \item \textbf{Queries} request information. They end with a question mark. \end{itemize} Some commands are both events and queries, depending on whether the question mark is present: \begin{lstlisting} VNA:FREQ:SPAN 50000000 # Set the span VNA:FREQ:SPAN? # Read the current span \end{lstlisting} \end{itemize} \section{Commands} \subsection{General Commands} \subsubsection{*IDN} \query{Returns the identifications string}{*IDN?}{None}{LibreVNA,LibreVNA-GUI,,} \begin{itemize} \item The serial number is the serial number from the connected LibreVNA. If none is connected, it will be set to ``Not connected'' \item The software version is the version of the \gui{}, not the firmware version of the connected \vna{} \end{itemize} \subsubsection{*RST} \event{Resets the GUI (and any connected device) to the default state}{*RST}{None} \subsubsection{*CLS} \event{Clears the event status register}{*CLI}{None} \subsubsection{*ESE} \event{Configures the event status enable register}{*ESE}{} \query{Returns the event status enable register}{*ESE?}{None}{} \subsubsection{*ESR} \query{Returns the event status register}{*ESR?}{None}{} The bits are used according to IEEE 488: \begin{longtable}{p{.1\textwidth} | p{.1\textwidth} | p{.4\textwidth} } \textbf{Bitvalue} & \textbf{Name} & \textbf{Meaning}\\ \hline 1 & OPC & Operation complete\\ 2 & RQC & Request control (not used)\\ 4 & QYE & Query error (not used)\\ 8 & DDE & Device dependent error (not used)\\ 16 & EXE & Execution error (not used)\\ 32 & CME & Command error\\ 64 & URQ & User request (not used)\\ 128 & PON & Power on (not used)\\ \end{longtable} \subsubsection{*OPC} \event{Sets the OPC bit in the event status register after all operations are complete}{*OPC}{None} \query{Returns a 1 after every active operation has completed}{*OPC?}{None}{1} \subsubsection{*WAI} \event{Blocks further command parsing until all active operations are complete}{*WAI}{None} \subsubsection{*LST} \query{Lists all available commands}{*LST?}{None}{List of commands, separated by newline} \subsection{Device Commands} This section contains general device commands, available regardless of the current mode. \subsubsection{DEVice:DISConnect} \event{Disconnects from the device}{DEVice:DISConnect}{None} \subsubsection{DEVice:CONNect} \event{Connects to a device. If no serialnumber is specified, the connection is made with the first device found}{DEVice:CONNect []}{ Serialnumber of the device that should be connected} \begin{example} :DEV:CONN 206039903350 \end{example} \query{Queries the serial number of the connected device}{DEVice:CONNect?}{None}{ or ``Not connected''} \begin{example} :DEV:CONN? 206039903350 \end{example} \subsubsection{DEVice:LIST} \query{Lists all available devices by their serial numbers}{DEVice:LIST?}{None}{List of serialnumbers} \begin{example} :DEV:LIST? 206039903350,208939A23350 \end{example} \subsubsection{DEVice:PREFerences} This command provides read/write access to the preferences. The recommended way is usually to change the preferences manually in the GUI. But if for some reason that is not an option, this is also possible through the SCPI server. There is no complete documentation for all available preferences, refer to the source code. \event{Set a preferences entry}{DEVice:PREFerences }{ Name of the preferences entry\\ New value for the preferences entry} \begin{example} :DEV:PREF Startup.ConnectToFirstDevice false \end{example} Most settings take effect immediately but some (such as changing the port for the SCPI server) are only applied when the preferences are saved. Also see command~\ref{DEV:APPLYPREF}. \query{Returns a preferences entry}{DEVice:PREFerences? }{ Name of the preferences entry}{Current value of the preferences entry} \subsubsection{DEVice:APPLYPREFerences} \label{DEV:APPLYPREF} \event{Permanently stores the preferences after a setting has been changed}{DEVice:APPLYPREFerences}{None} \subsubsection{DEVice:MODE} \event{Switches the device to the specified mode}{DEVice:MODE }{:\\ \hspace{1cm} VNA: set to vector analyzer\\ \hspace{1cm} GEN: set to signal generator\\ \hspace{1cm} SA: set to spectrum analyzer} \begin{example} :DEV:MODE VNA \end{example} \query{Queries the currently active mode}{DEVice:MODE?}{None}{:\\ \hspace{1cm} VNA: set to vector analyzer\\ \hspace{1cm} GEN: set to signal generator\\ \hspace{1cm} SA: set to spectrum analyzer} \begin{example} :DEV:MODE? VNA \end{example} \subsubsection{DEVice:SETUP:SAVE} \event{Saves the GUI setup to a file}{DEVice:SETUP:SAVE}{} Important points when saving/loading setup files through SCPI commands: \begin{itemize} \item Filenames must be either absolute or relative to the location of the GUI application. \item If the LibreVNA-GUI (and thus also the SCPI server) is running on a different machine than the SCPI client, the setup files will be saved/loaded from the machine that runs the GUI. \item If no (or a wrong) file ending is specified, ``.setup'' is automatically added to the filename. \end{itemize} \subsubsection{DEVice:SETUP:LOAD} \query{Loads a setup file}{DEVice:SETUP:LOAD?}{}{TRUE or FALSE} \begin{itemize} \item Filenames must be either absolute or relative to the location of the GUI application. \item The filename must include the file ending ``.setup''. \end{itemize} \subsubsection{DEVice:REFerence:OUT} \event{Sets the reference output frequency}{DEVice:REFerence:OUT }{ in MHz, either 0 (disabled), 10 or 100} \query{Queries the reference output frequency}{DEVice:REFerence:OUT?}{None}{Output frequency in MHz} \subsubsection{DEVice:REFerence:IN} \event{Set the reference input mode}{DEVice:REFerence:IN }{:\\ \hspace{1cm} INT: use internal reference\\ \hspace{1cm} EXT: use external reference\\ \hspace{1cm} AUTO: automatic reference switching} \query{Queries the reference source}{DEVice:REFerence:IN?}{None}{INT or EXT} \subsubsection{DEVice:STAtus:UNLOcked} \query{Queries the PLL lock error flag}{DEVice:STAtus:UNLOcked?}{None}{TRUE or FALSE} \subsubsection{DEVice:STAtus:ADCOVERload} \query{Queries the ADC overload error flag}{DEVice:STAtus:ADCOVERload?}{None}{TRUE or FALSE} \subsubsection{DEVice:STAtus:UNLEVel} \query{Queries the output level error flag}{DEVice:STAtus:UNLEVel?}{None}{TRUE or FALSE} \subsubsection{DEVice:INFo:FWREVision} \query{Returns the firmware revision of the connected device}{DEVice:INFo:FWREVision?}{None}{..} \begin{example} :DEV:INF:FWREV? 1.0.0 \end{example} \subsubsection{DEVice:INFo:HWREVision} \query{Returns the hardware revision of the connected device}{DEVice:INFo:HWREVision?}{None}{, single char} \begin{example} :DEV:INF:HWREV? B \end{example} \subsubsection{DEVice:INFo:LIMits:MINFrequency} \query{Queries the lowest frequency the device can measure}{DEVice:INFo:LIMits:MINFrequency?}{None}{lowest frequency in Hz} \subsubsection{DEVice:INFo:LIMits:MAXFrequency} \query{Queries the highest frequency the device can measure}{DEVice:INFo:LIMits:MAXFrequency?}{None}{highest frequency in Hz} \subsubsection{DEVice:INFo:LIMits:MINIFBW} \query{Queries the lowest IF bandwidth setting}{DEVice:INFo:LIMits:MINIFBW?}{None}{lowest possible IF bandwidth in Hz} \subsubsection{DEVice:INFo:LIMits:MAXIFBW} \query{Queries the highest IF bandwidth setting}{DEVice:INFo:LIMits:MAXIFBW?}{None}{highest possible IF bandwidth in Hz} \subsubsection{DEVice:INFo:LIMits:MAXPoints} \query{Queries the maximum number of points per sweep}{DEVice:INFo:LIMits:MAXPoints?}{None}{maximum number of points} \subsubsection{DEVice:INFo:LIMits:MINPOWer} \query{Queries the minimum output power}{DEVice:INFo:LIMits:MINPOWer?}{None}{minimum output power in dBm} \subsubsection{DEVice:INFo:LIMits:MAXPOWer} \query{Queries the maximum output power}{DEVice:INFo:LIMits:MAXPOWer?}{None}{maximum output power in dBm} \subsubsection{DEVice:INFo:LIMits:MINRBW} \query{Queries the lowest resolution bandwidth setting}{DEVice:INFo:LIMits:MINRBW?}{None}{lowest possible resolution bandwidth in Hz} \subsubsection{DEVice:INFo:LIMits:MAXRBW} \query{Queries the highest resolution bandwidth setting}{DEVice:INFo:LIMits:MAXRBW?}{None}{highest possible resolution bandwidth in Hz} \subsubsection{DEVice:INFo:LIMits:MAXHARMonicfrequency} \query{Queries the (theoretical) maximum frequency when using harmonic mixing in VNA mode}{DEVice:INFo:LIMits:MAXHARMonicfrequency?}{None}{maximum frequency in Hz} \subsection{VNA Commands} These commands change or query VNA settings. Although most of them are available regardless of the current device mode, they usually only have an effect once the VNA mode is active (e.g. it is possible to change the span while in signal generator mode but it does not effect the \vna{} until the mode is switched to VNA). Certain commands (like taking a calibration measurement) are only available in VNA mode and will return an error if another mode is active. \subsubsection{VNA:SWEEP} \event{Sets the type of the sweep}{VNA:SWEEP}{, either FREQUENCY or POWER} \query{Queries the currently selected type}{VNA:SWEEP?}{None}{, either FREQUENCY or POWER} \subsubsection{VNA:FREQuency:SPAN} \event{Sets the span of the sweep}{VNA:FREQuency:SPAN}{, in Hz} \query{Queries the currently selected span}{VNA:FREQuency:SPAN?}{None}{span in Hz} \subsubsection{VNA:FREQuency:START} \event{Sets the start frequency of the sweep}{VNA:FREQuency:START}{, in Hz} \query{Queries the currently selected start frequency}{VNA:FREQuency:START?}{None}{start frequency in Hz} \subsubsection{VNA:FREQuency:CENTer} \event{Sets the center frequency of the sweep}{VNA:FREQuency:CENTer}{
, in Hz} \query{Queries the currently selected center frequency}{VNA:FREQuency:CENTer?}{None}{center frequency in Hz} \subsubsection{VNA:FREQuency:STOP} \event{Sets the stop frequency of the sweep}{VNA:FREQuency:STOP}{, in Hz} \query{Queries the currently selected stop frequency}{VNA:FREQuency:STOP?}{None}{stop frequency in Hz} \subsubsection{VNA:FREQuency:FULL} \event{Sets the device to the maximum span possible}{VNA:FREQuency:FULL}{None} \subsubsection{VNA:FREQuency:ZERO} \event{Sets the device to zero span mode}{VNA:FREQuency:ZERO}{None} \subsubsection{VNA:POWer:START} \event{Sets the start power of the power sweep}{VNA:POWer:START}{, in dBm} \query{Queries the currently selected start power}{VNA:POWer:START?}{None}{start power in dBm} \subsubsection{VNA:POWer:STOP} \event{Sets the stop power of the power sweep}{VNA:POWer:STOP}{, in dBm} \query{Queries the currently selected stop power}{VNA:POWer:STOP?}{None}{stop power in dBm} \subsubsection{VNA:SWEEPTYPE} \event{Selects between linear and logarithmic sweeps}{VNA:SWEEPTYPE}{, either ``LIN'' or ``LOG''} \query{Queries the currently selected sweep type}{VNA:SWEEPTYPE?}{None}{``LIN'' or ``LOG''} \subsubsection{VNA:ACQuisition:RUN} \event{Puts the VNA into run mode (sweep active)}{VNA:ACQuisition:RUN}{None} \query{Queries whether the VNA is in run mode}{VNA:ACQuisition:RUN?}{None}{TRUE or FALSE} \subsubsection{VNA:ACQuisition:STOP} \event{Puts the VNA into stop mode (sweep inactive)}{VNA:ACQuisition:STOP}{None} \subsubsection{VNA:ACQuisition:IFBW} \event{Sets the IF bandwidth}{VNA:ACQuisition:IFBW}{, in Hz} \query{Queries the currently selected IF bandwidth}{VNA:ACQuisition:IFBW?}{None}{IF bandwidth in Hz} \subsubsection{VNA:ACQuisition:POINTS} \event{Sets the number of points per sweep}{VNA:ACQuisition:POINTS}{} \query{Queries the currently selected number of points}{VNA:ACQuisition:POINTS?}{None}{points} \subsubsection{VNA:ACQuisition:AVG} \event{Sets the number of sweeps over which a moving average is calculated}{VNA:ACQuisition:AVG}{} \query{Queries the currently configured number of sweeps}{VNA:ACQuisition:AVG?}{None}{} \subsubsection{VNA:ACQuisition:AVGLEVel} \query{Queries the number of sweeps that have been acquired by the average function.}{VNA:ACQuisition:AVGLEVel?}{None}{} resets to zero whenever a setting is changed. It is incremented at the end of each sweep, but will not go above the number of configured sweeps for the averaging. Example (assuming = 3): \begin{longtable}{p{.2\textwidth} | p{.2\textwidth} } \textbf{\# of active sweep} & \textbf{}\\ \hline 1 & 0\\ 2 & 1\\ 3 & 2\\ 4 & 3\\ 5 & 3\\ \end{longtable} \subsubsection{VNA:ACQuisition:FINished} \query{Queries whether the average filter has reached a steady state (that is = )}{VNA:ACQuisition:FINished?}{None}{TRUE or FALSE} \subsubsection{VNA:ACQuisition:LIMit} \query{Queries the status of limits that maybe set up on any graph}{VNA:ACQuisition:LIMit?}{None}{PASS or FAIL} \subsubsection{VNA:ACQuisition:SINGLE} \event{Configures the VNA for single or continuous sweep}{VNA:ACQuisition:SINGLE}{TRUE or FALSE} \query{Queries whether the VNA is set up for single sweep}{VNA:ACQuisition:SINGLE?}{None}{TRUE or FALSE} If single sweep is enabled, the acquisition is stopped when the required number of averages have been reached. There are two ways to trigger a new sweep: \begin{itemize} \item Change any sweep setting (e.g. center frequency) \item Issue the command again (i.e. VNA:ACQ:SINGLE TRUE always triggers a new sweep) \end{itemize} \subsubsection{VNA:ACQuisition:FREQuency} \query{Returns the current frequency of the sweep}{VNA:ACQuisition:FREQuency?}{None}{} This command only returns valid data when a sweep is running and the the sweep is a frequency sweep. \subsubsection{VNA:ACQuisition:POWer} \query{Returns the current power of the sweep}{VNA:ACQuisition:POWer?}{None}{} This command only returns valid data when a sweep is running and the the sweep is a power sweep. \subsubsection{VNA:ACQuisition:TIME} \query{Returns the current time of the sweep}{VNA:ACQuisition:TIME?}{None}{