PiLC - S7 PLC for Raspberry Pi
Image preview of awlsim-on-pixtend.jpg

PiLC is an Awlsim based PLC (programmable logic controller) package for the Raspberry Pi.

PiLC based on the Raspberry Pi OS distribution and runs on the Raspberry Pi 1B+, 2, 3, 4 and Raspberry Pi Zero devices.

PiLC supports digital I/O (I/Q, E/A operands) on the Raspberry GPIO. The BCM-GPIO-I/O is handled via Awlsim's rpigpio hardware module. See the example project raspberrypi.awlpro for a usage example.

A hardware module for the PiXtend v1.3 and v2-S hardware is included in the PiLC distribution. So the PiXtend I/Os (Relays, digital inputs, digital outputs, analog inputs, GPIOs) can be used.

Experimental support for PROFIBUS-DP is provided via the pyprofibus hardware module. This can be used to read data from and write data to PROFIBUS-DP slaves using the Raspberry Pi RS232 transceiver. A RS232 to RS485 converter such as the one shipped with PiXtend is required.

Image preview of pilc.jpg

Basic documentation about PiLC can be found here.

PiLC is beta quality software.
That means it does not include all anticipated features and probably contains some bugs.
The documentation is not complete.
The software is not fully tested.
You are encouraged to test PiLC and report all identified bugs or missing features to the author.

Just extract the SD-card image and raw-copy it to an SD-card.
Note that it does not work to copy the image into a pre-formatted SD-card's filesystem. The image brings its own partition table and filesystem, so it needs to be copied directly to the raw SD-card.

On a Linux host this can be done as follows:

7z x pilc-x.y.img.7z                       # Extract the image using 7-Zip
dd if=pilc-x.y.img of=/dev/mmcblk0 bs=8M   # Copy the image to the SD card

Where x.y is the PiLC version number and /dev/mmcblk0 is the raw SD card device.
Note that on some systems you will have to use /dev/sdX instead of /dev/mmcblk0.

A more detailed description of the installation of SD card images can be found on the RaspberryPi site for Linux, Windows or Mac operating systems.

The program 7-Zip can be used to extract the PiLC image file.

You can login over the network to a Raspberry Pi running PiLC using the default Raspbian credentials with OpenSSH or PuTTY or any other SSH client program:

User: pi
Password: raspberry

DHCP is installed on the PiLC. So if you connect the ethernet port to your router, PiLC will automatically request an IPv4 address from the router at startup.
So if your router assigned the IP address (for example) to your PiLC, the following commands would be used to log in:

user@hostPC:~ ssh pi@
pi@'s password: raspberry

Please note that the IP address that your router assigns to PiLC will be different. Check your router configuration for more details.
Also note that the password will not show up (not even *** stars) in the console while you are typing it. Just type it in blindly and press enter.

If you don't want anybody else to login to your PiLC over the network, you are encouraged to change the password. That can be done with the passwd command. See man passwd for more help.

Alternatively, if you do not want to use a network connection, you may want to connect a display to the Raspberry Pi's HDMI port and a keyboard to one of the USB ports. Once PiLC is booted up it will show a console login prompt on the screen where you can locally login using the credentials from above.

Awlsim will already be up and running as a systemd service on a fresh PiLC image. You can connect to the running Awlsim server using the Awlsim GUI over SSH. So everything is ready to download and run an AWL program on the PiLC. Please see the Awlsim documentation for more details about how to do that.

If you want to stop the Awlsim systemd service on the PiLC, the following command can be used:

pi@PiLC:~ sudo systemctl stop awlsim-server
[sudo] password for pi: raspberry

If you want to start the Awlsim systemd service again, use this command:

pi@PiLC:~ sudo systemctl start awlsim-server
[sudo] password for pi: raspberry
Image preview of pilc_et200s.jpg

Communication via PROFIBUS-DP can be achieved using the pyprofibus PROFIBUS software stack and the corresponding Awlsim hardware module.

In the photo to the left hand side you can see a prototype setup of a Raspberry Pi 2 driving the digital inputs and outputs of a Siemens ET 200S PROFIBUS-DP slave. The Raspberry Pi controls the ET 200S via the PiLC example AWL program that runs in Awlsim.

The development source code of pilc can be downloaded using the Git version control system as follows:

git clone https://git.bues.ch/git/pilc.git

To browse the Git repository online, go to the repository web interface.
Or download the compressed snapshot.
A mirror of the repository is available on GitHub, GitLab, Bitbucket and on NotABug.org.
If you want to contribute to pilc, please read the contribution guidelines first.

A PiLC SD-card image can be built by running the pilc-bootstrap.sh script. Note that pilc-bootstrap.sh does only run on a Debian Linux host system (or another system that has debootstrap).
See pilc-bootstrap.sh --help for options.

If you find any bugs in PiLC or if you have any suggestion for new features, we would like to hear from you.
Your help is greatly appreciated and will help to create better software and improve the overall experience for everybody. So don't hesitate to report anything that that limits your PiLC usage.

If you have got any code improvements or other improvements that should be merged into the project, please send such enhancements to the PiLC maintainer.

Please read the contribution guidelines first.

Copyright (C) Michael Büsch
Licensed under the terms of the GNU General Public License version 2 or (at your option) any later version. See the sourcecode for details.

Updated: Monday 20 May 2024 13:27 (UTC)
xhtml / css