西门子1200 PLC CRC效验程序功能块

时间:2024-04-01 13:15:37

添加变量
西门子1200 PLC CRC效验程序功能块西门子1200 PLC CRC效验程序功能块
西门子1200 PLC CRC效验程序功能块
#crc_v := word#16#FFFF;
FOR #i := 0 TO #length - 1 BY 1 DO
#crc_v := #crc_v XOR BYTE_TO_DWORD(“DB_CRC”.buffer[#db_offset + #i]);
FOR #j := 0 TO 7 BY 1 DO
IF ((#crc_v & 1) <> 0) THEN
#crc_v := SHR(IN := #crc_v, N := 1) XOR WORD#16#A001;
ELSE
#crc_v := SHR(IN := #crc_v, N := 1);
END_IF;
END_FOR;
END_FOR;
#low_crc_22 := DWORD_TO_BYTE(#crc_v & 16#00FF);
#crc_v := ROR(IN := #crc_v, N := 0);
//#high_crc := DWORD_TO_BYTE(#crc_v);
#high_crc_23 := #crc_v.%B1;

调用
西门子1200 PLC CRC效验程序功能块