OpenPLC Installation

This site has videos for installing OpenPLC and SCADABr.

The installation described on this page is used for UAH's CPE 459/559 class. Much of it will work for other purposes.

You will install and configure:

  1. Two virtual machines with Ubuntu Desktop LTS (PLC and HMI).

  2. Moba Xterm.

  3. OpenPLC runtime.

  4. OpenPLC Editor.

  5. Arduino IDE.

  6. SCADABr Human Machine Interface (HMI) software.

Download and install the Oracle Virtual Box.

  1. Select the link that matches your operating system (Windows, MAC, Linux).

  2. Run the downloaded executable and accept all defaults.

  3. You may need to reboot your computer.

Download and install the extension pack.

Link: https://www.virtualbox.org/wiki/Downloads

    1. Click the link under “VirtualBox 6.1.16 Oracle VM VirtualBox Extension Pack

    2. Clink on the downloaded file, in Explorer or in your browser, and follow directions to install.

Install Ubuntu Desktop LTS

Download an Ubuntu Desktop LTS .iso file.

  1. Click the Download link to download. The file is quite large (2GB+). It will take a while to download. Coffee break 😊

  2. Install the .iso within VirtualBox.

  3. Open the Oracle VirtualBox VM Manager.

  4. Press New

  5. Name the new VM PLC

  6. Change the type to Linux

  7. Select Defaults for Memory Size, Hard Disk, Hard disk file type, Storage on physical hard disk, File location and size.

  8. Your VM is now created, but we still must install the OS on the VM.

  9. Within the Oracle VirtualBox VM Manager, select the PLC VM, and then click Settings.

  10. Click Storage.

  11. Under Controller IDE select the DVD symbol.

  12. On the far right click the DVD symbol and select Choose a disk file.

  13. Select the .iso file downloaded from the Ubuntu website.

  14. Start the VM and follow install instructions within the Ubuntu OS.

  15. Remove the .iso from the VM DVD drive.

  16. Reboot your PLC VM (this new VM).

Configure to turn off the desktop (GUI) environment.

We will run with command line to conserve computer resources.

Link: https://linuxconfig.org/how-to-disable-enable-gui-on-boot-in-ubuntu-20-04-focal-fossa-linux-desktop

    1. Open a terminal.

    2. Enter command sudo systemctl set-default multi-user

    3. Enter command shutdown -r to reboot.

Clone the PLC Linux to create a second VM for your HMI.

  1. In the Oracle VM VirtualBox Manager

  2. Select and highlight the PLC VM

  3. Right click and select Clone

  4. Set the name to HMI then click Next Select Linked clone then click Clone

For the HMI VM change the MAC address to be different than the PLC VM.

      1. In the Oracle VM VirtualBox Manager

      2. Select and highlight the HMI VM

      3. Right Click and select Settings

      4. Select Network

      5. Press the arrow to open Advanced settings

      6. Press the button to the right of the MAC Address box to select a new random MAC address.

Install OpenPLC runtime in the PLC VM

Link: https://www.openplcproject.com/runtime/linux/

    1. git clone https://github.com/thiagoralves/OpenPLC_v3.git

    2. cd OpenPLC_v3

    3. ./install.sh linux

    4. Use command ip a to note your VM’s IP address.

The OpenPLC runtime starts automatically whenever your VM boots.

Create a network proxy to access the OpenPLC runtime from your host’s browser.

    1. In the Oracle VM VirtualBox Manager, Select the PLC VM

    2. Click settings and select Network

    3. Under Adapter 1, Advanced, click port forwarding.

    4. Add a rule to forward port 8080 from the PLC VM to port 8000 on the host. Fill in the host (8000) and local (8080) port fields only.

    5. Then in your browser navigate to http://localhost:8000 (This webpage is the control interface for your PLC)

      1. Note: you may need to reboot the VM for the proxy to take effect.

Install MobaXterm

Link: https://mobaxterm.mobatek.net/download.html

  1. Download the installer application.

  2. Run the installer.

  3. Open the MobaXterm application.

  4. Click Start local terminal.

  5. Record the IP address provided in the local terminal. This will be used when starting GUI applications in VM’s.

Install the OpenPLC editor in the PLC VM

Link: https://www.openplcproject.com/plcopen-editor/

    1. sudo apt-get install git

    2. git clone https://github.com/thiagoralves/OpenPLC_Editor

    3. cd OpenPLC_Editor

    4. ./install.sh

To start the OpenPLC Editor:

    1. Open a terminal in the VM.

    2. Use the command: DISPLAY=192.168.86.63:0.0 plcopeneditor&

    3. Note: replace the IP address above with the IP address from Mobaxterm

Install the Arduino IDE in the PLC VM

Link: https://www.arduino.cc/en/guide/linux

    1. In your PLC VM, download https://downloads.arduino.cc/arduino-1.8.13-linux64.tar.xz

    2. Uncompress the IDE installer (tar -xvf arduino-1.8.13-linux64.tar.xz)

    3. cd Downloads/Arduino-1.8.13

    4. ./install.sh

To run: DISPLAY=192.168.86.63:0.0 arduino& (a window will open on the host PC)

Note: replace the IP address above with the IP address from Mobaxterm

Install SCADABr in the HMI VM

Link: https://www.openplcproject.com/reference/scadabr/

    1. git clone https://github.com/thiagoralves/ScadaBR_Installer.git

    2. cd ScadaBR_Installer

    3. ./install_scadabr.sh

To open SCADABr in a browser (option 1):

    1. Open a terminal in the VM.

    2. Use the command: DISPLAY=192.168.86.63:0.0 firefox&

      1. Note: replace the IP address above with the IP address from Mobaxterm

    3. Navigate to http://localhost:9090/ScadaBR

To open SCADABr in a browser (option 2):

  1. Create a port forwarding rule to map VM port 9090 to host port 9000.

    1. In your host’s browser Navigate to http://localhost:9000/ScadaBR

    2. Note: you may need to reboot the VM for the proxy to take effect.

Note: There may be problems with the apache server.

  1. Navigate to the tomcat directory (cd /opt/tomcat6/apache-tomcat-6.0.53/).

    1. cd logs

    2. cat catalina.out | less (look for SEVERE)

    3. restart apache (sudo /opt/tomcat6/apache-tomcat-6.0.53/bin/startup.sh)

Linux Command Line tips:

Set your display for MOBAXTERM.

    1. Use export DISPLAY=192.168.1.1:0.0

    2. Change the IP address above to match your MOBAXTERM IP address. Start a local terminal in MOBAXTERM to find your MOBAXTERM IP address.

Shutdown a Linux VM with the shutdown now command.

Reboot a Linux VM with the shutdown now -r command

Capture or release mouse (move mouse control from VM to host or host to VM).

    1. Press the capture key. This is the right CTRL key by defa