Very bumpy raw data from ultrasonic device

Hi,

I have just bought a MaxSonar EZ-1 and maked some tests with it.
The first outcome was very disappointing, because the raw data was almost useless, because it has so many "random" data.
Is the device bad or is this normal and I have to strongly flatten it?
But the disadvantage of flattening is, that the speed of recognition would go down, right?

Can anyone give me a hint?

Thanks a lot!
Sebastian

BTW, the negative data are from a badly set up variable (int instead of long int), so don´t be bothered by this :slight_smile:

If I understand things correctly you probability want to do some averaging over the course of your sampling. Such as setting up 5 samples which get averaged, then the next sample reading causes the oldest sample to drop out? so you just keep averaging the 5 most recent readings. This will slow things down a tiny fraction. Did that help at all?

Chris

Hi Christ, thanks for the answer.
Yes, I already had this idea of averaging. I tried it with 5, 10 and 20 samples.
5 and even 10 was to few to get a good result.
And with 20, it is MUCH to slow for my purpose.

I am wondering, if the data itself is buggy.
I mean, there are so many and big runaway values...
Is this normal??
Does anyone have experience with these kind of sensors?

I don't have experience with this exact sensor, but the Sharp IR sensors I am using displayed similar results when I started working on them. I solution was to add a capacitor across the power leads close to the sensor input on the Arduino board. This solved some of the noise. The next step was to add a very basic filtering before using any of the math. A simple min/max comparison to throw out anything that was simply junk (i.e. a reading of 100cm when the max range is 50) The I used a 2 part averaging to smooth out the results. This might not work for that sensor, but it may help someone else...

Sebastian,

This data does not seem representative of what we observe from our sensors, (excepting a wildly moving sensor or field of view, but even then they don't report negative values)
MaxBotix rates our sensors to range correctly in a wide variety of circumstances.
Please let MaxBotix Inc. help.

I have a few questions about your set up that will help us get to the bottom of this:
First, are you using the new XL line of sensors, or the LV line?
Second, what is the nature of the test you used to collect your data?
Did you hook up the sensor and point it around the room? Have you tried ranging a stationary target first to ensure the output is connected correctly?
Feel free to e-mail us if you have any questions.

Carl Myhre, Systems Engineer, Carl@maxbotix.com

Hi,

I have found out several things:

  1. The bad data only appear when I have connected a servo to the Arduino
  2. With the servo attached, the data for near objects is pretty okay, but when objects are more than 1 meter away, it makes this huge noise.
    Kiltjim, I have the feeling, that the capacitor should work. How did you connect it, and which kind of capacitor did you choose?

Here is the setup, maybe there is some error in it...?

The bad data only appear when I have connected a servo to the Arduino

Ok so your problem is one of decoupling. Both the sensor supply and the servo.

http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html

Sebastian,

Grumpy_Mike is mostly correct here. Significant changes in the voltage applied to the part can cause false readings to occur. Thus, a dirty power supply will cause the sensors to see something that isn't there.
If you refer to our FAQ page:http://www.maxbotix.com/MaxSonar-EZ1__FAQ.html there is a portion near the bottom (question 22, search for "UAV and Mobile Robotic Users") that has a diagram which will help you supply clean stable power to our sensor. Just attaching a capacitor is not enough to supply stable power but a 100 ohm resistor and a 100 uF capacitor is all you will need.
Also, as a favor, once you get our sensor working could you edit your first post with some stable range data? Thanks. If this fix doesn't work let us know and we will continue to troubleshoot your setup.

Carl Myhre, Systems Engineer, Carl@maxbotix.com

Hi and thank you for the excellent hints!
It seems, that I am on a very good way!
I really could see an improvement, but I also have to state, that it is not easy to completely kill the noise.
Here is how it looks right now:

As you can see, without the servo the maxbotix does PERFECTLY work!
With the solution with the capacitor it interestingly flattens the lower part, but the peaks above are still remaining.
Maybe, because I am using an electrolyte capacitor? Maybe it should just be a ceramic capacitor?

I also had the capacitors at the sensor and servo (at the same time), but still noisy :frowning:

Are there any other possibilities?

What about using a separate supply for the servo , or the same power supply unit, but a separate regulator just to drive to servos ?

Yes, that seems to be a good idea.
How could I realize that, as I am not an electronix expert?
With transistors?
But the problem is, that I have 9 Volts, which I somehow should make to 5 V.

A LM7805 and 2 capacitors

Maybe, because I am using an electrolyte capacitor? Maybe it should just be a ceramic capacitor?

Yes they should be both in parallel. What this means is that you do not have enough decoupling on the supply, so you will have to go with the LC version or even the CLC version.

Sorry, what does LC and CLC version mean...?

LC - Inductor in series capacitor to ground.
CLC - Capacitor to ground , inductor in series, capacitor to ground.

Like this:-

Thinking about it a different way I'll ask a few questions to see if we are on track.
Are you powering it from a battery or a wall power supply unit ?
If what rating is it and how many servo are you driving at one time just the one ?

Sebastian,

It seems you also have spikes on your ground. We will be posting a circuit diagram that should fix your problem on our website tomorrow and I will link to that here.
For now I'll try to explain in text: from the circuit you have implemented you can try adding an additional 100 ohm resistor in series to ground. This means you have a 100 ohm resistor from your power source to the +5 pin, a 100 ohm resistor from ground to the GND pin, and a 100 uF capacitor linking the power and ground. Hope this works!

Carl Myhre, Systems Engineer, Carl @ Maxbotix."com" (remove spaces and quotes)

All,

Here is the picture that Carl was going to post.

"Sebastian,

It seems you also have spikes on your ground. We will be posting a circuit diagram that should fix your problem on our website tomorrow and I will link to that here.
For now I'll try to explain in text: from the circuit you have implemented you can try adding an additional 100 ohm resistor in series to ground. This means you have a 100 ohm resistor from your power source to the +5 pin, a 100 ohm resistor from ground to the GND pin, and a 100 uF capacitor linking the power and ground. Hope this works!"

If you have any questions, please let me know.

Scott Wielenberg, Technical Support and Sales, Email: scott@maxbotix.com Web:www.maxbotix.com