In Water Vel Sensor
This section documented our journey to develop a low-cost water velocity sensor based on doppler effect!
20th November 2019
So the first task we are going to try is to use Arduino to generate 40 kHz square wave and emit that signal by using a ultrasonic transducer.
By facing another same transducer to the one emitting the ultrasonic signal, we can successfully detect that signal.
Figures below show the generated square wave from the emitting transducer (measured by an oscilloscope), and the detected wave signal from the receiver transducer (by using AnalogRead).
The figure here shows how we wire up the transducers with Arduino to conduct this quick test. The code we used is also attached here to show you how to use Arduino to generate a certain frequency.
21th November 2019
What are we going to try today is to place the two transducers next to each other and facing the same direction.
One emit the signal to a metal wall, and the receiver to detect the signal bounce back.
Multiple op-amps will be used to strength the signal to make it strong enough for Arduino to detect.
25th November 2019
For the arduino to effectively read the low amplitude high frequency signals it is going to need some assistance via external circuitry.
We tested an non-inverting op-amp design based on the LM324. This proved to have challenges reproducing the high frequency signals and after some diagnosis, we determined that the slew rate of the LM324 was too low.
The image above shows the limited slew rate experienced from the LM324N. In this domain the waveform appear as linear as the OpAmp attempts to match the proper signal. It demonstrated a slew rate of about 0.5 V / μS. To overcome this we will need to replace the LM324N with a better OpAmp.
By default the Arduino ADC sample frequency is rather slow at 45 kHz. For our application we will need much faster sampling rates. Fortunately, the clock divider which the ADC runs on (default 32x) is user settable. In testing various values for this, a sample rate of 615 kHz was able to be achieved. <1>
This was accomplished via the following code:
26th November 2019
We tested out some LM883N and NE5532AP OpAmps to see if they performed better than the LM324 (they have a slew rating of ~5 V / μS so they should). Both worked much better than the LM324 being able to reproduce the waveform however, we found that the NE5532AP was better at higher gains.
It was found that the circuit below performed well at amplifying the AC signal of the receiver resonator.
The gain can be adjusted through resistors Ra and Rb via the formula: Gain = 1 + Ra/Rb
Issues were faced where very high noise was present on the output of the op-amp. Some investigation revealed that this was due to the same Arduino driving the 40 kHz squarewave as powering the op-amp. This limited the ability to receive low amplitude signals and made it difficult to detect the reflected ultrasonic waves. A temporary solution to this was to use separate Arduinos for the transmitted and receiver.
A noise profile was obtained by having the ultrasonic receiver covered and placed such that no ultrasonic frequencies would be measured by it. The op-amp output was then measured. Below are the measurements for the two-Arduino setup vs the one-Arduino setup.
The noise is improved in the two-Arduino setup however there is still a significant ammount, it may be necessary to make a PCB with better noise isolation for test which require higher sensitivity.
Arduino Sample Frequency
<1> From doing more test it appears that not all Arduinos are able to sample at the 615 kHz rate, a more reliable max appears to be 215 kHz.
Testing the values of the clock divider registers ADPS2, ADPS1, ADPS0, the following table was made indicating about the various sample frequency on a 16 MHz 5 V ATmega382P (Arduino Uno).
ADPS2 | ADPS1 | ADPS0 | Sample Frequency (kHz) | Working |
---|---|---|---|---|
0 | 0 | 0 | 325 | No |
0 | 0 | 1 | 325 | No |
0 | 1 | 0 | 215 | Yes |
0 | 1 | 1 | 125 | Yes |
1 | 0 | 0 | 66 | Yes |
1 | 0 | 1 | 35.6 | Yes |
1 | 1 | 0 | 17.6 | Yes |
1 | 1 | 1 | 8.9 | Yes |