Upload
hazmi-hanif
View
219
Download
0
Embed Size (px)
Citation preview
7/27/2019 PR14_DD
http://slidepdf.com/reader/full/pr14dd 1/8
Created by Cytron Technologies Sdn. Bhd. – All Rights Reserved 1
OVERVIEW
This document describes the development of CytronTechnologies DIY (Do It Yourself) Project No.14(PR14). This project will use PIC16F876A(microcontroller) to control the alarm system (buzzer & LED) with a PIR Sensor (Motion Detector). Circuitschematic and PIC source code will be provided.
PR14
FEATURES
PIC16F876A- 8-bit microcontroller with 22 I/O- operate with 5V supply- operating speed 20MHz
Motion Detector (PIR Sensor)- The unit output is high whenever human’s
motion is detected
Alarm System: Motion Detector
Version 1.2
Aug 2008
Cytron Technologies Sdn. Bhd.
Information contained in this publication regarding device applications and the like is intended through suggestion only and may be superseded byupdates. It is your responsibility to ensure that your application meets with your specifications. No representation or warranty is given and no liability is
assumed by Cytron Technologies Incorporated with respect to the accuracy or use of such information or infringement of patents or other intellectual
property rights arising from such use or otherwise. Use of Cytron Technologies’s products as critical components in life support systems is notauthorized except with express written approval by Cytron Technologies. No licenses are conveyed, implicitly or otherwise, under any intellectual
property rights.
7/27/2019 PR14_DD
http://slidepdf.com/reader/full/pr14dd 2/8
ROBOT . HEAD to TOE
PR14 – Alarm System: Motion Detector
Created by Cytron Technologies Sdn. Bhd. – All Rights Reserved 2
SYSTEM OVERVIEW
GENERAL DESCRIPTION
Several models of PIR (Passive InfraRed) sensors are
available in Cytron Technologies. There have two typeof PIR sensor; one is wireless PIR sensor while another is using wire to PIC microcontroller. For this project,PIR sensor with wire is selected and buzzer represented the siren because it is cheaper.
Buzzer (DC 6V)
Since the I/O pin from PIC has limited current to drivethis buzzer, a transistor 2N2222 is used to drive it.
PIR (Passive Infrared) Sensor
Figure 1
PIR stands for Passive InfraRed. In simple terms, it is a
motion detector. This sensors measure infrared radiation emanating from objects in the field of view. It
only has one output pin and another two pins isconnected to 5V and GND separately. Apparent motionis detected when an infrared emitting source with onetemperature, such as human body, passes in front of source with another temperature, such as wall. The unitoutput is high whenever there is motion detected. If the
motion is continuous, the output remains high. After motion stops, the output remains high for a few
seconds (depend on the variable resistor adjusted). Itwill remain high for longer if H from the jumper isselected. For this project, the resistant of variable
resistor is adjusted to as low as possible so that theoutput of the sensor would not remain high for longtime after motion stops.
PIC16F876A (Microcontroller)
This powerful (200 nanosecond instruction execution)yet easy-to-program (only 35 single word instructions)CMOS FLASH-based 8-bit microcontroller packsMicrochip's powerful PIC® architecture into an 28-pin
package and is upwards compatible with thePIC16C5X, PIC12CXXX and PIC16C7X devices.The PIC16F876A features:
• 256 bytes of EEPROM data memory
• Self programming
• In ICD
• 2 Comparators
• 5 channels of 10-bit Analog-to-Digital (A/D)converter
• 2 capture/compare/PWM functions
• The synchronous serial port can be configured
as either 3-wire Serial Peripheral Interface(SPI™) or the 2-wire Inter-Integrated Circuit
(I²C™) bus
• A Universal Asynchronous Receiver Transmitter (UART)
Figure 2
Figure 2 shows the pin diagram for PIC16F876A. For
more detail, please download the datasheet frommicrochip web site at: http://www.microchip.com
Microcontroller
(PIC16F876A)
PIR Sensor
LED
Buzzer
Vcc
Output
GND
7/27/2019 PR14_DD
http://slidepdf.com/reader/full/pr14dd 3/8
ROBOT . HEAD to TOE
PR14 – Alarm System: Motion Detector
Created by Cytron Technologies Sdn. Bhd. – All Rights Reserved 3
HARDWARE
This project will require following hardware:
a. 1 x PIC16F876A b. 1 x PR14 Printed Circuit Board (PCB)
c. 1 x PIR Sensor d. 1 x Buzzer (DC 6V)
e. Other related electronic components
Please refer to the schematic diagram of PR14. Theschematic is provided free therefore CytronTechnologies will not be responsible for any further modification or improvement.
Interface PIC16F876A with PIR Sensor
Output pin from PIR sensor can be connected to anyI/O pin from PIC16F876A while the Vcc pin and GND
pin should be connect to 5V and GND respectively.The PCB of this project provides 2 connectors for PIR
sensor (labeled as ‘Sensor1’ and ‘Sensor2’). Output of ‘Sensor1’ and ‘Sensor2’ was connected to pin 23 (RB2)and pin 22 (RB1) respectively.
Interface PIC16F876A with Buzzer
The base of 2N2222 (transistor) can be connected to
any I/O pin through a 1K Ohm resistor and the emitter should be connected to GND. Negative terminal (black
wire) of buzzer should be connected with collector (2N2222) and positive terminal (red wire) should beconnected to Vcc as shown in schematic diagram.
Power Supply for Circuit
Figure 3
For this project, the voltage range of power sourcecould be given for this circuit board is between 7V and
15V. Higher input voltage will produce more heat atLM7805 voltage regulator. Typical voltage is 12V.Anyhow, LM7805 will still generate some heat at 12V.There are two types of power connector on the circuit board, DC plug ‘Adaptor’ is for AC-DC adaptor and 2510-02 ‘Power’ is for battery source. Normally AC toDC adaptor can be plugged to ‘Adaptor’ typeconnector. LM7805 (1A maximum) will regulate the
given voltage to 5V (VCC) to supply to thePIC16F876A and pull-up the push button (input). The purpose of using diode (D1) is for circuit protection incase the polarity of the power source is incorrect.Capacitor (C5) and capacitor (C1) is use to stabilize thevoltage input and output of the LM7805. DS1 is agreen LED (small) as power indicator.
ICSP for Programming PIC
Microcontroller
Figure 4
In Circuit Serial Programming (ICSP) is used for loading program in this project. ICSP offers aconvenience way to load program into PICmicrocontroller without removing the PIC from thecircuit board. So pin 1 (Vpp), pin 27 (PGC) and pin 28
(PGD) from PIC should be connected to Cytron USBIn Circuit Programmer (UIC00A) through the externalcable. Besides, GND from the circuit board also should be connected with GND from UIC00A and pin 24(PGM) should be pulled to GND through a 10K resistor as shown in Figure 4. The programmer (UIC00A) is not included in DIY project set since it
can be used several times for different project set. User can also choose other type of PIC programmer to load the program. Since the ICSP is used, three I/O pins(RB3, RB6 and RB7) should not be used as input,anyway it still can be used for output.
Push Button as Input for PIC
microcontroller
Figure 5
One I/O pin is needed for one push button as input of PIC microcontroller. The connection of the push button
to the I/O pin is shown in Figure 5. The I/O pin is pullup to 5V using a resistor (with value range 1K-10K)
and this configuration will result an active-low input.When the button is being pressed, reading of I/O pin
will be in logic 0, while when the button is not pressed,reading of that I/O pin will be logic 1.
7/27/2019 PR14_DD
http://slidepdf.com/reader/full/pr14dd 4/8
ROBOT . HEAD to TOE
PR14 – Alarm System: Motion Detector
Created by Cytron Technologies Sdn. Bhd. – All Rights Reserved 4
LED as Output for PIC microcontroller
Figure 6
One I/O pin is needed for one LED as output of PICmicrocontroller. The connection for a LED to I/O pin isshown in Figure 6. The function of R8 is to protect theLED from over current that will burn the LED. When
the output is in logic 1, the LED will ON, while whenthe output is in logic 0, the LED will OFF.
SOFTWARE
Flow Chart:
Program
Please download the sample program from Cytronwebsite (same directory as this DIY project)
The source code is provided free and Cytron
Technologies will not be responsible for any further modification or improvement.
PR 14 is just a simple alarm system by using motiondetector. The PCB provides two PIR sensor connectors,3 LEDs and 3 push buttons. But only one PIR sensor (Sensor1), one LED (LED1) and one push button(SW1) are used if this sample program is being loaded.User can modify the program for more modes and patterns with the extra LEDs, push buttons and sensor
connector. Please refer to the schematic diagram for these pins connection.
Figure 7
The value inside the red circle in Figure 7 can bechanged for desired permitted period duration.
Figure 8
After permitted period, status = 2 (Scanning Mode startrunning). Refer to the program shown in Figure 8, LEDwill blinks in low frequency for Scanning Modeindicating.
Start
‘SW1’ button
pressed?
PIR sensor set?
Delay
15 seconds
Alarm
(Buzzer and LED)
activated
No
Yes
No
No
Yes
‘Reset’ button
pressed?
Alarm set (LED
blink in low
frequency)
Yes
7/27/2019 PR14_DD
http://slidepdf.com/reader/full/pr14dd 5/8
ROBOT . HEAD to TOE
PR14 – Alarm System: Motion Detector
Created by Cytron Technologies Sdn. Bhd. – All Rights Reserved 5
Figure 9
Refer to the Figure 9, status = 3 if sensor = 1 and status= 2. That’s mean Detected Mode only can activated when the motion detected during the Scanning Mode.
GETTING START
User can obtain the hardware set for this project (PR14)either by online purchasing (www.cytron.com.my) or purchase it in Cytron Technologies Shop.
1. Once user has the hardware set, soldering
process can be started now. Please solder theelectronic components one by one according
the symbols or overlays on the Printed CircuitBoard (PCB). Make sure the component valueand polarity is correctly soldered. Please refer to PCB Layout in Appendix A.
Notice: Only one PIR sensor is given for this project
set. User can purchase another PIR sensor for scanning2 different protection area at the same time.
Caution: Make sure all the connectors (2510) aresoldered in proper side. Those electroniccomponents have polarity such as capacitor,diode, PIC, PIR sensor, buzzer and LEDshould be soldered in right polarity or it maycause the circuit board fail to work.
Warning:Before the battery (Power) is plugged in,make sure the polarity is correct to prevent theexplosion. Wrong polarity of capacitor alsomay cause explosion.
Step for soldering 2510 connector:
Figure 10
2. After soldering process is finished, please plug in the PIC16F876A to the 28 pins ICsocket in proper side.
3. Please download the necessary files and
document from Cytron Technologies website,www.cytron.com.my. These included documentation, sample source code,schematic, component list and software.
4. The next step is to install MPLAB IDE and HI-TECC C PRO into a computer. TheMPLAB IDE and HI-TECC C PRO can be
downloaded from www.cytron.com.my .Please refer MPLAB IDE installation stepdocument to install the software. Thedocuments can be used to any version of MPLAB IDE software.
5. After the installation complete, open the project file provided using MPLAB IDE.
Please refer MPLAB Open Project documentto open the sample program.
6. Plug in power supply for the circuit. User canchoose to use battery or AD to DC adaptor.
Motion Detected Scanning Mode
2 1
5 6
87
4
7/27/2019 PR14_DD
http://slidepdf.com/reader/full/pr14dd 6/8
ROBOT . HEAD to TOE
PR14 – Alarm System: Motion Detector
Created by Cytron Technologies Sdn. Bhd. – All Rights Reserved 6
AC to DC adaptor:
Figure 11 (not included in DIY project set)
9V battery connector:
Figure 12 (not included in DIY project set)
Connection to the PCB board:
Figure 13
7. Build the project and load the hex file into the
PIC microcontroller using the USB In CircuitProgrammer (UIC00A). When user build the project, MPLAB IDE will generate hex file.
The hex file generated from MPLAB IDE will be named according to project name, not Cfile name. Cytron Technologies also providehex file for user. Do not forget to switch ONthe power. The programmer is not included inthe hardware set but it can be found at Cytron
website. (User manual is provided at website).
8. User can modify this program. After modification, build the project once again and load the hex file into the PIC microcontroller using Cytron USB In Circuit Programmer
(UIC00A).
9. When the power is provided, the green LED(small) will turn ON. Let say the sample
program (without modification) is being used.The ‘SW1’ button is a switch for setting thealarm system. When it is pressed, the sound ‘Beep’ will be heard and the permitted period
(15 seconds) is start running. The red LEDwould be turn ON at this period. The purposeof this permitted period is allowing theoccupant move freely in the protection areawithout triggering a false alarm. After 15seconds, scanning mode is started and theLED will blinks at this time.
10. Once the motion is detected, the buzzer would be activated and the LED would blink more
frequent. Just press the ‘Reset’ button on thePCB to reset the system.
TEST METHOD
1. Switch ON the power
• Power Led (green) will turn ON2. Press SW1 button
• Buzzer will beep once and LED 1 (red)will turn ON
• After 15 seconds, it will enter scanningmode and LED 1,2 and 3 will blink
3. Put your hand near the detector
• LED 1 will blink and Buzzer will beep4. If all steps mention above can be executed,
your project is done successfully.Congratulations!!
WARRANTY
No warranty will be provided as this is DIY project.Please check the polarity of each electronic component before soldering it to board.
12V Polarity
7/27/2019 PR14_DD
http://slidepdf.com/reader/full/pr14dd 7/8
ROBOT . HEAD to TOE
PR14 – Alarm System: Motion Detector
Created by Cytron Technologies Sdn. Bhd. – All Rights Reserved 7
Appendix A
PCB Layout:
4K7
PIR
Sensor
LED 5mm
Buzzer
LM7805
C-cap
30pF
BoxHeader
1K220R
20MHz
Crystal
Adaptor
socket
LED 3mm
2510-02
Connector
E-cap10uF 16V
2510-02
Connector
220R
2510-03
Connector2510-03
Connector
C-cap
104
4K7
4K7 LED 5mm
LED 5mm
PIC16F876A
4K7
Slide
Switch
1N4148
Diode
1N4007
Diode
2N2222
C-cap
104
7/27/2019 PR14_DD
http://slidepdf.com/reader/full/pr14dd 8/8
ROBOT . HEAD to TOE
PR14 – Alarm System: Motion Detector
Created by Cytron Technologies Sdn. Bhd. – All Rights Reserved 8
lkjkjkjlhiouihdfhgdshgahg
Prepared byCytron Technologies Sdn. Bhd.19, Jalan Kebudayaan 1A,
Taman Universiti,
81300 Skudai,
Johor, Malaysia.
Tel: +607-521 3178
Fax: +607-521 1861
URL: www.cytron.com.my