Quote Originally Posted by mikebar
I've connected the open collector output of the single channel encoder of the motor to a 2.2Kohm pull-up resistor and then to a NOT gate made with a BC547 transistor and a couple of resistors. From this NOT gate, directly to a spare quad-or gate 7432. The output of the OR gate is applied to the RA4 (Timer0) input of the PIC 16F877, running at 4MHz with two 22pf capacitors on the crystal.
The RA4 pin is set to be incremented from an external source.

Mike.
HI MIKEBAR, Your schematic attachment did not come through, but I think I understand from your description how your circuit works. First off the old style TTL 7400 series chips while plentiful still really BLOW, they are lazy and usually do not switch cleanly, are severly noisey and cantankerous, and that's their good points. I would use a more modern IC, probably an inverter with schmitt triggers. make sure to use a pullup / pulldown on your RA4 depending on which level you have it setup to trigger on. I do not know where you live or how difficult parts are to get there, here goes some part numbers:
old style TTL:7413 dual 4 input NAND with schmitt trigger,74132 quad 2 input schmitt trigger NAND gates 7414 hex schmitt trigger inverter, Advanced low power shotkey:74ALS14 hex schmitt trigger inverter, etc etc the newer logic has 2 or 3 letters between the 74 and the next 2 or 3 numbers the letters define what improved device type they are I. E. LS = Low Power Shotkey,
ALS = Advanced LS, AS=Advanced Shotkey, hc/hct High speed cmos etc.

Bottom line . . make sure your sensor is switching cleanly your RA4 input and that you have a measurable voltage swing in that pin, and if you do and it still doesn't count, I believe your problem lies elsewhere, chip failure, software glitch . . .
Regards
JS