Skip to content

Very1ucky/OpenPLCEditor---KauriIOT-Edition-base-

Repository files navigation

OpenPLC Editor - KauriIOT Edition (base)

OpenPLC Editor - IDE capable of creating programs for the OpenPLC Runtime. This edition supports PLC developed in Kauri IOT company.

OpenPLC Editor repository contains modified versions of Beremiz (GPLv2 and LGPLv2) and MatIEC (GPLv3) projects.

The codebase has been updated to Python3 and wxPython Phoenix.

It's platform independent base that can can be configured to run on different platforms. Tested on Windows and Ubuntu 22.04.

You can run app from Beremiz.py file.

Requirements

  • Python 3.9
  • python packages from requirements.txt
  • make utils
  • C/C++ compiler to use matiec
  • arm-none-eabi-gcc

Changes in relation to the OpenPLC Editor

  • Changed the app logo (brz.ico, editor/images/brz.logo) and startup banner (editor/images/about_brz_logo.png).
  • Matiec was divided into two parts. One part, included here, contains platform-independent PLC libraries and functional blocks logic written in C and ST PLC languages (matiec/lib). The second part contains the compiled Matiec code (matiec compiler from ST IEC-61131 format to C code) for the platform, which needs to be added to the Matiec folder (iec2c.exe and iec2iec.exe for example (Windows)).
  • Removed Arduino library, libraries to work with P1AM, Sequent Microsystems and Jaguar modules from matiec and editor/plcopen/definitions.py due to using different platform.
  • Added MODBUS, RS485, MQTT libraries (see Adding new functional blocks section).
  • Removed unsupported examples from the editor/examples folder.
  • Removed the editor/arduino and editor/arduino_ext folders, as well as editor/dialogs/ArduinoUploadDialog.py (because of this the editor/ProjectController file was changed).
  • Added the editor/kauri_parser folder, which contains scripts and parts of source files to compile the PLC program for devices with a PLC runtime environment. Also it contains matiec modified functional blocks functions realizations which uses platform specific api and libraries (MODBUS library, for example). It contains following files:
    • The builder.py script is used to build project and send it to device (it runs from editor/dialogs/KauriUploadDialog.py).
    • The Sources folder with two subfolders: Common and PLCSpecified. First of them contains platform independent source files (Common/Generated contains generated by builder.py files, Common/MatiecBased contains PLC libraries C source files). Second contains source files specific for PLC devices.
    • The hals.json describes each used device characteristic in json format.
    • The settings.json stores last device configuration settings in json format.
  • Added editor/dialogs/KauriUploadDialog.py for easy setup of PLC device configuration and transferring PLC programs to devices. It uses editor/kauri_parser/hals.json to configure window for chosen device and editor/kauri_parser/settings.json to restore last entered configuration settings (see file docstring comments for realization details).
  • Changed editor/BeremizIDE.py:
    • Modified the RefreshTitle function, now it set app name to OpenPLC Editor (KauriIOT Edition) instead of OpenPLC Editor.
    • Modified the __init_execute_path function to set PATH variable on Windows with build tools.
  • Changed editor/ProjectController:
    • Fixed the _Generate_runtime function to support working with library functional blocks using byte, bool, or word arrays of size 128.
    • Modified the findCmd function to search the Matiec folder within its parent parent folder.
    • Changed the _generateArduino method to the _generateKauri, which is bound to the Transfer program to PLC button and runs KauriUploadDialog (before button pressing ran editor/dialogs/ArduinoUploadDialog.py). Changed import from from dialogs import ArduinoUploadDialog to from dialogs import KauriUploadDialog.
    • Added the _debugPLCWithoutBuild function for use after program transfer using KauriUploadDialog, allowing for debugging without pressing the Live debug remote PLC button if needed.
    • Updated the _debugPLC function to utilize the _debugPLCWithoutBuild function.
    • Removed the button responsible for generating firmware for OpenPLC Runtime due to the use of our own runtime environment with a different firmware representation.
  • Changed editor/dialogs/DebuggerRemoteConnDialog.py, editor/modbus/mb_utils.py and editor/modbus/web_settings.py to support baudrate equal to 256000 bod.

Adding new functional blocks

Different ways to add new functional blocks described here. Further comments will be given for Manual Approach:

  • To generate .xml, MatIEC lib file and C code files can be used new OpenPLC Editor project with integrated functinal block creation tool. After project building you can extract .xml data from {build folder}/plc.xml file, .st data from {build folder}/build/plc.st file and C code data from {build folder}/build/POUS.h and {build folder}/build/POUS.c (you need to change all functions to static to not have conflicts during compile time).
  • The .st files should be put only into matiec/lib folder. The .xml files must be put editor/plcopen folder to use library blocks in editor window.
  • The C sourse files should be put into matiec/lib/C folder and editor/kauri_parser/Sources/Common/MatiecBased. First source location is used to compile program for simulation and debugging program comparing and visualization. Second source location is used to compile program for PLC device (they can be different from first location's sources and use platform specific libraries).

Supporting new devices

To add new device support need to do following steps:

  • Write library for new platform that implements specific functions to work with the device periphery (you can see list of them in the editor/kauri_parser/Sources/README.md file). It can be shared library for devices with os supporting it or pseudo "shared" library with fixed predefined function addresses (see the editor/kauri_parser/Sources/PLCSpecified/KauriPLC folder).
  • Setup toolchain for cross-compiling C language source files for used as PLC platform (bare metal microcontroller, Unix, Windows and etc). If it distributes with editor or stores in fixed location then the inner PATH variable can be changed in the __init_execute_path function (editor/BeremizIDE.py file).
  • Add new board into hals.json file.
  • Write function in editor/kauri_parser/builder.py for building generated PLC program source files for the needed platform. It must have the same contract as _buildKauriPLCBinary function. Into editor/kauri_parser/Sources/PLCSpecified/{your board name} can be added additional make scripts, other source files.
  • Write runtime environment to use generated PLC program. It must include the thread for running PLC initialization function (runs editor/kauri_parser/Sources/Common/Config.c config_init function) and PLC program logic cyclically (runs editor/kauri_parser/Sources/Common/Config.c config_run function each common_ticktime__ interval). Also there should be threads with modbus rtu and tcp to support firmware uploading and debugging. New modbus functional codes that need to be implemented are as follows:
    • 65 - get debug information
    • 66 - set debug trace (force variables)
    • 67 - get debug trace (read variables)
    • 68 - get debug trace list (read list of variables)
    • 69 - get current program MD5
    • 102 - start firmware downloading (sends before first firmware packet)
    • 103 - get next firmware packet
    • 104 - end firmware loading (sends after last firmware packet)

About

No description, website, or topics provided.

Resources

License

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors