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.
Python 3.9python packages from requirements.txtmake utilsC/C++ compiler to use matiecarm-none-eabi-gcc
- 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.exeandiec2iec.exefor example (Windows)). - Removed Arduino library, libraries to work with P1AM, Sequent Microsystems and Jaguar modules from matiec and
editor/plcopen/definitions.pydue to using different platform. - Added MODBUS, RS485, MQTT libraries (see Adding new functional blocks section).
- Removed unsupported examples from the
editor/examplesfolder. - Removed the
editor/arduinoandeditor/arduino_extfolders, as well aseditor/dialogs/ArduinoUploadDialog.py(because of this theeditor/ProjectControllerfile was changed). - Added the
editor/kauri_parserfolder, 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.pyscript is used to build project and send it to device (it runs fromeditor/dialogs/KauriUploadDialog.py). - The
Sourcesfolder with two subfolders:CommonandPLCSpecified. First of them contains platform independent source files (Common/Generatedcontains generated bybuilder.pyfiles,Common/MatiecBasedcontains PLC libraries C source files). Second contains source files specific for PLC devices. - The
hals.jsondescribes each used device characteristic in json format. - The
settings.jsonstores last device configuration settings in json format.
- The
- Added
editor/dialogs/KauriUploadDialog.pyfor easy setup of PLC device configuration and transferring PLC programs to devices. It useseditor/kauri_parser/hals.jsonto configure window for chosen device andeditor/kauri_parser/settings.jsonto restore last entered configuration settings (see file docstring comments for realization details). - Changed
editor/BeremizIDE.py:- Modified the
RefreshTitlefunction, now it set app name to OpenPLC Editor (KauriIOT Edition) instead of OpenPLC Editor. - Modified the
__init_execute_pathfunction to set PATH variable on Windows with build tools.
- Modified the
- Changed
editor/ProjectController:- Fixed the
_Generate_runtimefunction to support working with library functional blocks using byte, bool, or word arrays of size 128. - Modified the
findCmdfunction to search the Matiec folder within its parent parent folder. - Changed the
_generateArduinomethod to the_generateKauri, which is bound to theTransfer program to PLCbutton and runsKauriUploadDialog(before button pressing raneditor/dialogs/ArduinoUploadDialog.py). Changed import fromfrom dialogs import ArduinoUploadDialogtofrom dialogs import KauriUploadDialog. - Added the
_debugPLCWithoutBuildfunction for use after program transfer usingKauriUploadDialog, allowing for debugging without pressing theLive debug remote PLCbutton if needed. - Updated the
_debugPLCfunction to utilize the_debugPLCWithoutBuildfunction. - Removed the button responsible for generating firmware for OpenPLC Runtime due to the use of our own runtime environment with a different firmware representation.
- Fixed the
- Changed
editor/dialogs/DebuggerRemoteConnDialog.py,editor/modbus/mb_utils.pyandeditor/modbus/web_settings.pyto support baudrate equal to 256000 bod.
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.xmlfile, .st data from{build folder}/build/plc.stfile and C code data from{build folder}/build/POUS.hand{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/libfolder. The .xml files must be puteditor/plcopenfolder to use library blocks in editor window. - The C sourse files should be put into
matiec/lib/Cfolder andeditor/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).
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.mdfile). It can be shared library for devices with os supporting it or pseudo "shared" library with fixed predefined function addresses (see theeditor/kauri_parser/Sources/PLCSpecified/KauriPLCfolder). - 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_pathfunction (editor/BeremizIDE.pyfile). - Add new board into
hals.jsonfile. - Write function in
editor/kauri_parser/builder.pyfor building generated PLC program source files for the needed platform. It must have the same contract as_buildKauriPLCBinaryfunction. Intoeditor/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.cconfig_initfunction) and PLC program logic cyclically (runseditor/kauri_parser/Sources/Common/Config.cconfig_runfunction eachcommon_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)