David Pilling |
Main »
STM32 with HC-SR04Started 1st February 2016 - work in progress - correctness level low The background to this page is my experience with the HC-SR04 ultrasonic ranging module using an ATMega 328p. Having learnt to program the STM32F103C8T6 board with Arduino, I created some simple programs to use it with the HC-SR04. First with interrupts and then a timer capture register; the latter relies on the code from [1]. Compared to the ATMega 328p interrupt results are more stable. There is the problem of matching the 5 V world of the HC-SR04 to the 3.3 V of the STM32. I started by using the safe option of a couple of FET level shifters[3].
However a sketch to use the HC-SR04 is included with the STM32 addition to the Arduino IDE, it can be found here: Arduino\hardware\Arduino_STM32\STM32F3\examples\f3_ultrasonic
or using the sketch menus to navigate to the same location. I extracted the analogue final amplifier output signal from the HC-SR04 as described. To get the STM32 to digitise it I copied the ADC DMA code from [4].
|
David Pilling's Wiki Set view |
Page last modified on March 12, 2019, at 12:51 AM - Powered by PmWiki pmwiki-2.3.31 (pmwiki-2.3.31) |