Console commands
Console is a text command based interface that can directly interact with Spectrometer and Devices.
Script is a sequence of Console commands that performs some task.
Scripts can be used to enhance GUI, program GUI elements and plugins and alter program environment at run-time.
Commands can be issued from the Log Window and Status Bar tabs.
Console is under development and not all functions are available and can be used. Here are some ideas which may work.
Syntax:
expression - show result of the expression expression; - do not show expression result
Comments:
Introduced in version 3.8.7
Console uses the same comment syntax as PPL — see Comments.
%% the rest of the line is ignored a = 35; %% trailing comment a = %this is ignored% 35;
Inline comments %...% may only contain letters, digits, spaces and underscores. Because % is also the modulo operator, avoid writing two modulo operations in one line without brackets (a % b % c) — write (a % b) % c instead.
Supported functions:
- clear(var) - clear() clears all variables; clear('var') clears variable 'var'
- help(function) - help on functions
- iff(condition,expression) - conditional assignment, iff evaluate string _expression if _contion is true
- sleep(delay_ms) - delay in ms
- whos(var) - list variable(s) type and value, var - name of variable or nothing
Math functions:
- abs(x) sqrt(x) sin(x) cos(x) exp(x) ln(x) log(x) - single-argument math; ln is the natural and log the base-10 logarithm
- round(x,step) floor(x,step) ceil(x,step) trunc(x,step) - round x to the nearest / lower / upper / toward-zero multiple of step (default 1), e.g. round(f, 1e6) snaps to the MHz
- val2str(x,unit) - format x as a string with an SI prefix and the unit, e.g. val2str(720e6,'Hz') gives 720 MHz
Power calibration functions:
Introduced in version 3.8.11
The pcal_* functions used in Compound Property rules are available in the console as well, evaluated against the spectrometer's [PowerCalibrations] table; i is the 0-based position of the calibration in that table. This lets you check a compound rule, or script an amplitude from a target power, without defining a compound property.- pcal_AWG(i,amp) - AWG amplitude in [0, 1] to amplifier output power in dBm
- pcal_dBm(i,drive) - AWG drive power in dBm to amplifier output power in dBm
- pcal_inv_AWG(i,power) - amplifier output power in dBm to the AWG amplitude that produces it (not clamped; above 1 means unreachable)
- pcal_inv_dBm(i,power) - amplifier output power in dBm to the required AWG drive power in dBm
- pcal_maxamp(i) - highest AWG amplitude inside the calibrated range
- pcal_maxamp_bw(i,bw) - the same, also keeping a pulse of bandwidth bw (Hz) linear across the calibration's frequency model
- pcal_B1(i,amp), pcal_inv_B1(i,b1), pcal_maxB1(i) - AWG amplitude to nutation frequency ω/2π in Hz and back, and the highest calibrated B1; need the calibration's B1 reference
amp = pcal_inv_AWG(0, 5); %% AWG amplitude for 5 dBm out of calibration 0 pcal_AWG(0, amp) %% back to 5
A missing calibration or an out-of-range index is reported in the console output and the expression evaluates to an error. See Power and Frequency Calibration for the calibration model.
Simple math:
a = 35; b = 45; c = 'hello'; d = ' world!'; a+b c+d
Devices:
.spec.dev.list %% list of devices
Properties:
.spec.System.prop.list %% list properties .spec.System.prop.Wait = 10 %% set property (wait 10 sec) s = .spec.AP.Sampling; %% get property
Interfaces:
.spec.intf.list %% list of interfaces .spec.intf.TCPIP.list %% list of sessions .spec.intf.NIVISA.session0.help %% help on commands .spec.intf.delete='NIVISA' %% delete interface (if not used) .spec.intf.NIVISA.session0.query='*IDN?' %% send GPIB command and read
Pulse configuration:
.spec.puls.softsync=1; %% software synchronization options .spec.puls.rtpos=0; %% repetition time position (0 - no repetition time) .puls.comm.mwpulse.phase.ch1.use=0; %% -- experimental syntax -- .puls.awg.shape.MATLAB='px=1:100; p=[sin(px/100),cos(px/100)];'
Pulse shape of an analog (AWG) pattern:
Introduced in version 3.8.7
The waveform, its expression and its pattern file are the fields the pulse configuration dialog edits on its Shape tab. They are addressed as .puls.<command>.<pattern>.<property> and a console change is applied exactly like a change made in the dialog.
.puls.awg.shape.help %% commands of the pattern .puls.awg.shape.shapes %% names accepted by .shape .puls.awg.shape.shape %% current waveform, e.g. 'psSechTanh' .puls.awg.shape.shape='psSechTanh' %% set the waveform by name .puls.awg.shape.shape='SechTanh' %% the bare name works as well .puls.awg.shape.expression='amp*exp(-t^2/par1^2)' %% psEXPRESS waveform .puls.awg.shape.source='mypattern.dat' %% pattern file of psPattern...
Here awg is the pulse command and shape is the pattern inside it. The waveform can also be set by its index (.shape=11), the name is the recommended form. Digital and bitwise patterns have no waveform — setting one reports an error.
Post acquisition processing:
Introduced in version 3.8.7
The stages of the Post Acquisition Processing dialog are addressed as .e.ppars.<stage>.<parameter>, one node per stage, and each stage node has its own .use switch. A console change is applied exactly like a change made in the dialog.
.e.ppars.list %% list of processing stages .e.ppars.json %% the whole chain as JSON, in one reply .e.ppars.mixer.list %% commands of one stage .e.ppars.mixer.use=1 %% switch digital down-conversion on .e.ppars.mixer.freq=50e6; %% demodulation frequency, Hz .e.ppars.mixer.bw=10e6; %% bandwidth after mixing, Hz .e.ppars.baseline.use=1 %% switch baseline correction on .e.ppars.baseline.alg='first' %% first order baseline .e.ppars.baseline.fp1=0; %% region 1: first point ... .e.ppars.baseline.w1=50; %% ... and width, in points .e.ppars.int.use=1 %% switch boxcar integration on .e.ppars.int.fp=120; %% integration window, in points .e.ppars.int.w=200; .e.ppars.phase=30 %% zero order phase, deg
Each numeric parameter is a property subtree, so .e.ppars.mixer.freq and .e.ppars.mixer.freq.value are the same thing, and .minvalue / .maxvalue / .increment are available too. The phase stage has a single parameter, so .e.ppars.phase is that value and .e.ppars.phase.use is its switch. A stage only runs when its switch is on: setting .e.ppars.notch.freq without .e.ppars.notch.use=1 changes nothing.

