Why do my optical encoder signals look this way?

I received an email from a customer who was seeing “not symmetrical” data channels on some optical encoders we shipped to them

Hi Jim,

The data channels are not symmetrical and there appears to be something superimposed on the index. Attached are pictures. Can I return these for your evaluation?

Regards,

Al

Below are the screen shots that he sent:

Read more of this post

Finding the Index on an Incremental Encoder with a DMM

Sometimes you don’t have the right tools to do the job.

Lets say you needed to identify where the index pulse was firing on your incremental encoder, but you left your oscilloscope in your other jacket pocket, and now all you have on hand is a DMM.

Well fear not, finding the index with a multimeter is possible although a bit tedious.

The index fires once per revolution and at higher line counts this makes it VERY easy to miss.  Since there is some delay in a multimeter’s display time, you will need to rotate the encoder very slowly to catch a change in voltage level.

The Blue box has a nine-volt battery inside that I regulated down to 5Vdc for the encoder power.  I have pulled out connections to ground (Black wire) and the index channel (Orange wire). When the index fires, the voltage will go from zero to five volts.

Jim is an Applications Engineer with Quantum Devices Inc. A leading manufacturer of Optical Encoders.

Quantum Devices Optical Encoder Black/White Wire

What’s with this black-white wire?

Quantum devices QD145 and QD200 Optical Encoders feature an extra black & white-stripped wire that serves as an alternate grounding connection for the encoder.

This wire is intended to be used in situations where the encoder flex mount is not case grounded.  The Black/white wire is at the same potential as the Optical Encoder’s conductive polymer housing and  flex mount.

Internally the electrical path of the black-white wire is tied to the optical encoder housing and flex mount through the circuit board.  Our optical encoders tend to live on the back of hardware like Brushless DC motors, where the motor housing is at ground potential.  In cases like this it is usually best to leave the black-white wire tied off and floating.

Arrow showing flex mount grounding Optical Encoder to Motor.

Jim is an application engineer for Quantum Devices INC, a leading manufacturer of optical encoders.

Jim reached at jmiller@quantumdev.com.

Inverted Flex Mount for QD145 Optical Encoder

O.

.Another way to mount an Optical Encoder

Instead of using an end bell,  a lot of our motor manufacturer customers recess the QD145 optical encoder into an extended motor housing and then seal the motor with an end plate.

This has the advantage of being a lower cost item to manufacture, as the  motor housing is often extruded  or cast.  Just making the housing longer and providing an end plate usually costs less than casting a separate end bell.

Conventional Motor End Bell

But the downside to a recessed motor housing is that mounting an optical encoder in a recess like this creates a problem when tightening the set screws to the shaft. It often has to be done through an MS connector hole, or blind, by reaching the Allen wrench around and under the encoder.

Cast recess in motor housing

Because of this, we occasionally get asked for a a version of our QD145 optical encoder that allows the assembler to  access the set screws above the body of the encoder.  The inverted flex mount turns the encoder upside down allowing easy access to the set screws that are normally underneath the encoder.

The QD145 inverted flex mounti9ng option is not currently listed on our web site, but can be ordered using the following part numbers under the mounting options:

Use an 06 Mounting option for the inverted 1.157″ Bolt Circle flex mount.

Use an 07 Mounting option for the inverted 1.812″ Bolt circle flex mount.

The wiring is changed internal to the encoder so that the QD145 maintains correct phasing for all channels.

Another option for a drop in recess mounted encoder is the JR12 Jam Nut style encoder which does not use set screws to secure the encoder to the shaft, but a compression nut instead.

Dimensions for the 07 version of the QD145 Inverted flex mount.


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:

http://encyclopedia2.thefreedictionary.com/Grey+code

http://www.itl.nist.gov/div897/sqg/dads/HTML/graycode.html

http://mathworld.wolfram.com/GrayCode.html

Sample C code:

http://www.nrbook.com/a/bookcpdf/c20-2.pdf

WIKI:

http://en.wikipedia.org/wiki/Gray_code#Constructing_an_n-bit_gray_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

Using an Optical Encoder to show RPM on a PLC

.

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.

For an RPM application we will not be needing X2.

To calculate RPM with  an optical rotary encoder we use this formula:

RPM = (Frequency X 60)/ Line Count

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.

.

.

Optical encoders that can be used to find RPM can be found at http://www.quantumdev.com

For help with optical encoders in your application,  E-mail the author at jmiller@quantumdev.com

.

Optical Encoder Pulse Counting with a PLC

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:

Optical Encoder Counting with PLC

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.

Optical Encoder Ladder Logic for Counting with a PLC

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.

For more information on Optical Encoders check out the Quantum Devices Inc web page.

Ladder Logic to decode direction from an Optical Encoder

I set up a QD145 optical encoder on a Direct Logic DL06 PLC with some simple ladder logic to determine direction based on the A and B incremental inputs.

below is a video of the optical encoder in action:

In the PLC I used (DL06), the inputs are filtered, which makes the response time very slow and limits the RPM that can be read.  Please note that you will always need to take into account the maximum input frequency of your PLC when interfacing to an encoder.

Also please note that this code was set up for demonstration/learning  purposes only and has not been tested in a feild application.

The first two rungs of ladder logic are used to lock direction after it has been determined from the optical encoder.

Inputs X0 and X1 are the respective A and B signals from the QD145 optical encoder.

outputs C0 and C1 are used to latch direction, which is determined by the next high pulse after both signals go low ( Latch C4) .

Rung three is used to latch when both channels are low.  This a penultimate point in that the first signal to go high after this latch is set tells us the direction of the encoder.

Rungs four and five drop out the current direction latch when a direction change occurs.

Rung six is used to reset the low latch.  If we don’t have this,  the program will permanently latch into the first direction is sees.


Follow

Get every new post delivered to your Inbox.