Analog Discovery 2 Communicates with Arduino

0

Recently, for a project I was doing, I wanted to use the Analog Discovery 2 to help intelligently interpret live audio and send the data to LED strips controlled by an Arduino. However, in order to do this I would need WaveForms to have some way to talk to the Arduino. After exploring some options on my own, I turned to the Digilent Forum and posted the following question.

I am trying to send oscilloscope data from the Analog Discovery 2 to the Arduino Uno. Would there be a way I could do this so that the Arduino could read it in live time?

Before I knew it I had a solution proposed to me by attila, a Technical Forum Moderator and WaveForms software developer. He suggested using the Python libraries in WaveForms SDK by doing the following:

You could use the WaveForms SDK. Starting with the AnalogIn_Record_int16.py or AnalogIn_Record.py example script and modifying it to send the data chunks from the record loop to the desired protocol (like COM), or using the device DIO (see Digital_Spi.py, Digital_Uart.py, Digital_I2c.py)
The examples are located in the following path: C:/Program Files (x86)/Digilent/WaveFormsSDK/samples/py/
image.png.0f88183b5798f461989d6d3eda2669f5.png

He also suggested that I could also send acquisition data over SPI with a custom script in the script editor like the one shown below:

image.thumb.png.9cd9a4660b5dd7cc9882b195e71307c7.png

Scope1.run()
while(Scope1.wait()){
    var rg16 = []
    var r = Scope1.Channel1.Range.value
    var o = Scope1.Channel1.Offset.value
    // convert float to 16bit integer
    Scope1.Channel1.alldata.forEach(function(v){
        rg16.push(max(-32768, min(32767, v*32768/r+o)))
    })
    Protocol.SPI.Start()
    if(!Protocol.SPI.Write(16, rg16)) break
    Protocol.SPI.Stop()
}

 

For the design I am working on, this communication is essential, as I am basically using the Analog Discovery 2 as an advanced sound sensor. Since my current setup involves manipulating the data from WaveForms in the Arduino IDE, I am going to experiment with attila’s suggested option of using the AnalogIn_Record example scripts to send to the COM port that the Arduino is on.

Stay tuned for updates on this project as well as how to use the Analog Discovery 2 with Arduino!

Share on FacebookTweet about this on TwitterShare on Google+Pin on PinterestShare on RedditShare on TumblrShare on LinkedInShare on StumbleUponEmail this to someone
Share.

About Author

I enjoy creative writing, engineering, thinking, building, exploring and sharing with people. Huge aficionado of spending time thinking about things that “don’t matter.” I am very interested in unconstrained creativity. I love cross-discipline ideas and all of their integration into complete original systems. And I like things that do things.

Leave A Reply