We only need to measure one of the incremental channels in order to calculate the RPM of an optical encoder. Using an oscilloscope to measure the period of one incremental channel A cycle.

We will need to find the frequency of the incremental signal. Keep in mind that converting from time to frequency is just a simple press of the “one over X” button on a scientific calculator.

Frequency =(1/X time)

Time = (1/X Frequency)

To find RPM Once you have the frequency, Multiply by sixty and divide by the line count.

RPM = (Frequency X 60)/Line count of encoder

The encoder in the video is a 5000 Line Count encoder. Channel A is outputting pulses at a frequency of 224.2 Khz

RPM = (224.2Khz X 60)/5000

RPM = (13452000)/5000

RPM = 2690.4 RPM

I often use this method to either verify the speed of a motor controller I have built, or if I know the RPM of the motor, I will sometimes use this as a quick way to verify the line count of an encoder.

.

Seeing Encoder Quadrature with a two-channel scope

.

I received an e-mail from a customer concerned about the “out of control” optical encoder signals he was seeing on his Oscilloscope.

The photo below shows the type of signal he was seeing:

The encoder in question was a 10,000 Line Count optical encoder. I noticed that he was running relatively slowly, about 100 RPM. At that speed a lot of BLDC motors will show some degree of motor cogging, which is irregularity in rotation due to the magnetic fields in the rotor.

The customer was also triggering on an incremental channel (A&B) and not the index (Z) channel .

I am sure he had omitted the index as he wanted to see if the A&B incremental encoder signals were in quadrature.

I knew that when triggering on an incremental channel, the oscilloscope triggers off of whichever ever edge happens to occur within the scopes timing window. What the customer was seeing on the oscilloscope was overlapping screen shots of the incremental channels as the motor speed changed.

In other words, he was seeing the encoder report exactly what the motor was doing.

If the customer were to trigger on Optical Encoder channel Z (Index) with one scope channel, they could see a nice steady signal. If they wanted to check quadrature, they could then compare the phasing of A and then the phasing of B relative to where the index channel was located.

That’s a little bit of a hassle, it’s much nicer to see both A and B optical encoder signals on the scope at the same time. The way to do this with a two-channel scope like the Tektronix TDS 210 we have, is to use the scope’s external trigger and trigger off of channel Z.

The video below compares the optical encoder signals being triggered off of channel A and then being triggered off of channel Z.

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.

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.

Every once in while it’s nice to have a hand-held device that can be used to see quickly if encoder signals are present. I designed and built a quick-tester that allows for fast interface to an encoder without having to drag out a power supply and oscilloscope.

The Quick-tester is an optical encoder tester that is powered by a 9V battery. An internal 5V regulator drops the voltage to 5V, as two of the connections are power connections for the optical encoder.

Current limiting resistors are wired in to red LEDs. The LED’s illuminate when the optical encoder signals are High. By rotating the base by hand we can see if a channel is dead or even improperly phased.

Here is the schematic for the Optical Encoder Quick-Tester

Things the Quick Tester can tell you:

Which channels are working.

The LED’s should rapidly blink on and off while the optical encoder hub is slowly rotated. Keep in mind that turning the hub too fast will make the LED’s switch on and off quickly and cause them to appear to be continuously illuminated.

Proper phasing

When channel A is illuminated, channel A- should be dark and vice versa. If both lights are on or off at the same time, there is a problem with the encoder.

If A leads B, or B leads A

Rotate the encoder shaft slowly until both A and B are low (off), then look for the next high channel, that channel is the leading channel for that direction of rotation.

Location of the index pulse

It can be easy to fly right past an index pulse, particularly on higher line count encoders, but the Quick tester can tell you precisely when the index pulse occurs. This can be handy for mechanically timing the optical encoder to a real world position.

Other things to note:

If you have an optical encoder with open collector outputs, the Quick-tester’s LED’s will not illuminate unless you use pull up resistors between each channel and the positive supply of the Quick Tester.

If all lights are on, you have probably lost the signal ground connection to the Quick tester.

The Quick tester is set up to look at six channels at a time, so it is likely you will be looking at only incremental channel or only commutation channels.

