Hi all, I'm having a weird encoder problem and I'd like your advice. I'm using some 512 count incremental encoders from US Digital and trying to track the exact angular position of a shaft attached to a motor. First of all, I've noticed that the B output of the encoder has a slow risetime (few microseconds, perhaps 3 or 4) compared to it's fall time, and the A output is much more symmetrical (both rise and fall are fast). I tried replacing the electronics part of the encoder and it made no change to this. Both outputs are simply going to a couple of digital gates on my board so I don't think it is caused by my electronics. I have not yet tried replacing the encoder wheel but I don't see how that could be causing something different to happen to chB as opposed to ch A, although replacing that is probably the next thing I will try. Ok, so now to the real problem: when running the shaft one direction, my code tracks the position fine. The other way, it will randomly occasionally loose track by a count or so perhaps every minute (shaft running at about 3000 rpm). This may seem minor but I'm doing brushless motor control and the encoder is being used as the sensor for the commutation and it is connected to the motor via a timing belt with a significant reduction ratio, so there are actually only about 6 counts of the encoder per commutation step. This happens when running at a constant speed in one direction. I am tracking the encoder position by interrupting on both rising and falling edges of the XOR of A and B. In my interrupt routine, I compare the current A and B to the previous A and B to determine which has experienced a change and whether it is rising or falling. Based on this as well as whether the other (unchanged) channel is high or low, I either increment or decrement the count. I also take the gear ratio into account and compute the correct motor shaft position. Any ideas? Sean -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads