> Say we multiply by 10 to get a faster response for the high level > If we sample in 10kHz we would reach 20 000/10kHz*10=2 sec > And we would reach 0 level in 20 secs: 20 000/10kHz*1=20 sec > The counter will _never_ be reset since its an endless process. I have now implemented and tested in production the solution I talk about here. It works outstanding !!! It follows the tank level and gives a nice smooth reading of the level on the LEDs. No false triggers what so ever, and pulse response is close to perfect. By changing two constants in the algorithm I can easily change the responsetime for either increasing or decreasing level. Currently I have 2.5 times faster response for increasing level. Seems to be a good value in combination with the mashine. Must say this was a more edjucational project than expected ! /PJ -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.