ZeroOne AI
← 返回文章列表

PLCOpen 运行环境测试与搭建(Beremiz 开源软 PLC)

👁 1
分类:工业互联网

在 Ubuntu 18.04 实时内核上搭建 PLCOpen(Beremiz)开源软 PLC 运行环境:依赖安装、MatIEC/CanFestival/modbus/BACnet/EtherCAT 源码编译,以及 IDE 与 Runtime 的启动调试全流程。

PLCOpen 运行环境测试与搭建(Beremiz 开源软 PLC)

一、项目背景

PLCOpen 是 PLC 编程领域的国际标准化组织,定义了 IEC 61131-3 编程语言标准。Beremiz 是一款遵循该标准的开源软 PLC(Soft PLC)IDE + Runtime 解决方案:IDE 负责编写/编译梯形图、ST、FBD 等 IEC 61131-3 语言,Runtime 负责在 Linux 等平台上实时执行编译后的代码,并支持 Modbus、CANopen、BACnet、EtherCAT 等多种现场总线。

本篇文章在 Ubuntu 18.04 实时内核上完整搭建 Beremiz 运行环境,为后续 PLC 应用开发与总线调试提供平台基础。

二、技术方案:环境与组件

实时内核配合软 PLC Runtime,可在通用 x86 平台上实现确定性控制周期,替代部分传统硬 PLC 场景。

三、系统架构:安装依赖

# 基础编译工具
sudo apt-get install build-essential bison flex autoconf
sudo apt-get install python-wxgtk3.0 pyro mercurial
sudo apt-get install python-nevow python-matplotlib python-lxml python-zeroconf python-cycler
sudo apt-get install python-autobahn python-u-msgpack
sudo apt-get install libpython2.7-dev

# Python 2 环境(Beremiz 依赖)
sudo apt install python-pip
pip2 install --user sslpsk posix_spawn
sudo apt install subversion
pip install future

四、实施过程:源码下载与编译

4.1 下载源码

git clone https://bitbucket.org/automforge/beremiz.git
git clone https://bitbucket.org/automforge/matiec_git.git
git clone https://bitbucket.org/mjsousa/modbus_git.git
svn checkout https://svn.code.sf.net/p/bacnet/code/trunk /bacnet-stack/ BACnet

4.2 编译各总线模块

# (1) 编译 MatIEC(IEC61131-3 编译器)
autoreconf -i
./configure
make

# (2) 编译 CanFestival(CANopen 协议栈,虚拟模式)
./configure --can=virtual
make

# (3) 编译 modbus
make

# (4) 编译 BACnet
make MAKE_DEFINE='-fPIC' MY_BACNET_DEFINES='-DPRINT_ENABLED=1 -DBACAPP_ALL      -DBACFILE -DINTRINSIC_REPORTING -DBACNET_TIME_MASTER      -DBACNET_PROPERTY_LISTS=1 -DBACNET_PROTOCOL_REVISION=16' library

# (5) 编译 EtherCAT 主站
tar -xvf ethercat-1.5.2.tar.bz2
./configure --help        # 查询需要的模块
./configure --enable-8139too=no

4.3 启动 IDE 与 Runtime

# 创建工作目录
mkdir plcwork

# 开启 IDE
python Beremiz.py

# 开启 Runtime(监听 61194 端口,绑定本地)
cd ~/plcopen/beremiz/
python Beremiz_service.py -p 61194 -i localhost -x 0 -a 1 ~/plcopen/plcwork/

五、应用价值

六、SEO关键词

PLCOpen、Beremiz、开源PLC、软PLC、MatIEC、IEC61131-3、Ubuntu18.04、CanFestival、EtherCAT主站、PLC编程环境

评论(0