On Tuesday 14 June 2005 02:27 pm, Spehro Pefhany scribbled: > No, you're not off track. You could take the reading (with minimal LPF) and > compare it to the displayed variable. If the difference exceeds a threshold > you preload the variable (essentially set K = 0). That way you can tolerate > a very long filter time constant because it only affects the last few > counts. You could try more levels than just two but it might not be > necessary. > > As Olin points out, it's possible with any of the "non-sticky" schemes that > the variable sits on the edge of a threshold long term and flickers back > and forth. You can make that less likely, but it's still probably possible. Exactamundo. And I am still noticing this. > If you added a smidge of stickiness you could eliminate even that, but that > adds some complexity. For example, suppose for the moment you have the > number y = x * 10 available and are going to display d, to approximate x > /10; (d is the previous display variable). > > y += ((y-10*d)> 5) ? -2:+2; > d = y/10; > Maybe it's late, I'm hungry, or both, but I can't get a clear picture of the result of this in my head. I need to plot some values on paper and track this.... after dinner though. > Will give you just a whisper of stickyness. Probably enough to be > irritating if you're using pots to calibrate the old-fashioned and > time-tested way. ;-) If you're doing calibration in EEPROM, of course, you > just use the original value of y. No pots here. > Of course you'd probably prefer to do this in powers of two and maybe in > assembly, > the C code and base-10 is just for pedagogic piclist purposes. Gotcha. Cheers, -Neil. -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist