860ee56 May 7, 2018
2 contributors

Users who have contributed to this file

@amike80 @jeras
221 lines (156 sloc) 7.74 KB

Remote control (Matlab, Labview, Scilab or Python)


STEMlab board can be controlled remotely over LAN or wireless interface using Matlab, Labview, Scilab or Python via Red Pitaya SCPI (Standard Commands for Programmable Instrumentation) list of commands. SCPI interface/environment is commonly used to control T&M instruments for development, research or test automation purposes. SCPI uses a set of SCPI commands that are recognized by the instruments to enable specific actions to be taken (e.g.: acquiring data from fast analog inputs, generating signals and controlling other periphery of the Red Pitaya STEMlab platform). The SCPI commands are extremely useful when complex signal analysis is required where SW environment such as MATLAB provides powerful data analysis tools and SCPI commands simple access to raw data acquired on STEMlab board.


  • Quickly write control routines and programs using Matlab, Labview, Scilab or Python
  • Use powerful data analysis tools of Matlab, Labview, Scilab or Python to analyze raw signals acquired by STEMlab board
  • Write testing scripts and routines
  • Incorporate your STEMlab and Labview into testing and production lines
  • Take quick measurements directly with your PC

Quick start

Start SCPI server, this is done simply by clicking the SCPI server icon and starting the SCPI server. When SCPI server is started the IP of your board will be shown. This IP you need to input in to your scripts. Starting SCPI server can be also done manually via Terminal(check bellow).

To run an examples follow instructions bellow:

  1. Go to your STEMlab main page and Select SCPI server.

    scpi-homepage.png scpi-development.png
  2. Start SCPI server by selecting RUN button. Please notice the IP of your STEMlab ( board as it will be needed to connect to your board.

    scpi-app-run.png scpi-app-stop.png
  3. Follow the instructions bellow sutable to your environment.


    It is not possible to run SCPI commands/programs in parallel with web applications.


  1. Open MATLAB on your computer
  2. Copy the Code from :ref:`blink <blink>` tutorial example to MATLAB workspace
  3. Replace the IP in the example with the IP of your STEMlab board
  4. Hit RUN or F5 on your keyboard to run the code

Check demo video.

More examples about how to control STEMlab from MATLAB can be find :ref:`here <examples>`.


The PyVISA library in combination with the PyVISA-py backend are used. To install them do:

$ sudo pip3 install pyvisa pyvisa-py
  1. Open the :ref:`blink <blink>` tutorial and copy the code to your favorite text editor

  2. Save the file as to your working folder → for example examples_py

  3. Copy and save the `` script in to the same folder where you have saved example (in our case it will be examples_py).

    Note script is a standard script needed to establish the connection between your PC and STEMlab board. Without having this script in the same folder as your python script the execution of your script will fail.

  4. Open the Terminal and go to the folder containing your python script (examples_py) and run: python IP where you give an STEMlab IP as the argument when calling an execution of the example. Example is given bellow where is the IP of the STEMlab board.

    cd /home/zumy/Desktop/exmples_py

More examples about how to control STEMlab from MATLAB can be find :ref:`here <examples>`.


To set up the LabVIEW driver for Red Pitaya, download the Red_Pitaya_LabVIEW_Driver& file. Unpack it and copy the RedPitaya folder to your LabVIEW installations instr.lib folder e.g. C:/Program Files/National Instruments/LabVIEW 2010/instr.lib. The RedPitaya driver should appear after restarting LabVIEW in Block Diagram -> Instrument I/O -> Instr Drivers -> RedPitaya. Depending on your settings Instrument I/O may be hidden. Please consult LabVIEW Help on how to activate/deactivate those categories. You can access example VIs by going to:

  1. Help -> Find Examples...
  2. click Search tab
  3. Enter RedPitaya in Enter keyword(s) field

More examples about how to control STEMlab from MATLAB can be find :ref:`here <examples>`.


To use the SCPI commands you will need to set up Scilab sockets. The procedure is described below.

  1. Go to Scilab download page and download and Install Scilab for your OS
  2. Go to Scilab socket toolbox page and download the basic socket function for Scilab.
  3. Go to the extracted Scilab folder then to folder named contrib
  4. Copy socket_toolbox zip file to contrib folder
  5. Extract socket_toolbox zip file inside the contrib folder
  6. Delete socket_toolbox zip file because we dont need it any more
  7. Go to socket_toolbox folder
  8. Open loader.sce with your Scilab and press RUN (grey run button on SCILAB editor gui)

These last two steps must be executed each time you start Scilab. To install installing you must have an internet connection. Running the examples is same as on MATALB

  1. Copy the Code from :ref:`blink <blink>` tutorial example to MATLAB workspace
  2. Replace the IP in the example with the IP of your STEMlab board
  3. Press RUN to run the code

Different code examples can be found on the Examples page.


Communicating with scpi server and working with web based instruments at the same time can diminish the performance of your Red Pitaya. This is because the same resource is used for both tasks.

More examples about how to control STEMlab from MATLAB can be find :ref:`here <examples>`.

Starting SCPI server manually

Assuming you have successfully connected to your STEMlab board using :ref:`these<faqConnected>` instructions. Remotely connect using Putty on Windows machines or with :ref:`SSH <ssh>` using Terminal on UNIX (macOSX/Linux) machines.

Connect to your STEMlab board via terminal on a Linux machine and start SCPI server with the following command:

systemctl start redpitaya_scpi &



In the list bellow you will find examples of remote control and C algorithms. This examples are covering all basic STEMlab functionalities such as:

  • signal generation
  • signal acquisition
  • digital I/O control
  • communication protocols

You can edit and change them according to your needs and develop customized programs and routines.

.. toctree::
   :maxdepth: 2