HCSR04 and STM32 using Input Capture || Pulse width || CubeIDE

  Рет қаралды 49,067

ControllersTech

ControllersTech

Күн бұрын

Пікірлер: 78
@kennygomez3291
@kennygomez3291 4 жыл бұрын
The pin A9 is connected to the Trig but in the main you define the A8 as Trig pin, I think it was a little confusion. Great video!!
@jackdonchew7301
@jackdonchew7301 4 жыл бұрын
I wonder how it work...
@noweare1
@noweare1 4 жыл бұрын
Excellent as always. I like the way you converted decimal to ascii. Thank you.
@mateusz809
@mateusz809 8 ай бұрын
Hello! I have STM32 Nucleo L476RG. If you have problem like me that sensor doesn't measure anything or LCD is bombarded by random numbers here is solution, which worked for me. 1. Change these lines in your code to this: #define TRIG_PIN GPIO_PIN_9 #define TRIG_PORT GPIOA According to this video, TRIG should be connected do PA9 and ECHO to PA8. Remember that TRIG should be as GPIO_Output. On pin PA8 (to which is connected ECHO) you should make TIMER and enable option Input Capture mode. 2. Make sure that sensor is connected to 5 V DC. 3. Add this function to properly display values on your LCD: void lcd_display_distance(uint8_t distance) { char buffer[16]; sprintf(buffer, "Distance: %d cm", distance); lcd_clear(); lcd_put_cur(0, 0); lcd_send_string(buffer); } 4. Make sure you add these lines in main: MX_TIM1_Init(); MX_I2C1_Init(); /* USER CODE BEGIN 2 */ lcd_init(); HAL_TIM_IC_Start_IT(&htim1, TIM_CHANNEL_1); lcd_send_string ("Dist= "); 5. In while make sure you have: HCSR04_Read(); HAL_Delay(200); And add this line too: lcd_display_distance(Distance); That's all worked for me. I hope that this comment will help you. Greetings!
@shreyakaria8761
@shreyakaria8761 2 жыл бұрын
Excellent video!! I tried this with my STM, the data is captured once and can only be updated when reset button is pressed, what to do?
@NamNguyen-ti8ku
@NamNguyen-ti8ku Жыл бұрын
the same
@Pushpam1995
@Pushpam1995 4 жыл бұрын
Keep making these kind of videos
@satishm4635
@satishm4635 4 жыл бұрын
Thanks man! Great video
@ervanurcicek8256
@ervanurcicek8256 Ай бұрын
hi What is the code that you copied to the src and inc files at 8:15? i couldn't find it anywhere, could you help?
@ControllersTech
@ControllersTech Ай бұрын
Its i2c lcd library. It should be present in src and inc folders.
@eduardodelarosaferrer2205
@eduardodelarosaferrer2205 4 жыл бұрын
Perfect again !!
@nguyennguyenvu8212
@nguyennguyenvu8212 4 жыл бұрын
thank you! I did it with stm32f4
@haziqizzat3558
@haziqizzat3558 3 жыл бұрын
hi there, can i know how you do it with stm32f4?
@MamidipalliBujji
@MamidipalliBujji 5 ай бұрын
For me we did not get the output can you please tell me the problem once
@tupoy_ytub_uberi_psevdonim
@tupoy_ytub_uberi_psevdonim 2 жыл бұрын
Hello! I like this video, to easy for learn. I make universal lib for any STM microcontroller. Big thanks!
@misterjacqwelll
@misterjacqwelll 3 жыл бұрын
if i want to set a random number of the lcd, like push a button and save that value to calculate other values... You have a video to do that thing? PD: Great video :3
@hanilam3389
@hanilam3389 3 жыл бұрын
where is PA9 used in the code?
@minhcongho3639
@minhcongho3639 4 жыл бұрын
how to multiple input capture channels
@self-studyelectronicengine7294
@self-studyelectronicengine7294 4 жыл бұрын
hi, thanks for this code But I think this code has problem you define PA8 as trig pin but put it on wrong way to use I try this code on my micro and change PA8 to PA9 as trig and coxe work it as well
@ControllersTech
@ControllersTech 4 жыл бұрын
I'll see it. Maybe i have used the pin name directly somewhere..
@self-studyelectronicengine7294
@self-studyelectronicengine7294 4 жыл бұрын
@@ControllersTech thanks for mention
@siurpussiurpuliukas598
@siurpussiurpuliukas598 4 жыл бұрын
If the distance if greater than 127 it Distance variable becomes negative number. How should I fix this?
@ControllersTech
@ControllersTech 4 жыл бұрын
Try changing the data type of distance
@siurpussiurpuliukas598
@siurpussiurpuliukas598 4 жыл бұрын
@@ControllersTech Thanks, it worked. However, I have one more question. What is the maximum speed of reading the sensor? It seems that if I reduce HAL Delay to less than 15 miliseconds, callback does not return correct values.
@siurpussiurpuliukas598
@siurpussiurpuliukas598 4 жыл бұрын
@@ControllersTech Also, when I'm using the other timer for PWM signal, it somehow interferes with sensor and the results fluctuate depending on pwm signal
@dorstern245
@dorstern245 Жыл бұрын
hey, there are two problems: 1. When the LCD reaches number more than 9 it shows A, how can I fix it? 2. The ultrasonic sensor fakes the distance measurement by 3 or 4 centimeters, do you have a solution for this?
@DuyNguyen-ty4uk
@DuyNguyen-ty4uk 3 жыл бұрын
I dont use lcd, how can i show distance on watch1
@nsanandkumarak
@nsanandkumarak 3 жыл бұрын
Hi Sir, Can you please make video on Timer Tigger source and usage of it
@Levi.6570
@Levi.6570 7 ай бұрын
I have a question, if we apply to real life, what is the purpose of this project/
@ControllersTech
@ControllersTech 7 ай бұрын
That is up to you to decide.
@EmbeddedProfile
@EmbeddedProfile 6 ай бұрын
How to add a second ultrasonic sensor to this work please ?
@ControllersTech
@ControllersTech 6 ай бұрын
Use another timer for it. In the Input capture callback function, perform the check which timer called the interrupt. If (htim->Instance == TIM1) { write the entire code here} else if (htim->Instance == TIM2) {Write entire code here again} Also define new set of variables( IC_VAL, difference etc..) for second sensor.
@EmbeddedProfile
@EmbeddedProfile 6 ай бұрын
​​@@ControllersTechI did this but one sensor works fine but the second one give juste one correct value and stop working
@minayakarimova
@minayakarimova 3 жыл бұрын
Huge thanks
@ThànhVinh64
@ThànhVinh64 3 жыл бұрын
why can't I display the distance value on lcd16x2.
@aniketsubudhi2260
@aniketsubudhi2260 2 жыл бұрын
WHERE should i use the file lcd_userConf?
@davidbalog1014
@davidbalog1014 4 жыл бұрын
Distance is jumping rarely. I take an object 2 m away from the sensor, but it shows rarely bad value. What is the mistake?
@ControllersTech
@ControllersTech 4 жыл бұрын
Try changing the data type of distance
@akshadawaghmode6550
@akshadawaghmode6550 8 ай бұрын
Can you send i2c-lcd .h and .c files?
@truongho2771
@truongho2771 2 жыл бұрын
TIMX global interrupt consists of TIM capture compare interrupts ?
@ControllersTech
@ControllersTech 2 жыл бұрын
If its not given separately, then yes.
@monsieurovni5740
@monsieurovni5740 3 жыл бұрын
Great job! But why would it not be possible to use HAL_delay() instead of delay() in HCSR04_Read() ?
@ControllersTech
@ControllersTech 3 жыл бұрын
01:40
@பொத்தகம்
@பொத்தகம் 3 жыл бұрын
is the header file of i2c is same for STM32F466RE? and i can't find your i2c header file. please help me...
@北科大-王裕誠
@北科大-王裕誠 Жыл бұрын
hello may i ask what will be the distance value,i mean if the actual distance was 100cm ,the distacne variable value will be (int)100 or something else?
@ControllersTech
@ControllersTech Жыл бұрын
It should be 100.
@lorenefields2838
@lorenefields2838 3 жыл бұрын
Good video. I have a question. If I have a signal coming at 65 Hz, at what speed should I set the timer2 to read that signal in input capture mode. Thanks.
@ControllersTech
@ControllersTech 3 жыл бұрын
Somewhat in kilohertz would work
@jay16myv.
@jay16myv. 3 жыл бұрын
Hello, is there a tutorial for LCD communication? I don't know how to connect the LCD to STM32. Thank you.
@ControllersTech
@ControllersTech 3 жыл бұрын
Look in the stm32 playlist
@jennyshaio463
@jennyshaio463 3 жыл бұрын
Hi, I followed your instruction but got this error message"CM4 Failed to read all registers FAILED to REGISTER Values from the target Debugger connection lost. Shutting down..." Do you know any way to solve this? I've tried every method I could come up with...
@ControllersTech
@ControllersTech 3 жыл бұрын
What does this have to do with the instructions ? This is your hardware issue...
@theraja011
@theraja011 4 жыл бұрын
Hi, Grt. Pls share tutorial on EEPROM Emulation on STM32F103C8T6 flash memory (Ref cd00165693) HAL Lib is there. thx
@thophamngoc7178
@thophamngoc7178 3 жыл бұрын
can you explain for me ? else if (IC_Val2
@ControllersTech
@ControllersTech 3 жыл бұрын
It's to compensate the overflow. Ic val2 can only be less than icval1, only if there is overflow
@viethuynhquoc4049
@viethuynhquoc4049 4 жыл бұрын
Hello, i have some problem with TCS3200, can you make a project about it. Thanks very much. I'm from Vietnam
@vikneswaranrajandaran6588
@vikneswaranrajandaran6588 4 жыл бұрын
how to edit the coding by not using lcd monitor? i'm using teamspeak to display the distance
@ControllersTech
@ControllersTech 4 жыл бұрын
just remove the LCD part
@vikneswaranrajandaran6588
@vikneswaranrajandaran6588 4 жыл бұрын
@@ControllersTech ok done...I had integrated your data logger video and had build it with 0 error but when debug, failed to start GDB server...reason (4) no device found on target appeared
@farhanamin4075
@farhanamin4075 2 жыл бұрын
where is the i2c-lcd libraries come from
@aniketsubudhi2260
@aniketsubudhi2260 2 жыл бұрын
same question sir, please can you reply
@ControllersTech
@ControllersTech 2 жыл бұрын
Check out this, you will understand kzbin.info/www/bejne/jXKqfYSFfq14n9E
@therubrat
@therubrat Жыл бұрын
What is the input frequency ??? Plz reply
@ControllersTech
@ControllersTech Жыл бұрын
Input frequency of what ?
@therubrat
@therubrat Жыл бұрын
Input frequency of Ultrasonic sensor
@therubrat
@therubrat Жыл бұрын
And btw can u tell me how much frequency we need to give to produce 25khz ultrasonic sound??
@ControllersTech
@ControllersTech Жыл бұрын
Here ultrasound module produces the output pulse, which we read using the mcu and calculate the distance. We are not producing the ultrasound here. Ultrasound is being used by the sensor to calculate the distance of the object in front of it.
@therubrat
@therubrat Жыл бұрын
@@ControllersTech yeah but if u don't mind can u tell me about what frequency i can give to generate 25khz ultrasonic sound in transducer?
@sekoutounkara243
@sekoutounkara243 4 жыл бұрын
im not getting any value at all ...
@Fabio-211
@Fabio-211 Жыл бұрын
me too...
@EmbeddedProfile
@EmbeddedProfile 6 ай бұрын
Try to check the alimentation pin
@anhtaio4128
@anhtaio4128 4 жыл бұрын
Error in initializing ST-LINK device. Reason: ST-LINK: Could not verify ST device! Abort connection. Help me pro?
@ControllersTech
@ControllersTech 4 жыл бұрын
You might have a fake mcu. Check the video below and see @johan comment kzbin.info/www/bejne/m5CxhKSwarVrh80
@self-studyelectronicengine7294
@self-studyelectronicengine7294 4 жыл бұрын
Please instal driver of ST Link on ST website
How to use Flash Drive with STM32 || USB HOST MSC || CubeIDE
13:05
ControllersTech
Рет қаралды 31 М.
INPUT CAPTURE using DMA || Measure High Frequencies and Low Width
11:01
99.9% IMPOSSIBLE
00:24
STORROR
Рет қаралды 31 МЛН
Enceinte et en Bazard: Les Chroniques du Nettoyage ! 🚽✨
00:21
Two More French
Рет қаралды 42 МЛН
Мясо вегана? 🧐 @Whatthefshow
01:01
История одного вокалиста
Рет қаралды 7 МЛН
IL'HAN - Qalqam | Official Music Video
03:17
Ilhan Ihsanov
Рет қаралды 700 М.
42. STM32CubeIDE Ultrasonic Distance Sensor. HC-SR04 with STM32F103C8T6
6:56
MicroPeta by Nizar Mohideen
Рет қаралды 25 М.
STM32 TIMERS #4. INPUT CAPTURE  || Frequency and Width
13:57
ControllersTech
Рет қаралды 53 М.
Program an STM32F103C8T6 | Blue Pill | Different methods
7:17
Tech Talkies
Рет қаралды 11 М.
How to create delay in nano/micro seconds using timers in stm32
7:41
ControllersTech
Рет қаралды 49 М.
A RISC-V Stick-on
8:44
Jeff Geerling
Рет қаралды 474 М.
99.9% IMPOSSIBLE
00:24
STORROR
Рет қаралды 31 МЛН