Shop OBEX P1 Docs P2 Docs Learn Events
Ping sensor/ ultrasonic sensor use in a liquid tank? — Parallax Forums

Ping sensor/ ultrasonic sensor use in a liquid tank?

I was discussing a project with someone who is using a HC-SR04 ultrasonic sensor in a small tank less than 100 gal to
measure liquid level.

While the arduino code is pretty stright foward he seems to be getting some false high level alarms.

My questions are.

Because the sensor is so cheap is it just to be expected the it won't be accurate all the time?

Can't the transmitter and receiver head be effected by the tank environment. I'm not quite sure how sensor heads are constructed.

Can it be programmed out? Say like take a 100 readings and average them that way the couple erroneous ones will be overlooked?

I'm sure some one has done this already.

The industrial ultrasonic sensors I'm used to are sealed but cost prohibited. Is there something else I can use that better quality?

Thanks in advance
John.




Comments

  • Most likely, the water isn't, in itself, the cause of the false readings. You're right that the sensor itself is very quirky. A higher quality sensor will perform much better, and is the overall best fix.

    I don't think you need 100 readings. You only need a few. Throw out those readings that are obviously incorrect -- the water level can't change very quickly, and you should not average everything out. Merely remove the statistical anomalies, then average the rest. This allows you to take fewer readings, and to use a rolling average that doesn't require a lot of delay.

    I'm not sure, but something tells me a "single head" sensor would be better -- that is, a sensor that uses a single transducer for send and receive. Parallax doesn't make one, but there are others, such as the ones from Maxbotix.
  • ercoerco Posts: 20,256
    Could either the cheap sensor or that sketchy processor. :) There are waterproof sensors available... http://www.ebay.com/itm/Ultrasonic-Module-Distance-Measuring-Transducer-Sensor-Waterproof-/141975963021
  • How deep is the tank?
    erco wrote: »
    Could either the cheap sensor or that sketchy processor. :) There are waterproof sensors available... http://www.ebay.com/itm/Ultrasonic-Module-Distance-Measuring-Transducer-Sensor-Waterproof-/141975963021

    Have you used them? I got a few and couldn't get them to work in SPIN.

  • Check out Duane D's notes, he got a water proof ultrasonic sensor to catch the UPS delivery guy.
    Jim
  • ercoerco Posts: 20,256
    xanadu wrote: »

    Have you used them? I got a few and couldn't get them to work in SPIN.

    Gotta find it first!

  • Take 3 or 5 readings and compute the median - If any single reading is seriously out of range, it'll basically filter itself out.
  • A quick three-point median is,

    median_abc := (a #> b) <# (a <# b #> c)

    where a, b and c are the three most recent readings kept in a circular buffer. It will discard impulse (single sample) outliners. It can be cascaded for rejection of sequential impulses etc.

    Look at the actual values you get for 100+ samples to see how the outliers are separated or if it is just continuous sloppy noise. The best approach may be a combination of a median filter followed by an exponential filter or window average.

Sign In or Register to comment.