Introduction

Author: Kjetil Kirkholt, Microchip Technology Inc.

This application note describes how to use the 12-bit differential ADC with PGA in the tinyAVR® 2 Family of microcontrollers and how to collect measurements using a Passive InfraRed (PIR) sensor while keeping the current consumption at a minimum.

In this application example, the signal from the PIR sensor is amplified, oversampled, digitally filtered, and analyzed to determine if movement has occurred. LED0 on the ATtiny1627 Curiosity Nano (DM080104) board is used to indicate when movement is detected. The measured data can be sent to the serial terminal and illustrated in the Data Visualizer application or plugin for Atmel Studio.

The output signal levels from a PIR sensor are typically very low and less than 1 mV. To detect the movement and avoid false detections, the signal needs to be amplified before being sampled by the ADC. In typical PIR solutions, this is achieved by using several Operational Amplifier (op amp) stages with high gain. In this application example, no external op amps are used, and the amplification of the signal is purely done inside the microcontroller (MCU) by using the internal PGA. The ADC supports sampling in bursts, where a configurable number of conversion results are accumulated automatically into a single ADC result (sample accumulation). The application example accumulates 16 samples, which increases the resolution of the 12-bit ADC by two bits. It is possible to oversample the signal up to 1024 times and gain five additional bits, resulting in a 17-bit ADC resolution, if needed.

More information on oversampling can be found in the ADC Oversampling with tinyAVR 0- and 1-series, and megaAVR 0-series product brief.

For demonstration purposes, the ATtiny1627 Curiosity Nano board, Curiosity Nano Base for Click boards™, and a modified MIKROE-3339 PIR Click boards™ are used.

The example code for replicating the results described in this application note is available from Atmel START:

The bare metal code example (without using Atmel START drivers) is available on GitHub:

More information about the application is described in Sections Demo Operation and Code Implementation.

Additional details on the ADC performance and general configuration are available in the device data sheet.