Passive infrared alarm experiment based on Atmega8

Photocoupler

The alarm consists of infrared emission, reception, buzzer and LED indicator. Under normal circumstances, the green LED is always blinking, indicating that the monitoring area is normal. Once someone in the surveillance area breaks in, the green LED goes out, the red LED flashes quickly, and the buzzer immediately sounds an alarm.

experiment equipment

Equipment to be prepared: Atmega8, red LED, green LED, universal test board, 5V power supply, resistor, TTL0038 or other similar 38KHZ infrared receiver, 5V long buzzer.

基于Atmega8的被动式红外线报警器实验0

circuit diagram:

基于Atmega8的被动式红外线报警器实验1

Experimental circuit diagram and working principle

The working principle of this circuit is very simple. The PD0 port of Atmega8 outputs a modulated square wave signal of 38KHZ, and then emits an infrared signal through LED2 of the infrared emission tube LED0. TL0038 is a receiver that integrates infrared signal reception and amplification. The center receiving frequency is 38KZH, the output is TTL level, and the output level is normally high. When the code signal is received, the output is low.

BELL is a long beeping device. The two pins are positive and negative. When the positive and negative terminals are applied with 5V voltage, the buzzer will sound. Note that the buzzer's feet cannot be reversed, otherwise the buzzer will burn out.

After the circuit works, the TL0038 does not receive the infrared signal under normal conditions, and the output is high. When an object appears in front of the launch tube, the TTL0038 will receive the infrared light signal reflected from the object, and then output a low level to inform the MCU to turn on the buzzer alarm.

Programming ideas

The program of this experiment mainly needs to complete three major functions: the generation of 38KHZ carrier signal, the detection of the output level of the infrared receiving head TL0038, the driving of the LED and the buzzer.

This program uses the 8-bit timer counter T/C0 overflow interrupt to cause PD0 to generate a square wave signal of 38KHZ, and then drive the infrared emission tube. The T/C0 counter is a single up counter, and once the count value TCNT0 is counted to 0XFF, T/C0 immediately generates an overflow interrupt. Therefore, we can adjust the frequency of interrupt generation by setting the initial value of TCNT0. The level state of PD0 is changed every time an interrupt is generated, thereby generating a square wave signal of 38 kHz at the PD0 port.

The experimental MCU uses the internal 8MHZ RC clock signal, and the T/C0 clock source uses the system clock divided by 8, which means that each count (TCNT0 is increased by 1) takes 1us. The clock period of 38KZH is about 26us. Therefore, the half cycle needs to count about 13 times, that is, the initial value of TCNT0 is 256-13=243. In addition, we also need to modulate the previous code signal on the carrier signal of 38KHZ, that is to say, the carrier signal of 38KHZ is not always generated, but intermittent transmission. As shown below:

基于Atmega8的被动式红外线报警器实验2

At the same time, the program judges whether the TL0038 receives the infrared signal by continuously reading the level value of the PC5 pin. Once the PC5 is detected to be low for N times, the buzzer and the red LED are turned on immediately. The reason why it is continuously detected N times is to prevent false alarms from being generated on the TL0038.

5.08MM Power+ Signal Power Connector

2.54MM Pitch Signal Power Connector.Chip power connector is used in power module system. It can select the matching power + signal connector according to the need. The feature is that the number of power and signal contacts and the matching sequence can be selected arbitrarily while keeping the connector size and contact core number unchanged.
Plug (male) / socket (female) can be installed at 90 or 180 degrees. It supports mixed or independent combination of signal and power. The quantity range of power and signal is (2-16) pin and (12-128) pin respectively

Product features

High temperature resistant, glass fiber reinforced and flame retardant polyester is used as insulation material

Copper gold composite conductor with high conductivity is used, and the contact area of the conductor is plated with gold
It adopts shrapnel contact, which has the characteristics of integration, small volume, large current carrying capacity, soft plug-in, blind plug-in, self guidance and high dynamic contact reliability. This series of products can be interchanged with FCI's powerblade series and Tyco's multi-beam series

The length of power hole / signal pin can be selected in two sizes. The power rated current is 45A and the signal rated current is 2.5A

5.08MM Power+ Signal Power Connector

ShenZhen Antenk Electronics Co,Ltd , https://www.antenksocket.com