ultrasound sensor HC-SR04 - Are you satisfied ?

alda

Member
Hi all,
I have question to all users using HC-SR04. Are you satisfied how this sensor works on the ardumower ? I tested aprox 5 pcs of this sensor, but for me it isn't working good. Values are jumping, I tested one or three sensors in ardumower, but it's unreliable detection.

What is your experience ? Or are you using other type of detection for obstacle ?

Thanks

Alex
 
Hej Alex,

i have strugggled with the HC-SR04 as well. After i changed the driver.cpp to set all values below 350 to NO_ECHO, i got a much more reliable obstacle detection. I also deactivated the center sensor and only drive with the two outer sensors.
Aiko pointed me to an article regarding problems with the HC_SR04 - you can find it here: http://uglyduck.ath.cx/ep/archive/2014/01/Making_a_better_HC_SR04_Echo_Locator.html
Maybe this can help you.

Regards
Wolfgang
 
Hi Wolfgang
so you changed this code ? :

// HC-SR04 ultrasonic sensor driver
unsigned int readHCSR04(int triggerPin, int echoPin){
unsigned int uS;
digitalWrite(triggerPin, LOW);
delayMicroseconds(2);
digitalWrite(triggerPin, HIGH);
delayMicroseconds(10);
digitalWrite(triggerPin, LOW);
uS = pulseIn(echoPin, HIGH, MAX_ECHO_TIME + 1000);
if (uS > MAX_ECHO_TIME) uS = NO_ECHO;
return uS;
}

What you chanaged ?

Thanks

Alex
 
Hej Alex,

correct code snip, i put another IF statement under the existing IF statement:

if (uS < 350) uS = NO_ECHO;

I had a lot of trouble with values below 350 and that helped me out. Below 350 my Mower hit the obstacle anyway.

Regards
Wolfgang
 
I think this is not a Problem of the US Sensors. Instead i problem of power supply. I had/have the same Problems. But If I use two battery’s, one for the motors (ardumover akku pack) an one only for the Arduino Mega - Board (Lipo 7V) then the mover works ok.
But i want to use only ONE battery. Probably it is enough if you take another DC/DC converter????

I will try it.
 
No sure what was (and is) a problem. right now I'm working on problem evaluation.
Maybe use fix stabilizator : LM2940CT-5 TO220
 
Hi Alex,

