HC-SR04

For general Flowcode discussion that does not belong in the other sections.
Post Reply
medelec35
Matrix Staff
Posts: 1451
http://meble-kuchenne.info.pl
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 512 times
Been thanked: 472 times

HC-SR04

Post by medelec35 »

Hopefully, the changes I have made to the HC-SR04 will allow it to work at any clock speed on the 8bit pic devices and all other target devices.
I will post the FC9 and 10 components on two separate posts to avoid confusion
Martin

medelec35
Matrix Staff
Posts: 1451
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 512 times
Been thanked: 472 times

Flowcode v9 Re: HC-SR04

Post by medelec35 »

Browse to this location using file explorer , it's hidden by default so just paste the link into your address bar.

Code: Select all

C:\ProgramData\MatrixTSL\FlowcodeV9\Components
Place the attached component.
If Flowcode is already open, then you will need to reload your project for the new component to work
If you run any component updates, then the component you added will be overwritten, so it will stop working again.
Attachments
HC_SR04_Ultrasonic.fcpx
(40.69 KiB) Downloaded 11 times
Martin

medelec35
Matrix Staff
Posts: 1451
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 512 times
Been thanked: 472 times

Flowcode v10 Re: HC-SR04

Post by medelec35 »

Browse to this location using file explorer , it's hidden by default so just paste the link into your address bar.

Code: Select all

C:\ProgramData\MatrixTSL\FlowcodeV10\Components
Place the attached component.
If Flowcode is already open, then you will need to reload your project for the new component to work
If you run any component updates, then the component you added will be overwritten, so it will stop working again.
Attachments
HC_SR04_Ultrasonic.fcpx
(4.46 KiB) Downloaded 14 times
Martin

jgu1
Posts: 615
Joined: Thu Dec 03, 2020 8:25 pm
Location: Denmark
Has thanked: 507 times
Been thanked: 132 times

Re: HC-SR04

Post by jgu1 »

Hi Martin!

See that you not get any answer, I Will make a test later this evening, at least you deserve a reply for your work :D

You hear.

Jorgen

jgu1
Posts: 615
Joined: Thu Dec 03, 2020 8:25 pm
Location: Denmark
Has thanked: 507 times
Been thanked: 132 times

Re: HC-SR04

Post by jgu1 »

Hi Martin!

Sorry for delay, but yesterday evening I was figthing with this viewtopic.php?f=5&t=2427 :(

I have made some test with the HS SR04:

Arduino, Not Waterproff type working fine and the accuracy was very fine
The Waterproff (black, requere 20uS trig) not working.

Pic 16f876 not working with none of the type not waterproff and waterproff. Maybe cause I don´t know how the setting for Timer, prescaler and postscaler, I try some various, no luck?

Honest I prefer the old component for the HS SR04, They work and it is possible to choose between the two sensors. Concerning the accuracy the user could add an calculation box and: Distance= Distance + - the missing :)

Br Jorgen
Attachments
HC-SR04_Distance_Sensor_Mega_Not_Waterprof.fcfx
(11.74 KiB) Downloaded 8 times
HC-SR04_Distance_Pic16f876Not_Waterprof.fcfx
(11.3 KiB) Downloaded 9 times

medelec35
Matrix Staff
Posts: 1451
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 512 times
Been thanked: 472 times

Flowcode v10 Re: HC-SR04

Post by medelec35 »

Hi Jorgen.
Many thanks for your testing of the component.
Sorry, I did not spot the selection for the two versions are missing.
I have added it back in.
I have also changed the component, so you have a choice if to use the timer option or not.
If you do then the values should be as low as possible e.g. 1:1 for both prescaler and post scaler if available.
For PIC due the XC8 compiler, the distances will be inaccurate if not using the timer.
If using the Arduino, the timer option is not required.
Can you let me know if you are happier with the attached component, please.
Attachments
HC_SR04_Ultrasonic.fcpx
(4.67 KiB) Downloaded 14 times
Martin

jgu1
Posts: 615
Joined: Thu Dec 03, 2020 8:25 pm
Location: Denmark
Has thanked: 507 times
Been thanked: 132 times

Re: HC-SR04

Post by jgu1 »

Hi Martin!

Yes, of course if can I will always help, also in my interrest :D

Wow Martin, I have now perform various tests With an Arduino Mega and a Pic16f876 and both kind of sensors, playing around with Timer settings. For me it work perfect, and all is very accurate. (In room temperature measured by an AHT10 22gr Cel.) My expeince with the 8bit it is most stable by using the Timer interrupt, and the lower setting are, the better accuracy, as you say.
Thank you for your great job, and push it to the update, please+ Fc9 :lol:

Jorgen
Attachments
HC-SR04_Distance_Sensor__Arduino_WORKING.fcfx
(13.16 KiB) Downloaded 13 times
HC-SR04_Distance_Pic16f876Working.fcfx
(12.24 KiB) Downloaded 14 times

medelec35
Matrix Staff
Posts: 1451
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 512 times
Been thanked: 472 times

Re: HC-SR04

Post by medelec35 »

Hi Jorgen.
Thank you.
Hopefully the FC9 and FC10 updates will be pushed ASAP.
I'm glad you are finding HC range of ultrasonic sensors more accurate with PIC8 microcontrollers as that was the intention.
Thanks again for the testing you have done. :)
Martin

theopieleke
Posts: 3
Joined: Mon Jan 11, 2021 10:42 am

Re: HC-SR04

Post by theopieleke »

Sorry for the late respons.
I now downloaded the file for version 9 and will test it this week. Hopefully tomorrow.
Many thanks for the effort.
Theo

Post Reply