PIR-based Motion Detection: Sensor-to-Solution

Feb. 2, 2006
By Zack Albus, Texas Instruments Inc. You can find one almost everywhere you go. Maybe it is in your neighbor's driveway or at the super market or, more and more, in the hallways of our homes and workplaces.

By Zack Albus, Texas Instruments Inc.

You can find one almost everywhere you go. Maybe it is in your neighbor's driveway or at the super market or, more and more, in the hallways of our homes and workplaces. The item of interest is not terribly complex nor expensive but has a wide range of uses in our daily lives. It is the motion detector. Whether it is in the security light next door or the intelligence behind automatic lighting control, motion detection is a widely useful method of helping us feel safer and at the same time saving us money. How do you implement a simple motion detector using a passive infrared, or PIR, sensor? In the course of designing such a system, two goals should be kept in mind: 1.) Design for low power and 2.) Design for low cost. Both are key elements to consider for motion detection.

1. CHOOSE A SENSOR
First let's discuss the hardware. The sensor selected for this design is the Glolab (www.glolab.com) PIR325 dual element pyroelectric sensor. There are a number of different PIR sensors available, ranging from a single element to as many as four. Each of them works off of the same basic principle: a crystalline material creates an electric charge when exposed to infrared radiation. A change in this radiation, i.e. a thermal change, causes a change in the charge, which can then be measured using a sensitive FET integrated into the sensor.

Figure 1 below shows a graphical representation of the sensor along with the output characteristic when a change in infrared radiation is detected. The sensor has a built-in optical filter to limit the detected radiation to the wavelengths emitted by the human body in the 8 to 14 µm range.

The radiation change is internally amplified and the analog output pulse can be measured externally. The signal output is still quite small with respect to VCC. This requires special attention from a design perspective to be able to sense such a small peak-topeak-change in the range of a few millivolts or even 10's of microvolts depending on the distance between the sensor and the radiating body as well as the size of the body. In addition, the output is offset depending on VCC. This design uses a 3V battery, which gives an output offset in the 500 mV range.

Amplifying the signal into a useable range is a requirement, and the use of an additional amplifier stage to do this is definitely a viable solution. The gain of such a stage is dependent on the final analog-to-digital conversion method used for the back-end processing. Often a simple comparator is used for this a/d conversion, the output of which might drive a relay or trigger a microcontroller to take some action. In this case, there are only two possible results: high or low. For more robust implementations, the comparator can be replaced by a true a/d converter, providing more information to the MCU and allowing for advanced signal processing.

2. CHOOSE AN MCU
In the name of lower cost and lower power we selected an MCU, the TI MSP430F2003, that integrates all of the required elements onto a single chip, making the solution smaller, cheaper and easier to design and control. This MCU has an integrated 16-bit a/d converter, providing better measurement resolution and lower gain requirements for the sensor. Quite possibly, the more important feature of the MCU is the integrated programmable gain amplifier (PGA) built into the a/d converter and used for a direct sensor connection. To make the analog connections even more straightforward, the input to the PGA and a/d converter is fully differential. This makes the large signal offset easy to handle and maximizes the matching of the small signal output of the sensor to the dynamic range of the a/d converter.

3. INTERFACING THE SENSOR AND THE MCU
Of course, the sensor output itself is not differential. This can be solved by creating a DC bias for the inverting PGA input using the sensor output itself. Figure 2 shows the details of the sensor connection to the MCU and the analog signal chain.

In this configuration, sensor source output S provides the output signal of interest to the noninverting input of the PGA via a small anti-aliasing RC filter (R1/C1). In addition, the output is used to create the needed DC bias for the Ainput of the differential pair. This is accomplished using a large RC lowpass filter (R2/C2) at the A-input. With a large enough RC, not only will noise be filtered from the signal but also the signal of interest itself, creating a DC level that will automatically adjust with respect to VCC. This has the advantage that no additional circuitry is needed to create an independent bias voltage. Using this configuration, the a/d converter output represents approximately 60 µV per LSB. This is calculated based on using the 1.2V internal reference and a PGA gain of 16x:

