DonnellyPi
Posts: 8
Joined: Fri Jun 07, 2013 2:10 pm

Storing Data from analog inputs

Tue Oct 06, 2015 1:58 pm

I have a RPi and attached to an input pin I have an ADC (MCP3002) and an op-amp (MCP601) and a piezo element connected to them. The RPi reads the input pin, gets the digital data and at the moment generates a graph using Matplotlib.

I want to take this data and store it in a meaningful way so I can analyse the input from the piezo and determine the frequency of the vibration. I understand I may need to use a codec (not sure how to develop using this) and to get the data I plan on using FFT algorithm to establish the frequencies present. The code I have used is an adaptation of the code found here

The voltage generated is digitized and converted to it's digital number equivalent and plotted on a graph to generate a waveform graph. I just want to convert it to a WAV file or something that can be analysed effectively using FFT because I am reading data which resembles a musical note waveform.

Can anyone give some advice on how I would store this data in a form that would enable it to be analysed with an algorithm like FFT?
Something like a audio file or waveform?


Thank you.
Last edited by DonnellyPi on Tue Oct 06, 2015 2:38 pm, edited 2 times in total.

User avatar
joan
Posts: 14652
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Storing Data from analog inputs

Tue Oct 06, 2015 2:00 pm

I'm not sure I understand the intent behind the question.

To store the data just write it to a file (on the SD card or over the network).

DonnellyPi
Posts: 8
Joined: Fri Jun 07, 2013 2:10 pm

Re: Storing Data from analog inputs

Tue Oct 06, 2015 2:36 pm

I've edited the last part of the question. Mainly how to store it and what file format would be suitable for further use.

AndersM
Posts: 33
Joined: Sun Sep 06, 2015 1:18 pm

Re: Storing Data from analog inputs

Tue Oct 06, 2015 2:41 pm

CSV is read by most analysing software

DonnellyPi
Posts: 8
Joined: Fri Jun 07, 2013 2:10 pm

Re: Storing Data from analog inputs

Tue Oct 06, 2015 3:24 pm

So I could store the values as a CSV, e.g. Voltage (volts) , time(seconds)
3.4522, 0.0001
3.4521, 0.0002

I'll see if I can use the algorithm on CSV formats

Return to “Graphics, sound and multimedia”