Quick advice on ultrasonic sensors.

I guys, i found many options for small ultrasonic sensors:

Ultrasonic Range Finder - Maxbotix LV-EZ4
Parallax PING))) Ultrasonic Sensor
Ultrasonic sensor HC-SR04
Ultrasonic sensor SRF05

But my problem is that i will be measuring the level of a garbage can, like 1.2m long and not very wide.

I already have one SRF05 but the beam width is big and the measure isn't accurate when the can is almost empty.

Now i am thinking about the Maxbotix EZ4 because it says it is the one with the narrowest beam width but i don't really understand the drawings they have on their datasheet.

Was anyone experience this kind of problem or as already worked with different ultrasonic sensors that can advice me one?
I think that the HC - SR04 is the cheapest and the beam width looks narrower than the SRF05 and it is really cheap, maybe has some downsides?

Thank you for reading guys !

I think you're probably getting a lot of reflections off the sidewalls of the trashcans, but
you didn't mention HOW the measurements are inaccurate. Too long, too short,
inconsistent, what?

For large reflection areas, like the inside of your trashcan, the EZ4s appear to have a beamwidth
in the 20-degree range, and I think that all of the other devices have a larger beam in general.
Also, I tried some of the SRF0x devices a few years ago, but they had "huge" sidelobe pickup so
I abandoned them completely in favor of Pings and Maxsonars.

I don't have my calculator with me, so I can't compute the angular width of your trashcan, but
it looks like you need a beamwidth of less than 20-deg. Something that might work is a Sharp
GP2D12 IR ranger, which has a beamwidth on the order of 5-deg, IIRC.

I get shorter distances.

The problem is that inside there will be many bottles filled with cooking oil, and maybe that can be a problem with the output of the ir sensor? Because the bottles can change in color and so on, depending on which bottle people choose to put the oil in.

Im thinking to buy the ez4 but i still have some doubts and maybe someone already had similar problems that could advice me in some way.

Otherwise i will have to buy many different sensors and try them out.

Thanks for helping :smiley:

As mentioned, I think the EZ4 has the narrowest beam of all the usual suspects by a
good margin, 50-100%, so I doubt trying the others will be better. If you do get any
of the various SRF0x devices, check the sidelobe pickup FIRST.

Re the GP2 devices, I would get one and try it first before abandoning the idea.

I once did some business with a company that made ice machines, and they used the old
style Polaroid sonars to detect the ice level, so you might check those out too.

If all else fails, I just had any idea generated out of the other thread of the guy trying to
measure raindrops, and the chinese water torture. :-). You have a little bucket of water
that will release a drop every now and then, and you measure the time it takes for the
echo to come back. 3-feet drop will give approx 6-msec to echo receipt. [only half joking].

I did an experiment, i made 2 paper tubes like 5cm long or so and i sticked them on the transducers, almost like a silencer on a gun xD
And i was acctualy able to get better readings from the buttom because the sound would start dispersing a bit later but maybe to the cost of increasing 5cm the dead zone.

But since it is for a company and probably many will be made its not a good solution ...

Ill have to buy the EZ4 and one infrared and try them out

Actually the directional tubes sound like a good idea. Except maybe use something more
robust, like aluminum, plastic, etc. I thought to try the same thing last week with the
EZ4 sonars on my robot, but haven't found a proper tube as yet. I picked some small
PVC tubing from Home Depot, but it's I.D. was slightly too small to fit over the sonar.

The EZ1 and EZ4 sonars on my robot can NOT see a gap 14" wide located 15" away from
the robot [Duh!], while the GP2D12 has no problem. See reply #13 on this thread,

http://arduino.cc/forum/index.php/topic,93247.0.html

i see...

I have never worked with irsensors. But since you have one does the output differs significantly if what you are measuring an opaque object or a transparent object? Does it differs too much with color? Maybe bad for measuring black objects ?

I read one post and the guy just kept saying how the ir sensors needed to be costumized for every type of object..
Someone even said that they were obsolete? I will need many of them in the future to and if thats true...

But as you say it as like a 5º beamwidth right. I will buy one and test it, is it hard to measure the output? i saw that it wasnt linear, you had to do the inverse of the output ( 1/output) or something.
About the irsensor resolution many people say its not has good as the ultrasonic but how much is it? 3cm resolution ? i dont need the exact value, just an idea if you know it, i searched the datasheet and couldnt find :S

And thanks again for your help i really appreciate it !!

The GP2s do not see perfectly transparent objects well, but I think there may be enough
clutter in your trashcan that they might work. I still think it's worthwhile to give them a try.

The curves indicate they give very similar responses for both dark and light objects.

You are correct about the 1/x response business. Here is the code I am using on my robot,
you will notice I include a fudge-factor, empirically determined, for range > 17 inches.
Also, Vdd on my board can be set to either 3.3V or 5V, so I factored that in there too.

/**********************************/
int read_Sharp()
{ 
  // returns range in cm.
  int k;
  long cm;
  int rng  = analogRead( anRNGR );  // returns value in 0..1023.   
  
  // scale output for full-range = 0..3.3V or 0..5V.
  // max usable range for GP2D12=80cm -> 0.4V, or 1024*0.4V/3.3V=124,
  //  use 0.3V -> 1024*3/VDD, or 0.25V -> 1024*2.5/VDD.
  k = 2560 / VDD;
  if( rng < k ) rng = k;  // preclude div by 0, set lower limit on voltage.
  
  // compute distance in cm = (25 * 1024)/(AD * Vdd).
  cm = (256000L)/ ( (long)rng * (long)VDD );
  
  // calibration is accurate from 5" to 17", then reads low. 
  // - use fudge factor: for x > 16" (0.8v), use 25/22 = 1.14 scaling.
  k = (int)( (1024L * 8L)/(long)VDD );
  if( rng < k ) cm = (114L * cm) / 100L;  // fudge for long-dist.
  return( (int)cm );
}

BTW, as a point of information, there is always a problem that no sensors are perfect.
Joe Jones goes on and on about this in his book Robot Programming, and advocates
always using backups and redundant systems, ie different sensor types.