Understanding Incremental Encoder signals

Which incremental encoder wires should I use?

Channels A & B (Incremental Channels)

Use only A (or only B) for an RPM or counting applications where the rotation is either unidirectional, or where you don’t need to know direction.

Use A and B together to know direction. After two low pulses the next high pulse indicates direction.  This is due to the phasing offset between A and B of 90 electrical degrees, placing the signals in what is known as quadrature.

These signals can also be used to set up an up/down counter

Index pulse, also known as Z, marker, or I

Index pulse is a pulse that occurs once per rotation. It’s duration is nominally one A (or B) electrical cycle, but can be gated to reduce the pulse width.

The Index (Z) pulse can be used to verify correct pulse count

The Incremental Encoder Index pulse is commonly used for precision homing.  As an example, a lead screw may bring a carriage back to a limit switch.  It is the nature of limit switches to close at relatively imprecise points. This only gives a coarse homing point. The machine can then rotate the lead screw until the Z pulse goes high.

For a 5000 line count encoder this would mean locating position to within 1/5000 of a rotation or a precision of .072 Mechanical Degrees.  This number would then be multiplied against lead screw travel.

Commutation (UVW) signals are used to commutate a brushless DC motor. I always like to compare these signals to that of a distributor in a car. The commutation (sometimes called “Hall”) signals tell the motor windings when to fire

You would need to have encoder commutation signals if the motor you are mounting the encoder to has a pole count and there is no other device doing the work of commutation.  It is important to note that commutation signals need to be aligned or “timed” to the motor.

Single ended VS differential

These terms refer not to the waveforms of signals, but instead to the way the signals are wired.

Single ended wiring uses one signal wire per channel and all signals are referenced to a common ground.

TTL and Open Collector are types of single ended wiring.

Differential wiring uses two wires per channel that are referenced to each other.  The signals on these wires are always 180 electrical degrees out of phase, or exact opposites.  This wiring is useful for higher noise immunity, at the cost of having more electrical connections.

Differential wiring is often employed in longer wire runs as any noise picked up on the wiring is common mode rejected.

RS-422 is an example of differential wiring.


Gray Code for Rotary Incremental Encoders

Gray code was named for Frank Gray, a Bell labs researcher, who patented the procession in 1953,  even though a form of it was used by Emile Baudot for telegraphy as early as 1878.

The most important thing to understand about Gray code is that only one bit changes from transition to transition.   In binary it is possible for a number to go from all ones to all zeros, as is the case with 11111111 (255 decimal)  going back around to 00000000 (zero).

Dec           Bin                    Gray
0              0000                0000
1              0001                0001
2              0010                0011
3              0011                0010
4              0100                0110
5              0101                0111
6              0110                0101
7              0111                0100
8              1000                1100
9              1001                1101
10            1010                1111
11            1011                1110
12            1100                1010
13            1101                1011
14            1110                1001
15            1111                1000

Notice how only one of the 0’s or 1’s of the Gray code change as the number increments?  In binary there are times when all of the bits change, (0111  to 1000 (Seven to Eight ) and 1111 back to 0000 (Fifteen to Zero) ).

Error Checking

The advantage to only one bit changing in Gray code is that it gives you error-checking ability.  If you sum the number of bits the bit total will always change by only one.

You could also do some error checking knowing that the bit sum will always alternate between even and odd.

Gray      Bit Sum
0000         0
0001           1
0011           2
0010           1
0110           2
0111            3
0101            2
0100           1

Gray Code in Incremental Encoders

The A & B channels of Incremental Encoders are in quadrature, which makes a two-bit gray code progression.  Depending on direction, the Incremental Encoder bit progression with be a cyclical pattern of either 00 – 01 -11 – 10  or  00 – 10 – 11 – 01 – 00.

Only one bit changes from transition to transition.

The QD787 absolute encoder shown at the top of this post has an option for an eight bit Gray code output.

Links to more information on Gray code:




Sample C code:




For more information on encoders, go to http://www.quantumdev.com

Jim can be reached at:  jmiller@quantumdev.com

Interfacing a 5Volt Incremental Encoder to 12 Volts


Interfacing to an Incremental Encoder using an optoisolator

When I chose the PLC that I wanted to build incremental encoder applications around, The DL06 seemed like a perfect low cost option, but what I failed to notice was that it had a minimum 12V input requirement to turn on the DC inputs. No problem, I thought, I’ll just get production to build me some of those 5-26V incremental encoders that are so popular with the kids now days.   I realized that plan was flawed once I saw how busy the production schedule was. It appears that word has gotten out that the QDI series of encoders are a great positional feedback option.

So what could I do? I already had 5V incremental encoders mounted on the motors. This carried the added bonus of the commutation tracks already being phased, meaning I didn’t have to worry about timing the Com tracks of the incremental encoder to the BLDC motor.

If only there was some way to turn a 5V signal into a 12V signal…

Well there is. You can use a device called an optoisolator, sometimes called an optocoupler, or photocoupler, although there are technically differences among these devices.

Here are some of them from my component stash. They seem to often come in white packaging.

My guess is that the white color is for better optical properties internal to the device, as white is much more reflective.

Looks like I only have one black sheep left in my flock.

An optoisolator consists of a light source on one side (usually an LED), and a phototransistor on the other.  It should probably be mentioned that the “tail end” of an optoisolator can also contain other devices, like an SCR,  Triac, or varistor. For what I needed, the transistor style output would work just fine.

Each side of the device is electrically isolated from the other so there can be a 5 volt potential on one side and a 12 volt potential on the other, each having a separate a ground.

I also needed to use at least a 100 ohm resistor on the cathode side of the LED.   This was done to limit the current though the optoisolator in order to keep from burning out the internal LED.   The inputs on the PLC already have built in internal resistance, so no resistors were needed there. I just wired it in series between the +12V source and the input. The PLC’s common was wired to ground.

Below is a down and dirty”trial run” at interfacing to the PLC.

There is sometimes a need for a customer to separate out incremental and commutation signals with separate voltage supplies.  Usually this is the case if the signals are running to two different devices, each with separate grounds.  For example, having a drive and a controller that are separated by a great distance.

For these custom designs we have used the optoisolators internal to the encoder.  Here they are in a smaller surface mount package.

While optoisolators can be a good solution to an incremental encoder  voltage-interfacing problem, ordering an encoder like a 5-26 Volt QD145, or QD200 and NOT having to mess with interfacing makes a lot more sense.

You should also keep in mind that there is a real delay using devices like this that can result in positional error. For demonstration purposes, or slow movers, this may not matter, but if you are trying to keep a the reigns tight on a control loop, 20 uS or so of delay may be too much.

To find your multi-voltage encoder answers go to http://www.quantumdev.com

Jim can be reached at:  jmiller@quantumdev.com