Ultrasonic sensor

<< Click to Display Table of Contents >>

Navigation:  STM32F4 Target > Demos > Standard Peripherals Demos > TIM > PWM Capture >

Ultrasonic sensor

Previous pageReturn to chapter overviewNext page

Demo File: stm32f4_hcsr04_ultrasonic_sensor_demo.mdl

pwm_capture_model

Description

The demo showing how to use PWM capture to capture the pulse echo from Ultrasonic sensor. Convert the captured value +Width to unit of micro-seconds, then divide by 58 to get distant in unit of centimeters (Cm). The output result show on LCD and also send out via UART.

Hardware setup

Host

1. aMG F4Connect + aMG CLCD 2

2. aMG USB Converter N (Optional, to receive output data via UART.

Sensor device

pwm_capture_hw1

Note: Make sure the selected pin for Trigger Output and PWM Input is 5V tolerant.

Testing

1. Testing result displayed on LCD

pwm_capture_testing1

2. Testing result displayed on COM port.

pwm_capture_testing2