Message Boards Message Boards

Using Redpitaya board with Mathematica ?

Posted 9 years ago

I just discovered the Red Pitaya board and borrowed a unit to play during this weekend. It seems there is a real buzz starting around this Open source board and ecosystem since they started to be distributed by RS components. It seems to be issued from a successful crowd-funding that started in 2013.

For detailed info see their website: Redpitaya site Basically it is a physical board the size of an Arduino Mega 2560 which runs a dual core ARM under a Linux flavor and provide Web server applications, along with a Virtex FPGA driving high frequency acquisition hardware. Basic functionality consist in 2 Data acquisition 50MS/s 14bits built-in channels and two other built-in channels for signal generation + memory and all the stuff . So basically it is the combination of a dual channel 14 bits 50Mhz scope and a arbitrary waveform synthesizer, plus a couple of I/O's and slow(?) 100kHz ADC inputs, so it can be used for controlling external hardware like a Raspberry Pi or (to a lesser extend I believe) like an Arduino.

It seems that the guys from Matlab and National Instruments are already proposing seamless interfaces to their respective ecosystems. It also exists on Python, C,etc... and will shortly use Web UI application development(whatever it is...I am not specialist). The last but not the least is that this board is sold about $325 (count +$100 for a complete kit with 2 scope probes and housing) or €300 for the full kit in Europe. It is amazingly cheaper than the sum of the two instruments it can replace, knowing also that the combination of the board ressources allow building standalone virtual instruments like a LCR meter and has the power to drive external sensors or actuators. Of course I have not tried it intensively so I am maybe a bit overenthusiastic... :)

Nevertheless I was a bit disappointed not to find any reference to Mathematica on the Red Pitaya forum, nor did I find any reference to Red Pitaya on Mathematica Stack Exchange. Following some advice, I post here to get some feedback from potential users or developpers who has heard about the thing or thinks it could be interesting.

My first question was "Can someone give me some leads to a tutorial that shows how to start with the board? " , but it seems that there is no such tutorial available yet, not on devices.wolfram.com anyway. So maybe this post can trigger some interest in the developer's community so they can give some advices of "how to start", such as: - should I go to use pitaya C libraries and call them from Mathematica? - is there an easy way to communicate from Mathematica through Ethernet with the board? - Is the use of MathLink a good start? - Is it possible to call the Malab interface from Mathematica?...all these different approach and I am probably far away from a good approach since I am not specialist AT ALL of these interoperability questions from Mathematica to other environment. My need: In the beginning I just want to store and process a digitized waveform with Mathematica and/or generate an arbitrary waveform, built with Mathematica.

BTW, on Mathematica stack-exchange I have been asked also to give a feedback of why I think connecting this device to Mathematica is important... well, my feeling is that if there are so many other dta acquisition or data processing ecosystems that are interested to join the Redpitaya community is that there is some interest. My personal feeling is that the board could be like an Arduino adventure in the domain of Intrumentations, & data acquisition. And from a professional viewpoint , using this board to prototype real-time hardware in the loop systems would be a dream with Mathematica!

I would be glad for any comment

Best regards

Christian Néel

POSTED BY: Christian Neel
7 Replies

Dear @Christian Neel could you pease make a new post completely dedicated to that material on this forum (cross-post)?

We have a special Mathematica Add-Ons group for package introductions.

You can also attach files to the post if needed.

Thanks!

POSTED BY: Vitaliy Kaurov

Ok will do. Thanks

POSTED BY: Christian Neel

Done. See : here

POSTED BY: Christian Neel

Hi Ian,

Thanks for the feedback! You are right, at the present time my next move will be to learn more about calling external programs with Mathematica, then accessing the board via the various API's that are provided by Red Pitaya.

Christian

POSTED BY: Christian Neel

Hi Christian,

At the moment, the only supported ARM board to run Mathematica natively on is the Raspberry Pi with Debian. If you wish to run Mathematica, you can either try and sign up for the prerelease program by sending an email to prerelease@wolfram.com, or you can simply wait for the generalized Linux-ARM kernel, but we do not have any kind of time estimate for when that will be released.

At this point, you are probably best suited to doing as you have found and reading the data off the device's serial port into another computer running Mathematica. I'm not too familiar with this device, nor it's tools like acquire that you use, but that is probably your best bet for interfacing with the device at the moment.

Ian

POSTED BY: Ian Johnson

I finally succeeded to get some data to and from the board by a very clumsy method but it is a beginning. The best would be to have direct access to the SCPI served that is provided on the Red Pitaya and sending string command, or better go thru MathLink but I am not a that level yet. Anyway I just got that, by connecting the ADC to the DAC:

enter image description here

I attach the notebook I just used for this (code summary below). It is emulating the input in a console, sending line command at high level with the commands "acquire" and "generate" provided by the board.

Christian


Open device

pitaya = DeviceOpen[ "Serial", {"COM5", "BaudRate" -> 115200, "ReadBufferSize" -> 16384, "StopBits" -> 1, "Parity" -> None}]

Note that the serial port can be used as a console like with Hypeterminal or PuTTy in Serial Mode.

Generate signal on chanel 1 DAC device

DeviceWrite[pitaya, "generate 1 1 750000 sine" <> "\n"];
Pause[1];
DeviceReadBuffer[pitaya] // FromCharacterCode

Record signal on chanel 1 ADC device (connected to chanel 1 DAC)

AbsoluteTiming[n = 500;(*want n samples*)
DeviceWrite[pitaya, "acquire " <> ToString[n] <> "\n"];
 (*the high level "acquire" function that wortks either under SSH terminal or Serial terminal from USB FTDI"*)
 s = Table[DeviceReadBuffer[pitaya, "ReadTerminator" -> "\r"], {n + 1}];
 DeviceReadBuffer[pitaya]; (*flush the rest*)
  s = Cases[s // FromCharacterCode // StringSplit // ToExpression, {_Integer, _Integer}];]

ListPlot[s // Transpose, Joined -> True, PlotRange -> All]
Attachments:
POSTED BY: Christian Neel
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract