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.


About Quantum Devices Inc.
Quantum Devices, Inc. (QDI) Barneveld, WI, was established as a Wisconsin corporation in October 1989, as an outgrowth of activities in the general area of optoelectronics. The main goal of QDI is to provide customers with a complete source for all stages of product design and development, starting from concept to a marketable commodity. These products include application specific Silicon Photodiodes, Optical Encoders and Light Emitting Diodes (LED) for commercial, industrial and medical applications. QDI's photodiodes and LED's are used in instrumentation for photosynthesis and photobiological research, biomedical and medical instrumentation for measuring blood sugar levels (glucometer), oxyhemoglobin and pulse rate (pulse oxymeter). One of the most dramatic products developed at QDI was the application of LED lighting systems for use as the light source for Photodynamic Therapy (PDT). Sales of QDI products include both domestic and international markets. Quality and reliability are very important concepts in maintaining our company wide commitment to overall product performance. Quality simply means continuous process improvement. We are committed to continually increasing our product excellence through increased quality and reliability. Quantum Devices, Inc. is ISO 9001 certified and the ISO Standard will provide the guidance for the vital function of maintaining our commitment to constantly improve our product quality. Quantum Devices is now proud to introduce it's new line of rotary encoders. Incorporating QDI's patented sensor technology, our QPhase™ Family of Encoders feature high resolution, increased frequency response and superior reliability over temperature (0 to 120 degrees C). QDI incremental and absolute encoders set a new standard and are backed by a 2 year factory warranty. We invite you to request an evaluation unit, additional information or price quotations. Mission Statement Quantum Devices is dedicated to the principle that light provides the power for all life on earth. We believe the quality, delivery and control of light is essential to the wellness of man and his advancement into the future.

One Response to Ladder Logic to decode direction from an Optical Encoder

  1. Dear QUANTUM DEVICES INC. , My name is Jay-Lee, I work for a company the provides Wind Turbine Trainers for educational facilities, I having an issue with setting my encoder for my DL06 to read position, find specific points, and reset position. I am new at the DL06 and could use a hand. If you could help, please contact me with any advice.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: