Professional Documents
Culture Documents
EE034-4-2-SNA
SENSORS AND ACTUATORS
Building Management Systems (BMS)
APU2F2002EEE-ME
INTRODUCTION..................................................................................................................................................1
DISCUSSION.......................................................................................................................................................36
CONCLUSIONS..................................................................................................................................................38
REFERENCES.....................................................................................................................................................39
APPENDIX...........................................................................................................................................................41
ii
APU2F2002EEE-ME TP054785
LIST OF FIGURES
iii
APU2F2002EEE-ME TP054785
Figure 34:(Stored readings in Excel).......................................................................................30
Figure 35:(Front panel results 1)..............................................................................................31
Figure 36:(Front panel results 2)..............................................................................................32
Figure 37:(Front panel results 3)..............................................................................................33
Figure 38:(Front panel results 4)..............................................................................................34
Figure 39:(Front panel results 5)..............................................................................................35
Figure 40:(Half full/Half empty issue).....................................................................................37
Figure 41: (HC-SR04 Datasheet, (elecfreak,2020)).................................................................41
iv
APU2F2002EEE-ME TP054785
LIST OF TABLES
v
APU2F2002EEE-ME TP054785
INTRODUCTION
Building Management System (BMS) is needed for large areas and large number of
floors in modern buildings, which makes it difficult to monitor all spaces and floors. BMS is
also needed because there are a large number of electrical and mechanical equipment in one
building, including air conditioning, lighting, elevators, and generators, which makes it
difficult to operate, maintain, and monitor the performance of these equipment and to know
whether these equipment are in a working or malfunctioning state or if they perform the
functions which is assigned to them in proportion to the energy spent on operating this
equipment. Furthermore, BMS can also Increase the investors profits for commercial and
industrial buildings by reducing the operating costs of these buildings. From here it comes to
light the need for building management systems.
For example, it can decide when is the appropriate time for lighting work, the right
time to make air conditioning or heating, the appropriate time for the temperature to be 24
degrees and the time for the temperature to be 20 degrees, the time in which a device
malfunction occurred inside the building.
1
APU2F2002EEE-ME TP054785
And also, it can decide where the place that needs lighting, the place that needs air
conditioning or heating, the place where a device malfunctions. (Smith, 2020)
On a daily basis, we see in large organizations that the garbage bins are full or some
garbage that distorts the surrounding environment, and causes the spread of unpleasant odors,
bacteria and harmful gases, and this in turn leads to the spread of diseases and epidemics,
hence the idea of creating a smart garbage monitoring system in order to eliminate this
problem or reduce it as much as possible.
Through the studies of the causes of this problem, It is found that when garbage
collector pass through the areas in a building according to a schedule for garbage collection,
sometimes some garbage bins are not full, and therefore there is no need to empty them, but
the employee in charge of garbage collection does not know this, and this leads to waste of
efforts and loss of time, so this project is developing a model for a system that works to alert
the main office that the garbage bin is full. This is done by placing Ultrasonic sensors in the
garbage bin to monitor the garbage status, and according to the messages issued from these
sensors, the main office sends a notification of the garbage location to the garbage collector,
to go to the garbage place. (author, 2020)
2
APU2F2002EEE-ME TP054785
Working Voltage DC 5 V
Working Current 15mA
Working Frequency 40Hz
Max Range 400cm
Min Range 2cm
Measuring Angle 15 degree
Trigger Input Signal 10uS TTL pulse
Echo Output Signal Input TTL lever signal and the range in
proportion
Dimension 45*20*15mm
3
APU2F2002EEE-ME TP054785
Trigger and Echo are the I / O pins of this sensor, thus they can be connected to the I /
O pins of the Arduino microcontroller. When the receiver detects the return wave, the Echo
pin will go high for a certain period of time which will be equal to the time it takes for the
wave to return to the sensor. Ultrasonic HC-SR04 offers distance sensing capabilities from
2cm to 400cm, and accuracy ranging from 3mm. (Pilling, 2019)
The figure 5 below basically shows the HC_SR04 sensor and how the ultrasonic
works. For the working principles of the ultrasonic when the sound waves are sent through
the Trig port, and after the waves collide with the object, they are reflected and received
through the Echo port, and through the time between the waves being sent and the time they
are received, the distance is calculated.
4
APU2F2002EEE-ME TP054785
5
APU2F2002EEE-ME TP054785
Where the speed is constant and the speed of sound is 340 meters per second, but in this
assignment the signal is calculated in centimeter, so the speed of sound will be equal to
0.0340 centimeter, but it is noticed that the sensor will send and receive a signal and this
allows the distance value to be doubled so we need to divide it by 2 to make the equation in
the final form as shown below in equation 2. (PC Services - Circuit Ultrasonic Range
Sensing, 2018)
time
Distance= ∗speed …………….. (Equation 2)
2
6
APU2F2002EEE-ME TP054785
The working equation for HC-SR04 Ultrasonic sensor is shown above in equation 2 which it
has been tested based to the data sheet and simulated by using LabView software. The
expected graph of the ULTRASONIC characteristic will be a linear line as shown in figure 6
below. Because time and distance have a proportional relationship to each other since
whenever the distance increases the time will increase. Also, this relationship is shown from
the equations above.
t ∝ s ………….. (Equation 3)
The most important applications of Ultrasonic sensor are found in submarines and radars,
collision avoidance robots.
The design of ultrasonic signal simulated system by using LabVIEW software is shown in
figure 7 below. By using LabView the time values were simulated by using the Random
7
APU2F2002EEE-ME TP054785
Number function. And then the random number was multiplied by 23500 which it is the
maximum time taken range (For 400cm) for a signal for this sensor in microseconds, the
following mathematical equation shows how it was calculated:
400∗2 400∗2
Time= = =23529 μs …………….. (Equation 4)
speed of sound 0.034
Since the range of the HC-SR04 sensor is from 2cm to 400cm, the time values which are
equal or less than 2cm was ignored to get only the distance range from 2cm to 400cm. Which
it is calculated to be 117.65 microseconds by using equation 5 below.
2∗2 2∗2
Time= = =117.65 μs …………….. (Equation 5)
speed of sound 0.034
8
APU2F2002EEE-ME TP054785
As can be seen from figure 7 above an Array Size function was placed and connected to the
N terminal of the For loop. And a Search 1D Array function was used to look for the zero
values from the case structure. And after that a Delete From Array function was placed to
delete the 0 values, so it won’t appear in the final array. Lastly, a Sort 1D Array function was
used to arrange the array in ascending order. These steps were done twice. One for the
Distance values and one for Time Taken values. Two Arrays was placed to store the data of
Distance and Time Taken.
The following figure 8 shows the ultrasonic sensor formula:
9
APU2F2002EEE-ME TP054785
10
APU2F2002EEE-ME TP054785
15 13518.7 229.818
16 14610.2 248.373
17 14628.6 248.686
18 14789.2 251.416
19 15093 256.581
20 18233.1 309.963
21 18410.6 312.98
22 18458.7 313.797
23 18530.4 315.017
24 21110.7 358.882
25 21380.6 363.471
26 21703.1 368.952
27 22661.6 385.247
28 22693.6 385.791
29 22800.9 387.616
30 22980.8 390.673
25000
20000
15000
Time (µs)
10000
5000
0
6 8 1 9 8 5 6 8 6 1 8 7 1 7 6
28 228 607 40 27 .6 62 81 68 58 .9 01 47 24 61
6.0 7. 2. 18. 34. 173 82. 29. 48. 56. 312 15. 63. 85. 87.
4 5 6 1 1 1 2 2 2 3 3 3 3
Distance (cm)
The figure 10 above demonstrates the Ultrasonic sensor graph by using the simulation with
formula from the data sheet.
11
APU2F2002EEE-ME TP054785
12
APU2F2002EEE-ME TP054785
13
APU2F2002EEE-ME TP054785
As shown from the circuit diagram of the system in figure 12 above the material used in the
hardware of this system is as follows:
1. Computer / Laptop.
2. Microcontroller (Arduino uno).
3. USB cable to connect Arduino to the computer.
4. ULTRASONIC distance sensor HC-SR04.
5. Red LED.
6. 220Ω resistor.
7. Female to Female jumper wires.
8. Male to Male jumper wires.
14
APU2F2002EEE-ME TP054785
15
APU2F2002EEE-ME TP054785
Figure 15:(Code 1)
The Ultrasonic sensor was connected to the Arduino as shown in the hardware connections.
The code shown above in figure 15 is used to define for the Arduino that pin 4 is connected
16
APU2F2002EEE-ME TP054785
to the Trigger and pin 2 is connected to the Echo port. Also, the constant MAX_DIST is used
to define that the maximum length of the garbage can is 20 cm (20*58 = 1160 µS pulse).
The code in Figure 16 above is used for the Trigger pin to tell the sensor to range-find. The
code Serial.begin(9600) is used to set the serial monitor to view the sensor output.
17
APU2F2002EEE-ME TP054785
The code in Figure 17 above is used to hold the Trigger pin for 10 microseconds and for the
Echo pin to wait for the reflected pulse. For the equation which includes the constants t1 and
t2 is to measure how long the Echo pin was held high (pulse width). Finally, for the cm
equation is to calculate the distance in centimeters as shown from the following mathematical
equations:
18
APU2F2002EEE-ME TP054785
In figure 18 above an equation was set to minus the measured distance from 20 cm because in
this case if there is no trash in the can the distance measured will be maximum (20cm) which
wanted to be displayed as ZERO which means it is empty as shown from the following
mathematical equations:
When printing out the results an IF Statement was used. First statement in any case
the measured distance is out of range (higher than 20cm even if the distance is limited to
20cm only but sometimes the Ultrasonic gives false readings) the printed result will be
ZERO, so we don’t get a negative value from equation 9 above. Second statement is basically
to print any readings passes the first condition.
NOTE:
Finally, a delay code was set to delay 200 microseconds before the next measurement.
19
APU2F2002EEE-ME TP054785
The idea of creating a smart garbage monitoring system has come in order to reduce
or even eliminate the garbage can that distorts the surrounding environment and causes the
spread of bacteria and harmful gases and leads to spread of diseases and epidemics. By
detecting the trash level in the garbage can which is done by using ultrasonic sensor
whenever the garbage bins are full or not full the management or the garbage collector will
get notifications about the trash status whether if there is need to empty them or no need and
according to the messages issued from these sensors, the main office sends a notification of
the garbage location to the garbage collector, to go to the garbage place. This leads to save
efforts and time as well, so basically this project is developing a model for a system that
works to alert the main office that the garbage bin is full and lock up the garbage can.
20
APU2F2002EEE-ME TP054785
To simulate the trash level and to test the performance of the system a paper balls
were used to provide a constant rising level by each ball. Consequently, the readings obtained
from this experiment were more reliable.
Figure 21 below shows the paper balls used in the system to simulate the trash level.
Thirty paper balls were thrown into the bin one by one and the readings of each throw were
stored in excel software by LabView. This thirty balls experiment was done twice to get an
accurate and precise reading results.
A red LED was used in the system as an actuator so whenever the trash level is
maximum the red LED will be turned ON. This was implemented so other people in the
building will know that the garbage can is full. The LED was connected in series with 220-
ohm resistor since the LED cannot survive the power supply voltage directly which it is 5
volts.
21
APU2F2002EEE-ME TP054785
22
APU2F2002EEE-ME TP054785
Below are some pictures of the prototype designed while taking the readings:
23
APU2F2002EEE-ME TP054785
24
APU2F2002EEE-ME TP054785
Figure 27 above demonstrates the LabView front panel of the system and as can been
seen it is designed to do the needed process of the system in a simple an efficient way
(Simplicity is the ultimate sophistication).
Three While Loop functions were used in the system each one has its own specific
timing and they cannot be merged together. The larger Loop is used for the main system with
Visa tools and functions and it is implemented to the prototype designed for real time
readings by using the Ultrasonic sensor ( Garbage can A) . Second Loop is for simulating the
other can (Garbage can B) by using a Random Number function for the trash level with a
25
APU2F2002EEE-ME TP054785
Time Delay function by 5 seconds. Lastly, the smallest While Loop basically was designed to
show the exact real time and date with Wait timer function by 100 milliseconds.
Figure 28 above demonstrates the block diagram of this system in LabView which it
is designed to get the readings from the Arduino software since we didn’t have the ability to
get a DAQ device to collect the readings from the HC-SR04 sensor.
Firstly, the main While loop shown above is implemented for real time Garbage can
A, where a VISA Clear function was used to clear the input and output buffers of the device
and VISA Open and VISA Read functions were used to collect the information from the
Arduino. The data will be collected as a string values because of this a String To Number
converter function was used to display the numbers in a Numeric Indicator. The Numeric
Indicator was replaced with a tank to give simulations as it really happening.
26
APU2F2002EEE-ME TP054785
Lastly, a Boolean LED was added and set to be ON whenever the trash level is equal
or higher than 14 centimeters. Boolean LED state is connected with a case structure to easily
display the locker state.
Figure 29 above demonstrates the default simulations for Garbage can B. The trash
level is simulated by using Random Number function and then it was multiplied by 20 to
produce a number from 0 – 20 centimeters (Maximum level for trash is 20cm). Then a
Boolean LED is placed and controlled with a comparison condition. Stated to be turned ON
whenever the trash level is equal or higher than 14 centimeters. A case structure is basically
used to display the locker state.
27
APU2F2002EEE-ME TP054785
Figure 30 above demonstrates the smallest while loop. This loop is used to get the real
time and date and display them in a string indicators as a decoration. This was done by
placing Get Time/Date String function and connected to two constant string indicators. A
True/False Boolean function is placed and connected to display the seconds for the time if
needed (True with seconds/False without seconds).
Figure 31 above demonstrates the main system with some modifications. This
different system is designed to only store the readings in an Array function to plot the Graph.
This process was done by placing a Bundle function connected with an Array function to
store the data. Shift Registers were used for the indexing tunnel with the While Loop.
28
APU2F2002EEE-ME TP054785
Figure 32 below shows the LabView front panel of the system designed.
29
APU2F2002EEE-ME TP054785
No. No. of Paper balls Trash level (cm) Locker state LED state
1 0 0 Unlocked OFF
2 0 0 Unlocked OFF
3 1 0 Unlocked OFF
4 2 0 Unlocked OFF
5 2 0 Unlocked OFF
6 3 0.28 Unlocked OFF
7 4 0.21 Unlocked OFF
8 4 0.28 Unlocked OFF
9 5 2.83 Unlocked OFF
10 5 2.83 Unlocked OFF
11 6 3.21 Unlocked OFF
12 6 3.21 Unlocked OFF
13 6 3.32 Unlocked OFF
14 7 9.03 Unlocked OFF
15 7 9.03 Unlocked OFF
16 8 8.21 Unlocked OFF
17 8 8.26 Unlocked OFF
18 8 8.26 Unlocked OFF
19 9 7.66 Unlocked OFF
20 9 7.66 Unlocked OFF
21 10 7 Unlocked OFF
22 11 7.52 Unlocked OFF
23 11 7.59 Unlocked OFF
24 11 7.59 Unlocked OFF
25 12 9.24 Unlocked OFF
26 12 9.24 Unlocked OFF
27 12 12 Unlocked OFF
28 13 13.24 Unlocked OFF
30
APU2F2002EEE-ME TP054785
31
APU2F2002EEE-ME TP054785
Graphs
32
APU2F2002EEE-ME TP054785
The figures below outline some results of the LabView front panel of the system designed.
33
APU2F2002EEE-ME TP054785
34
APU2F2002EEE-ME TP054785
35
APU2F2002EEE-ME TP054785
36
APU2F2002EEE-ME TP054785
37
APU2F2002EEE-ME TP054785
DISCUSSION
In this system a HC-SR04 Ultrasonic sensor is used as a main element to sense and
detect the trash level, basically by sending a high-frequency waves which collides with an
object and then bounce back in an echo form. One important foundation thing in dealing with
this type of sensors is the need to know the speed of these waves and the difference between
the transmission time and the return time of these waves.
An interesting observation from this experiment that ultrasonic sensor cannot detect
how many individual objects. It can only state how long it took the sound waves sent out to
bounce back. It will only measure the closest object.
In addition, based on confirming the information provided with the working principles
from the data sheet, the graph in figure 1 demonstrates the linear relationship between
distance and time. When distance between the sensor and an object increases the time needed
for the waves sent to bounce back will increase. This directly confirms the operating
principles of this HC-SR04 ultrasonic sensor. And these foundations are a recall of Newton's
law:
One of the issues were faced during conducting this system is shown in figure 33. The
graph shows several points having a deviation because the number of paper balls thrown in
the bin has increased but the trash level did not increase and even at some point has
decreased, this is because the sensor measuring angle is 10 -15 degrees (ultrasonic
specifications shown in table 1), so basically the sensor sends out waves in a cone shape, so
only the balls within the cone will bounce back the waves and it will be detected. As a rule,
this issue will increase occasionally when covering larger bins.
38
APU2F2002EEE-ME TP054785
For further improvement a locker should be added and used as an actuator to lock the
garbage can whenever the trash level is high. So, inconsiderate people cannot through the
trash recklessly this is to avoid distorting the surrounding environment, and the spreading of
unpleasant odors. Only one actuator was used in this prototype designed of this system to
prevent further complexity of the system flow.
39
APU2F2002EEE-ME TP054785
CONCLUSIONS
This waste monitoring system designed does not only monitor but also can control
and do actions, as in this system there are two actuators which are Locker and Red LED.
These two actuators operate as an indicators for the trash level on the garbage can.
In conclusion, it has been noticed that the results from this experiment are logical and
as expected with some minor errors and a recommendations to these errors were explained.
Altogether, through this assignment the characteristics of Ultrasonic sensor has been
understood, and the results were demonstrated by using LabView software and tabulated in
excel.
40
APU2F2002EEE-ME TP054785
REFERENCES
1. author:, M., 2020. Smart Garbage Monitoring System Using Internet Of Things
(IOT). [online] Instructables. Available at: <https://www.instructables.com/id/Smart-
Garbage-Monitoring-System-Using-Internet-of-/> [Accessed 3 September 2020].
6. Pilling, D., 2019. Making A Better HC-SR04 Echo Locator. [online] David Pilling's.
Available at: <https://www.davidpilling.com/wiki/index.php/HCSR04> [Accessed 11
September 2020].
41
APU2F2002EEE-ME TP054785
42
APU2F2002EEE-ME TP054785
APPENDIX
LINK: https://www.electroschematics.com/wp-content/uploads/2013/07/HCSR04-datasheet-
version-1.pdf
43
APU2F2002EEE-ME TP054785
ARDUINO CODES:
const int TRIG_PIN = 4;
const int ECHO_PIN = 2;
const unsigned int MAX_DIST = 1624;
int data;
void setup() {
pinMode(TRIG_PIN, OUTPUT);
digitalWrite(TRIG_PIN, LOW);
pinMode(13,OUTPUT);
Serial.begin(9600);
}
void loop() {
unsigned long t1;
unsigned long t2;
unsigned long pulse_width;
float cm;
digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);
while ( digitalRead(ECHO_PIN) == 0 );
t1 = micros();
while ( digitalRead(ECHO_PIN) == 1);
t2 = micros();
pulse_width = t2 - t1;
cm = pulse_width / 58.0;
cm = 28 - cm;
44
APU2F2002EEE-ME TP054785
else
{
Serial.print(cm);
Serial.print("\n");
else
{
digitalWrite(13,0);
}
}
delay(200);
}
45