Well, I would think the better sampling would be more immune to noise. The old code was a kind of state machine, and it would be deaf to the encoder when it was transmitting the IR bits. I didn't really analyze all the old encoder code as I was replacing it anyway and it's unusually complex. Not to mention that I am looking at a disassembly of it with no comments.

But I suspect that because the old code wasn't always listening to the encoder, it would try to 'infer' the count direction if something happened while it was deaf.

The new programming is pretty simple. It compares the 'new' A phase to the old 'A' phase, and if they are different it counts. The direction of counting is determined by which way 'A' changed and also the state of 'B' phase. It's important to note that it doesn't look at the transition of 'B', as this transitions at the detent. If it happens to sample 'A' when there is noise, no matter, as worst case it will be correct a couple milliseconds later.

Here's the new ISR code for the curious:
http://pastebin.com/0nMEFgAZ


As far as I can tell there's no hardware debounce. So it wouldn't hurt to throw a couple small 0.01uF caps across the encoder leads if one has a unit with a flaky encoder. This could actually improve the lifetime of an encoder as the current from discharging the caps will have a cleaning action ("wetting") on the encoder contacts.

So in conclusion, it could be a lot better with the improved PIC, and won't be worse, I hope. smile