Difference between revisions of "In Water Vel Sensor"

From BoSL Wiki
Jump to navigation Jump to search
Line 106: Line 106:
  
 
Concerningly the peak height is at about 90 kHz, and the predominant frequency when measured with an oscilloscope is 40 kHz.
 
Concerningly the peak height is at about 90 kHz, and the predominant frequency when measured with an oscilloscope is 40 kHz.
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
  
 
== 27th November 2019 ==
 
== 27th November 2019 ==

Revision as of 23:50, 26 November 2019

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.


Experiment design.png


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).

Siliscop 40khz square wave.jpg Arduino detetcted wave.png


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.

Schematic diagram.png


Code.png


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.

Bouncing back.png

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.

LM324N Waveform in Slew Limited Domain

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:

Fast ADC Code.png

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.

Amplification Circuit for Ultrasonic Receiver

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

Arduino Frequency Measurement

To measure frequency an DFT was performed on a 128 size sample at 215 kHz of the amplified ultrasonic receiver signal.The sample frequency was chosen as it was the highest stable, and the sample size as this was the limit of the ATmega382p's memory.

Arduino FFT of Ultrasonic Receiver Signal

The y-axis height represents strength of that component frequency, and the x-axis the frequency bins, where eight bins corresponds to 1.7 kHz

Concerningly the peak height is at about 90 kHz, and the predominant frequency when measured with an oscilloscope is 40 kHz.






27th November 2019

Some thought was conducted into the feasibility of direct frequency measurement using the ATmega328 and extracting the Doppler shift digitally.

The velocity is given by the equation: v = c/2 (fd/f) cos(θ), where c is the speed of sound, fd is the Doppler shift, f is the emitted frequency, and θ is the angle between the flow and sensor.

Let us assume that the sensor is parallel to the flow (θ = 0). By Nyquist-Shannon sampling theory, to detect a frequency at f we need the ATmega328p to sample at 2f. Applying a DFT to this sample gives a frequency resolution Δf of 2f/N, where N is the number of samples. Therefore, making the substitutions fd = 2f/N, θ = 0, we get: Δv = c/2 (2f/(f*N)) = c/N