An-000227 SmartSonic Presence Detection User Guide - v1.0
An-000227 SmartSonic Presence Detection User Guide - v1.0
Chirp Microsystems
Chirp Microsystems reserves the right to change 2560 Ninth Street, Ste 220, Berkeley, CA 94710 Document Number: AN-000227
specifications and information herein without U.S.A Revision: 1.0
notice. +1(510) 640–8155 Release Date: 7/8/2020
www.chirpmicro.com
AN-000227
INTRODUCTION
This example project shows how to build and run an ultrasonic presence detection application using the Chirp
SonicLib sensor API.
This is a companion document to AN-000214 Presence Detection, and AN-000226 CH201 Ultrasonic Presence
Detection Reference Design User Guide. Application note AN-000214 focuses on the test results of the embedded
static target rejection algorithm and the presence detection algorithm used in the CH201 presence detection
evaluation module. Application note AN-000226 is a user guide for the CH201 ultrasonic presence detection
reference design module. The Presence Detection example is a simple C application that demonstrates the use of
motion detection to determine the presence of people and objects. The application uses the Chirp SonicLib API
functions to initialize, configure, and operate one or more ultrasonic sensors. It uses special sensor firmware along
with API functions which specifically support presence detection.
The application discovers what sensors are connected to the board, programs and configures them, and then triggers
and displays ultrasonic measurement results through a serial connection. Each measurement result includes both a
range to the detected object and a confidence level, based on the presence detection algorithm.
In this example, the application is built using Atmel Studio 7 for the Chirp SmartSonic evaluation board, which
features an Atmel SAMG55 microcontroller. The SmartSonic board uses a sensor daughterboard that supports up to
four ultrasonic sensors. The Presence Detection application can detect and run with either a single sensor or multiple
sensors connected to the board, however the most common configuration is to use a single sensor.
The source/application/smartsonic-presence-example/main.c file is the main file in the application. It contains
extensive comments explaining how the SonicLib interfaces are used. The source/application/smartsonic-
presence-example/app_config.h file contains the setting for the application’s overall timing.
TABLE OF CONTENTS
Introduction ........................................................................................................................................................... 2
1.1 Required Equipment .................................................................................................................................... 2
1.2 Required Software Packages ........................................................................................................................ 2
Installation / Preparation ...................................................................................................................................... 4
Building the Presence Detection Application ........................................................................................................ 6
Programming the SmartSonic Board ..................................................................................................................... 7
Running the Presence Detection Application ........................................................................................................ 9
Changing the Presence Detection Application Settings ...................................................................................... 13
6.1 MEASUREMENT_INTERVAL_MS................................................................................................................. 13
Reference Documents ......................................................................................................................................... 14
Revision History ................................................................................................................................................... 15
LIST OF FIGURES
Figure 1. SmartSonic with CH201 Daughter Board ........................................................................................................ 4
Figure 2. Device Programming Screen ........................................................................................................................... 7
Figure 3. Device Signature and Target Voltage.............................................................................................................. 8
Figure 4. Programming Hex File ..................................................................................................................................... 8
Figure 5. Successful Programming ................................................................................................................................. 9
Figure 6. Typical Output During Initialization - 2 Sensors............................................................................................ 11
Figure 7. Typical Output During Operation - 2 Sensors ............................................................................................... 12
INSTALLATION / PREPARATION
• Download and install Atmel Studio 7 IDE.
• Download and install (unzip) the SmartSonic_Presence application to a project directory of your choice.
• Install terminal emulator.
• Connect the Chirp sensor daughterboard to the SmartSonic board. Be careful to align the white arrows.
• Optional: Using flat flex cables, attach additional off-board sensor(s) to the connectors on the
daughterboard. If an offboard sensor is connected to the Sensor 0 connector (J6), you must set the switch
on the side of the daughterboard to use the off-board sensor as Sensor 0 instead of the sensor on the
daughterboard.
• Connect the SmartSonic board to a Windows PC with the USB cable. Configure the jumpers on the board
as shown in the following photo with J1 in EDBG USB mode (short 3-4)
• Verify that the tool is EDBG, device is ATSAMG55J19, and interface is SWD.
• Select Apply.
o Note: Atmel Studio 7 may require you to update the EDBG debug interface firmware on the
SmartSonic board before continuing. Follow the on-screen instructions to update the EDBG
firmware.
• The Device Programming screen will prompt to set the programming clock frequency. Leave the clock
frequency unchanged (use the default).
• Select Read near the Device signature field. The device signature bytes should be read and should not
generate any error messages. The Device programming menu should look as follows:
6.1 MEASUREMENT_INTERVAL_MS
Specifies how often a new measurement cycle will be initiated, in milliseconds. Default = 100 ms (10Hz sample rate).
This value is used in main() as a parameter to the chbsp_periodic_timer_init() function. Once set, the timer will
generate an interrupt every MEASUREMENT_INTERVAL_MS milliseconds, which will cause the
periodic_timer_callback() routine in main.c to execute. That routine then triggers a new measurement cycle by
calling ch_group_trigger().
REFERENCE DOCUMENTS
• AN-000214 – Presence Detection
• AN-000226 – CH201 Ultrasonic Presence Detection Reference Design User Guide
REVISION HISTORY
REVISION DATE REVISION DESCRIPTION
This information furnished by Chirp Microsystems, Inc. (“Chirp Microsystems”) is believed to be accurate and reliable. However, no responsibility
is assumed by Chirp Microsystems for its use, or for any infringements of patents or other rights of third parties that may result from its use.
Specifications are subject to change without notice. Chirp Microsystems reserves the right to make changes to this product, including its circuits
and software, in order to improve its design and/or performance, without prior notice. Chirp Microsystems makes no warranties, neither
expressed nor implied, regarding the information and specifications contained in this document. Chirp Microsystems assumes no responsibility
for any claims or damages arising from information contained in this document, or from the use of products and services detailed therein. This
includes, but is not limited to, claims or damages based on the infringement of patents, copyrights, mask work and/or other intellectual property
rights.
Certain intellectual property owned by Chirp Microsystems and described in this document is patent protected. No license is granted by
implication or otherwise under any patent or patent rights of Chirp Microsystems. This publication supersedes and replaces all information
previously supplied. Trademarks that are registered trademarks are the property of their respective companies. Chirp Microsystems sensors
should not be used or sold in the development, storage, production or utilization of any conventional or mass-destructive weapons or for any
other weapons or life threatening applications, as well as in any other life critical applications such as medical equipment, transportation,
aerospace and nuclear instruments, undersea equipment, power plant equipment, disaster prevention and crime prevention equipment.
©2020 Chirp Microsystems. All rights reserved. Chirp Microsystems and the Chirp Microsystems logo are trademarks of Chirp Microsystems, Inc.
The TDK logo is a trademark of TDK Corporation. Other company and product names may be trademarks of the respective companies with which
they are associated.