Design of sound and light alarm system based on single chip microcomputer

Publisher:闪耀的星空Latest update time:2014-04-12 Source: 电子技术网 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

  Abstract: This paper introduces a design scheme of an audible and visual alarm device based on the control of the STC89C52 single-chip microcomputer (MCU). The system designed in this scheme can realize the security monitoring of a specific area. When an intruder appears in the monitoring area, the front-end ultrasonic sensor transmits the detection signal to the main control chip MCU of the system by transmitting and receiving ultrasonic waves.

  1 Basic principles of sound and light alarm system

  Ultrasonic waves refer to mechanical waves with a frequency higher than 20,000 Hz. In order to realize ultrasonic echo ranging, ultrasonic waves must be generated and received by ultrasonic sensors. Ultrasonic sensors use the principles of piezoelectric effect and inverse piezoelectric effect to realize the mutual conversion between electrical energy and ultrasonic energy. That is, the ultrasonic transmitter converts electrical energy into ultrasonic energy through the inverse piezoelectric effect to generate ultrasonic waves; while the ultrasonic receiver converts ultrasonic energy into electrical energy through the piezoelectric effect to receive ultrasonic waves. If the ultrasonic wave emitted by the ultrasonic transmitter propagates in the medium at a speed of v (unit: m/s), and encounters the object to be measured in the effective prevention area, the ultrasonic wave is reflected and received by the ultrasonic receiver. The propagation time is t (unit: s), then the distance s (unit: m) between the intruder and the prevention object can be calculated. The formula is:

  The system structure block diagram is shown in Figure 1. The single-chip microcomputer receives the intruder distance electrical signal output by the ultrasonic sensor according to the clock timing given by the crystal oscillator circuit, and displays the distance value in real time on the LCD screen. At the same time, it controls the sound and light alarm system composed of light-emitting diodes and buzzers to make it flash at a certain frequency and sound an alarm.

  

  Figure 1 System structure diagram

  2 System Hardware Design

  2.1 Hardware Circuit

  The design of the hardware circuit mainly includes four parts: the single-chip microcomputer system and display circuit, the ultrasonic transmitting and receiving circuit, and the sound and light alarm circuit. The single-chip microcomputer uses STC89C52. A 12 MHz high-precision crystal oscillator is used to reduce the measurement error. The ultrasonic sensor uses a piezoelectric ultrasonic transducer. The single-chip microcomputer port P2.7 is set to output the 40 kHz square wave signal required by the ultrasonic transducer, and the port P3.2 monitors the return signal output by the ultrasonic receiving circuit. The display circuit uses the KXM12864M display screen. The sound and light alarm circuit consists of a light-emitting diode and a buzzer.

  2.2 Hardware of each main module

  2.2.1 STC89C52 main control circuit

  Figure 2 STC89C52 main control circuit

  2.2.2 Ultrasonic transmitting and receiving circuit

  The piezoelectric ultrasonic transducer realizes the conversion between ultrasonic energy and electrical energy through the resonance of piezoelectric crystals, thereby realizing the emission and reception of ultrasonic waves. The ultrasonic transmitter is installed at the J1 end, and the P27 port of the microcontroller outputs a square wave electrical signal at a frequency of 40kHz. Then the piezoelectric crystal will vibrate at the same frequency due to the reverse piezoelectric effect, realizing the conversion of electrical energy into ultrasonic energy and generating ultrasonic waves, as shown in Figure 3.

  

  Figure 3 Ultrasonic transmitting circuit

  Install the ultrasonic receiver at the J2 end. When there is no electrical signal applied to the two ends of the piezoelectric crystal, when the ultrasonic signal is received, the piezoelectric crystal will produce a piezoelectric effect and vibrate at the same frequency, realizing the conversion of ultrasonic energy into electrical energy and generating an electrical signal. The electrical signal is amplified by LM358 and sent to LM567 for phase-locked loop detection, so that the single-chip microcomputer can detect a ground wave. As shown in Figure 4 below.

  

  Figure 4 Ultrasonic receiving circuit

  2.2.3 Display Circuit

  The display circuit uses KXM12864M LCD display screen.

  2.2.4 Sound and light alarm circuit

  As shown in Figure 5, the sound alarm circuit uses a piezoelectric buzzer. When the microcontroller outputs a low level, the transistor is turned on and the buzzer alarms.

  

  Figure 5 Sound alarm circuit

  As shown in Figure 6, in the light alarm circuit, when the microcontroller outputs a low level at the corresponding port, the green, yellow and red light-emitting diodes flash at different frequencies.

  

  Figure 6 Light alarm circuit

  2.2.5 Power supply circuit

  As shown in Figure 7, the power supply VCC is composed of 2 to 4 No. 5 battery packs, C1, C2, C3, and C4 play a role in voltage stabilization. Pressing the switch SW1 turns on the power supply and the green LED lights up.

  

  Figure 7 Power supply circuit

  3 Software Solution

  3.1 Main Program

  The main program flow chart is shown in Figure 8. After the program is initialized, the confirmation button is pressed, the microcontroller transmits a square wave, and the entire system enters the deployment state. After each square wave is transmitted, the program will enter the delay state to determine whether an echo is received, that is, whether an interruption occurs. If an echo is generated, the program enters the interrupt service program, first turns off the interrupt, measures and reads the timer time t, and calculates the distance of the intruder by the formula, and displays the value on the LCD screen. Since the alarm program has three built-in alarm states, as the intruder approaches the intrusion distance, the "beep" sound of the buzzer and the flashing frequency of the light-emitting diode will gradually increase.

  

  Figure 8 Main program flow chart

  3.2 Function Display

  3.2.1 Enter the system interface

  Press the power switch, as shown in Figure 9, the system enters the initialization state, the system prompts you to press the "Confirm Key" (the first key from left to right below the LCD screen), and the system enters the monitoring mode.

  

  Figure 9 The system enters the standby stage

  Press the "Confirm button", as shown in Figure 10, the system enters the monitoring mode, the system starts to arm, and then prompts "Items are safe".

  

  Figure 10 The system enters monitoring mode

  Press the "Confirm Key" again, as shown in Figure 11, the system enters the monitoring range setting mode, and the second and third buttons from left to right below the LCD screen can increase or decrease the distance value of the monitoring area.

  

  Figure 11 Entering the monitoring range setting mode

  3.2.2 Real-time monitoring of intruder distance

  (1) As shown in Figure 12, an intruder enters the guarded area, the alarm system is activated, the ultrasonic sensor measures a distance of 33 cm, and the green LED light and buzzer flash and sound at a slower frequency (the warning distance is 30-40 cm at this time).

  

  Figure 12 Ultrasonic ranging range is 30-40 cm

  (2) As shown in Figure 13, an intruder enters the guarded area, the alarm system is activated, the ultrasonic sensor measures a distance of 24 cm, and the yellow LED light and buzzer flash and sound at a faster frequency (the warning distance is 20-30 cm at this time).

  

  Figure 13 Ultrasonic ranging range is 20-30 cm

  (3) As shown in Figure 14, an intruder enters the guarded area, the alarm system is activated, the ultrasonic sensor measures a distance of 11 cm, and the red LED light and buzzer flash and sound at a faster frequency (the warning distance is 10-20 cm at this time).

  

  Figure 14 Ultrasonic ranging range is less than 20cm

  From the above, it can be seen that as the intruder continues to approach the ultrasonic sensor (or the target of defense), the alarm signal of the sound and light alarm device will be reflected through the sound of the buzzer and the flashing of light-emitting diodes of different colors at three different frequencies, thereby effectively reminding relevant personnel to be on guard and respond to the intrusion in time; at the same time, if the intruder finds the alarm signal, it is also a deterrent to his intrusion.

  4 Steps

  4.1 Initial State

  Press the self-locking switch to turn on the power, and the LCD screen will display the system's initial status "System Introduction Ultrasonic monitoring system can monitor three adjustable areas. Press the confirmation button to enter the system."

  4.2 Arming Status

  According to the text prompt displayed on the LCD screen, press the confirmation button, which is the first button from left to right below the LCD screen. You will hear a "beep" sound and the system will enter the monitoring mode, that is, the armed state.

  4.3 Setting Status

  Press the confirmation key again to enter the monitoring range setting mode, that is, press the second and third buttons from left to right below the LCD screen to adjust the distance values ​​of the three monitoring areas.

  4.4 Return to the armed state

  After the monitoring range is adjusted, press the return key, that is, press the fourth key from the left to the right below the LCD screen, and the system will re-enter the deployment state. At this time, the monitoring range is the adjusted range.

  4.5 Disarmed state

  Press the self-locking switch again, the power is turned off, and the system enters the disarmed state.

  5 Innovations

  5.1 Non-contact alarm

  Compared with the traditional contact alarm system, this alarm system adopts ultrasonic ranging non-contact alarm method, which can provide maximum safety protection for the protected object in space.

  5.2 Three adjustable monitoring areas

  The alarm system monitors a dynamically adjustable prevention area, which is divided into three adjustable zones. The distance values ​​of the three monitoring areas can be adjusted arbitrarily within the maximum effective distance, and the values ​​can be accurate to centimeters.

  5.3 The device is small and easy to install

  The device volume is about 400cm3, which occupies a small space and is easy and concealed to install, and is basically not restricted by installation conditions.

  6 Conclusion

  The hardware circuit design of the sound and light alarm system based on single-chip microcomputer mainly consists of four parts: single-chip microcomputer system and display circuit, ultrasonic transmitting and receiving circuit, and sound and light alarm circuit. The circuit is simple and the cost price is 50 to 60 yuan. It is a low price and can be widely promoted and applied with a little packaging according to special needs.

Reference address:Design of sound and light alarm system based on single chip microcomputer

Previous article:Community anti-theft alarm: How does Linux beat Windows in seconds?
Next article:DIY home burglar alarm technology and design reference

Latest Security Electronics Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号