> I'm trying to accurately count reed switch closures on the end of a cable that > is 20 metres in length. The pulses occur at a rate of about 4 per second and > are feed to the input port of a PIC for processing. > > The best that I have been able to achieve is a variation of 2.5% in the count > and that was through the use of a Schmitt Trigger (74LS13 with the inputs > tied together). > > Should I expect an accuracy better than 2.5%? How do commercial satellite dish > trackers, for example, achieve an accurate count? 100% accuracy should be possible. Assuming your program is OK, then switch debounce is probably your problem. The Schmitt trigger you are using should help BUT if the bounce is "deep" then the Schmitt will simply square the bounces up. Try a small series resistor to the input from the switch and a capacitor to ground from input. Resistor value depends on the reed switch resistor value. (Hopefully the switch has got a resistor to high if switch is to ground or vice versa?). For a 4 Hz signal rate a time constant of about 1/40 second may be about right. With a 0.1 uF cap that needs a 250k series resistor. The reed switch pull up (or down) resistor will need to be a tenth of this value or less to avoid noticeably asymmetric operation. The following needs a CMOS Schmitt due to the high resistances used. If you stick with the LS Schmitt you will need much lower resistance values and a proportionately larger capacitor. You could also try this without the Schmitt at all. eg 2 wire Input from reed switch One wire to ground Other wire (call this point B) to supply via 10k resistor. 220k or 270k resistor to input (via Schmitt or not) 0.1 uF (100 nanofarad) cap from input to ground. The RC filter removes fast bounce noise and allows the Schmitt to handle the slower bounces. You could also wrote PIC code that debounced the signal entirely in software. eg If signal is high ignore low transitions that last for less than eg 100 mS Once low do similar for high transitions. RM -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.