Intro: Raspberry Pi Based IEC 61131-3 Compatible PLC
IEC 61131 is a de-facto standard for PLC programming. Meanwhile runtime versions for the Raspberry Pi are also available - for example CODESYS by the company 3S-Smart Software Solutions. They provide a commercial runtime kernel for the Raspberry Pi, but it will run without any payment as demo version for 120min before they stop... It's a good possibilty for students and hobbists to learn IEC 61131 programming.
The idea of this instructable was to realize a really cheap IEC 61131-3 compatible PLC based on the RPI and the CODESYS target. Like a real PLC we will put the Raspberry Pi board together with a development board in a rugged industrial enclosure to have the “industrial” feeling. In the end we will have a PLC running an EtherCAT master in the CODESYS runtime for almost no money at all.
Step 1: Hardware and Software
Step 2: PCB Assembly
We start with the assembly of the pcb. Please follow the instructions of the PDF manual.
Step 3: Test the Pcb
We should test the pcb before we can mount the Raspberry Pi. You have to connect a power supply (9...35V DC) to the pcb power terminal. Please check with a multimeter the 5V supply voltage for the RPI.
Now you can disconnect the pcb from the supply voltage and mount the Pi as in the picture above.
Step 4: Mount the Top Shell
It's time to mount the top shell now. Looks like a small din rail PLC now.
Step 5: Install the Operating System
Step 6: Install CodeSYS
1.) Pls download CODESYS Control for Raspberry Pi SL first. The free version is limited to 120min runtime (you have to restart the RPI to have 120 min again). You can buy a commercial version for 35€ without any limitation.
2.) Pls download CODESYS Development System now. You will need this software to write later the programs for the PLC on your PC.
3.) Install the Development System on your PC. Don't forget to install the CODESYS_Control_for_Raspberry_PI.package via the package manager: „Tools – Package Manager“ --> „Install“
4.) Restart Codesys on your PC now
5.) Load the CODESYS Runtime in the Raspberry Pi "Tools" --> "Update Raspberry Pi"
The runtime will run for 120min now. To restart it you can use this script: