fg71
This is in progress, but here is the first version.
 
How to install OpenPLC Runtime on Raspberry Pi

If you decide to install OpenPLC runtime in other directory and your home, make sure you have permission to write to it
One way to know for sure is if the installation complain about permission.


- Inside your home folder in the terminal

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

   This will clone the  OpenPLC runtime from GitHub

- Change the directory to OpenPlC_v3

- Setup a Python environment https://docs.python.org/3/library/venv.html

   python -m venv .venv

   This will create Python environment inside OpenPLC_v3 folder

- Install OpenPLC Runtime

   ./install.sh rpi <options>

   This will install the OpenPLC Runtime and compile it source code.

- Starting OpenPLC Runtime

   ./start_openplc.sh

- Access the OpenPLC Runtime Web UI from the browser

   http://<your_ip>:8080

   The default login: openplc password: openplc


When we upload a program.st (Structured Text) file to the OpenPLC Runtime, it will parse the source to c file and compile.

ex.

   Generating C files...
   POUS.c
   POUS.h
   LOCATED_VARIABLES.h
   VARIABLES.csv
   Config0.c
   Config0.h
   Res0.c
   Moving Files...
   Compiling for Raspberry Pi
   Generating object files...
   Generating glueVars...
   varName: __QX0_3  varType: BOOL
   Compiling main program...
   Compilation finished successfully!


We now need to start/set the OpenPLC Runtime to running mode. The Dashboard status show if OpenPLC are in running/stopped mode.

- Installing WiringPi 32/64bit prebuilt version from GitHub

   wget <url_path_to_wiringpi_x.xx_arm64.deb"
   sudo apt install ./wiringpi_x.xx_arm64.deb

- To update OpenPLC Runtime to use WiringPi

   There is 2 parts to be able to do this.
  
      - Update or create new hardware layer file for Raspberry Pi.
      - Update the compiler script compile_program.sh

   Hardware layer:

  Wiring is using same syntax as Arduino. ex. digitalRead, digitalWrite, pinMode... If we copy a hardware layer for rpi
        that use pigpio we need to change the part that match Wiring API.

  Reference: https://github.com/WiringPi/WiringPi

   Compile Script:

       Find the line: echo "Compiling main program..." and next line include if statement. In this if statement we include -lwiringPi

  
- Set OpenPLC Runtime in running mode (WiringPi) we need to start with sudo

   sudo ./start_openplc.sh

- We need also to change the default input, output and analog to match WiringPi.

   The way we set the inputs, outputs and analog is to use pin number. If we face the Raspberry Pi so GPIO pins are to right side.
   left side column from 1 - 39 (odd numbers), right side column from 2 - 40 (even number).

   To make it easier we could use this site as reference: https://pinout.xyz/

   [UPDATE]
 
Reply 1 0
Reply