We will now look at the programming and wiring of a rotary encoder to the Click PLC 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 setpoint with the dial (rotary encoder) without looking at the control. This will allow the operator to concentrate 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.
Previously in this series we have discussed:
System Hardware – Video
Installing the Software – Video
Establish Communication – Video
Numbering System and Addressing – Video
Timers and Counters
– Counter Video
– Timer Video
Compare and Math Instructions – Video
Program Control Instructions – Video
Shift Register – Video
Drum Instruction – Video
Send and Receive Instructions – Video
AdvancedHMI Communiation – Video
Firmware Update – Video
Create an Analog Voltage Input Tester for a PLC – Video
Wiring Testing Analog PLC Input Click – Video
Modbus RTU Click PLC Master to BRX PLC Slave Communication – Video
The programming software and manuals can be downloaded from the Automation Direct website free of charge.
Rotary Encoder – Hardware
We will be using a rotary encoder that has 20 momentary resting points within the 360 degree rotation. These dent locations give the operator a feel for the movement of the PLC input. Here are the specifications of the rotary encoder we will be using:
• Material: plastic, metal, encoder switch
• Net weight: 12G
• Main color: silver tone, blue
• Size shaft: 6 x 13mm / 0.24 ‘x 0.5’ (D * L)
• Thread DIA: 7mm / 0,28 ‘
• Total size: 15 x 12 x 30 mm / 0.6 ‘x 0.47’ x 1.2 ‘(L * W * H)
• Wave direction: 360 degrees
• Action Type: Momentary
• Resting points: 20
Wiring the Rotary Encoder to Click PLC Input
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 – Input Signals
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 for Encoder Input
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.
Download the Click PLC programs here. (20 pulses / turn and 40 pulses / turn)
Click PLC Support Links
The Click PLC can be programmed using free Click programming software from Automation Direct. Here is a link to the software.
The following links will help you to install the software and establish communication.
The entire Click PLC series can be found at the following URL:
Watch on YouTube : Click PLC HMI Rotary Encoder Dial Input
If you have any questions or need further information please contact me.
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.
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.