VLSB = \[(1.2/2)/16\]/(216-1) While many motion/presence detection systems may require sensitivity at the single-digit microvolt level, a general purpose system with detection ranges of 10's of meters can be constructed using the design described in Figure 2. For those systems with such high levels of resolution, additional sensor output amplification is required.

4. DEVELOPING THE SOFTWARE
Now that the analog interface is defined, the software controlling the system is the next key design element.

Remember, the two main goals are low cost and low power. The hardware selected definitely comes a long way to meet these goals. Not only does the hardware provide-lower cost through analog and digital integration but also lower power as the integrated elements can be more easily power-managed. To be effective however, efficient software development is critical. Figure 3 shows the high-level software flow for the system.

A key component of the software is the ability to make the entire system interrupt driven. This means no CPU instruction execution unless something needs to be done. In this case, the CPU is in a low power standby mode awaiting one of two events: 1) a timer interrupt that begins a new a/d conversion or 2) an a/d interrupt indicating that the result is ready.

Once the result is ready, it is compared to the last sample. The absolute value of the difference is compared to a userdefined set-point, which when crossed indicates the presence of motion. This simple flow allows for maximum flexibility in defining the sample rate via an internal timer as well as handling conversion results without any flag polling or software delays whatsoever.

5. DETERMINING POWER REQUIREMENTS
The ability of the MSP430F2003 MCU to operate in a sub-1 µA low power mode for the majority of the life of the system, provides for excellent battery life from a single CR2032 3V coin cell. Using a built-in internal lowfrequency oscillator to clock the timer, new conversions are started about every 340 ms. A sampling rate of approximately 3 samples/s may sound slow, but when taking into consideration the very slow signal output of the sensor in human interaction applications, such a slow sampling rate is more than adequate to reliably detect motion. The ability to also use a fast turn-on, highfrequency internal clock source set to 1 MHz to drive the a/d converter yields a conversion time for each sample of 1.024 ms. Keeping the conversion time as short as possible is important from a low power perspective considering that the internal reference and a/d converter represent more than 70% of the total current consumption.

To get a better picture of the current budget of the system, the table provides a breakdown of the active and average currents in the application.

Total system current will vary based on the final solution. From the table you can see that the active current is dominated by the a/d converter reference and conversion. However, the average consumption is mainly a function of the sensor current. Since the PIR325 sensor requires a somewhat long turn-on settling time in the range of a few or more seconds, power cycling the sensor is not an option. Although the sensor must remain on continuously, the current consumption is still quite low. For this design and software flow, a total average current of less than 10 µA is achievable for a general purpose motion detection system. Running from a standard 3V CR2032, battery life in excess of two years is achievable.

View System Current Breakdown

CONCLUSION
So there it is, a simple motion detection design using a standard PIR sensor. The hardware is straightforward and the software is a simple interrupt driven routine. Add to this design the Fresnel optical lens for increased sensor directionality and a basic relay to drive a flood lamp or communication channel to a host processor for a security system and the complete end application can be realized. Who said motion detection was anything other than the simple task of choosing the right MCU and sensor.

Company: TEXAS INSTRUMENTS

Product URL: Click here for more information

Sponsored Recommendations

What are the Important Considerations when Assessing Cobot Safety?

April 16, 2024
A review of the requirements of ISO/TS 15066 and how they fit in with ISO 10218-1 and 10218-2 a consideration the complexities of collaboration.

Wire & Cable Cutting Digi-Spool® Service

April 16, 2024
Explore DigiKey’s Digi-Spool® professional cutting service for efficient and precise wire and cable management. Custom-cut to your exact specifications for a variety of cable ...

DigiKey Factory Tomorrow Season 3: Sustainable Manufacturing

April 16, 2024
Industry 4.0 is helping manufacturers develop and integrate technologies such as AI, edge computing and connectivity for the factories of tomorrow. Learn more at DigiKey today...

Connectivity – The Backbone of Sustainable Automation

April 16, 2024
Advanced interfaces for signals, data, and electrical power are essential. They help save resources and costs when networking production equipment.

Comments

To join the conversation, and become an exclusive member of Electronic Design, create an account today!