22/03/2021 To 28/03/2021
1.Continue amplifier circuit tuning
After final tuning of the circuit, all the resistor values are shown in below.
R23 = 100 Ohms
RV1 (10k) = 0.5 Resistor ratio
RV2 (5k) = 0.3 Resistor ratio
R2 = 1k
R5 = 1k
R1 = 150 Ohms
R4 = 150 Ohms
RV3(10k) = 0.3 Resistor ratio
RV4 (100k) = 0.45 Resistor ratio
R3 = 1.2k
R12 = 1k
R13 = 1k
R14 = 10k
R15 = 10k
RV5 (10k) = 0.5 Resistor ratio
RV6 (22k) = 0.6 Resistor ratio
All the supply voltages pins of the amplifiers are connected with 100nF capacitors.
Final output node is connected with 1uF capacitor.
2.Atmega328P Microcontroller code improvement for thresholding output processed signal without errors
In this model, the output processed signal (smoothed 2nd derivative signal) was converted to voltage signal (0V - 5V range) using mathematical formula through the code. Then this voltage signal was sent through the positive voltage filter code. After that resultant signal was amplified by the code for easy drop detection algorithm. Finally, output signal was sent through the thresholding algorithm.
Tuned drop signals
1.Amplified drop signal with different flow rates (Read by the Atmega328p serial bus path)
2.Processed output signal (Read by the Atmega328p serial bus path)
3.Converted processed signal to voltage signal (Read by the Atmega328p serial bus path)
4.Signal that after go through the positive voltage filter
Choose Threshold Value
Processing code for new model
#include <MovingAverageFilter.h>
MovingAverageFilter movingAverageFilter(20);
MovingAverageFilter movingAverageFilter1(20);
MovingAverageFilter movingAverageFilter2(20);
float input;
float output;
float caltime;
float initialarray[2] = {0.0,0.0};
float currentarray[2];
float dy;
float dt;
float derivative_output;
float output1;
float initialarray1[2] = {0.0,0.0};
float currentarray1[2];
float dy1;
float dt1;
float derivative_output1;
float output2;
float output3;
float threshold=475.0;
int peakcount=0;
int k=0;
int PersonID = 1;
float peak = 0.0;
float time1=0.0 ;
float time2=0.0;
float time3= 0.0;
float voltage = 0.0;
float zero= 0.0;
float timegap=0.0;
float Volume =0.0;
float Flowrate = 0.0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
input = analogRead(A0);
//float z = (5.0*input)/1023;
caltime = millis();
output = movingAverageFilter.process(input); // here we call the fir routine with the input. The value 'fir' spits out is stored in the output variable.
currentarray[0] = output;
currentarray[1] = caltime;
dy = currentarray[0]- initialarray[0];
dt = currentarray[1] - initialarray[1];
derivative_output = dy/dt;
initialarray[0] = currentarray[0];
initialarray[1] = currentarray[1];
output1 = movingAverageFilter1.process(derivative_output*150);
currentarray1[0] = output1;
currentarray1[1] = caltime;
dy1 = currentarray1[0]- initialarray1[0];
dt1 = currentarray1[1] - initialarray1[1];
derivative_output1 = dy1/dt1;
initialarray1[0] = currentarray1[0];
initialarray1[1] = currentarray1[1];
output2 = movingAverageFilter2.process(derivative_output1*150);
output3= output2*75;
voltage = (5.0*output3)/1023;
if (k!=1){
if(voltage > 2.5){
//peak = threshold;
k= 1;
time1=millis();
}
}
if(k==1){
if(voltage < 2.3){
peakcount = peakcount +1;
k=0;
timegap = (time1-time3)/1000;
time3 = time1;
Volume= Volume+0.02517;
Flowrate = (0.02517*3600.0)/timegap;
}
}
if (voltage>0.0){
Serial.println(voltage);
}
else{
Serial.println(zero);
}
}
Atmega328p microcontroller code file
5.Final outputs showing with original drop signal simultaneously
Drop Count
Flow Rate