OpenPLC on PiXtend

Make sure that your PiXtend is running a recent version of the Raspbian operating system. To avoid compatibility problems, it is better to download the most recent Raspbian form the Raspberry Pi website and make a fresh install.​

The best way to get OpenPLC files into your PiXtend is by using git. Usually, git comes preinstalled on Raspbian. If for some reason you don’t have git installed on your system, you can install it by typing: ​

sudo apt-get install git

To install OpenPLC type these lines on the terminal:

git clone https://github.com/thiagoralves/OpenPLC_v3.git
cd OpenPLC_v3
./install.sh rpi

The installation process will take a while (up to 1 hour depending on your system). Meanwhile, grab a [insert your favorite beverage here] and relax! Once OpenPLC is installed, just reboot your device and it will start automatically after boot.

Tip

To use in-development capabilities, checkout the development branch (git checkout development) prior to running install.sh.

The OpenPLC runtime has a built-in webserver that allows you to configure OpenPLC and also to upload new programs for it to run. This webserver can be accessed by opening a web browser on your computer and typing the IP address of your OpenPLC device at port 8080. For example, if your PiXtend has the IP 192.168.0.103 on your network, you should type this on your browser:

If you don’t know the IP address of your board, the Raspberry Pi foundation has a nice guide to help you out.

Once you access OpenPLC webserver, you should see in your browser window a login page like this:

The default username and password is openplc (login) and openplc (password). This means that the first thing you must do after logging in for the first time is change the default username and password! It is very easy to do that. Just go to the Users menu, click on the OpenPLC User and change the information as you like.

Once you save the changes you will be prompted to login again. Just login with your new credentials and you will be good to go!

Pin Mapping

By default OpenPLC runtime is installed with a blank driver. This means that it won’t be able to control your PiXtend inputs and outputs straight away. To enable the PiXtend driver, go to the “Hardware” section and from the popup menu, select either “PiXtend” or “PiXtend 2s” depending on your board. Click on “Save changes” and wait for a little bit while the driver is applied.

Below you will find the OpenPLC I/O mapping for the PiXtend board. The mapping should be the same across all the different board revisions.

My First Project

The Reference menu on this website has a nice tutorial that teaches you how to create your first project. However, if you’re in a hurry, you can download the official Hello World project, which is basically one rung, a button, a timer and a coil, all connected together. The button is attached to %IX0.0 and the coil is attached to %QX0.0. When the button is pressed and released, the coil is energized and remains on for 2 seconds, and then turns off.

Download the project below and open it on OpenPLC Editor. Click on Generate program for OpenPLC Runtime in order to compile the diagram into a ST file. Then upload the ST file to the OpenPLC using the web interface.