Raspberry Pi Based IEC 61131-3 Compatible PLC

by Zihatec in Circuits > Raspberry Pi

8920 Views, 13 Favorites, 0 Comments

Raspberry Pi Based IEC 61131-3 Compatible PLC

titel_codesys.jpg

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.

Hardware and Software

RaspiBox Open Plus - Cap Rail Enclosure Kit for Raspberry Pi
RasPiBox transparent kit.jpg

Hardware

Software

Tools

  • soldering iron
  • multimeter
  • screwdriver
  • some solder

PCB Assembly

RaspiBox_pcb_assembled.jpg

We start with the assembly of the pcb. Please follow the instructions of the PDF manual.

Test the Pcb

Breadboard_raspibox1.jpg

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.

Mount the Top Shell

RasPiBox transparent front view.jpg

It's time to mount the top shell now. Looks like a small din rail PLC now.

Install the Operating System

raspbian_install.png

We have to install Raspbian on the SD-card using the instructions provided by the Raspberry Pi webpage first.

You can follow this instructable.

Don't forget to copy an empty file with the filename "SSH" in the root directory of the SD card to have access over SSH (Putty) later.

Install CodeSYS

codesys-raspi-import-768x394.png

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:

/etc/init.d/codesyscontrol start
/etc/init.d/codesyscontrol stop