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.
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/
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:
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!
Miranda,
Any updates on the project? I am also wanting to use Waveforms to communicate with the Arduino.
Thanks.