3.2.10. SCPI

This is a new SCPI server based on API1.

TODO: - link to the standard,

3.2.10.1. Install dependencies

For running SCPI client examples written in Python the next dependencies have to be installed:

sudo apt install python3-pip
pip3 install --upgrade pip
sudo pip3 install pyvisa
sudo pip3 install pyvisa-py

Since PyVISA-py is not fully featured and buggy, you might prefer using NI-VISA. Only RPM based distributions are supported, for those follow the installation instructions.

For Debian/Ubuntu based distributions try the next instructions:

  1. Download the NI-VISA ISO file and mount it.
sudo apt-get install rpm
sudo ./INSTALL --accept-license --no-install-labview-support --nodeps
sudo updateNIDrivers
sudo visaconf

http://forums.ni.com/t5/Linux-Users/Using-NI-VISA-with-Arch-Linux-or-Ubuntu-14-04/gpm-p/3462361#M2287

3.2.10.2. Running the server

The SCPI server can be started as a systemd service.

systemctl start scpi

To start the server at boot, the service should be enabled.

systemctl enable scpi

3.2.10.3. Implementation

3.2.10.4. Building

For developers who wish to modify the SCPI server and/or the underlying API, the best option is to compile directly on the Red Pitaya board. After cloning the Git repository and changing into the directory do:

meson builddir --prefix /opt/redpitaya --buildtype release
cd builddir
ninja

The server can be installed using the nect commands:

rw
ninja install

Prerequisite for running mercury based scpi server is to apply mercury dtbo.

sh /opt/redpitaya/sbin/overlay.sh mercury

And run as a systemd service:

systemctl restart scpi.service

Alternatively the server can be run directly from the build directory:

/opt/redpitaya/sbin/overlay.sh mercury
LD_LIBRARY_PATH=api1:subprojects/scpi-parser-redpitaya-2017/libscpi/ scpi/scpi

3.2.10.5. SCPI commands

The next subsystems are available:

Oscilloscope:

Generator: :SOURCE[<n>] :OUTPUT[<n>]

The value of n selects one of the N oscilloscope channels. The indexing starts at 1 and ends at N. The available options for n are 1 or 2.

