为了提供可梯形图和Basic语音编程的物联网模块,研究了PLC,重点是解析型梯形图,LDMicro估计是可以重点参考的。本文先简要记录一下,后续再仔细分析。
LDmicro: Ladder Logic for PIC and AVRhttps://cq.cx/ladder.plGitHub - LDmicro/LDmicro: This is LDmicro support repositoryhttps://github.com/LDmicro/LDmicro/
openplc 与 plcopen这两个不是一个东西,差别还挺大
(1)PLCopen
PLCopen | for efficiency in automationhttps://www.plcopen.org/
PLCopen是独立于生产商和产品的全球性协会。其宗旨是成为一个领导协会来解决该领域中有关控制编程的问题从而支持使用国际标准。PLCopen为此下设了技术和推广委员会。PLCopen的主要经济来源是会费。PLCopen支持从供应商到大专院校各个层次的会员单位。PLCopen大力支持各个领域的用户,为此它创建了附加的会员种类。PLCopen成立于1992年,总部设在荷兰。
有官网,上面还有一大推文件可下载。
(2)OpenPLC---开源实体,包括硬件和软件
感觉有两套架构
第一套--AVR,Ardunio
AVR OPENPLC硬件架构
OpenPLC是根据市场上实际plc的架构创建的。它是一个模块化的系统,具有扩展功能,是一个RS-485总线,用于模块之间的通信和硬件保护。
为了创建第一个OpenPLC原型,我们构建了四个板:
- 总线板
- CPU板
- 输入板
- 输出板
AVR OpenPLC Firmware--提供了Ardunio工程文件,PC机端LDMicro,这个软件可以出C文件作为编译型PLC,也可以出可解析的字节码,还提供可一个解析器c程序作为参考。LDMicro还可以仿真。
这个PLC循环过程如下,其中 PlcCycle(); //run the ladder program once就是LDMicro
void OpenPLCcycle()
{
readPLCSwitch(); //read the switch to determine the PLC status
setStatusLeds(); //set the leds according to PLC status
if (PLCstatus==RUN)
{
updateInput(); //read the state of each input card connected
ModbusCycle(); //check modbus messages
PlcCycle(); //run the ladder program once
updateOutput(); //update output state of each output card connected according to the internal output buffer
}
else if (PLCstatus==STOP)
{
clearOutputs(); //certify that all outputs are turned off
CheckSerial(); //check to see if there are any serial messages received
ProcessMessage(); //if there are messages at the serial buffer, process them
}
else if (PLCstatus==HALTED)
{
clearOutputs(); //certify that all outputs are turned off
}
//verify if it's possible to clear errors
if (errorCount > 0 && PLCstatus != HALTED)
{
if (millis()-lastError > ERROR_TIMEOUT)
{
errorCount=0;
}
}
countTimers(); //special function timers
}
-----------------------------------------------------------------
第二套,如下,资源需求较多,暂时用不上,先不分析了。
OPENPLC软件架构
这个runtime对资源需求应该不少,ardunio好像只能作为slave设备,不能运行完整runtime。对吧?
Editor---这个应该是最新的,
The Windows installer was created using source code from OpenPLC Editor repository in April 17, 2019