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.
AN-000227 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. •...
Page 5
AN-000227 Open Windows Device Manager, open the Ports (COM & LPT) list, and identify the COM port number • assigned to the SmartSonic board. There will be one port associated with the SmartSonic board called“EDBG”. (A second COM port will also be assigned but is not used in this application). The EDBG port is used to connect to the on-board debugger and for programming the board, as well as to display output from the program when it runs.
AN-000227 BUILDING THE PRESENCE DETECTION APPLICATION • Open Atmel Studio 7 • Open the Presence Detection project: Open File menu Select File > Open > Project/Solution… Select the atmelstudio/smartsonic-presence-example/smartsonic-presence-example.atsln file in the project directory. Click Open. The program should locate the project files and display the name of the project. The Presence Detection project files are organized in three top-level sub-directories under source: •...
AN-000227 PROGRAMMING THE SMARTSONIC BOARD • Setup SmartSonic board Jumper J1 as in Figure 1. If only one cable is used (connected to the EDBG port), pins 3 & 4 should be shorted. • Connect the SmartSonic board to a Windows PC with EDBG USB cable. •...
AN-000227 Figure 3. Device Signature and Target Voltage • Select Memories on the Device Programming menu. • The Device Programming menu will prompt for the name of the file to program: Figure 4. Programming Hex File Page 8 of 15 Document Number: AN-000227 Revision: 1.0...
AN-000227 From the Device Programming screen scroll to the project’s Debug directory and select the smartsonic- • presence-example.hex file. Note: Alternately, you may use the smartsonic-presence-example.elf file, which contains symbolic debug information. (Both files are generated when you build the application. If you are simply running the Presence Detection application, and do not need to use the Atmel Studio 7 debugging features, it does not matter which file you use.) Select Program.
Page 10
AN-000227 Reset the SmartSonic board using the board’s reset button (next to the Programming EDBG connector). • • Status messages from the application will appear on the terminal output, followed by summary data from the sensor initialization (device frequency, etc.) and configuration (maximum range, etc.). •...
AN-000227 Because the Presence Detection algorithm detects changes in the ultrasound environment, it is normal for • the first few measurement cycles to report no presence detected. Figure 6 shows the typical application output during initialization, including the first measurement results. Figure 6.
AN-000227 After a baseline set of measurements has been made, the presence of objects can be detected. Figure 7 shows typical application output during operation, with two sensors. The “Merged” output lines indicate the overall Presence Detection result, based on data from both sensors. Figure 7.
AN-000227 CHANGING THE PRESENCE DETECTION APPLICATION SETTINGS The app_config.h header file contains symbolic definitions for parameters that affect the application execution. You may change the following definition to adjust the application’s timing. 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.