We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I am in possession of an incremental encoder, mounted on the shaft of an electrical machine. The encoder gives 1000 ppr. From the manual I read that it was a good idea to configure timer 3 in incremental interface mode. Also I configured it to trigger on any transition of T3IN only. Signal A from the encoder is physically coneceted to input port 3.4, and signal B to port 3.6. With the current software implementation I am able to relate counter clockwise shaft revolution with a negative decreasing value and vice versa. However I have some trouble figuring out how to relate the magnitude of the values to a given physical position of the shaft. Does anyone have an idea how to do that?
It seems to me that with no other information you'd have to calibrate the zero position. Given that, and the fact that you get 1000 pulses per revolution, you can calculate the shaft angle from the zero position in radians or degrees if you like. Many incremental encoders have a zero-point output signal. Connect that to another I/O pin, and you can detect the zero position directly.
Probably I shoud have mentioned, I have already connected the z-signal to an input pin (cannel 3.5 - I do not know if that is a bad choice?). So I shoud be able to detect the zero position directly jet I have not implemented it in the code as up to now. My problem is if it is possible at all: How do I relate the number of pulses generated in incremental interface mode to a given angular position within a single rotation e.g. 45° or 60°? If I got it right from the manual the counter does not count a 1000 ppr when setup in incremental interface mode. Also I observed that as it generates around 2-3 ppr in my test environment. Am I right?
Incremental encoders come in all sorts of resolutions, anywhere from 1 cycle per revolution to at least 72,000 counts per revolution. Only you and your manual know exactly what you have. You haven't mentioned a part number yet. The shaft angle, in degrees, is a measurement with 360 counts per revolution. In grads, it's 400 counts per revolution. In radians, it's 2 pi counts per revolution. All you need to do to convert is scale the number of counts you have received since the zero point to degrees, based on how many counts the encoder provides in a full revolution. If you have a 1000 ppr encoder, then (counts * 360 / 1000) gives you degrees. You'll want to zero "counts" when the Z signal is asserted. Your application may prefer all positive angles (0-360) rather than negative ones (-180 to 180). So you might add to counts by a full revolution to avoid negative numbers. If your encoder really is generating 2 or 3 counts per revolution, then the resolution will be very low, 180 or 120 degrees per pulse. This could be fine for applications like measuring shaft speed for control feedback, or too low for applications like precise positioning using a stepper motor.
I found out what was wrong, it was a hardware problem. Anyway thaks for helping me :o)