TABLE OF CONTENTS FIGURES iii LIST OF ABBREVIATIONS iv CHAP 1: TOPIC OVERVIEW 1 1.1 Purpose of implementing the topic 1 1.2 Topic requirements 2 1.3 Research subjects 2 1.4 Implementation ideas 2 1.5 Expected results 3 CHAP 2: THEORETICAL BASIS 4 2.1 PIC mirocontroller 4 2.2 Rain sensor 6 2.3 Motor 7 CHAP 3: DESIGN AND CONSTRUCTION OF MODELS 8 3.1 Block diagram 8 3.1.1 Source block 9 3.1.2 Sensor block 10 3.1.4 Motor block 14 3.1.5 Display block 19 3.2 Designed on Proteus simulation software 22 3.3 Model design 24 CHAP 4: ALGORITHM AND CONTROL 27 4.1 Operating system 27 4.2 Algorithmic flow chart 27 CHAP 5: PRACTICE 28 5.1 Experimental process 28 5.2 Results 28 5.3 Conclusion 30 CHAP 6: CONCLUSIONS 31 6.1 Advantages 31 6.2 Disadvantages 31 6.3 Development 31 REFERENCES 32 CODE 33 FIGURES Figure 1.1 Drying rice paper 1 Figure 1.2 Clothesline 1 Figure 2.1 Microcontroller (PIC16F877A) Nagar, J. (2019, May 31) 4 Figure 2.2 PIC 16F877A pins Nagar, J. (2019, May 31) 5 Figure 2.3 Rain sensor 6 Figure 2.4 IC L293D 7 Figure 3.1 Block diagram 8 Figure 3.2 Components in the block 9 Figure 3.3 DC adapter 10 Figure 3.4 Rain sensor 11 Figure 3.5 PIC 16F877A 13 Figure 3.6 PIC 16F877A pins 13 Figure 3.7 GA12N20 15 Figure 3.8 IC L293D 16 Figure 3.9 L293D pins 17 Figure 3.10 Schematic diagram of L293D 17 Figure 3.11 LCD 1602 20 Figure 3.12 Presents the simulation steps on Proteus8.13 22 Figure 3.13 Layout of the diagram shows the systems wiring 23 Figure 3.14 Present 3D perspective 23 Figure 3.15 Printed circuit processing 24 Figure 3.16 PCB (behind side) 24 Figure 3.17 PCB (infront of side) 25 Figure 3.18 PCB (infront of side) 25 Figure 3.19 The model is nearly complete 26 Figure 3.20 Completed model 26 Figure 4.1 Algorithmic flow chart 27 Figure 5.1 Door closes when rainfall >40% 29 Figure 5.2 Operates in manual mode 29 Figure 5.3 Door opens when power is applied 30
Trang 1LIST OF ABBREVIATIONS iv
CHAP 1: TOPIC OVERVIEW 1
1.1 Purpose of implementing the topic 1
1.2 Topic requirements 2
1.3 Research subjects 2
1.4 Implementation ideas 2
1.5 Expected results 3
CHAP 2: THEORETICAL BASIS 4
2.1 PIC mirocontroller 4
2.2 Rain sensor 6
2.3 Motor 7
CHAP 3: DESIGN AND CONSTRUCTION OF MODELS 8
3.1 Block diagram 8
3.1.1 Source block 9
3.1.2 Sensor block 10
3.1.4 Motor block 14
3.1.5 Display block 19
3.2 Designed on Proteus simulation software 22
3.3 Model design 24
CHAP 4: ALGORITHM AND CONTROL 27
4.1 Operating system 27
4.2 Algorithmic flow chart 27
CHAP 5: PRACTICE 28
5.1 Experimental process 28
Trang 26.1 Advantages 31
6.2 Disadvantages 31
6.3 Development 31
REFERENCES 32
CODE 33
Trang 3Figure 1.1 Drying rice paper 1
Figure 1.2 Clothesline 1
Figure 2.1 Microcontroller (PIC16F877A) [Nagar, J (2019, May 31)] 4
Figure 2.2 PIC 16F877A pins [Nagar, J (2019, May 31)] 5
Figure 2.3 Rain sensor 6
Figure 2.4 IC L293D 7
Figure 3.1 Block diagram 8
Figure 3.2 Components in the block 9
Figure 3.3 DC adapter 10
Figure 3.4 Rain sensor 11
Figure 3.5 PIC 16F877A 13
Figure 3.6 PIC 16F877A pins 13
Figure 3.7 GA12-N20 15
Figure 3.8 IC L293D 16
Figure 3.9 L293D pins 17
Figure 3.10 Schematic diagram of L293D 17
Figure 3.11 LCD 1602 20
Figure 3.12 Presents the simulation steps on Proteus8.13 22
Figure 3.13 Layout of the diagram shows the system's wiring 23
Figure 3.14 Present 3D perspective 23
Figure 3.15 Printed circuit processing 24
Figure 3.16 PCB (behind side) 24
Figure 3.17 PCB (infront of side) 25
Figure 3.18 PCB (infront of side) 25
Figure 3.19 The model is nearly complete 26
Figure 3.20 Completed model 26
Figure 4.1 Algorithmic flow chart 27
Figure 5.1 Door closes when rainfall >40% 29
Figure 5.2 Operates in manual mode 29
Figure 5.3 Door opens when power is applied 30
Trang 4ADC Analog-to-Digital Converter
LCD Liquid Crystal Display
PIC Programmable Intelligent Computer
Trang 5CHAP 1: TOPIC OVERVIEW1.1 Purpose of implementing the topic
Nowadays, many households have traditional occupations that work with
products that require sunlight and avoid exposure to rainwater Or family members are busy with work and don't pay attention to the weather, leading to drying clothes outsideand getting wet in the rain Therefore, based on the above situation, design a drying rack system that automatically opens/closes when it rains
Figure 1.1 Drying rice paper
Trang 6Figure 1.2 Clothesline
1.2 Topic requirements
Design a model capable of detecting rain or snow and then display the amount of rain
on the screen If the amount of rain exceeds the allowed level, the door will
automatically close (open) The system has the ability to adjust between two modes: automatic or manual
1.3 Research subjects
The microcontroller has the function of reading the sensor and processing it to display
it on the screen and then control the motor to close or open the door according to the request
The rain sensor detects rain or snow falling on the sensor board and then sends a signal
to the microcontroller for processing
The LCD screen has the function of displaying the amount of rain after the
microcontroller processes the rain sensor and the system's operating mode
The motor has the function of receiving control signals from the microcontroller and then operating
1.4 Implementation ideas
Components include PIC 16F877A, rain sensor, LCD 1602, IC L293D, DC gearmotor Use the rain sensor to measure then display the rain percentage on the LCD thenset a certain rain level to control the rotary motor to close the door when it is equal to
or greater than the set rain percentage The system has two modes: automatic or
Trang 71.5 Expected results
When it rains, the percentage of rain will be displayed on the LCD If the rain amount is more than 40%, the door will automatically close in 6 seconds or if less, the door will automatically open We can use the push button to open/close the door when needed
Trang 8CHAP 2: THEORETICAL BASIS2.1 PIC mirocontroller
PIC is the abbreviation for Programmable Intelligence Computer and is a type
of microcontroller manufactured by Microchip Technology company (Figure 2.1 introduce about PIC 16F877A) Nowadays, PICs are developed strongly and widely because they have many functions integrated into them PICs are very popular with users because they are very flexible and can perform user-programmed tasks, helping
to save costs and work efficiently
Figure 2.3 Microcontroller (PIC16F877A) [Nagar, J (2019, May 31)]
Trang 9Figure 2.4 PIC 16F877A pins [Nagar, J (2019, May 31)]
Trang 10potential for the future It is small, easy to use, and packed with useful
functionality
2.2 Rain sensor
When the weather is rainy and sudden, if you do not have time to bring the items into the house or if the items are drying outside have not yet been brought in, the rain will get wet, affecting the quality of the product, causing a loss in price treat treat.However, the rain sensor will signal to help us in those cases
Rain sensors (Figure 2.3) are widely used to warn of rain or snowfall and will send an alert to the tracking device to request the door to be closed or opened They aremost commonly used in automatic drying racks
Figure 2.5 Rain sensor
Rain sensor uses in real life:
In agricultural activities, rain sensors help save water when detecting rainy
Trang 11 Installed in the car's wiper system, it detects the amount of water and then the system wipes the windshield to help the driver's visibility not be affected.
In the internal skylight system, rain sensors are incorporated Knowing the weather allows the house to remain airy during sunny days and damp during rainy ones
Smart clothes drying racks can collect clothes when it rains to prevent clothes from getting wet
[Brindley, K (2011)]
2.3 Motor
All DC and AC motors can rotate in both directions However, today DC motorsare more widely used and popular due to their high efficiency IC l293D ( Figure 2.4) has been invented with the ability to rotate in two directions in a simple way Besides, other functions can operate quickly used in robots, cars, etc…
Figure 2.6 IC L293D
Trang 13rain-Figure 3.7 Block diagram
The power block supplies power to the three sensor, control and display blocks The sensor block will receive signals from the outside and then send them to the control block The control block processes information and controls the operation of the motor block and display block
Trang 14Figure 3.8 Components in the block
Trang 15Figure 3.9 DC adapter 3.1.2 Sensor block
The rain sensor is responsible for detecting rain or snowfall, which can come into contact with water They are often placed outdoors such as roofs
Recommended: Rain sensor
The rain sensor consists of two parts:
Sensing pad: It is placed outdoors such as the roof, and is responsible for detecting rain when water falls on the Sensing pad
The electronic module includes four pins:
- VCC: connected to power (5V)
- GND: connected to ground (0V)
Trang 16- A0: output is analog signal.
- D0: output is digital signal
Trang 18Figure 3.12 PIC 16F877A pins
Trang 20Figure 3.13 GA12-N20
Use IC L293D to control the motor:
Using this L293D motor driver IC is very simple The IC works on the principle
of Half H-Bridge, let's not go too deep into what H-Bridge means, just know that H Bridge is a setup used to run the motor both in clockwise direction clockwise and counterclockwise As said earlier, this IC is capable of running two motors in any direction at the same time, the circuit to do this is as below
Trang 21Figure 3.14 IC L293D
Specifications:
Can control speed and direction
Motor voltage Vcc2 (Vs): 4.5V to 36V
Maximum peak motor current: 1.2A
Maximum continuous motor current: 600mA
Supply voltage for Vcc1 (vss): 4.5V to 7V
Transition time: 300ns (at 5V and 24V) [7]
Trang 22Figure 3.15 L293D pins
Trang 23Input 1 Directly control Output 1 pin Controlled by digital circuit
Output 1 Directly controls Output pin 1 Controlled by digital circuit Connected to
one end of motor 1
Ground The ground pin is connected to ground of the circuit (0V)
Ground The ground pin is connected to ground of the circuit (0V)
Output 2 Connected to another end of motor 1
Input 2 Direct control of Output pin 2 Controlled by digital circuit
Vcc2 (Vs) Connect to voltage pin to run motor (4.5V to 36V)
Enable
3,4
This pin turns on input pins Input 3 (10) and Input 4 (15)
Input 3 Direct control of Output pin 3 Controlled by digital circuit
Output 3 Connected to one end of motor 2
Ground The ground pin is connected to ground of the circuit (0V)
Ground The ground pin is connected to ground of the circuit (0V)
Output 4 Connected to another end of motor 2
Input 4 Directly controls Output pin 4 Controlled by digital circuit
Vcc2
(Vss)
Connect to +5V to enable IC function
[Lowe, D (2022)]
Trang 24High output voltage: > 2.4
Low output voltage: <0.4V
Power supply current: 350uA - 600uA
Operating temperature: - 30 - 75 degrees Celsius
Trang 25Figure 3.17 LCD 1602
Function of each LCD 1602 pin:
Pin number 1 – VSS: LCD ground pin
Pin number 2 - VDD: power supply pin for LCD, connected to VCC=5V of the control circuit
Pin number 3 - VE: adjusts the contrast of the LCD
- Digital pin 4 - RS: register select pin, connected to logic "0" or logic "1": +Logic “0”: Bus DB0 - DB7 will connect to the LCD's IR command register (in
"write" mode) or connect to the LCD's address counter (in "read" mode)
Trang 26+Logic “1”: Bus DB0 - DB7 will connect to the DR data register inside the LCD.
Pin number 5 - R/W: read/write mode selection pin (Read/Write), connected to logic "0" to write or connected to logic "1" to read
Pin number 6 - E: enable pin (Enable) After signals are placed on the DB0-DB7bus, commands are only accepted when there is an enable pulse of this pin as follows:
+ In write mode: Data on the bus will be transferred to the internal register bythe LCD when detecting a pulse (high-to-low transition) of the E pin signal + In read mode: Data will be output to DB0-DB7 by LCD when detecting a rising edge (low-to-high transition) at pin E and kept by LCD on the bus until pin E goes low
Pins 7 to 14 - D0 to D7: 8 lines of the data bus used to exchange information with the MPU There are 2 modes using these 8 bus lines: 8-bit mode (data is transmitted on all 8 lines, with the MSB bit being bit DB7) and 4-bit mode (data
is transmitted on 4 lines from DB4 to DB7 , MSB bit is DB7)
Pin 15 - A: positive source for backlight
Digital pin 16 - K: negative source for backlight
Trang 273.2 Designed on Proteus simulation software
Draw and simulate the system on Proteus software:
Figure 3.18 Presents the simulation steps on Proteus8.13
Trang 28Layout on Proteus: simulate the lines connecting components
Figure 3.19 Layout of the diagram shows the system's wiring
3D simulation of the implemented model
Trang 293.3 Model design
Circuit model: front and back of printed circuit board
Figure 3.21 Printed circuit processing
Figure 3.22 PCB (behind side)
Trang 30Solder components onto hard circuits
Figure 3.23 PCB (infront of side)
Figure 3.24 PCB (infront of side)
Trang 31Nearly complete model including all components
Figure 3.25 The model is nearly complete
Full model of all components and parts to complete:
Figure 3.26 Completed model
Trang 32CHAP 4: ALGORITHM AND CONTROL4.1 Operating system
After powering the system, the LCD screen displays the amount of rain based
on the sensor and the system is operating in automatic mode Currently the door will open (for 6 seconds) because there is no rain on the sensor After the sensor is exposed
to an amount of water greater than 40%, the door will close until it touches the travel sensor If you want to change the operating state of the system, you can use the push button to switch from automatic state to manual operation
4.2 Algorithmic flow chart
Present how the system works using an algorithm flow chart
Trang 33Figure 4.27 Algorithmic flow chart
CHAP 5: PRACTICE5.1 Experimental process
Step 1: Supply 5V power to the system
Step 2: The door will open because the rain sensor has not been supplied with water After providing a certain amount of water to the rain sensor, it will display on the LCD
if the rain amount is greater than 40%, the door will close
Step 3: Dry the water on the door sensor that will open
Step 4: Change the system's operating status with a button
Step 5: Turn off the power to turn off the system
5.2 Results
Door opening time is 1 second faster than expected
The engine speed is stable
Rainfall for opening and closing is in line with the set target
In manual mode, stable operation
Trang 34The system works when it rains:
Figure 5.28 Door closes when rainfall >40%
Manual operating status:
Trang 35Figure 5.29 Operates in manual mode
Power supply for the operating system:
Figure 5.30 Door opens when power is applied
5.3 Conclusion
The system operates stably and quickly However, the door opening time is faster than the target, so the door opening and closing time should be improved to increase the efficiency of the system
Trang 36CHAP 6: CONCLUSIONS6.1 Advantages
Cheap price, easy installation
The system is simple and easy to access and use
The rain sensor returns the value to the LCD quickly
6.2 Disadvantages
Opening and closing times are slow
If the rainfall is not greater than 40%, the door will still be open, affecting users
6.3 Development
The application adds a remote monitoring and control program on the phone using wifi so users can control at a distance
Trang 37nghiệp 4.0, IoT tổ ong Hà Nội: NXB Thông tin và Truyền thông.
Karpan, A (2021) The Internet of Things New York: Greenhaven Publishing LLC Lowe, D (2022) Electronics All-in-One For Dummies 3rd Edition New York: John
Wiley & Sons Inc
Nagar, J (2019, May 31) Components 101 Retrieved from
Trang 38Anh, T T (2018)
#include <Main.h>
#fuses NOWDT,NOPROTECT,PUT,NOLVP,HS
#use delay(clock = 8000000) //Tan so thach anh 8MHz
#define LCD_ENABLE_PIN PIN_D2
#define LCD_RS_PIN PIN_D0
#define LCD_RW_PIN PIN_D1
#define LCD_DATA4 PIN_D7
#define LCD_DATA5 PIN_D6
#define LCD_DATA6 PIN_D5
#define LCD_DATA7 PIN_D4
#define SWITCHLIMIT PIN_E2
#define BTCONTROL PIN_E0
#define BTMODE PIN_E1
#define TIMEOPEN 6000