1 Star 0 Fork 8

MarquisHou / stuNetCtl

forked from SenySunny / stuNetCtl 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

stuNetCtl

介绍

​ stuNetCtl是一款基于PikaPython的开源的软PLC和可编程运动控制器,我们旨在设计一款软件开源的面向中低端工业控制系统的软PLC产品(也可以称之为解释性PLC),力求以较低的成本实现工业控制系统中的DI,DO,AI,AO,电机伺服系统控制等相关功能。在低成本的同时必须满足基本的实际工业应用需求,电路设计满足一定的工业抗干扰能力,软件系统必须满足足够的开放性和可扩展性。

​ 在设计之初,我们并没有把StuNetCtl定义为一款独立工业产品,我们希望它可能包括多种形式的工业控制器主机系统,各类的基本扩展模块,嵌入式软件系统,PC端编程软件和仿真系统(初步定义有基于windows的编程和编译插件,可以运行在windows和linux系统之上的PLC Simulator仿真套件,支持vscode的编程编译和下载插件),

NetCtl_14DI0DO

EXT_8DI8DO

stuNetCtl_EXT

​ 上图为设计的NetCtl_14DI10DO的主控和EXT_8DI8DO的IO扩展模块,以及内部电路板连接的示意图。后续如果有精力,我们会逐步设计更多的不同功能的主控和扩展模块。以满足不同的应用需求。

1. stuNetCtl的特点:
  1. 一款软件开源的面向中低端工业控制系统的软PLC产品,能以较低成本满足中低端的工业控制系统的基本功能
  2. 能够尽可能的兼容国内的HMI生态,除开能够使用市面上的组态屏,能尽可能的兼容和使用国产的串口屏,一起嵌入式的UI组件框架一起配合使用(例如:LVGL, LingLongGUI),所以我们设计了RS232/TTL可切换的串型通信接口,RS485接口,以太网接口
  3. 能够满足一定的伺服步进控制系统的应用,所以配置高低DI和高速DO接口(也有低速的DIDO接口,DO可选继电器输出)。支持电机的加减速算法驱动伺服步进系统。
  4. 以最低成本实现稳定可靠的外部扩展功能,能够实现外设的自动识别/自动挂载,无需软件配置,可以实现像操作本机IO一样操作扩展模块
  5. 支持市面工业自动化和工业物联网最常用的modbus和mqtt等协议,支持常用的mbedTLS加密算法,可实现基本的用户代码的加密功能。
  6. 支持RTC时钟功能。配合mbedTLS加密算法可以实现设备使用权限管理,配置项目的周期试用,实现时间的权限管理,采用ntp网络授时协议,并不允许用户随意篡改RTC时钟。
  7. 采用PikaPython编程,与Python3语法兼容,采用PC端编译为字节码,串口/网口下载的模式,同时支持工程文件加密备份功能,支持从设备端加载工程文件到PC的功能。
  8. 提供PC编译和下载的软件,支持采用VsCode编程和编译下载(后续可以提供Vscode插件,这一块目前没有研究透,目前提供的软件为终端调用执行)。
  9. 后续考虑推出基于WindowsLinuxSimulator,可以实现无硬件仿真运行编程代码。也可以通过工控机或者linux终端外挂扩展模块,仿真器的真实外设控制功能。

以下是画大饼环节:后续有精力会持续为其扩展功能,但毕竟是业余时间在维护项目,所以不保证如下功能功能一定实现,如下功能可能会作为单独的工程提供,并不一定会直接集成到基本的功能固件当中。也就是如果实现如下特定的功能,可能会失去部分基本功能(比如以下功能可能短时间无法在WindowsLinuxSimulator上实现)。

  1. 整合运动控制器的多轴联动插补功能,并且集成部分机器人构型的正逆解算法。实现例如:XYZA,四轴码垛,SCARA等构型的机器人的正逆解算法,实现笛卡尔坐标系和轴坐标系,以及工件坐标系的相对控制功能。
  2. 提供兼容三菱Gx-Works的工程或者固件,实现采用Gx-works的PLC编程工具对设备进行PLC编程。
  3. 提供基于IEC611131-3编程语言进行编程,兼容国际通用的PLC编程标准(最近正在研究IEC2Python框架,如果实现,可以通过开源的matiec架构实现IEC2IEC,在通过IEC2Python实现把IEC611131-3标准的编程语言转化为python语法结构,最终通过pikaPython解释执行 )
  4. 提供数控加工的G代码解析功能,实现简易的数控控制系统(比如涂鸦,激光雕刻,简易数控加工)。
  5. 发挥想象,创造stuNetCtl的无限可能。
