Click PLC HMI Rotary Encoder Dial Input

Rotary encoders are modern digital devices that have taken over from the potentiometer in stereos and many other applications. This is because of their fine digital control and they can fully rotate without end stops. We can connect the rotary encoder into the PLC using just two digital inputs. This human machine interface (HMI) has the advantage over touch screens and other methods of control into the PLC. The operator can control the rate and set point with the dial (rotary encoder) without looking at the control. This will allow the operator to concentration on other tasks.
We will be connecting a rotary encoder with dial into the Click PLC. The signals being sent from the rotary encoder will be explained. Different methods of programming this input in our PLC will be discussed. Let’s get started.

Attached to the rotary encoder will be our dial. The dial is black 36mm top rotary with a 6mm diameter shaft.

Wiring the Rotary Encoder
The rotary encoder has open collector outputs. Our PLC will act as the load (resistance) in the above diagram.
You will see that our common PLC input will be at +24VDC. We will be wiring the encoder inputs as follows:
X2 – A phase of the rotary encoder
X3 – B phase of the rotary encoder
Our rotary encoder also comes with a switch. This is momentary upon pressing down on the encoder. We will be wiring this encoder switch into X1 of our Click PLC.

Rotary Encoder Operation
The rotary encoder has two square wave outputs (A and B) which are 90 degrees out of phase with each other. The number of pulses or steps generated per complete turn varies. This Rotary Encoder has 20 steps but others may have more or less. The diagram below shows how the phases A and B relate to each other when the encoder is turned clockwise or counter clockwise.
As we rotate clockwise, phase A will turn on and we can trigger the input when phase B transitions from off to on. When we rotate counter clockwise, phase B will turn on and we can trigger the input when phase A transitions from off to on. It is important to pick up the direction so we can increase or decrease the value in the PLC.

Programming the Click PLC
As mentioned above when the dial is turned clockwise we look for A phase to be on and the leading edge of B phase. Memory location DS1 is incremented by 1.
When the dial is turned counter clockwise we look for B phase to be on and the leading edge of A phase. Memory location DS1 is decremented by 1.
Our program will make this a ten turn maximum on the dial. This means that we will have a maximum limit of 200 pulses. (20 pulses/turn x 10 turns = 200 pulses)
We compare DS1 with the maximum count of 200. If it is greater than 200 we will move 200 back into DS1.
The smallest value in DS1 will be 0. We do a compare on DS1 for values less than 0 and if this is true we move 0 into DS1 to ensure that it is not below the value of 0.
Our rotary encoder switch will be used to reset the current value in DS1 to 0. If X1 turns on then the value of 0 is moved to DS1.

We have used 20 counts per revolution in our program because this is where the dents are on the rotary encoder. 40 counts per revolution is possible because we can pick up on the leading and trailing edge of each of the phases.
As we pick up on the leading and trailing edge of A phase, the state of B phase will determine when to increment the count.
The leading and trailing edge of B phase along with the state of A phase will determine when to decrement the count.

Watch the video below to see the Click PLC HMI Rotary Encoder Input in action.

If you’re like most of my readers, you’re committed to learning about technology. Numbering systems used in PLC’s are not difficult to learn and understand. We will walk through the numbering systems used in PLCs. This includes Bits, Decimal, Hexadecimal, ASCII and Floating Point.

To get this free article, subscribe to my free email newsletter.

First Name:Last Name:Email address:

Leave this field empty if you're human:

Use the information to inform other people how numbering systems work. Sign up now.

The ‘Robust Data Logging for Free’ eBook is also available as a free download. The link is included when you subscribe to ACC Automation.