{.pattern = “SOURce#:RESET”, .callback = rpscpi_gen_reset,},
{.pattern = “SOURce#:START”, .callback = rpscpi_gen_start,},
{.pattern = “SOURce#:STOP”, .callback = rpscpi_gen_stop,},
{.pattern = “SOURce#:TRIGger”, .callback = rpscpi_gen_trigger,},

3.2.10.5.1. :OUTPut[<n>][:STATe]

3.2.10.5.1.1. Syntax:

:OUTPut[<n>][:STATe] ON|OFF|0|1 :OUTPut[<n>][:STATe]?

3.2.10.5.1.2. Description

Enable/disable the generator output where n is the index (1,2). Query returns generator output enable status as a number.

3.2.10.5.1.3. Parameters

Name Type Range Default
  bool ON|OFF OFF

3.2.10.5.2. :SOURce[<n>]:MODE

3.2.10.5.2.1. Syntax:

:SOURce[<n>]:MODE PERiodic|BURSt :SOURce[<n>]:MODE?

3.2.10.5.2.2. Description

Select either periodic or burst mode for generator. Query returns generator mode in the same format as the parameters.

3.2.10.5.2.3. Parameters

Name Type Range Default
  mnemonic PERiodic|BURSt PERiodic

3.2.10.5.3. [:SOURce[<n>]]:FREQuency[:FIXed]

3.2.10.5.3.1. Syntax:

[:SOURce[<n>]]:FREQuency[:FIXed] <frequency> [:SOURce[<n>]]:FREQuency[:FIXed]?

3.2.10.5.3.2. Description

Specify signal frequency when generator is in periodic mode. Query might return a slightly different value, since internaly all values are rounded.

3.2.10.5.3.3. Parameters

Name Type Range Default Default unit
<frequency> positive real number up to 62.5MHz 1 kHz Hz

If no unit is provided the default is Hz, but units like kHz and MHz can also be used.

3.2.10.5.4. [:SOURce[<n>]]:PHASe[:ADJust]

3.2.10.5.4.1. Syntax:

[:SOURce[<n>]]:PHASe[:ADJust] <phase> [:SOURce[<n>]]:PHASe[:ADJust]?

3.2.10.5.4.2. Description

Specify signal phase when generator is in periodic mode. Query might return a slightly different value, since internaly all values are rounded.

A new frequency is applied immediately.

3.2.10.5.4.3. Parameters

Name Type Range Default Default unit
<phase> real number 0° to 360° 1 kHz degree (°)

The unit (degree symbol) should not be provided, other units are not supported yet. Negative values and values greater then 360° are properly wrapped.

3.2.10.5.5. [:SOURce[<n>]]:PHASe[:ADJust]

3.2.10.5.5.1. Syntax:

[:SOURce[<n>]]:PHASe[:ADJust] <phase> [:SOURce[<n>]]:PHASe[:ADJust]?

3.2.10.5.5.2. Description

Specify signal phase when generator is in periodic mode. Query might return a slightly different value, since internaly all values are rounded.

A new phase is only applied after the generator is triggered again.

3.2.10.5.5.3. Parameters

Name Type Range Default Default unit
<frequency> Positive real number 0° to 360° 1 kHz degree (°)

The unit (degree symbol) should not be provided, other units are not supported yet. Negative values and values greater then 360° are properly wrapped.

3.2.10.5.6. [:SOURce#]:FUNCtion[:SHAPe]

3.2.10.5.6.1. Syntax:

[:SOURce#]:FUNCtion[:SHAPe] SINusoid|SQUare|TRIangle|USER, [<duty_cycle>] [:SOURce#]:FUNCtion[:SHAPe]?

3.2.10.5.6.2. Description

Specify the shape to be loaded into the waveform table. The USER shape is ignored, since an arbitrary waveform can be loaded regardless of the current shape setting.

The SQUare and the TRIangle shapes support the <duty_cycle> parameter. The <duty_cycle> parameter is unitless in the range from 0 to 1 by default. Optional units are PCT (%) and PPM (parts per milion).

For SQUare the waveform is 1 for <duty_cycle>*period and -1 for the rest. For TRIangle the waveform is rising from -1 to +1 for <duty_cycle>*period and falling toward -1 for the rest.

Query returns waveform shape in the same format as the parameters.

3.2.10.5.6.3. Parameters

Name Type Range Default Default unit
  mnemonic SINusoid|SQUare|TRIangle|USER    
<duty_cycle> float 0 to 1 or 0PCT to 100PCT 0.5 none

3.2.10.5.7. [:SOURce#]:TRACe:DATA[:DATA]

3.2.10.5.7.1. Syntax:

[:SOURce#]:TRACe:DATA[:DATA] <data> [:SOURce#]:TRACe:DATA[:DATA]? [<len>]

3.2.10.5.7.2. Description

Specify the the arbitrary waveform table. An arbitrary number (between 1 and table size) of data points in the normalized range [-1,+1] can be provided. The number of data points will also initilalize in internal periodic mode table size register. For burst mode data length needs to be set separately.

An arbitrary number <len> (between 1 and table size) of data points can be requested. If the <len> parameter is absent, the entire table will b returned.

3.2.10.5.7.3. Parameters

Name Type Range Default Default unit
<data> float array -1 to +1   V
<len> integer 1 to 16384 16384  
{.pattern = “[SOURce#]:BURSt[:MODE]”, .callback = rpscpi_gen_set_burst_mode,}, {.pattern = “[SOURce#]:BURSt[:MODE]?”, .callback = rpscpi_gen_get_burst_mode,}, {.pattern = “[SOURce#]:BURSt:DATA:REPetitions”, .callback = rpscpi_gen_set_data_repetitions,}, {.pattern = “[SOURce#]:BURSt:DATA:REPetitions?”, .callback = rpscpi_gen_get_data_repetitions,}, {.pattern = “[SOURce#]:BURSt:DATA:LENgth”, .callback = rpscpi_gen_set_data_length,}, {.pattern = “[SOURce#]:BURSt:DATA:LENgth?”, .callback = rpscpi_gen_get_data_length,}, {.pattern = “[SOURce#]:BURSt:PERiod:LENgth”, .callback = rpscpi_gen_set_period_length,}, {.pattern = “[SOURce#]:BURSt:PERiod:LENgth?”, .callback = rpscpi_gen_get_period_length,}, {.pattern = “[SOURce#]:BURSt:PERiod:NUMber”, .callback = rpscpi_gen_set_period_number,}, {.pattern = “[SOURce#]:BURSt:PERiod:NUMber?”, .callback = rpscpi_gen_get_period_number,}, {.pattern = “[SOURce#]:VOLTage[:IMMediate][:AMPlitude]”, .callback = rpscpi_gen_set_amplitude,}, {.pattern = “[SOURce#]:VOLTage[:IMMediate][:AMPlitude]?”, .callback = rpscpi_gen_get_amplitude,}, {.pattern = “[SOURce#]:VOLTage[:IMMediate]:OFFSet”, .callback = rpscpi_gen_set_offset,}, {.pattern = “[SOURce#]:VOLTage[:IMMediate]:OFFSet?”, .callback = rpscpi_gen_get_offset,},