Welcome: Hunan Intelligent Applications Tecgnology CO.,ltd.-HNIAT.com
Language: Chinese ∷  English

Smart test

Use PIR sensor to realize the design of motion detector

You can find it on the private driveway of a neighbor’s house, in a supermarket, or, increasingly, on the highway between home and work, almost wherever you go. It is neither too complicated nor expensive, but it has a wide range of applications in our daily lives. It is a motion detector. We can see it everywhere from the security light by the door to the smart circuit behind the automatic lighting control. It makes us feel safer and saves us money. So, how to use passive infrared (PIR) sensors to simply realize movement detection? When designing such a system, two goals should be kept in mind: one is low power, and the other is low cost. Both are key factors that need to be considered when designing a motion detection system.

1. Select sensor

Let's discuss the hardware first. The sensor we chose for this design is the PIR325 dual-element pyroelectric sensor from Glolab. From single element to 4-element, there are many PIR sensors with different structures on the market. They are all based on the same basic principle: infrared radiation emitted by an object causes a certain crystal material to generate an electric charge. Different radiation intensity (that is, a change in heat) causes a change in the amount of charge generated, and this change can be measured by a sensitive FET integrated in the sensor.

Figure 1 shows the principle diagram of the sensor and its output characteristics when it detects changes in infrared radiation. The sensor has a built-in optical filter, which can limit the detected radiation to the wavelength range of human radiation (8-14?m). The changes in radiation are amplified inside the sensor to produce analog output pulses that can be measured externally. The output signal (between a few microvolts to tens of microvolts, the specific value depends on the distance between the sensor and the radiator and the size of the radiator) is still very small compared to VCC. To sense such small peak-to-peak changes requires special design considerations. In addition, the output varies in amplitude with different VCC. This design uses a 3V battery, and the resulting output offset does not exceed 500mV.

Use PIR sensor to realize the design of motion detector
Obviously, the signal needs to be amplified to the usable range, and it is undoubtedly a feasible solution to add an amplification stage to complete this work. The gain of such an amplifier stage depends on the analog-to-digital conversion method required by the back-end processing. Generally, a comparator can be simply used as an AD converter, and its output can be used to drive a relay or trigger a microcontroller to take some actions. The conversion result of this scheme can only be high or low. For more demanding systems, real AD converters can be used instead of comparators to provide more information to the MCU and advanced signal processing.

2. Choose MCU

In order to reduce cost and power, we chose TI’s MSP430F2003 MCU, which integrates all required components on a single chip, making our mobile detection solution smaller, cheaper, and easier to design and control. This MCU integrates a 16-bit AD converter, which can provide higher measurement resolution and can reduce the gain requirements for sensing. Perhaps a more important feature of this MCU is the programmable gain amplifier (PGA) contained in the AD converter and directly connected to the sensor. To make the analog connection more direct, the signal input to the PGA and AD converter is completely differential. These features make it easier for us to deal with large signal offsets and make it easier to match the small signal output of the sensor with the dynamic range of the AD converter.

3. Interface to sensor and MCU

Of course, the sensor output itself is not differential. Adding a DC bias to the output signal of the sensor and adding the biased signal to the inverting PGA input can solve this problem. Figure 2 shows the details of the connection circuit and analog signal chain from the sensor to the MCU.

Use PIR sensor to realize the design of motion detector
In this configuration, the sensor output S passes an anti-aliasing RC filter (R1/C1) with a small time constant to transmit the output signal of interest to the non-inverting input of the PGA. In addition, we also use this output to establish the DC bias required by the A(-) input of the differential pair-by adding a RC low-pass filter (R2/) with a large time constant to the A(-) input. C2). A sufficiently large RC will not only filter out the noise, but also filter out the signal of interest, thereby generating a DC level that is automatically adjusted with VCC.

The advantage of this circuit is that an independent bias voltage can be established without additional circuitry. With this configuration, each LSB output by the AD converter is equivalent to approximately 60 ?V. This result is calculated assuming that the internal reference voltage is 1.2V and the PGA gain is 16 times: VLSB = [(1.2/2)/16]/(216-1). Although many mobile/presence detection systems may require a sensitivity of 1 microvolt/1LSB (such a high-resolution system needs to further amplify the sensor output), the circuit shown in Figure 2 can be used to develop a detection range of tens of meters. Universal system.

4. develop software

Now that we have defined the analog interface, the next key design task is to design the software that controls the system.

Again, the two main goals are low cost and low power consumption. In order to meet these two goals, we undoubtedly put a lot of thought into choosing hardware. This kind of hardware not only makes the cost lower because of the analog/digital hybrid integration, but also because the integrated device is easier to perform power management, and the power consumption is lower. Of course, in order to effectively achieve the design goals, the development of efficient software is also very critical. Figure 3 shows the overall software flow of the system.

The key to this software is to make the entire system driven by interrupts. This means that the CPU does not execute any instructions unless there is something to do. In this case, the CPU is in a low-power standby mode and waits for one of two events: a timer interrupt (indicating that a new AD conversion will start) or an AD converter interrupt (indicating that the conversion result has been obtained).

Use PIR sensor to realize the design of motion detector
Once the conversion result is obtained, it is compared with the previous sample. Compare the difference with the user-defined set point, if it exceeds, it indicates that there is movement. In general, this simple process can flexibly define the sampling rate through the internal timer, and does not use flag polling or software delays when processing the conversion results.

Use PIR sensor to realize the design of motion detector
5. Determine power requirements

In the working life of the system, the MSP430F2003 MCU runs in a low power consumption mode of less than 1 ?A most of the time, and only a single CR2032 3V button battery can achieve long-term power supply. The system uses the built-in internal low-frequency oscillator as the timer clock and starts a new conversion every 340ms. The sampling rate of about 3 samples per second sounds slow, but because the sensor output signal changes very slowly in human sympathetic applications, such a low sampling rate is sufficient to achieve reliable motion detection. Using a fast-start high-frequency internal clock source (the frequency is set to 1MHz) to drive the AD converter can make the conversion time per sample 1.024 ms. From the perspective of low power consumption, it is important to keep the conversion time as short as possible, because the internal reference voltage and the current consumption of the AD converter account for more than 70% of the total consumption.

In order to have a clearer impression of the current consumption of the system, the following table details the operating current and average current of each part of the system.

The total current of the system will depend on the final scheme of the system. It can be seen from this table that the current consumption of the working state mainly depends on the reference voltage and the current of the AD conversion, and the average current consumption mainly depends on the sensor current. Because the turn-on adjustment time (several seconds or longer) of the PIR325 sensor is relatively long, the method of power cycling the sensor cannot be used. Although the sensor must be kept on continuously, the current consumption is still very low. Using the hardware design and software process given here, a general mobile detection system with a total average current of less than 10 A can be realized. If a standard 3V CR2032 battery is used, the working time can exceed two years.

CONTACT US

Contact: Manager Xu

Phone: 13907330718

Tel: 0731-22222718

Email: hniatcom@163.com

Add: Room 603, 6th Floor, Shifting Room, No. 2, Orbit Zhigu, No. 79 Liancheng Road, Shifeng District, Zhuzhou City, Hunan Province

Scan the qr codeClose
the qr code