Home

codesys.com Ingo Falk
Attachments
PLC_PRG.PNG (14146 bytes)
There is a newer version of this page. You can find it here.

Hardware

This library supports currently only the rotary encoder KY040. But it should support more in the future.

Usage

The exact usage of the driver depends on the hardware and the implementation of the driver. As this varies a bit, every driver has its own documentation.

As an example we will use the Raspberry Pi 1 Model B. You also have to install CODESYS Control for Raspberry Pi SL. (link here: https://store.codesys.com/codesys-control-for-raspberry-pi-sl.html?___store=default)

Now connect the outputs of the first KY040 with the Raspberry Pi like this:
CLK --> GPIO 0
DT --> GPIO 1
SW --> GPIO 3
+ --> 5.0 VDC Power
GND --> 0 V (Ground)

At this point you could install another KY040 if you want to play for example the game Pong (How to install: https://forge.codesys.com/lib/retro-games/wiki/Home/)

Step 1: In your CODESYS Development System open or create a project.
Step 2: Go to Tools -> Library Repository and Install the RotaryEncoder.library