Skip to content

Commit

Permalink
Merge pull request #40 from Lightsaver7/August-patch-4
Browse files Browse the repository at this point in the history
August patch 4
  • Loading branch information
Lightsaver7 committed Aug 30, 2023
2 parents 2cfe1a2 + a708b30 commit 2d2c43f
Show file tree
Hide file tree
Showing 4 changed files with 157 additions and 11 deletions.
34 changes: 23 additions & 11 deletions appsFeatures/applications/streaming/appStreaming.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Streamed data can be stored into:

* Standard audio WAV file format
* Technical Data Management Streaming (TDMS) file format
* Fast and compact binary format (BIN), which can later be converted to CSV format.
* Fast and compact binary format (BIN). It can be converted to CSV format.

Max. streaming speeds are limited to:

Expand All @@ -32,12 +32,24 @@ Max. streaming speeds are limited to:

.. note::

We plan to expand the functionality by adding the generation to the Streaming application in the future. For now, it is possible for a user to implement it by themselves, but it is complicated.
The maximum continuous streaming speeds are limited to the total input data rate, not the network transfer rates. If the maximum data rate is exceeded, the data pipeline inside Red Pitaya starts to clog, which leads to unpredictable behaviour.
Here are a few examples of maximum data rates:

- One channel, 8-bits per sample: Max sampling frequency 20 MHz.
- One channel, 16-bits per sample: Max sampling frequency 10 MHz.
- Two channels, 8-bits per sample: Max sampling frequency per channel 10 MHz (assuming same frequencies for both channels)
- Two channels, 16-bits per sample: Max sampling frequency per channel 5 MHz (assuming same frequencies for both channels)

********************************************
Start using the Red Pitaya streaming feature
********************************************
If acquiring a limited amount of samples in a short duration, it is possible to reach higher sampling frequencies (up to the sampling speed of fast analog inputs).

.. note::

We plan to expand the functionality by adding the generation to the Streaming application in the future. For now, it is possible for a user to implement it by themselves.


******************************************************
Getting started with the Red Pitaya streaming feature
******************************************************

#. Run the Streaming app from the Red Pitaya Web interface

Expand All @@ -63,15 +75,15 @@ Start using the Red Pitaya streaming feature
:width: 50%
:align: center

#. Open the file in a program that supports TDMS file reading, visualization, and processing, such as |DIAdem|.
#. Open the file in a program that supports TDMS file reading, visualisation, and processing, such as |DIAdem|.

.. figure:: img/diadem_tdms_file_viewer.png
:width: 80%
:align: center

#. Streaming to a remote computer

#. Get the streaming client for your computer. Clients are located on the board itself, and you can download them from there.
#. Get the streaming client for your computer. Clients are located on the board itself and can be downloaded from there.

.. figure:: img/download_client.png
:width: 50%
Expand Down Expand Up @@ -137,14 +149,14 @@ Start using the Red Pitaya streaming feature
:align: center


The application saves data from the board in BIN format. This is a binary format. If the application has finished writing data correctly or there is enough free space on the disk, the conversion to CSV format will be automatic.
The application saves data from the board in BIN format. This is a binary format. If the application has finished writing data correctly and there is enough free space on the disk, the conversion to CSV format will be automatic.

.. figure:: img/csv_list.png
:width: 50%
:align: center


The created csv file can be opened with any text editor or spreadsheet editor:
The created CSV file can be opened with any text editor or spreadsheet editor:

.. figure:: img/csv_view.png
:width: 80%
Expand Down Expand Up @@ -181,7 +193,7 @@ Start using the Red Pitaya streaming feature
Streaming application for the Desktop (Linux, Windows)
******************************************************

You can also use the desktop version of the client for streaming
You can also use the desktop version of the client for streaming.

#. Download the client

Expand All @@ -200,7 +212,7 @@ You can also use the desktop version of the client for streaming

.. note::