2. NetCtl_14DI10DO主控的硬件设计特点:
  1. 主控采用控制核心板,接口电路板,电源板堆叠而成,可以方便的选择DC供电模式/AC供电模式,主控可以选择AT32F435+W5500的网络形式,也可以选择AT32F437+lan8720A运行lwip的网络形式,主频:288Mhz,最高4032KB的Flash,512KB的RAM,外部扩展8MB的SPI NorFlash。同时输出部分可以同时兼容高速MOS输出,低速MOS输出,继电器输出多种输出形式。
  2. 核心板和接口电路板均采用4层板设计,设计独立的地层分割设计。提高系统的稳定性和抗干扰性。
  3. 核心板除开默认的AT32F435+W5500/AT32F437+lan8720A的方案之外,为了二次开发方便,硬件上兼容STM32F103/F407/F427/H 563/H573等基于STM32的MCU,以及绝大部分兼容STM32的国产控制器(例如AT32F403A/APM32系列)。只需要修改几个电阻电容和主控既可以快速切换其他平台。(目前项目主线维护AT32F435+W5500/AT32F437+lan8720A两大平台),后期会同时提供STM32F103+W5500/STM32F407+lan8720A的硬件接口驱动代码,以方便用户自己用来开发自己的应用程序。
  4. 通信接口包括:RS232/TTL、RS485、ETH接口。考虑到项目的应用成本,设计了可以通过拨码开关选择的RS232/TTL切换通信接口电路,以满足目前国内的低成本串口屏,或者自主设计的基于LVGL等UI框架的屏幕开发板作为该PLC的HMI界面。当然也可以使用工业上常用的RS485,或者以太网接口的组态屏作为HMI交互界面。RS485和以太网同时也可以外接各类的外设和扩展设备。
  5. 内置法拉电容超级电容器和电源输入检测电路,检测外部电源断开会中止程序运行,保存数据,以防重要数据丢失。
  6. 自带10Pin的自主设计的支持自动识别的外设扩展接口,基于modbus通信扩展,理论支持最高可以扩展上百路的扩展模块(目前只做了一款8DI/8DO的扩展板,目前测试10几个扩展板相当于上百路DI上百路DO通信稳定),且DI/DO/AI/AO等扩展模块会自动映射的PLC的IO接口和寄存器上,无需任何配置,直接像使用主机的IO一样使用扩展外设。另外可以根据开源的电路,自行设计自定义的各种扩展模块。
  7. 扩展模块支持自动识别,无需配置添加,上电会自动识别扩展模块的类型和对应的接口,自动映射到对应的IO和外设上(比如主机占用Q0和Q1两组输出,第一个DO的扩展模块会自动映射到Q2组以及后续的的输出上)。
  8. DIDO采用全隔离设计,高速DO模块支持200K以上的脉冲输出,高速输入支持计数输入和AB项计数。
  9. AIAO输出,AI输入检测支持0-10V(0~20ma)检测,两种可选。AO输出默认为0-20ma输出,可以通过焊接或者外置采样电阻实现0-10V输出。
  10. 默认为4路高速输入,8路高速输出,8路高速输出可以配置为4路AB项输入功能。硬件上默认可以支持8路高速输出(因为主机默认10个DO,默认配4路高速比较合理,伺服电机还需要方向和使能引脚。更多的输出意义不大)。
  11. 默认配置4路AI输入和2路AO输出。
3. EXT_8DI8DO扩展模块的特点:
  1. DIDO驱动全隔离,可选择MOS管DO驱动和继电器驱动
  2. 核心板和接口电路板均采用4层板设计,设计独立的地层分割设计。提高系统的稳定性和抗干扰性。
  3. 内置type-C的USB通信接口,可以通过接口实现配置,固件升级等功能。
  4. 可以独立使用,可以设置为外设主机模式和外设从机模式,当作为外设主机模式时,无需PLC主机,直接通过USB口连接PC或者Linux系统,实现通过一个USB先控制扩展模块,以及扩展模块连接的后续扩展模块。实现在stuNetCtl的仿真环境中连接真实外设的功能。

软件架构

更新日志

使用教程

  1. xxxx
  2. xxxx
  3. xxxx

感谢以下项目作者

  1. PikaPython(一个完全重写的超轻量级 python 引擎): https://github.com/pikasTech/PikaPython
  2. rt-thread(一款以开源的物联网操作系统): https://github.com/RT-Thread/rt-thread
  3. agile_modbus(一款开源的支持跨平台的轻量型 modbus 协议栈): https://github.com/loogg/agile_modbus
  4. mqttclient(一个高性能、高稳定性的跨平台MQTT客户端): https://github.com/jiejieTop/mqttclient
  5. mbedtls(一个实现加密、X.509证书操作以及SSL/TLS和DTLS协议的C库): https://github.com/Mbed-TLS/mbedtls
  6. beremiz(一个开源的符合IEC61131-3标准的PLC集成开发环境): https://github.com/beremiz/beremiz
  7. matiec(一个开源的基于IEC 61131-3标准的PLC编译器,beremiz所使用的编译器内核): https://github.com/beremiz/matiec
  8. Modbus(一款开源的Modbus库,beremiz所使用的modbus协议库): https://github.com/beremiz/Modbus
  9. modbus_rt(一款纯C实现的跨平台modbus协议通信库): https://github.com/SenySunny/modbus_rt.git
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

一款基于PikaPython的开源的软PLC和可编程运动控制器 展开 收起
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/Marquis_Hou/stuNetCtl.git
git@gitee.com:Marquis_Hou/stuNetCtl.git
Marquis_Hou
stuNetCtl
stuNetCtl
main

搜索帮助

344bd9b3 5694891 D2dac590 5694891