Thanks, Tom
I am going to use that averaging technique to smooth out the signal. It will slow down the rate of change, but I have plenty of time to allow it to settle out.
I should have said earlier: the biggest "noise" in this case is literally just that, audible noise made by the metal falling into the scrap bins. I have visited a similar plant to the one we are building, and the racket at the scrap bins is horrendous. The swivel chute manufacturer says that some of the high-pitched sounds reach up into the ultrasonic range, but that this sensor is the best type that they have found for this particular problem. Me, I don't know if I will ever get it to work right, or not.
No, Jesper, this Banner ultrasonic sensor does not have any built-in filtering capability. If I had a choice I think I would buy one that did have a filter, or as you said, load cells would be the most sure way. But as these projects go, I am part of a team, and the boss has made the decision based on other factors and what the customer wants and so on.
So my sensor only has Zero and Span settings for the analog output signal, and a selector switch that lets me select either a "positive" or "negative" slope on the 0-10 vdc output. I am planning to set it for negative to make the sensor reading increase as the the distance between the sensor and the scrap pile decreases. Then I will scale the output to represent the height in inches of the pile (0 to 130").
It seems that the bin will fill at some linear rate, or slope, and if I can calculate that average rate, then just look at the signal levels that fall within an envelope around that rate, then I can filter out most of the ultrasonic noise, leaving only signals that represent (or could represent) the bin fill level.
Matthias, I will use a delay timer here, to only take a reading once a second, and then to only use the reading if it falls within 0.2 inches/sec of change from the previous reading. Then I will average what is left using Tom's averaging method. The reason that I have some hope for these methods is that (a) the fill rate will be fairly slow; (b) Once it starts filling, the level should only go up, never down, until I move the chute to the new index position; (c) I don't really care what it does from 0 to 100 inches, but if it is between 120 and 130 inches, then I need to swap to another bin; and (d) I only need to see the real signal every now and then, not continuously. It is like walking through a thick forest, and seeing the sun only every few minutes through the tree branches, but still you will know about how high it is in the sky. So if I can look through all that racket and catch a glimpse of the real signal from time to time, then it might work. Is this called fuzzy logic? It sure seems fuzzy to me!
I may seem overly concerned, but this is part of a new automotive stamping plant, being built 24/7 as we speak. If this lowly scrap bin causes the robotic production line to shut down, then I may be out on the street!