For Linux clients, after unpacking, you need to make the files (rpsa_client_qt.sh, bin/rpsa_client_qt) executable.
For Linux clients, after unpacking, the files (rpsa_client_qt.sh, bin/rpsa_client_qt) must be made executable.

.. figure:: img/qt1.png
:width: 50%
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
basic/basic_top
sensor/sensor_top
motor/motor_top
data/iso_adc3
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
.. _click_iso_adc3:

#######################
ISO ADC 3 Click Board
#######################

Description
============

This is an example of using Red Pitaya with the Red Pitaya Click Shield and ISO ADC 3 Click Board.
This example measures the differential voltages up to +-250 mV with a 12-bit ADC.


Required hardware
==================

- Red Pitaya device
- Red Pitaya Click Shield
- ISO ADC 3 click board


Code C
=======

The code should be copied to the Red Pitaya using the *"scp"* or similar command and compiled on the board.

.. note::

Instructions on how to compile the code are :ref:`here <comC>`.


.. code-block:: C
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <sys/ioctl.h>
#include <linux/i2c-dev.h>
#include <linux/i2c.h>
#include <i2c/smbus.h>
#include <arpa/inet.h>
#include <pthread.h>
#include <errno.h>
#include "rp_hw.h" // This library must be included manually using Linux scp command
// It is available here "https://github.com/RedPitaya/RedPitaya/blob/master/rp-api/api-hw/include/rp_hw.h"
#define FAIL "\033[91m[FAIL]\e[0m"
// Function to initialize the I2C communication
int setup() {
int deviceAddress = 0b1001101;
const char *filename = "/dev/i2c-0";
int fd = open(filename, O_RDWR);
if (fd < 0) {
printf("Failed to open I2C %s\n", FAIL);
printf("I2C %s\n\n", FAIL);
return -1;
}
if (ioctl(fd, I2C_SLAVE, deviceAddress) < 0) {
printf("Setting I2C_SLAVE %s\n", FAIL);
printf("I2C %s\n\n", FAIL);
close(fd);
return -1;
}
return fd;
}
// Convert the ADC value to the correct voltage
double convertToVoltage(int adcValue) {
int adcRange = 3174;
double voltageRange = 0.62;
double voltage = (adcValue / (double)adcRange) * voltageRange - 0.31;
printf("\nADC Voltage: %.4lf V\n", voltage);
// OVERVOLTAGE: if the diferential voltage is too big, the ADC can be destroyed
if (voltage < -0.25 || voltage > 0.25) {
printf("\nWarning: This device is rated for a voltage range of -+250mV\n\n");
}
return voltage;
}
// Function to read data from MCP3221 over I2C
int readValue(int fd) {
char buf[4]; // Buffer for MCP3221 communication
memset(buf, 0, 4);
int x = read(fd, buf, 2);
if (x != 2) {
printf("Read operation failed %d %s\n", x, FAIL);
return -1;
}
else {
int value = ((buf[0] & 0x0F) << 8) | buf[1];
printf("\nADC Value: %d\n", value);
printf("\nDevice supports +-250mV at 22.3 ksps. Connect 5V DC to Vext \n");
return value;
}
}
int main(int argc, char **argv) {
// Configure I2C
int fd = setup();
if (fd < 0) {
return -1;
}
// Read data from ISO ADC 3 CLICK
int adcValue = readValue(fd);
// Measure the voltage
double voltage = convertToVoltage(adcValue);
// Close the I2C file
close(fd);
return (adcValue < 0) ? -1 : 0;
}
Code written by Žiga Fon.
6 changes: 6 additions & 0 deletions appsFeatures/remoteControl/jupyter/Jupyter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,12 @@ LCD
Examples
********

.. note::

Please note that we have updated the backend of the Jupyter Notebook application with the 2.00 OS, so some of these examples will not work with OS versions 2.00 or higher.
We are preparing a new set of examples which will function almost the same as the SCPI examples.


1. |Drive LEDs|
2. |Control GPIOs|
3. |Write slow analog I/Os|
Expand Down

0 comments on commit 2d2c43f

Please sign in to comment.