2.3.1. SCPI server (MATLAB, LabVIEW, Scilab or Python)¶

Red Pitaya 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 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 Red Pitaya board.
Features
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 Red Pitaya board
Write testing scripts and routines
Incorporate your Red Pitaya and LabVIEW into testing and production lines
Take quick measurements directly with your PC
2.3.1.1. 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:
Go to your Red Pitaya main page and Select SCPI server.
Start SCPI server by selecting RUN button. Please notice the IP of your Red Pitaya (192.168.178.100) board as it will be needed to connect to your board.
Follow the instructions bellow sutable to your environment.
Note
It is not possible to run SCPI commands/programs in parallel with web applications.
2.3.1.1.1. MATLAB¶
Open MATLAB on your computer
Copy the Code from blink tutorial example to MATLAB workspace
Replace the IP in the example with the IP of your Red Pitaya board
Hit RUN or F5 on your keyboard to run the code
More examples about how to control Red Pitaya from MATLAB can be find here.
2.3.1.1.2. Python¶
The PyVISA library in combination with the PyVISA-py backend are used. To install them do:
$ sudo pip3 install pyvisa pyvisa-py
Note
To run the examples, you need Python version 3. Make sure the Python versions before running. If the system has Python version 2.7, this version will be used by default.
$ python --version Python 2.7.17Then, in order to run the examples, specify explicitly the Python version
$ python3.5 blink.py 192.168.178.108
Open the blink tutorial and copy the code to your favorite text editor
Save the file as
blink.py
to your working folder → for exampleexamples_py
Copy and save the redpitaya_scpi.py `` script in to the same folder where you have saved
blink.py
example (in our case it will beexamples_py
).Note
redpitaya_scpi.py
script is a standard script needed to establish the connection between your PC and Red Pitaya board. Without having this script in the same folder as your Python script the execution of your script will fail.Open the Terminal and go to the folder containing your Python script (
examples_py
) and run:Python blink.py IP
where you give an Red Pitaya IP as the argument when calling an execution of theblink.py
example. Example is given bellow where192.168.178.108
is the IP of the Red Pitaya board.cd /home/zumy/Desktop/exmples_py python blink.py 192.168.178.108
More examples about how to control Red Pitaya from MATLAB can be find here.
Note
Python examples can also be run directly from RP device itself. To do so fist start SCPI server and then use local device IP: 127.0.0.1
2.3.1.1.3. LabVIEW¶
To set up the LabVIEW driver for Red Pitaya,
download the
Red_Pitaya_LabVIEW_Driver&Examples.zip file.
Unpack it and copy the Red Pitaya folder to your LabVIEW installations instr.lib
folder
e.g. C:/Program Files/National Instruments/LabVIEW 2010/instr.lib
. When using the 64-bit LabVIEW version (mostly
paid). Or here : C:/Program Files (x86)/National Instruments/LabVIEW 2020/instr.lib
when using the 32-bit LabVIEW version, like the free Community Edition.
The Red Pitaya 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:
Help -> Find Examples…
click Search tab
Enter RedPitaya in Enter keyword(s) field
More examples about how to control Red Pitaya from LabVIEW can be found here.
2.3.1.1.4. SCILAB¶
To use the SCPI commands you will need to set up Scilab sockets. The procedure is described below.
Go to Scilab download page and download and Install Scilab for your OS
Go to Scilab socket toolbox page and download the basic socket function for Scilab.
Go to the extracted Scilab folder then to folder named
contrib
Copy socket_toolbox zip file to contrib folder
Extract socket_toolbox zip file inside the contrib folder
Delete socket_toolbox zip file because we dont need it any more
Go to socket_toolbox folder
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
Copy the Code from blink tutorial example to MATLAB workspace
Replace the IP in the example with the IP of your Red Pitaya board
Press RUN to run the code
Different code examples can be found on the Examples page.
Note
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 Red Pitaya from MATLAB can be find here.
2.3.1.2. Starting SCPI server manually¶
Assuming you have successfully connected to your Red Pitaya board using these instructions. Remotely connect using Putty on Windows machines or with SSH using Terminal on UNIX (macOSX/Linux) machines.
Connect to your Red Pitaya board via terminal on a Linux machine and start SCPI server with the following command:
systemctl start redpitaya_scpi &

