I received this e-mail from a potential customer who is trying to determine why his Encoder waveform doesn’t look right. His name has been changed to protect his identity.

Hi Jim

I have just come across your Web page on RPM calculation using an optical encoder and oscilloscope. I was keen to test out this method of RPM calculation so rigged up my little encoder and oscilloscope without hesitation. I don’t seem to be getting a nice wave wave form across my display, its rather skewed. Could you just point out where I’m going wrong?

Really enjoyed reading your articles. Look forward to hearing back from you soon.

Eddie

Eddie’s photos are below:

Hi Eddie,

I would love to say the problem is that you aren’t using a Quantum Encoder….

But instead it looks like you are just missing a ground reference for the scope. There is usually a little black alligator clip hanging off the side of the scope probe. That clip needs to be attached to the signal common on the encoder (black or negative on the power supply)

The red arrow below indicates where the ground clip should connect to the scope probe.

The reason your waveform looks skewed is because the absence of a ground reference causes the scope to pick up ambient 60 Hz noise (it is everywhere, outlets, lights etc.) and couple it with your encoder signal.

Connecting the scope ground to the incremental encoder signal common will clear that right up.

I have been working on a project to automate a manual lathing operation for our incremental encoder/optical encoder line.

To keep things simple, thumb switches allow the set point, along with some offsets for fine-tuning, to be entered.

I am not completely finished with project, but in the video below you can get a feel for how the machine will mill down the incremental encoder shaft. We have control of the tool position to within .0001”

We recently teamed up with one of our distributors to create a Demo box that showcased our QD145 optical encoder with a Delta Tau PLC and touchscreen panel. It was sent off to a trade show where potential customers would get to spin the encoder and watch on the screen as counts were incremented and decremented and needles on dials spun.

I thought the Optical Encoder Demo box would make for a fantastic topic to write a post on, so that was my plan as soon as the demo box returned from the show.

Well… it never did come back. I would love to tell you that I did such a great job on it that our distributor insisted on keeping it but the truth of the matter is that it was lost in shipping.

What I do have is the code and screenshot of the Optical Encoder Demo box, which should be more than enough to explain the functionality. What I don’t have are pictures, or video of the Optical Encoder Demo box in action, so you will have to use a little imagination on your part.
I mounted the PLC, HMI and encoder to an enclosure that can set on a table. The default screen (shown above) tells a little about the encoder. From this screen you can select a few different screens that allow you to interact with the encoder.

This screen shows mechanical degrees. The needle rotates in conjunction with encoder rotation:

Optical Encoder Mechanical Degree Screen

Pulse Count:
This screen shows the direct read count of the encoder, the needle rotates in conjunction with encoder rotation:

Optical Encoder Pulse Count Screen

Tank Screen:
This is sort of a fun screen where rotation the encoder fills tanks in sequence, tank one fills, when tank one is full it “empties” into tank 2, when tank 2 is full it “empties” into tank 3. Tank 3 continues to accumulate until 2 billion counts or so. The Drain button clears the levels on all of the tanks.

Optical Encoder Tank Filling Screen

ABZ screen:
This screen indicates status of inputs coming from the encoder. Since I used a 5000 LC encoder, the screen was not be able to keep up real time when the encoder was rotated really fast, and it was nearly impossible to land on Z(Index) and have it light.

Optical Encoder Incremental Signals Screen

Programming

The Delta Tau was pretty easy to program, with only a couple hiccups. The manual was a little vague in its explanation of the way two registers were used for some of the counter functions, but a little troubleshooting showed me which bits were activated when the counter set point was hit.

This first rung of code is needed to do some basic housekeeping to ensure that D1022 is properly configured with a “1” on the first program scan. It is set by M1002 and forever latched by M110. The value of 1 tells the high speed input that we want a double frequency selection A/B phase counter.

The second rung sets up our high speed counter and checks the count to see if we have gone negative in value. If so, bit M120 is set high.

Rung three turns on a physical output Y11 if the counter set point has been hit.

Rung four moves the set point of 5000 back into the counter if we have gone negative in value. This allows the needles on our display screens to rotate continuously and not peg out to a high or low value.

Rung six divides the counter value by 16 and moves the answer into Register D302. This is where we start our math for the degree conversion. The rest is scaled by the configuring the screen register in the screen editor software.

Run seven uses the trailing edge of our 10 mS clock pulse to move the counter value into register D310. This value is held for comparison in time to get RPM.

Rung eight uses the leading edge of our 10mS clock pulse to find the difference in our stored value and put it out to register D312. D312 is then doubled and sent out to register D350.

For any of you interested in repeating the project, I have included the BOM below.

Of course, I also used some miscellaneous wire and hardware to construct the Optical Encoder Demo box, but the list below includes all the big ticket items.

.

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.

.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.

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.

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.