I have interfaced a 200 line count QD145 optical encoder to a DL06 PLC. The PLC’s inputs are set up in high speed mode to receive the incremental quadrature pulses coming from the optical encoder.

.

CT174, the designated high speed up/down counter is used to interface to the encoder. By default inputs X0 and X1 are used for the A& B incremental signals, without having to code them to the counter. Input X2 is designated as the reset, and may normally be connected to the index pulse of the encoder.

Since frequency is “cycles per second” we set up our high speed timer on rung three to give us a count total every second; this is our frequency.

Rung four is where all the heavy lifting happens:

After the high speed timer has timed out to one second, we load the PLC’c accumulator with the value from the counter (CT174). This will be our frequency, or the number of optical encoder counts that we have accumulated in one second.

We then multiply that value by 60, which uses our one second total to convert to the number of pulses occurring in a minute.

And we divide that total by 200, the line count, to get the RPM of the optical encoder.

We move the value to V2500, a location that we can pick up with the screen.

C3 is then used to reset the timer and counter and start the process over again.

I have interfaced a 200 LC QD145 to a DL06 PLC to show how to convert from a line count to mechanical degrees. This type of conversion may be useful for any application needing to know an angular measurement.

To calculate a degree measurement we divide 360 by the line count to get the number of degrees per pulse.

(360 Degrees /200 Pulses per revolution) = 1.8 Degrees per pulse.

The High Speed counter we have set up will automatically add one to it’s running total any time the encoder is rotated counter-clockwise, and subtract one from the running total any time the optical encoder is rotated clockwise.

This value is loaded into the PLC’s accumulator and multiplied by 1.8 (K18) to convert to degrees. The number is then outputted to an address(V2500)that we can display on the screen.

When the index (Z) pulse occurs, we reset the counter to let it know we are back at zero.

Below is the PLC code for the pulses to degree conversion.

It is good to note that the PLC is set up to retain the count value when powered off, but if the optical encoder is rotated during this time, the count will not change and the value at power up will be different than the encoders real world position.

It is good practice to rotate an incremental encoder/optical encoder on power up until an index pulse is seen and start counting from there. This is technique is known as “homing”.

By default the quadrature counting mode within the PLC keeps track of negative numbers, so we are able to accumulate a negative degree value depending on the direction of rotation after zero. While this may seem a bit confusing, it is really just a matter of your point of reference. –90 Degrees is the same exact point as a positive 270 Degrees. If we wanted to convert to where we stayed within a positive degree range, you could change the PLC code to add 360 to the measured value any time it went negative.

I have interfaced a QD145 200 Line Count Optical Encoder to a DL06 PLC and set up the PLC for mode 20 ‘High speed Up/Down counter’.

Here is a video of Optical Encoder Counting:

Below is the ladder logic code for programming the PLC to count pulses from the QD145 optical encoder using high speed counting mode. Note that “high speed” for the DL06 standard inputs is still limited to 7kHz. Where the encoder can go as high as 500 kHz by specification.

Setting up the ladder logic code for the DL06 is fairly straightforward in that the UDC (up down counter) seems to be built to take optical encoder inputs.

When in high speed mode, inputs X0 and X1 are inputs to the counter (CT174) by default. Input X2 is a reset input and could be wired to the index channel on the optical encoder if we were looking to translate the count into a 360 Position, but is left unwired for this up down count application.

The first rung on the counter (CT174) is the ENABLE. I latched C11 off of the first scan bit (SP0) to enable the counter. Note that CT174 was not picked arbitrarily, it is the specified counter location for high speed counting

The use of X0 and X1 on the second rung of the counter may seem a bit odd if you thought they were feeding counts the counter; instead those inputs are being used to updated the count from the input buffer to the counter memory location. To ensure that we always have the most accurate information. I place the two inputs parallel to trigger the update whenever we see a pulse from A OR B. This rung could also be held on for constant updating.

I am using bit 2501.0 (the F1 Key from the panel) to force a reset on the counter when ever the button is pressed.

Bit 1175.15 is the MSB from counter CT174 and indicates when the count has gone negative.