2.3.1.3. List of supported SCPI commands¶
2.3.1.3.1. LEDs and GPIOs¶
Parameter options:
<dir> = {OUT,IN}
<gpio> = {{DIO0_P...DIO7_P}, {DIO0_N...DIO7_N}}
<led> = {LED0...LED8}
<pin> = {gpio, led}
<state> = {0,1}
Table of correlated SCPI and API commands on Red Pitaya.
SCPI |
API |
description |
---|---|---|
DIG:PIN:DIR <dir>,<gpio> Examples:
DIG:PIN:DIR OUT,DIO0_N DIG:PIN:DIR IN,DIO1_P |
|
Set direction of digital pins to output or input. |
DIG:PIN <pin>,<state> Examples:
DIG:PIN DIO0_N,1 DIG:PIN LED2,1 |
|
Set state of digital outputs to 1 (HIGH) or 0 (LOW). |
DIG:PIN? <pin> > <state> Examples:
DIG:PIN? DIO0_N DIG:PIN? LED2 |
|
Get state of digital inputs and outputs. |
2.3.1.3.2. Analog Inputs and Outputs¶
Parameter options:
<ain> = {AIN0, AIN1, AIN2, AIN3}
<aout> = {AOUT0, AOUT1, AOUT2, AOUT3}
<pin> = {ain, aout}
<value> = {value in Volts}
SCPI |
API |
description |
---|---|---|
ANALOG:PIN <pin>,<value> Examples:
ANALOG:PIN AOUT2,1.34 |
|
Set analog voltage on slow analog outputs.
Voltage range of slow analog outputs is: 0 - 1.8 V
|
ANALOG:PIN? <pin> > <value> Examples:
ANALOG:PIN? AOUT2 > 1.34 ANALOG:PIN? AIN1 > 1.12 |
|
Read analog voltage from slow analog inputs.
Voltage range of slow analog inputs is: 0 3.3 V
|
2.3.1.3.3. Signal Generator¶
Parameter options:
<n> = {1,2}
(set channel OUT1 or OUT2)<state> = {ON,OFF}
Default:OFF
<frequency> = {0Hz...62.5e6Hz}
Default:1000
<func> = {SINE, SQUARE, TRIANGLE, SAWU, SAWD, PWM, ARBITRARY, DC, DC_NEG}
Default:SINE
<amplitude> = {-1V...1V}
Default:1
for SIGNALlab 250-12 this value {-5V…5V}<offset> = {-1V...1V}
Default:0
<phase> = {-360deg ... 360deg}
Default:0
<dcyc> = {0...1}
Default:0.5
Where 1 corresponds to 100%<array> = {value1, ...}
max. 16k values, floats in the range -1 to 1<burst> = {BURST , CONTINUOUS}
Default:CONTINUOUS
<count> = {1...50000}
, Default:1
<time> = {1µs-500s}
Value in µs.<trigger> = {EXT_PE, EXT_NE, INT, GATED}
EXT
= ExternalINT
= InternalGATED
= gated busts
SCPI |
API |
description |
|
---|---|---|---|
OUTPUT:STATE <state> Examples:
OUTPUT:STATE ON |
rp_GenOutEnableSync |
Runs or Stop two channels synchronously |
|
OUTPUT<n>:STATE <state> Examples:
OUTPUT1:STATE ON |
rp_GenOutEnable rp_GenOutDisable |
Disable or enable fast analog outputs.
|
|
SOUR<n>:FREQ:FIX <frequency> Examples:
SOUR2:FREQ:FIX 100000 |
|
Set frequency of fast analog outputs. |
|
SOUR<n>:FUNC <func> Examples:
SOUR2:FUNC TRIANGLE |
|
Set waveform of fast analog outputs. |
|
SOUR<n>:VOLT <amplitude> Examples:
SOUR2:VOLT 0.5 |
|
Set amplitude voltage of fast analog outputs.
Amplitude + offset value must be less than maximum output range ± 1V
|
|
SOUR<n>:VOLT:OFFS <offset> Examples:
SOUR1:VOLT:OFFS 0.2 |
|
Set offset voltage of fast analog outputs.
Amplitude + offset value must be less than maximum output range ± 1V
|
|
SOUR<n>:PHAS <phase> Examples:
SOUR2:PHAS 30 |
|
Set phase of fast analog outputs. |
|
SOUR<n>:DCYC <par> Examples:
SOUR1:DCYC 0.2 |
|
Set duty cycle of PWM waveform. |
|
SOUR<n>:TRAC:DATA:DATA <array> Examples:
SOUR1:TRAC:DATA:DATA 1,0.5,0.2 |
|
Import data for arbitrary waveform generation. |
|
SOUR<n>:BURS:STAT <burst> Examples:
SOUR1:BURS:STAT BURST SOUR1:BURS:STAT CONTINUOUS |
|
Enable or disable burst (pulse) mode. Red Pitaya will generate R number of N periods of signal and then stop. Time between bursts is P. |
|
SOUR<n>:BURS:NCYC <count> Examples:
SOUR1:BURS:NCYC 3 |
|
Set N number of periods in one burst. |
|
SOUR1:BURS:NOR <count> Examples:
SOUR1:BURS:NOR 5 |
|
Set R number of repeated bursts. |
|
SOUR1:BURS:INT:PER <time> Examples:
SOUR1:BURS:INT:PER 1000000 |
|
Set P total time of one burst in in micro seconds. This includes the signal and delay. |
|
SOUR<n>:TRIG:SOUR <trigger> Examples:
SOUR1:TRIG:SOUR EXT_PE |
|
Set trigger source for selected signal. |
|
SOUR:TRIG:INT Examples:
SOUR:TRIG:INT |
|
Triggers selected source immediately for two channels
|
|
SOUR<n>:TRIG:INT Examples:
SOUR1:TRIG:INT |
|
Triggers selected source immediately for selected channel
|
|
GEN:RST |
|
Reset generator to default settings. |
|
PHAS:ALIGN |
|
Aligning output phase of dual channels. |
2.3.1.3.4. Acquire¶
Parameter options:
<n> = {1,2}
(set channel IN1 or IN2)
2.3.1.3.4.1. Control¶
SCPI |
API |
description |
---|---|---|
|
|
Starts acquisition. |
|
|
Stops acquisition. |
|
|
Stops acquisition and sets all parameters to default values. |
2.3.1.3.4.2. Sampling rate & decimation¶
Parameter options:
<decimation> = {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536}
Default:1
<average> = {OFF,ON}
Default:ON
SCPI |
API |
description |
---|---|---|
|
|
Set decimation factor. |
ACQ:DEC? > <decimation> Example:
ACQ:DEC? > 1 |
|
Get decimation factor. |
ACQ:AVG <average> |
|
Enable/disable averaging. |
ACQ:AVG? > <average> Example:
ACQ:AVG? > ON |
|
Get averaging status. |
2.3.1.3.5. Trigger¶
Parameter options:
<source> = {DISABLED, NOW, CH1_PE, CH1_NE, CH2_PE, CH2_NE, EXT_PE, EXT_NE, AWG_PE, AWG_NE}
Default:DISABLED
<status> = {WAIT, TD}
<time> = {value in ns}
<counetr> = {value in samples}
<gain> = {LV, HV}
<level> = {value in V}
<mode> = {AC,DC}
SCPI |
API |
DESCRIPTION |
---|---|---|
ACQ:TRIG <source> Example:
ACQ:TRIG CH1_PE |
|
Disable triggering, trigger immediately or set trigger source & edge. |
ACQ:TRIG:STAT? Example:
ACQ:TRIG:STAT? > WAIT |
|
Get trigger status. If DISABLED -> TD else WAIT. |
ACQ:TRIG:DLY <time> Example:
ACQ:TRIG:DLY 2314 |
|
Set trigger delay in samples. |
ACQ:TRIG:DLY? > <time> Example:
ACQ:TRIG:DLY? > 2314 |
|
Get trigger delay in samples. |
ACQ:TRIG:DLY:NS <time> Example:
ACQ:TRIG:DLY:NS 128 |
|
Set trigger delay in ns. |
ACQ:TRIG:DLY:NS? > <time> Example:
ACQ:TRIG:DLY:NS? > 128ns |
|
Get trigger delay in ns. |
ACQ:SOUR<n>:GAIN <gain> Example:
ACQ:SOUR1:GAIN LV |
|
Set gain settings to HIGH or LOW
(For SIGNALlab 250-12 this is 1:20 and 1:1 attenuator).
This gain is referring to jumper settings on Red Pitaya fast analog inputs.
|
ACQ:SOUR<n>:COUP <mode> Example:
ACQ:SOUR1:COUP AC |
|
Sets the AC / DC modes for input. (Only SIGNALlab 250-12) |
ACQ:SOUR<n>:COUP? > <mode> Example:
ACQ:SOUR1:COUP? > AC |
|
Get the AC / DC modes for input. (Only SIGNALlab 250-12) |
ACQ:TRIG:LEV <level> Example:
ACQ:TRIG:LEV 125 mV |
|
Set trigger level in mV. |
ACQ:TRIG:LEV? > level Example:
ACQ:TRIG:LEV? > 123 mV |
|
Get trigger level in mV. |
ACQ:TRIG:EXT:LEV <level> Example:
ACQ:TRIG:EXT:LEV 1 |
|
Set trigger external level in V. (Only SIGNALlab 250-12) |
ACQ:TRIG:EXT:LEV? > level Example:
ACQ:TRIG:EXT:LEV? > 1 |
|
Get trigger external level in V. (Only SIGNALlab 250-12) |
2.3.1.3.6. Data pointers¶
Parameter options:
<pos> = {position inside circular buffer}
SCPI |
API |
DESCRIPTION |
ACQ:WPOS? > pos Example:
ACQ:WPOS? > 1024 |
|
Returns current position of write pointer. |
ACQ:TPOS? > pos Example:
ACQ:TPOS? > 512 |
|
Returns position where trigger event appeared. |
2.3.1.3.7. Data read¶
<units> = {RAW, VOLTS}
<format> = {BIN, ASCII}
DefaultASCII
SCPI |
API |
DESCRIPTION |
ACQ:DATA:UNITS <units> Example:
ACQ:GET:DATA:UNITS RAW |
|
Selects units in which acquired data will be returned. |
ACQ:DATA:FORMAT <format> Example:
ACQ:GET:DATA:FORMAT ASCII |
|
Selects format acquired data will be returned. |
ACQ:SOUR<n>:DATA:STA:END? ><start_pos>,<end_pos> Example:
ACQ:SOUR1:GET:DATA 10,13 >{123,231,-231} |
rp_AcqGetDataPosRaw rp_AcqGetDataPosV |
Read samples from start to stop position.
<start_pos> = {0,1,...,16384} <stop_pos> = {0,1,...116384} |
ACQ:SOUR<n>:DATA:STA:N? <start_pos>,<m> > ... Example:
ACQ:SOUR1:DATA? 10,3 >{1.2,3.2,-1.2} |
rp_AcqGetDataRaw rp_AcqGetDataV |
Read |
ACQ:SOUR<n>:DATA? Example:
ACQ:SOUR2:DATA? >{1.2,3.2,...,-1.2} |
rp_AcqGetOldestDataRaw rp_AcqGetOldestDataV |
Read full buf.
Size starting from oldest sample in buffer (this is first sample after trigger delay).
Trigger delay by default is set to zero (in samples or in seconds).
If trigger delay is set to zero it will read full buf. size starting from trigger.
|
ACQ:SOUR<n>:DATA:OLD:N?<m> Example:
ACQ:SOUR2:DATA:OLD? 3 >{1.2,3.2,-1.2} |
rp_AcqGetOldestDataRaw rp_AcqGetOldestDataV |
Read m samples after trigger delay, starting from oldest sample in buffer
(this is first sample after trigger delay).
Trigger delay by default is set to zero (in samples or in seconds).
If trigger delay is set to zero it will read m samples starting from trigger.
|
ACQ:SOUR<n>:DATA:LAT:N?<m> Example:
ACQ:SOUR1:DATA:LAT? 3 >{1.2,3.2,-1.2} |
rp_AcqGetLatestDataRaw rp_AcqGetLatestDataV |
Read
m samples before trigger delay.Trigger delay by default is set to zero (in samples or in seconds).
If trigger delay is set to zero it will read m samples before trigger.
|
ACQ:BUF:SIZE? > <size> Example:
ACQ:BUF:SIZE? > 16384 |
|
Returns buffer size. |
2.3.1.3.8. UART¶
Parameter options:
<bits> = {CS6, CS7, CS8}
Default:CS8
<stop> = {STOP1, STOP2}
Default:STOP1
<parity> = {NONE, EVEN, ODD, MARK, SPACE}
Default:NONE
<timeout> = {0...255} in (1/10 seconds)
Default:0
<speed> = {1200,2400,4800,9600,19200,38400,57600,115200,230400,576000,921000,1000000,1152000,1500000,2000000,2500000,3000000,3500000,4000000}
Default:9600
<data> = {XXX,... | #HXX,... | #QXXX,... | #BXXXXXXXX,... }
Array of data separated commaXXX
= Dec format#HXX
= Hex format#QXXX
= Oct format#BXXXXXXXX
= Bin format
SCPI |
API |
DESCRIPTION |
UART:INIT Example:
UART:INIT |
|
Initializes api for working with uart. |
UART:RELEASE Example:
UART:RELEASE |
|
Releases all used resources. |
UART:SETUP Example:
UART:SETUP |
|
Applies specified settings to uart. |
UART:BITS <bits> Example:
UART:BITS CS7 |
|
Sets the character size in bits. |
UART:BITS? > <bits> Example:
UART:BITS? > CS7 |
|
Gets the character size in bits. |
UART:SPEED <speed> Example:
UART:SPEED 115200 |
|
Sets the speed for the uart connection. |
UART:SPEED? > <speed> Example:
UART:SPEED? > 115200 |
|
Gets the speed for the uart connection. |
UART:STOPB <stop> Example:
UART:STOPB STOP2 |
|
Sets the length of the stop bit. |
UART:STOPB? > <stop> Example:
UART:STOPB? > STOP2 |
|
Gets the length of the stop bit. |
UART:PARITY <parity> Example:
UART:PARITY ODD |
|
Sets parity check mode.
- NONE = Disable parity check
- EVEN = Set even mode for parity
- ODD = Set odd mode for parity
- MARK = Set Always 1
- SPACE = Set Always 0
|
UART:PARITY? > <parity> Example:
UART:PARITY? > ODD |
|
Gets parity check mode. |
UART:TIMEOUT <timeout> Example:
UART:TIMEOUT 10 |
|
Sets timeout for read from uart. 0 - Disable timeout. 1 = 1/10 sec.
Example: 10 - 1 sec. Max timout: 25.5 sec
|
UART:TIMEOUT? > <timeout> Example:
UART:TIMEOUT? > 10 |
|
Gets the timeout. |
UART:WRITE<n> <data> Example:
UART:WRITE5 1,2,3,4,5 |
|
Writes data to uart. <n> - Length of passed data to uart. |
UART:READ<n>? > <data> Example:
UART:READ5? > {1,2,3,4,5} |
|
Reads data from uart. <n> - Length of retrieved data from uart. |
2.3.1.3.9. SPI¶
Parameter options:
<mode> = {LISL, LIST, HISL, HIST}
Default:LISL
<order> = {MSB, LSB}
Default:MSB
<bits> = {7,..}
Default:8
<speed> = {1,100000000}
Default:50000000
<data> = {XXX,... | #HXX,... | #QXXX,... | #BXXXXXXXX,... }
Array of data separated commaXXX
= Dec format#HXX
= Hex format#QXXX
= Oct format#BXXXXXXXX
= Bin format
SCPI |
API |
DESCRIPTION |
SPI:INIT Example:
SPI:INIT |
|
Initializes api for working with spi. |
SPI:INIT:DEV <path> Example:
SPI:INIT:DEV "/dev/spidev1.0" |
|
Initializes api for working with spi. <path> - Path to spi device
On some boards, it may be different from the standard: /dev/spidev1.0
|
SPI:RELEASE Example:
SPI:RELEASE |
|
Releases all used resources. |
SPI:SETtings:DEF Example:
SPI:SET:DEF |
|
Sets the settings for SPI to default values. |
SPI:SETtings:SET Example:
SPI:SET:SET |
|
Sets the specified settings for SPI. |
SPI:SETtings:GET Example:
SPI:SET:GET |
|
Gets the specified SPI settings. |
SPI:SETtings:MODE <mode> Example:
SPI:SET:MODE LIST |
|
Sets the mode for SPI.
- LISL = Low idle level, Sample on leading edge
- LIST = Low idle level, Sample on trailing edge
- HISL = High idle level, Sample on leading edge
- HIST = High idle level, Sample on trailing edge
|
SPI:SETtings:MODE? > <mode> Example:
SPI:SET:MODE? > LIST |
|
Returns the specified mode for SPI. |
SPI:SETtings:SPEED <speed> Example:
SPI:SET:SPEED 1000000 |
|
Sets the speed for the spi connection. |
SPI:SET:SPEED? > <speed> Example:
SPI:SET:SPEED? > 1000000 |
|
Gets the speed the spi connection. |
SPI:SETtings:WORD <bits> Example:
SPI:SET:WORD 8 |
|
Specifies the length of the word in bits. Must be greater than or equal to 7. |
SPI:SETtings:WORD? > <bits> Example:
SPI:SET:WORD? > 8 |
|
Returns the length of a word. |
SPI:MSG:CREATE <n> Example:
SPI:MSG:CREATE 1 |
|
Creates a message queue for SPI. Once created, they need to be initialized.
<n> - Number of messages in the queue
The message queue can operate within a single CS state switch.
|
SPI:MSG:DEL Example:
SPI:MSG:DEL |
|
Deletes all messages and data buffers allocated for them. |
SPI:MSG:SIZE? > <n> Example:
SPI:MSG:SIZE? > 1 |
|
Returns the length of the message queue. |
SPI:MSG<n>:TX<m> <data> SPI:MSG<n>:TX<m>:CS <data> Example:
SPI:MSG0:TX4 1,2,3,4 SPI:MSG1:TX3:CS 2,3,4 |
rp_SPI_SetTX rp_SPI_SetTXCS |
Sets data for write buffer for the specified message.
CS - Toggles CS state after sending/receiving this message.
<n> - index of message 0 <= n < msg queue size.
<m> - TX buffer length.
|
SPI:MSG<n>:TX<m>:RX <data> SPI:MSG<n>:TX<m>:RX:CS <data> Example:
SPI:MSG0:TX4:RX 1,2,3,4 SPI:MSG1:TX3:RX:CS 2,3,4 |
rp_SPI_SetTXRX rp_SPI_SetTXRXCS |
Sets data for read and write buffers for the specified message.
CS - Toggles CS state after sending/receiving this message.
<n> - index of message 0 <= n < msg queue size.
<m> - TX buffer length.
The read buffer is also created with the same length and initialized with zeros.
|
SPI:MSG<n>:RX<m> SPI:MSG<n>:RX<m>:CS Example:
SPI:MSG0:RX4 SPI:MSG1:RX5:CS |
rp_SPI_SetRX rp_SPI_SetRXCS |
Initializes a buffer for reading the specified message.
CS - Toggles CS state after receiving message.
<n> - index of message 0 <= n < msg queue size.
<m> - RX buffer length.
|
SPI:MSG<n>:RX? > <data> Example:
SPI:MSG1:RX? > {2,4,5} |
|
Returns a read buffer for the specified message. |
SPI:MSG<n>:TX? > <data> Example:
SPI:MSG1:TX? > {2,4,5} |
|
Returns the write buffer for the specified message. |
SPI:MSG<n>:CS? > ON|OFF Example:
SPI:MSG1:CS? > ON |
|
Returns the setting for CS mode for the specified message. |
SPI:PASS Example:
SPI:PASS |
|
Sends prepared messages to the SPI device. |
2.3.1.3.10. I2C¶
Parameter options:
<mode> = {OFF, ON}
Default:OFF
<value> = {XXX | #HXX | #QXXX | #BXXXXXXXX}
<data> = {XXX,... | #HXX,... | #QXXX,... | #BXXXXXXXX,... }
Array of data separated commaXXX
= Dec format#HXX
= Hex format#QXXX
= Oct format#BXXXXXXXX
= Bin format
SCPI |
API |
DESCRIPTION |
I2C:DEV<addr> <path> Example:
I2C:DEV80 "/dev/i2c-0" |
|
Initializes settings for i2c. <path> - Path to i2c device
<addr> - Device address on the i2c bus in dec format.
|
I2C:DEV? > <addr> Example:
I2C:DEV? > 80 |
|
Returns the current address of the device. |
I2C:FMODE <mode> Example:
I2C:FMODE ON |
|
Enables forced bus operation even if the device is in use. |
I2C:FMODE? > <mode> Example:
I2C:FMODE? > ON |
|
Gets the current forced mode setting. |
I2C:Smbus:Read<reg> > <value> Example:
I2C:S:R2 > 0 |
|
Reads 8 bit data from the specified register using the SMBUS protocol.
<reg> - Register address in dec format.
|
I2C:Smbus:Read<reg>:Word > <value> Example:
I2C:S:R2:W > 0 |
|
Reads 16 bit data from the specified register using the SMBUS protocol.
<reg> - Register address in dec format.
|
I2C:Smbus:Read<reg>:Buffer<size> > <data> Example:
I2C:S:R2:B2 > {0,1} |
|
Reads buffer data from the specified register using the SMBUS protocol.
<reg> - Register address in dec format.
<size> - Read data size.
|
I2C:Smbus:Write<reg> <value> Example:
I2C:S:W2 10 |
|
Writes 8-bit data to the specified register using the SMBUS protocol.
<reg> - Register address in dec format.
|
I2C:Smbus:Write<reg>:Word <value> Example:
I2C:S:W2:W 10 |
|
Writes 16-bit data to the specified register using the SMBUS protocol.
<reg> - Register address in dec format.
|
I2C:Smbus:Write<reg>:Buffer<size> <data> Example:
I2C:S:W2:B2 0,1 |
|
Writes buffer data to the specified register using the SMBUS protocol.
<reg> - Register address in dec format.
<size> - Read data size.
|
I2C:IOctl:Read:Buffer<size> > <data> Example:
I2C:IO:R:B2 > {0,1} |
|
Reads data from i2c device through IOCTL.
<size> - Read data size.
|
I2C:IOctl:Write:Buffer<size> <data> Example:
I2C:IO:W:B2 {0,1} |
|
Writes data to i2c device via IOCTL.
<size> - Read data size.
|
Note
SMBUS is a standardized protocol for communicating with i2c devices. Information about this protocol can be found in this link: SMBUS specifcation. IOCTL writes and reads data directly from i2c.
2.3.1.3.11. Specific LEDs¶
Parameter options:
<mode> = {OFF, ON}
Default:ON
SCPI |
API |
DESCRIPTION |
LED:MMC <mode> Example:
LED:MMC OFF |
|
Turns on or off the yellow LED responsible for indicating the read memory card. |
LED:MMC? > <mode> Example:
LED:MMC? > ON |
|
Gets the state of the MMC indicator. |
LED:HB <mode> Example:
LED:HB OFF |
|
Turns on or off the red LED responsible for indicating board activity. |
LED:HB? > <mode> Example:
LED:HB? > ON |
|
Gets the state of the HeartBeat indicator. |
LED:ETH <mode> Example:
LED:ETH OFF |
|
Turns on or off the LED indicators on the network card. |
LED:ETH? > <mode> Example:
LED:ETH? > ON |
|
Gets the state of the Ethernet indicators. |
2.3.1.4. Examples¶
In the list bellow you will find examples of remote control and C algorithms. This examples are covering all basic Red Pitaya 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.
Additional examples: Add a button to control LED