Hi
Following on from the above.
This time I used the same setup as documented in the above posts but using software mode with the following results
Measured (cm) / Displayed (cm) / Pulse Width (mS)
109 / 78 / 6.27462
120 / 86 / 6.9197
140 / 100 / 8.0691
144 / 103 / 8.32248
162 / 116 / 9.3676
I have only attached the shot from 162
Regards
SR04 Ultrasonic Sensor
-
- Valued Contributor
- Posts: 1528
- http://meble-kuchenne.info.pl
- Joined: Thu Dec 03, 2020 10:57 am
- Has thanked: 353 times
- Been thanked: 549 times
-
- Matrix Staff
- Posts: 1913
- Joined: Wed Dec 02, 2020 11:07 pm
- Has thanked: 619 times
- Been thanked: 644 times
Re: SR04 Ultrasonic Sensor
Hi Iain
I have just looked into this, and its not a bug but a setting in which I gave incorrect advice.
What I have done is exposed the timer rollover time which is in seconds
The furthest distance that can be measured is 310 cm = 18ms.
Therefore, the value exposed can't be below the maximum ms time.
If using a clock speed of 32MHz, then you will need to set the prescaler to 1:4. That gives a maximum time of 32ms which is ample.
Rollover time needs to be a low as possible but higher than the ms max distance time (e.g 18ms).
To try the component.
Browse to this location using file explorer , it's hidden by default so just paste the link into your address bar.
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 (unless the component update has been pushed).
I have just looked into this, and its not a bug but a setting in which I gave incorrect advice.
What I have done is exposed the timer rollover time which is in seconds
The furthest distance that can be measured is 310 cm = 18ms.
Therefore, the value exposed can't be below the maximum ms time.
If using a clock speed of 32MHz, then you will need to set the prescaler to 1:4. That gives a maximum time of 32ms which is ample.
Rollover time needs to be a low as possible but higher than the ms max distance time (e.g 18ms).
To try the component.
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
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 (unless the component update has been pushed).
- Attachments
-
- HC_SR04_Ultrasonic.fcpx
- (4.87 KiB) Downloaded 408 times
Martin
-
- Valued Contributor
- Posts: 1528
- Joined: Thu Dec 03, 2020 10:57 am
- Has thanked: 353 times
- Been thanked: 549 times
Re: SR04 Ultrasonic Sensor
Hi Martin
Thanks for that. I'll try as soon as I can and get back to you.
Regards
Thanks for that. I'll try as soon as I can and get back to you.
Regards
-
- Valued Contributor
- Posts: 1528
- Joined: Thu Dec 03, 2020 10:57 am
- Has thanked: 353 times
- Been thanked: 549 times
Re: SR04 Ultrasonic Sensor
Hi Martin
Just did a quick test, not much time. Downloaded and set Prescaler 1:4
Measured (cm) / Read (cm)
162 / 160
187 / 180
213 / 211
Looking very good so far...
I'll do some more tests later but things seem sorted now.
Thanks again.
Just did a quick test, not much time. Downloaded and set Prescaler 1:4
Measured (cm) / Read (cm)
162 / 160
187 / 180
213 / 211
Looking very good so far...

I'll do some more tests later but things seem sorted now.
Thanks again.