Incremental Encoder Lathe Automation

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”

Advertisements

The lost Optical Encoder Demo Box

Optical ENcoder Demo Box Main Menu

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.

Count Screen:
This screen shows Pulse Count, Angle, RPM and direction.

Optical Encoder Data Screen

Degree Screen:

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.

The Ladder Logic

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 five updates Register D300 with our counter value every 10mS via the handy M1011 10 mS clock pulse.

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.

From Cymatix:

QD145-5/26-5000-0-02-T1-01-02 Optical Encoder

DOP-AS35THTD 3.5” Color touch screen

DVP12C11T Micro programmable Logic controller 8 inputs 4 High Speed outputs

DRP024V060W1AZ CliQ 24 Vdc, 60 Watt power supply

DVPACAB2A30 3 Meter connection cable

 

From Automation Direct:

DN-R35S1 Din Rail 35mm X7.5mm

WC12C12  N12 Desktop enclosure 12”X12”X9”

DN-T12A Terminal Blocks

DN-EB35MN End Brackets

DN-LAB terminal block labels

Finding the RPM of an Optical Encoder using an Oscilloscope

 

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.

You can also use the handy Web-based QDI optical encoder calculator  as well.

 

Jim

Optical Encoder Calculator

Quantum Devices optical encoder Resolution/RPM/Frequency Calculator.

We just added a new page to the main Quantum Devices Inc. web site that provides a way to calculate RPM, Frequency, or line count (optical encoder resolution) by entering in the other two variables.

Encoder RPM-Frequency-Resolution Calculator

When would you want to use such a tool?  You might find it useful under the following circumstances:

Read more of this post

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.

Optical Encoder Waveform Triggering

.

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.


Jim is an Applications Engineer for the leading optical encoder manufacturer Quantum Devices Inc. He can be reached via E-mail 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.