I am trying to use a cheap ultrasonic rangefinder HC-SR04 Ultra01+ inside the RobotMesh Python environment for my robotics class, and have encountered a problem. It mostly works when wired correctly and registered as an Ultrasonic Sensor, but it is only accurate to the nearest ~1.3 inches, despite the device having a published sensitivity of 3mm. I know that the default sensitivity for the VEX rangefinder is the nearest inch, so I was wondering if there is a way to receive more sensitive readings, making it more viable for our use.
When you plot measurements for several test points do they follow some line or are just all over the place?
I.e. is there some sort of the constant bias and scale problem or the values are non-repeatable with large errors?
Here is a snippet of my output when set to inches. These are printouts every second. I allow it to run for 4 seconds unblocked, then block it for 4 seconds. The first 4 were static, the next for were moving away, the third set involved moving up through a horizontal beam, and then I just started doing some random stuff after that.
33.56842
33.56842
33.56842
33.56842
10.133861
10.133861
10.133861
10.133861
33.357299
33.357299
33.357299
33.357299
7.178152
10.133861
11.400596
33.357299
33.779541
33.779541
33.779541
33.779541
60.169815
9.711616
9.711616
33.56842
33.56842
33.56842
33.56842
33.56842
9.711616
10.344985
10.767227
9.289371
33.146179
33.146179
33.146179
33.146179
75.792846
5.06693
5.06693
6.122541
33.56842
33.56842
So the 33" away is a filing cabinet. It is pretty static, but sometimes varies. What do you make of it?@technik3k
So if you have something 15", 20", or 25" away what does it read? From those you can tell if it is a constant error, a linear error or something else.
An ultrasonic normally works by sending a pulse to fire the wave out, and then the other signal goes high, once the reflected pulse is received. If you can count the time between these 2 events, using the speed of the wave, you can calculate the time for the pulse to return, and divide by 2 to get the one-way distance.
Normally the best way to do this is with an interrupt or a timer on a microcontroller to get more resolution, but you should be able to bit bang it in any language on any microcontroller.
Well I was using RobotMesh Python and could probably have my advanced robotics students to a faster processing using bit access programming in PROS, but I wanted to avoid writing my own class. Also, if you know of good cheap sensors that work natively with the vex classes, that would be great since I teach a large robotics class and the cost of VEX line sensors are 4x the cost of normal line sensors.