Software Analysis - Program for consecutive data
In
software part there are three section; Turbidity Sensor, Low Level Water Sensor
and High Level Water Sensor. Basically, all three sections are same from the
reading analogue voltage the condition can be made. There are almost no
problems for Turbidity Sensor and Low Level Water Sensor because the voltage
taken from the reading is stable which means if the voltage is below than
certain value for example half than the program will be executed. In fact the
voltage taken from the reading is exactly as the output situation if the water
is below than the low level rods, than the voltage will be below than half.
Similarly with the turbidity sensor if the voltage reading is below than
certain point than its mean that the water is contain pollution.
But
the case is difference with High Level Water Sensor. Unlike the other reading
measurement, for high level sensor the reading is unstable. Supposedly the
condition to execute a program (Stop Inlet Motor) is when the reading is above
than half which means that the water has touches the High Level rod. But
suddenly, the reading will jump above than half although the water has not
touched the High Level rod yet. The value taken from the analogue voltage
reading is unstable. When the water exactly touch the High Level sensor the
reading will showed six to ten consecutive value that above than half.
Therefore
the previous coding needs to be changed to adapt to the situation that
unstable. The problem is not from the hardware part (Rod Level Sensor) but the
problem is in the condition when making the program to stop the Inlet Motor.
4.3.1 Solution for Software Problem
·
First
step to do is to analyse the requirement for solution. From the data of the
analogue voltage reading, identified what and when the program need to be
executed. Table below will show an example of reading when REFILL process been
done.
Voltage reading
with water condition
Reading Taken
|
Reading Value(V)
|
Condition
|
1
|
1.05
|
Water below High Level
|
2
|
1.70
|
Water below High Level
|
3
|
2.75
|
Water below High Level
|
4
|
0.19
|
Water below High Level
|
5
|
3.34
|
Water below High Level
|
6
|
0.83
|
Water below High Level
|
7
|
2.57
|
Water above High Level
|
8
|
2.31
|
Water above High Level
|
9
|
2.05
|
Water above High Level
|
10
|
2.58
|
Water above High Level
|
11
|
2.09
|
Water above High Level
|
12
|
2.47
|
Water above High Level
|
·
From
the table above notice that at reading taken number 5 the reading value is 3.34
V although the water had not touch the High Level rod yet
·
The
water start touching the High Level rod at reading taken number 7 until 12
ranging from 2.05 V(min. Value) up to 2.58
V(max. value).
·
Number of
consecutive is 6.
·
After the all
the requirement for the solution have been identified start draw a flow chart
Solution Flow
Chart
·
From
the flow – chart above there are three checkpoints P1, P2 and P3. At checkpoint
P1 the process inside the loop will continuously repeated until x = 1
·
At
checkpoint P2 the value of analogue read will be filtered if the value is in
the range from 2.05 V (min. Value) until 2.58
V (max. value) then the counter will be increasing by one. Else if the value is
out of the range the counter will be reset to zero.
·
At checkpoint P3
is the condition to get out from the loop. If the counter equal to six which
means the value is in the range for six consecutive than x equal to zero. When
x equal to zero the checkpoint at P1 will be terminated and the Inlet Motor
will be stopped. Else if the counter not equal to zero it will check the
reading back.
·
The table below
will demonstrate how the flow – chart works.
Trace Table
P1
|
P2
|
P3
|
Motor
|
√
|
1.05
|
0
|
ON
|
√
|
1.70
|
0
|
ON
|
√
|
2.75
|
1
|
ON
|
√
|
0.19
|
0
|
ON
|
√
|
3.34
|
1
|
ON
|
√
|
2.05
|
2
|
ON
|
√
|
2.57
|
3
|
ON
|
√
|
1.05
|
0
|
ON
|
√
|
2.05
|
1
|
ON
|
√
|
2.57
|
2
|
ON
|
√
|
2.31
|
3
|
ON
|
√
|
2.05
|
4
|
ON
|
√
|
2.58
|
5
|
ON
|
√
|
2.09
|
6
|
OFF
|
X
|
2.47
|
–
|
–
|
- · Below is the adjusted coding for the solution of the problem.
void
loop() {
int y=1;
int cntVolt=0;
while(y!=0){
// Program to
read Analogue Voltage and Start INLET Motor
int HighValue
= analogRead(A2);
float voltageHigh = HighValue
* (5.0 / 1023.0);
Serial.print("High
Level Reading = ");
Serial.println(voltageHigh);
digitalWrite(Inlet, HIGH);
delay(1000);
//Filter value
that in range between 2.05 ~ 2.58
if ((voltageHigh<2.59)
&& (voltageHigh>2.04)){
cntVolt++; // count increase by 1
if (cntVolt==6){
y=0; // if count =
6, STOP the LOOP
}
}
// Value that
out of range between 2.05 ~ 2.58
else if
((voltageHigh>2.58) || (voltageHigh<2.04)){
cntVolt = 0; // RESET the count to zero
}
digitalWrite(Inlet,
LOW); // STOP the
INLET Motor
}
Next Week we finalized our project..