通过对串口的监听,终于找到了PPI通讯协议对S7-200PLC数据读取的格式。下面是DELPHI 7的源代码。
var
i,j,fcs_read,fcs_write:integer;
nbyte,readdata_byte,writedata_byte:array of byte;
procedure Tshenchanform.FormCreate(Sender: TObject);
begin
nbyte:=vararrayof([16,2,0,92,94,22]); //确认信息返回给PLC。
fcs_read:=0;
readdata_byte:=vararrayof ([104,27,27,104,2,0,108,50,1,0,0,0,0,0,14,0,0,4,1,18,10,16,2,0,1,0,1,132,0,3,32,139,22]);//读数据
readdata_byte[32]:=22; //结束符
readdata_byte[29]:=trunc(890*8/256); //起始地址为vw890
readdata_byte[30]:=(890*8)mod 256;
readdata_byte[27]:=132; //读取数据为一个字
readdata_byte[24]:=110;//总共有110个字长
for i:=4 to 30 do
begin
fcs_read:=fcs_read +readdata_byte[i];
end;
readdata_byte[31]:=fcs_rea
Delphi 7用PPI协议读写S7 - 200PLC数据代码

这篇博客介绍了一种通过Delphi 7利用PPI(Point-to-Point Protocol)协议与S7-200PLC进行数据读写的实现方式。提供了读取和写入数据的源代码示例,涉及串口通信、校验码计算和PLC地址操作。
最低0.47元/天 解锁文章
1017

被折叠的 条评论
为什么被折叠?



