I must admit it – I have a reverse Midas touch. When it comes to configuring electronics, if I can mess something up, I will. My experience with the Red Pitaya (RP) certainly will reinforce this statement. For those of you who live under a rock, the Red Pitaya is an FPGA development board with 2 ADCs (analog to digital converter) and 2 DACs (digital to analog converter) plus a few I/O and some signal conditioning hardware. Since it is based on an FPGA, the system can be configured to create several instruments. Its manufacturer’s claim is that it is an educational tool and comes with several examples: an oscilloscope with built in signal generator, a spectrum analyzer and several other configuration options. Some are community generated, and others are a paid-for upgrade. Red Pitaya also provides a simple visual programming language as a basic introduction to electronic control. The configuration of the instruments is open source and the tools are all public domain based on the Linux operating system.
There is quite a lot of superficial information about how the oscilloscope on the RP works and its promise. I was taken in. In my job I often design test jigs and procedures that are then shipped to subcontractors. (See “the Art of Test, Part 1”, part 2, part 3, and “PCB Test Jigs & My China Connection”). On occasion, the best way to make a measurement is with an oscilloscope; for instance you may want to check the output of a PWM driver. We rely on the subcontractors to provide their own oscilloscopes and so the description of the test procedure becomes difficult since pictures of the screen and the controls can be significantly different to reality. I thought that if I could configure a RP suitably, then we could build them into the test jig. Better yet, it was my (mis)understanding that it could be controlled from a script file and that that it used Python for this. I thought this would be the vehicle I could use to learn Python and kill two birds with one stone. Unfortunately this was not to be – there, I have spoiled the ending.
More than a few months ago Elektor had a great special on the Red Pitaya, probes and housing and so in a moment of weakness I forked over several hundred dollars of my own. I also bought some books on Python in anticipation. For some reason that eludes me, the RP stores its operating system and apps on a plug-in MicroSD card. Although there was a microSD in the kit, it ships untouched in its packaging. The first thing you have to do is download the OS onto your MicroSD. Maybe all newer PCs have a slot for the SD card, but in my environment only my home PC has the capability. I programmed it, tried to plug it into slot on the RP upside down since there is no indication of orientation. I don’t know if that damaged the MicroSD connector, but I couldn’t get the RP to work (based on the lack of flickering LEDs). I finally managed to raise the factory (since I got it from Elektor- if you get it from RS or Allied return will probably be easier) and we quickly decided that the board would be exchanged. The factory is in Slovenia and courier would cost more than the whole RP so we agreed to use snail mail.
When I eventually got the replacement, I inserted the microSD card and according to the LEDs it worked fine. I put it on one side awaiting the right time and inclination to start my investigation. I only got back to it four or five months later. The RP takes the form of an embedded server and communicates over a network to a browser. I just couldn’t get it to work properly. It would load the apps from the net, but wouldn’t run them. I dug around on the web site following many paths – every one ended up with more questions than answers. I posted a question on the forum and contacted tech support (I had the email from before – try finding it on the Red Pitaya site). The silence was and still is, deafening. I wasted a whole day trying to figure out all the different possibilities. Overnight I had the idea that since the whole website and even the approach of RP had changed, maybe the OS that I had downloaded was out of date. I downloaded the new OS and sure enough that resolved most of the problems. I could run all of the “official” apps (see Figure 1) and finally after I switched from Internet Explorer to Mozilla Firefox, they actually ran correctly!
Figure 1. These are all the free official apps. Multiple ones can be loaded, but only one can be run at a time. They can be run from this screen or from a special startup screen (Figure 3). (Source: Aubrey Kagan)
Figure 2. User contributed apps. They are also free. (Source: Aubrey Kagan)
You can see all the possible free applications in Figures 1 and 2. I could load and run all except the “CalScope” and the “CalGenScope”. Those two would load, but would not run. Given the level of support I have seen, I hesitate to even bother asking for help.
Figure 3. This is the normal startup screen. Note there are two locked apps requiring extra payment to open although the can be run in demo mode. (Source: Aubrey Kagan)
Figure 4 shows a very basic oscilloscope set up. I theorized it could be used for a common interface in my test jig scenario I described earlier, but I found a number of issues.
Figure 4. Generator plus scope. I have connected generator 1 output to channel 1 input via a BNC cable. Control is via the panels on the side or mouse control over the waveform (the green line and dot on the right of the waveform is the trigger level). (Source: Aubrey Kagan)
First, there is a definite offset in the DC level, something acknowledged by the RP authorities. This is supposed to be addressed by the “CalScope” and “CalGenScope” (“cal” being for calibration), but since I can’t run them, I can’t comment. Looking at the demo of the Oscilloscope Pro, they claim to have addressed this, but the demo left me underwhelmed and I can’t be persuaded to cough up another 49 Euros to try it out.
Second, you will note in the “Measure” panel there is no reading for frequency or period. From the tests that I made, the voltage input needs to be greater than 2.5Vpp before anything registers here.
I was still at the point of thinking that I could use a script to automatically change these settings. So I dug further only to discover that the philosophy appears to be (as far as I can tell) that you start with the source code, write your own code (in C, C++, Python and others) around it, cross compile and then rebuild it through the Linux/GNU toolchain using (shudder) Eclipse. I have got to the ripe age of 65 without mixing it up in Linux, public domain and open source and all the associated licensing issues. It would take a lot of persuasion for me to try to get into it now. But I didn’t want to create my own instrument; I wanted to control and read the instrument via a program.
Before admitting defeat, I discovered that there is a serial command line interface that allows you to control the RP from a terminal emulator. First you have to install the USB driver and then find a terminal emulator- set the baud rate to 115K 8 bits, no parity and away you go. You just need to know that both the login code and password is “root”. There are four possible relevant commands (that I could find) and typing just the command will receive a response of the format for that command.
Figure 5. Command line interface showing the generate command. To set a sine wave on channel 1 of 1.5V and 10000Hz the command would be: “generate 1 1.5 10000 sine” (Source: Aubrey Kagan)
The commands are:
- monitor – read and write the digital I/O
- calib – read and set the calibration constants
- generate – set the generator output to the desired value
- acquire – read the ADC channels
Could I create a script file of sorts to run through the terminal emulator or a program that would output instructions on the serial port? But in the end there are numerous problems with this approach, and I don’t think it is a viable. I thought that these commands would overwrite the settings in the app, but in fact it simply turns off the app generator control within the app and it is not possible to access any of the readings that appear in the app’s measurements. There are other problems too – generate will only provide a 2Vpp output (higher is possible through the standard app) and for some reason will not produce any output below about 7800Hz. No doubt there is some method of setting the IO using the ”monitor” command to solve this, but I could not find any documentation of how to do this short of picking apart the source code. I am not sure of what the sample rate is used in acquire or what the filters do – all you get is a series of readings, so frequency measurement is a chore left to you.
I revisited this topic and although I cannot find a link on the RP web site I finally come across a wiki that does include some of the above information plus a bit more, including a description on how to calibrate the RP. I don’t know if the additional facilities are available on the command line serial connection. The wiki does discuss connection over a SCP or SSH link, but my lack of knowledge stymied me there as well.
Also apparently it is possible to access the RP through the SCPI command structure and in this way also use Matlab and Labview , but with the possible exception of SCPI, I get the impression that you are accessing the raw data and not the ‘scope on the screen.
It may still be possible to use the RP as is in a test jig especially with SCPI, but there are other things I have reservations about. On the topic of calibration, I am not sure how you could legitimately sell this to an ISO auditor as a calibrated system, even if you could get “CalGenScope” running or using the “pro” version . I dislike the microSD card and have inadvertently popped it out while plugging or unplugging the USB connectors (one for USB, one for power) mounted immediately beneath it. And given my problem with updates, maintaining it may be difficult especially if someone inadvertently upgrades the browser and the system stops working. The RP is powered through a USB connector but is specified at 2 amp current draw which is outside the USB specs for anything other than Type C or USB-PD. RP does not seem to provide a schematic of any sort, so you are left to guess at the finer points, like if there is any input circuit protection.
So my summary- the Red Pitaya definitely works as an ambitious educational tool especially if you are happy to play in the GNU/Linux environment. It can serve as low cost multi-instrument piece of test gear in a non-professional electronics lab. However, any upsell that you (or anyone else) could turn this into a re-calibratable, reconfigurable piece of test equipment should be regarded with caution. I recently came across the Digilent Analog Discovery 2 (courtesy of Richard Wall & Jack Ganssle on “Give Me Knobs”) which seems to address the same market – maybe I will try to see if I can reach my objectives using it and Waveforms 2015 . I just need a sponsor!
I wonder how much I could get for my RP on e-bay?