RUNNING THE OPENPLC
The OpenPLC Software was redesigned to be portable. It relies on the MatIEC compiler to generate some .c files based on the program written by the user. These .c files, combined with other OpenPLC files can be compiled to a final application that runs your logic on the chosen platform. Besides the original concept hardware, the OpenPLC can also run on a Linux machine, RaspberryPi, UniPi and Arduino platform (nano, uno, mega, due, zero and other compatible boards)
Running OpenPLC on a Linux Machine (i.e. RaspberryPi)
The OpenPLC can run on any Linux machine, including embedded Linux boards like the Raspberry Pi. Before installing OpenPLC, you must have NodeJS installed. If you're running it on the Raspberry Pi, you will also need to install WiringPi first. After that, just clone the OpenPLC repository on github using the command:
Then run the build script by typing ./build on the OpenPLC directory. It will ask which driver you want to use. Select the proper driver for your board to finish the build process
To run, just type:
sudo nodejs server.js
The OpenPLC application has a NodeJS webserver that can be accessed using any web browser. Just point your browser to http://ip-address-of-the-linux-machine:8080 to access. It controls if the OpenPLC is running or not and enables the user to upload programs (.st) files generated using the PLCopen Editor to the OpenPLC. When a new ladder file is uploaded, it is automatically compiled into a new application and executed.
If you're using the default Raspberry Pi driver, take note:
Inputs %IX0.0 through %IX0.6 are pins 7, 11, 13, 15, 19, 21 and 23 of the RaspberryPi header.
Outputs %QX0.0 through %QX0.4 are pins 16, 18, 22, 24 and 26 of the RaspberryPi header.
The default RasberryPi driver doesn't accept analog I/O because RaspberryPi doesn't have any analog I/O.
If you are using RaspberryPi with the UniPi board, after compiling the project type:
gpio load i2c
in order to load the i2c module into the kernel. This will enable OpenPLC to communicate with the peripherals on the UniPi board. Sometimes a reboot is needed after using this command. You only need to type it once.
OpenPLC on other platforms
The OpenPLC is fairly portable. A blank driver was created to run it on any Linux machine. Since the hardware layer for this implementation is blank, it will not be linked to any I/O, but rather run as a PLC simulator on your computer. You can interact with it using any MODBUS HMI software such as Modbus Poll to view and change the I/O state of the simulated PLC. To make it run on a real hardware, just edit the file hardware_layer.cpp inside the core folder according to your hardware (such as USB I/O expansion boards).