Hi all,
I'm new to Arduino and after the reading of many tutorials and topics regarding my project (with sometimes contradictory information), I wonder if the project I step into is feasible.
What I'd like to do is use a Arduino Uno to:
-
Excite a sensor with a frequency sweep from 2 to 3.5 kHz of a total duration of 150 ms (5V peak-to-peak amplitude)
-
Wait 20 ms (this part I know I can do )
-
Register the response signal by storing the voltages (or even just the analogRead values between 0 and 1023 to reduce the calculation time) on a SD card with a sampling frequency above 7kHz during 500 ms. I don't really need to reach a specific value for the sampling frequency, but I have to know it with the best possible precision.
I don't need to use the Arduino board to deduce the frequency from the response signal, this part will be done on a computer later if I manage to get the data.
For now, my only question is "Is this feasible with the technical specifications of a Arduino Uno?" I'll probably ask more questions later if it is, but before starting, it would be good to have a confirmation that I don't step into something impossible.
Thanks for your help
alnilam
alnilam:
Excite a sensor
What do you mean by "exciting" a sensor? What kind of sensor?
alnilam:
A frequency sweep from 2 to 3.5 kHz of a total duration of 150 ms (5V peak-to-peak amplitude)
You can use the Tone library for this (keep in mind that it will produce a square wave, not a sine wave). If you need a sine wave, use a computer with Audacity to produce it.
alnilam:
Register the response signal by storing the voltages (or even just the analogRead values between 0 and 1023 to reduce the calculation time) on a SD card with a sampling frequency above 7kHz during 500 ms.)
@7kHz, 500ms will give you 3500 samples, if you want a value between 0 and 1023 (10-bit), you'll need at least 2 bytes to store it (uint16_t). An SD card is pretty slow, so you'll need to buffer it, and write it to the SD after the 500ms of measurements, meaning that you'll need enough memory to store an array (list) of 3500 2-byte values → 7000 bytes or 7 KB. This is way more than the 2KB SRAM of the Arduino Uno, for example, so you'll need a Mega, 101, Zero or a different microcontroller. (Note that the latter two are 3.3V boards.)
Another thing to keep in mind is that the Arduino's ADC is not a 'real' ADC, making it slow, and inacurate at higher speeds. (Read more)
If the voltage you want to measure is AC (20-20kHz), I'd recommend using your PC's sound card with Audacity to record it. You can then save it as .WAV and convert it to text if you want to. (Google: "Sound card oscilloscope" for circuits and safety precautions.)
If the voltage has a DC component as well, I'd use a real oscilloscope. (If you have one, or if you can lend it from someone you know.)
Hello Pieter,
Thank you for your answers.
What do you mean by "exciting" a sensor? What kind of sensor?
My sensor is a vibrating wire piezometer (used to measure water pressure). With the frequency sweep, I make the wire vibrate at all the frequencies in the range (that's what I meant by "exciting", sorry if it's a bad translation from french), and after 20 ms, only the resonance frequency remains, which depends on the wire length, herself linked to the water pressure that I'm interested in.
keep in mind that it will produce a square wave, not a sine wave
I think a square wave will do the job for the excitation part.
If the voltage you want to measure is AC (20-20kHz), I'd recommend using your PC's sound card with Audacity to record it. You can then save it as .WAV and convert it to text if you want to. (Google: "Sound card oscilloscope" for circuits and safety precautions.)
If the voltage has a DC component as well, I'd use a real oscilloscope. (If you have one, or if you can lend it from someone you know.)
As it's field material, sometimes placed in areas with difficult access, the point of the manipulation was to skip the computer part and get the data on a smartphone via the bluetooth extension of the arduino (with an app that still has to be programed, but that's another story).
I'll read your link about ADCs and see more about other microcontrollers.
alnilam
Another thing to keep in mind is that the Arduino's ADC is not a 'real' ADC, making it slow,
The ADC on the Arduino is indeed a 'real' ADC. It gives an accurate digital representation of the voltage on the input, compared to a reference voltage.
The Arduino ADC does have its limitations, as do all ADCs.
7KHz is pushing the analog capabilities of the Arduino. Absolutely flat-out, without storing the data or doing anything with it, you can do 10KHz on the 16MHz Arduinos. With some trade-offs in precision, it is possible to go faster. (Of course, faster Arduinos like the Teensy can do much better.)
Storing to SD card is slower than you think. There is at least one "fast SD" library which might be able to get the performance that you need. But why store the data? Just run a FFT on it in real-time. 128 or 256 samples will be enough for an FFT.
There are also other libraries more suited to finding the fundamental frequency. I forget the name but I'm sure that it could be modified to look for a KHz signal if you have the analog readings.
Alternatively, a bit of analog signal conditioning can feed the analog signal into a digital input. Then you can count the cycles easily, making a "frequency counter".
"Excite" is the right word in English. It's just there aren't many sensors that need this kind of excitation.
Thank you for your answers. It's a very good start to know it's feasible.
I thought that the FFT would be more efficient on the computer, but I was thinking in terms of speed, not storage. Considering both parameters, it seems in fact more logical to do it in real-time.
I'll check for libraries to find the fundamental frequency.
alnilam
MorganS:
Alternatively, a bit of analog signal conditioning can feed the analog signal into a digital input. Then you can count the cycles easily, making a "frequency counter".
This seems like the easiest solution: just convert the sine wave to a square wave, and count the frequency with a digital pin (much faster than analog).
How to convert a sine wave to a square wave