Jump to content
  • 0

digilent digital discovery save date from spi to pc and plott the data


XerXes777

Question

I am currently planning my next project and gathering information. I would like to get into the topic of DSP.
I have a microcontroller from TI (EK-TM4C123GXL). This is connected to a simple microphone (MAX4466). I want to sample frequencies and music with this microcontroller. The ADC has 12 BIT. Sample rate: 1K-44,1k. Samples: 32 - 2048 (could be much more, actually infinite as stream).
The microphone signal should be stored on my computer. And I also want to plot the signal in a coordinate system.

Because I want to use the digilent digital discovery for the logic part. I want to play this back on my computer with audacity. I thought I can send the sample data to Waveforms via SPI. 
1. Can Waveforms save this data to my computer?

2. And can Waveforms plot this data to a coordinate system?

I could add additional information to the incoming data via SPI. So that waveforms knows which data is which signal.
3. Also, can waveforms pllot me multiple signals in a coordinate system?

I am glad about any information.

Kevin

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 1

What you propose is pretty strange.

Your ADC is a peripheral inside the MCU, so it will be controlled by the MCU -- the Cortex processor can fetch samples from the ADC, or program a bunch of registers in the ADC peripheral to set up DMA, and to be notified via an interrupt if new samples are available. The MCU also has an SPI peripheral, and sure, you can make that talk to the Digilent Discovery device -- with limitations. The SPI support in the Digilent DWF library and Waveforms tool acts as the SPI bus master, which would normally support request/response type operations, initiated from the Digilent DWF side. This is not a good fit for the kind of streaming data transfer you want to do, which is naturally implemented as a "push"-type communication initiated by the MCU board.

What you describe is technically possible, bu it would involve writing a C program in the MCU, have that program buffer samples in the MCU, which could then be requested by the Digilent acting as a SPI master. It is possible but it is not a sensible design. An experienced engineer would never implement such an overly complex solution to what is in principle a simple problem.

If this is a learning exercise, you should re-think the project because implementing a weird design like this is not optimal for learning stuff. The best thing to learn from this is to understand what makes this design sub-optimal; and to come up with a better design. Specifically, if you want to transfer ADC samples into your computer, just program the MCU to get samples (preferable via DMA), and push them out using a serial interface which is multiplexed in your USB stream, and that the PC can read from as if it is a serial port. There is no sensible use for the Digilent Descovery in such a setup other than perhaps debugging.

If you insist on proceeding with this, split the projects in two sub-parts (1) ADC programming in the MCU; and (2) Programming the SPI peripheral in the MCU, to be able to talk to MCU using the the Digilent Discovery. Then, if you insist, you can tie those two parts together afterward -- but chances are that along the way you will figure out why that is not a good idea -- which, I suppose, is good for learning.


As to your questions: the Waveforms application is not a general-purpose plotting tool; it is only able to make specific visualizations of data it reads from the Discovery instruments. So the answer to (2) and (3) at least is "no".
 

Link to comment
Share on other sites

  • 1

Hi @XerXes777

1. You can use Logic Analyzer and Export SPI (Events) or Protocol/SPI/Spy/Receive to File.

2. The Logic Analyzer shows the analog representation with taller rows.

2-3. You can also import data from file in the Oscilloscope interface where you have various data processing (Views) available or the Script tool.

image.png

 

Link to comment
Share on other sites

  • 0

Thank you very much for this detailed answer.
The MCU I have already finished programming that this saves the microphone data via uDMA. I send this data directly through the CMSIS fft function to get a spectrum of the music. This all works so far. Now I would like to get further into the topic of DSP. My next steps would be: FIR and IIR filters. Anti Aliasing. Using a FFT with few samples. etc. The goal of all this should be to get as clear a spectrum of the music as possible.
And I like to see the things I am trying to change.
I have a frequency generator that can create multiple sine signals (100Hz+1000Hz+5000Hz). When I program an FIR filter to 1000HZ I want to see that actually the frequencies from 1000Hz+ are cut away. And I also want to play around with these things.

I am a bit sad that the Digilent is not so suitable to debug this. 

I have not yet dealt with SPI and UART.
If my sample rate would be 44,1kHz and I store the samples as 16Bit signed int.
This means 44.1k samples/s.
44,1kSamples/s * 16bits = 705,6kbit/s.

Or 44,1kSamples/s * 12bits = 529,2kbit/s.

Can UART or SPI do this at all ?

Do you have a better idea how to implement my project?

Unfortunately the MCU has no DAC. But I could buy one.
https://www.reichelt.de/de/de/d-a-wandler-12-bit-2-kanal-spi-2-7--5-5-v-dip-14-mcp-4922-e-p-p90090.html?r=1
Display the signal on an oscilloscope.

Edited by XerXes777
typo
Link to comment
Share on other sites

  • 0

In many ways it's a pity you have a Digital Discovery rather than an Analog Discovery -- the latter has both analog outputs and analog inputs, and much better ones than your MCU at that.

If the goal is to increase understanding of digital signal processing, it is not particularly necessary to work with "live" signals. It is easier and in fact much more convenient to just work with pre-recorded WAV files, or synthetic files. For this type of learning I'd just do everything in python with Numpy, or in Matlab if that is what you prefer.

I do see the appeal of toying around with live signals, of course. But did you consider just using your soundcard for that? It has some pretty capable ADCs for audio frequencies, and it is pretty easy to record and play (stereo) samples in Linux with a bit of ALSA programming, or if you want to avoid that, just piping data in via the "sox" utility. The only drawback is that if you want to do "live" filtering, you will surely introduce a small bit of latency.

UART and SPI from your Arty will in principle support high enough bit-rates. The non-suitability of SPI in this case is mostly because it only supports a "request-response" type of communication, which doesn't fit well with streaming data, unless one side is constantly and actively polling, which is just wasteful and more fragile.

I believe the Arty UART can send out data at at least 4 Mbaud (and perhaps even 12 MBaud), giving you at least 400 KiByte per second to toy with. And you're lucky to use Linux, because it can actually handle such data rates easily from an UART (in Windows, this is not practical -- you will see a lot of errors due to badly implemented drivers at (probably) the USB level).

Signal processing is a boatload of fun and the mathematics is super interesting and powerful. I mostly hope you will have fun with it :)

 

Link to comment
Share on other sites

  • 0

It may be that this may work better with an analog Discovery.
I would buy that too, but it is important to me to implement this with this MCU. Because I would like to tie to my previous project

1. would this routine be possible with Waveforms?
Send configuration to the MCU. Sample rate and the number of samples. Then Waveforms sends a start signal to the MCU. Then the MCU answers with a First Data Flag and Waveform starts recording to a file on the computer. Until the MCU sends a Last Data Flag and the recording is finished.
I have to admit that I don't know Phyton yet.
Do I have to program a lot of phyton with this plan so I can parameterize waveforms?

Link to comment
Share on other sites

  • 0

Hi XerXes,

I am unsure if the Waveforms scripting engine supports writing files; I have never used it.

A much simpler idea would be to do this communication using the serial port, from a normal programming language (outside of Waveforms). Having Waveforms and the Digilent device in this flow just makes matters unduly complicated, as I see it, for no benefit gained.

Do yourself a favor and invest the time to learn Python. If you have experience in C it will be quick to become used to its basics, and it will bring huge benefits in terms of the ability to write small scripts for many years to come.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...