the problem is, if i use only one power supply for Arduino AND the motors then the mover is driving backwards, because a failure of the US Sensors. But if i use two diffrent batterys then all is ok.
But i dont know why?????:-(
 
Hello

I have written a test program that allow to check all 3 sensors together in a standalone context.
It doesn't use the time consuming pulseIn() but interrupt instead.
On my robot measurements are correct between less than 5 cm up to more than 4 m.

You should only check that the pin used (the standard ones in Azurit-1.0a4) are the right ones for your robot.

Good luck

Jacques
Attachment: https://forum.ardumower.de/data/media/kunena/attachments/2809/tstSonar.ino/
 
Zuletzt bearbeitet von einem Moderator:
Jacques schrieb:
Hello

I have written a test program that allow to check all 3 sensors together in a standalone context.
It doesn't use the time consuming pulseIn() but interrupt instead.
On my robot measurements are correct between less than 5 cm up to more than 4 m.

You should only check that the pin used (the standard ones in Azurit-1.0a4) are the right ones for your robot.

Good luck

Jacques

I updated pin positions, but not working. Still no echo.
 
Zuletzt bearbeitet von einem Moderator:
Also ich habe folgendes festgestellt:


Vorab als Info: Ich habe momentan nur einen ganz einfachen Aufbau. Arduino, die 3 Motoren, die 2 US Sensoren, den Akku und das Gehäuse mit Rädern, DC/DC Wandler und den MC33926.


Da die US Sensoren temperaturabhängig sind, ticken sie halt manchmal ein wenig aus.

Da ich von Dezember bis Februar getestet habe, machte sich diese Temperaturabhängigkeit schnell bemerkbar. Im Raum bei 21 Grad lief die Kiste wunderbar. Keine Fehler bemerkbar.
Im Betrieb bei 4 Grad + (im Garten) kam es dann so nach 10 Minuten (ständig) zu diese Fehlern. Die Sensoren detektierten Hindernisse wo es aber keine gab. Mit zunehmender Zeit und zunehmender Abkühlung wurden diese Fehler immer häufiger. So dass alle 2 Meter die Kiste rückwärts fuhr(eigenes Tool).


Demzufolge habe ich mein Programm so umgeschrieben, dass ein Objekt nur dann als Hindernis akzeptiert wird , wenn die Sensoren 10 mal nacheinander, ohne Unterbrechung, anschlagen. (Bei 50 Messungen pro Sekunde ist das kein Problem.) Ja und das funzt auch mit zwei Sensoren wunderbar. Ohne Fehldetektionen.
Somit kann auch die in einem anderen Thread beschriebene Spezielle Filterung aller Messwerte im Bereich von 1-500 entfallen.
 
Hallo Lorenz,

das ist natürlich richtig. Schall auch Ultraschall ist Temperaturabhängig und das macht sich bei den von dir beschriebenen Temperaturunterschieden schon deutlich bemerkbar. Die Mathematik dazu werde ich in einem WORKSHOP beschreiben.

Es ist auf jeden Fall sinnvoll mehrere Messungen zu machen. Wenn man dann noch mit der Glockenkurve arbeitet und dazu Mittelwerte der Messungen bildet wird das ganze schon besser. Die Temperatur muss man jedoch auch mit einrechen bei solchen unterschieden wie du sie beschreibst. Oder man muss den Sensor dafür Kalibrieren.

An der Thematik der Erfassungswinkel ändert das jedoch leider nichts.

Der Scanner z.B. arbeitet mit 16 Messungen pro Messpunkt insgesamt werden 25 Messpunkte abgetastet. Bei jeder Messung wird der Mittelwert gebildet und über die Messpunkte die Glockenkurve gelegt um in der Mitte die vertrauenswürdigen Messpunkte zu erfassen. Ausgelöst wird erst dann wenn eine Schwelle X an Messpunkten in die Bereiche Gefahr oder Warnung fallen.

Aber auch dieses Verfahren ändert weder an den Erfassungswinkeln oder an der Abhängigkeit der Schallgeschwindigkeit im Bezug auf die Umgebungstemperatur etwas.

Gruß

Jürgen
 
I am trying get good data from the ultra sound. Basically this should be really easy. Currently I am getting intermittent values. Nothing predictable. I get say 10 cm and keep my hand there and it goes to zero???

I tested the individual units and they are ok

I tested some of the wiring for continuity however I could not test the continuity from the US to the echo and trigger pins on the mega maybe due to the level shifters?????
I would appreciate some help to get this working. Is it a code issue

regards
Max
 
I am using the Ardumower master code. I think I found the problem. I have 3 HC-SR04 sensors. I one I tested was not on the mower. It works. The 2 that are giving me the problem are not on the mower and I did not test them. I just replace one of the US sensors and the code seems to be working ok

What are the best US sensors to use as I want reliability and not too bothered about the cost

Max
 
The best option would be if one can reengineer a car ultrasonic sensor and bring it to run for the ardumower. You can buy one fo 20euro for example. The next level is Maxon. But this one cost 100euro.
 
Like this ? :

Code:
 [URL]http://www.ebay.com/itm/Ultrasonic-Module-Distance-Measuring-Transducer-Sensor-Perfect-Waterproof-UK-/302225022508?hash=item465e03de2c[/URL]

Alex
 
Hi Alda.
I have 2 chineses mower tianchen l2700 and s510.
On the 2 mowers there are ultrasonic sensors and on the 2 mowers they works (not perfectly) for 2 years only before break down.
For me it's not reliable enough but maybe roland can tell you because i remenber that we speak about this feature in old post.

Yes it's work on car and automower so need only to find the perfect and reliable component.

By
 
Oben