Esp 32 using HC-SR04 PROBLEM

For general Flowcode discussion that does not belong in the other sections.
Viktor74
Posts: 29
http://meble-kuchenne.info.pl
Joined: Sun Sep 22, 2024 9:13 pm
Has thanked: 5 times
Been thanked: 4 times

Re: Esp 32 using HC-SR04 PROBLEM

Post by Viktor74 »

Hello, everyone! Could you please tell me what I'm doing wrong? The compiler gives an error. In the simulator it works fine.
Attachments
Distance.fcfx
(20.72 KiB) Downloaded 26 times

medelec35
Matrix Staff
Posts: 1956
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 626 times
Been thanked: 656 times

Re: Esp 32 using HC-SR04 PROBLEM

Post by medelec35 »

Hello.
Thank you for the bug spot, it looks like there is a sharing violation of timer 0 when there should not be.
To get your project to work you have two options.
1. change timer interrupt from 0 to Timer 2 for example.
Or
2. Change properties of HC-SRO4 to Use Timer Interrupt = Yes.
Change the timer interrupt from 0 to 1 or 2 for example, then change Use Timer Interrupt back to No

I will look into fixing this component .
Martin

Viktor74
Posts: 29
Joined: Sun Sep 22, 2024 9:13 pm
Has thanked: 5 times
Been thanked: 4 times

Re: Esp 32 using HC-SR04 PROBLEM

Post by Viktor74 »

Thank you Martin! Yes, it really works great on Timer2.
Attachments
Distance.fcfx
(24 KiB) Downloaded 22 times

medelec35
Matrix Staff
Posts: 1956
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 626 times
Been thanked: 656 times

Re: Esp 32 using HC-SR04 PROBLEM

Post by medelec35 »

Thanks Viktor.
I fing using the timer interrupt for HC-SR04, the results are more accurate.
I'm glad your project is know working.
Thanks for letting us know.
Martin

Post Reply