Application Report SLAA283B – December 2005 – Revised May 2015 Ultra-Low-Power Motion Detection Using the MSP430F2013 Zack Albus .......................................................................................................... MSP430 Applications ABSTRACT Motion detection using pyroelectric passive infrared (PIR) sensor elements is a common method used for such applications. An implementation of such a system using the 16-bit Sigma-Delta ADC integrated into the MSP430F2013 to detect motion is presented in this application report. Design information and related software can be downloaded from http://www.ti.com/lit/zip/slaa283. 1 2 3 4 Contents Hardware Design ............................................................................................................ Software Design ............................................................................................................. Summary ...................................................................................................................... References ................................................................................................................... 2 4 5 5 List of Figures ................................................................................ 1 MSP430F2013 Motion Detection System 2 PIR Sensor Output and Signal Conditioning ............................................................................. 3 2 3 Motion Detection Software Flowchart ..................................................................................... 4 List of Tables 1 Typical System Power Budget (Over 1 second) ......................................................................... 5 All trademarks are the property of their respective owners. SLAA283B – December 2005 – Revised May 2015 Submit Documentation Feedback Ultra-Low-Power Motion Detection Using the MSP430F2013 Copyright © 2005–2015, Texas Instruments Incorporated 1 Hardware Design 1 www.ti.com Hardware Design A system capable of detecting motion using a dual element PIR sensor is shown in Figure 1 using the MSP430F2013 microcontroller. Using the integrated 16-bit Sigma-Delta analog-to-digital converter (ADC) and built-in front-end PGA (SD16_A), the MSP430F2013 provides all the required elements for interfacing to the PIR sensor in a small footprint. With integrated analog and a 16-MHz 16-bit RISC CPU, the MSP430F2013 offers a great deal of processing performance in a small package and at a low cost. MSP430F2013 VCC 3V CR2032 R1 CPU DCO 1.2 V VLO AX+ D PIR R2 C1 S RB C2 SD16_A Px.y AX- RLED VSS Figure 1. MSP430F2013 Motion Detection System Figure 1 shows a simplified circuit that is used to process the PIR sensor output signal. The external components consist of the bias resistor, RB, required for the sensor and two RC filters formed by R1/C1 and R2/C2. The two filters serve two different purposes. Because the input to the SD16_A is differential, both a positive and negative input must be provided. R1/C1 serves as an antialiasing filter on the AX+ input. The second RC filter made up of R2/C2 serves to create a DC bias for the AX- input of the SD16_A. This is required due to the large offset of the PIR source output with respect to VSS with relation to the input range specification for the SD16_A. Figure 2 shows the respective signals in the circuit during detection of a motion event. 2 Ultra-Low-Power Motion Detection Using the MSP430F2013 SLAA283B – December 2005 – Revised May 2015 Submit Documentation Feedback Copyright © 2005–2015, Texas Instruments Incorporated Hardware Design www.ti.com Direct PIR Source Output (S, DC-coupled) Motion-Triggered PIR Output AX+ Input Signal AX- Input Signal SD16_A Differential Input (CH2-CH1) Figure 2. PIR Sensor Output and Signal Conditioning In Figure 2, channel 1 is the direct output of the sensor. With a sensor drain voltage of 3 V, the output offset is approximately 500 mV. Connecting AX- directly to VSS and the sensor source output to AX+ would be valid only if the internal SD16_A PGA gain setting is 1. With such a small peak-to-peak sensor output, as seen on channel 2, a higher gain setting is required, which eliminates the possibility that AX- can be tied directly to VSS. Alternatively, a DC bias voltage can be generated to drive the AX- input. This is created from the R2/C2 low-pass filter. This signal is shown on channel 3. The sensor output signal after the antialiasing filter connected to AX+ is shown on channel 2. By heavily low-pass filtering the sensor output before connecting to AX- as well, a simple DC bias is established, maintaining the input range requirements of the SD16_A. The mathematical difference, CH2-CH3, is shown on M1. This is the differential voltage seen at the differential input pair, AX, of the SD16_A. A PGA gain of 4x with an oversampling rate (OSR) of 256 has been used in this implementation. Additional gains and OSRs up to 32 and 1024, respectively, are possible for systems requiring additional sensitivity. See the MSP430F2013 data sheet (SLAS491) for possible SD16_A PGA settings and appropriate analog input ranges. In addition to the PIR sensor and the analog signal conditioning, a port pin is used to drive an LED. The LED is illuminated to indicate to the user that motion has been detected. This signal could also be used to drive an analog switch or relay to turn on a lamp or otherwise indicate motion in a real-world system. As a final aspect of the hardware design, use of a Fresnel lens is critical to establishing good directionality of the sensor detection field. The internal architecture of the dual element sensor provides good noise immunity and false trigger rejection but also creates a limited directionality of the sensor’s sensitivity. Use of the lens widens this field, making the final solution more robust. SLAA283B – December 2005 – Revised May 2015 Submit Documentation Feedback Ultra-Low-Power Motion Detection Using the MSP430F2013 Copyright © 2005–2015, Texas Instruments Incorporated 3 Software Design 2 www.ti.com Software Design With low power as an essential goal in this application, analog sampling and data processing is kept to a minimum required to reliably detect motion. Figure 3 shows the software flow of the software implementation described. Main Initialization: VLO, WDT+, P1 and P2, SD16_A Enter LPM3 with Interrupts Enabled WDT+ ISR SD16_A ISR Enter WDT+ ISR (~340-ms interval from ACLK/8 = VLO/8 ≈ 1.5 kHz) Enter SD16_A ISR Turn off VREF LED ON? NO |ResultNEW – ResultOLD| > Threshold? YES Turn on VREF Start Conversion Exit in LPM0 on RETI (DOC and SMCLK active) Turn LED OFF YES Turn on LED NO ResultOLD = ResultNEW Exit in LPM3 on RETI (DCO and SMCLK disabled) RETI RETI Figure 3. Motion Detection Software Flowchart The software consists of three main elements: main routine, watchdog timer interrupt service routine and analog-to-digital converter interrupt service routine. The entire flow is interrupt driven using the internal very low frequency, very low power VLO oscillator. The VLO is approximately 12 kHz and provided internally on the ACLK clock line. This signal is then divided by 8 and drives the WDT+ to give the CPU an interval wakeup. With an interval divider of 512, this equates to a wake-up time of 512 clocks / (12 kHz / 8) = 341 ms. After initialization of all peripherals. the CPU enters into LPM3 via the VLO waiting for a WDT+ interrupt trigger. After 341 ms, the WDT+ ISR is entered and serves two basic functions: first, to start a new SD16_A conversion and, second, to control the LED indicating motion. If no motion was detected in the last measurement (meaning the LED is off), the SD16_A internal reference is enabled and a new conversion is started. Before exiting the WDT+ ISR, the status register value to be popped upon RETI is modified so that the DCO and SMCLK used to clock the SD16_A will remain active. This causes the CPU to switch from LPM3 to LPM0 after RETI. 4 Ultra-Low-Power Motion Detection Using the MSP430F2013 SLAA283B – December 2005 – Revised May 2015 Submit Documentation Feedback Copyright © 2005–2015, Texas Instruments Incorporated Summary www.ti.com During this time, the SD16_A is completing the conversion process. This takes 256 clocks / 1 MHz DCO × 4 = 1.024 ms. The factor of 4 comes from the INTDLYx setting of the SD16_A. This setting allows the SD16_A to take up to four conversions before interrupting the CPU to allow for any potential analog input changes that might impact the SD16_A decimation filter, causing an invalid result. This is important, because the SD16_A is used in a single conversion mode in this application. See the MSP430x2xx Family User's Guide (SLAU144) for more information concerning this setting. After the conversion is complete, the SD16_A ISR is entered and the internal reference is disabled. The absolute difference between the new result and the prior result is calculated, and compared against a preset threshold. When this threshold is exceeded, motion has been detected and the LED is enabled. The CPU exits the ISR back into LPM3 (DCO and SMCLK are disabled) and the next WDT+ interrupt is awaited. 3 Summary Using this flow, the average current consumption is maintained at a low level, low enough that the entire system can be powered from a standard CR2032 3-V battery at approximately 9.4 µA average ICC. Table 1 shows the breakdown of operation versus current consumption. Table 1. Typical System Power Budget (Over 1 second) Function Duration Active Current Average Current PIR325 sensor 1s 6 µA 6 µA SD16_A and VREF + DCO 1.024 ms, ~2.94 times per second 810 µA + 85 µA 2.69 µA CPU Active (1 MHz at 3 V) 262 MCLKs per second: 262 µs 300 µA 0.08 µA MSP430 Standby (LPM3 with VLO) 996.7 ms 0.6 µA .0598 µA Total 9.37 µA The method shown here is quite simple in terms of the measurement and algorithm applied to detect motion. With up to 2KB flash and up to 16 MIPs of processing power, the MSP430F2013 can be used to implement a much higher level of signal processing to add sensitivity as well as selectivity to a given PIR profile. The integrated analog and processing power of the MSP430F2013 family provides a low cost yet powerful MCU solution which can be used to differentiate custom motion detection applications. 4 References 1. MSP430x2xx Family User’s Guide (SLAU144) 2. MSP430F20x1, MSP430F20x2, MSP430F20x3 Mixed-Signal Microcontrollers data sheet (SLAS491) 3. "Infrared Parts Manual: PIR325 & FL65", GLOLAB Corporation, www.glolab.com, 2003 SLAA283B – December 2005 – Revised May 2015 Submit Documentation Feedback Ultra-Low-Power Motion Detection Using the MSP430F2013 Copyright © 2005–2015, Texas Instruments Incorporated 5 Revision History www.ti.com Revision History Changes from March 5, 2009 to May 21, 2015 ................................................................................................................. Page • Added link to download related zip file ................................................................................................. 1 NOTE: Page numbers for previous revisions may differ from page numbers in the current version. 6 Revision History SLAA283B – December 2005 – Revised May 2015 Submit Documentation Feedback Copyright © 2005–2015, Texas Instruments Incorporated IMPORTANT NOTICE Texas Instruments Incorporated and its subsidiaries (TI) reserve the right to make corrections, enhancements, improvements and other changes to its semiconductor products and services per JESD46, latest issue, and to discontinue any product or service per JESD48, latest issue. Buyers should obtain the latest relevant information before placing orders and should verify that such information is current and complete. All semiconductor products (also referred to herein as “components”) are sold subject to TI’s terms and conditions of sale supplied at the time of order acknowledgment. TI warrants performance of its components to the specifications applicable at the time of sale, in accordance with the warranty in TI’s terms and conditions of sale of semiconductor products. Testing and other quality control techniques are used to the extent TI deems necessary to support this warranty. Except where mandated by applicable law, testing of all parameters of each component is not necessarily performed. TI assumes no liability for applications assistance or the design of Buyers’ products. Buyers are responsible for their products and applications using TI components. To minimize the risks associated with Buyers’ products and applications, Buyers should provide adequate design and operating safeguards. TI does not warrant or represent that any license, either express or implied, is granted under any patent right, copyright, mask work right, or other intellectual property right relating to any combination, machine, or process in which TI components or services are used. Information published by TI regarding third-party products or services does not constitute a license to use such products or services or a warranty or endorsement thereof. Use of such information may require a license from a third party under the patents or other intellectual property of the third party, or a license from TI under the patents or other intellectual property of TI. Reproduction of significant portions of TI information in TI data books or data sheets is permissible only if reproduction is without alteration and is accompanied by all associated warranties, conditions, limitations, and notices. TI is not responsible or liable for such altered documentation. Information of third parties may be subject to additional restrictions. Resale of TI components or services with statements different from or beyond the parameters stated by TI for that component or service voids all express and any implied warranties for the associated TI component or service and is an unfair and deceptive business practice. TI is not responsible or liable for any such statements. Buyer acknowledges and agrees that it is solely responsible for compliance with all legal, regulatory and safety-related requirements concerning its products, and any use of TI components in its applications, notwithstanding any applications-related information or support that may be provided by TI. Buyer represents and agrees that it has all the necessary expertise to create and implement safeguards which anticipate dangerous consequences of failures, monitor failures and their consequences, lessen the likelihood of failures that might cause harm and take appropriate remedial actions. Buyer will fully indemnify TI and its representatives against any damages arising out of the use of any TI components in safety-critical applications. In some cases, TI components may be promoted specifically to facilitate safety-related applications. With such components, TI’s goal is to help enable customers to design and create their own end-product solutions that meet applicable functional safety standards and requirements. Nonetheless, such components are subject to these terms. No TI components are authorized for use in FDA Class III (or similar life-critical medical equipment) unless authorized officers of the parties have executed a special agreement specifically governing such use. Only those TI components which TI has specifically designated as military grade or “enhanced plastic” are designed and intended for use in military/aerospace applications or environments. Buyer acknowledges and agrees that any military or aerospace use of TI components which have not been so designated is solely at the Buyer's risk, and that Buyer is solely responsible for compliance with all legal and regulatory requirements in connection with such use. TI has specifically designated certain components as meeting ISO/TS16949 requirements, mainly for automotive use. In any case of use of non-designated products, TI will not be responsible for any failure to meet ISO/TS16949. Products Applications Audio www.ti.com/audio Automotive and Transportation www.ti.com/automotive Amplifiers amplifier.ti.com Communications and Telecom www.ti.com/communications Data Converters dataconverter.ti.com Computers and Peripherals www.ti.com/computers DLP® Products www.dlp.com Consumer Electronics www.ti.com/consumer-apps DSP dsp.ti.com Energy and Lighting www.ti.com/energy Clocks and Timers www.ti.com/clocks Industrial www.ti.com/industrial Interface interface.ti.com Medical www.ti.com/medical Logic logic.ti.com Security www.ti.com/security Power Mgmt power.ti.com Space, Avionics and Defense www.ti.com/space-avionics-defense Microcontrollers microcontroller.ti.com Video and Imaging www.ti.com/video RFID www.ti-rfid.com OMAP Applications Processors www.ti.com/omap TI E2E Community e2e.ti.com Wireless Connectivity www.ti.com/wirelessconnectivity Mailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265 Copyright © 2015, Texas Instruments Incorporated