1. CRC check generates CRC
1.1. Instruction Description#
Addr (starting address): Store the data when calculate the CRC check code in an area starting from Dn, and this operand can only be selected from the D data register;
Len (data length): In bytes, one D register occupies 2 bytes, with the lower bits before the higher bits.
Mode (CRC Check Mode): Different types of CRC checks can be selected.
| Name | Number | Polynomial | Check Code Length |
|---|---|---|---|
| CRC-16 | K0 | X16+X15+X2+1 | 2 bytes |
| CRC-12 | K1 | X12+X11+X3+X2+X+1 | 2 bytes |
| CRC-8 | K2 | X8+X2+X+1 | 1 byte |
| CRC-CCITT | K3 | X16+X12+X5+1 | 2 bytes |
| CRC-32 | K4 | X32+X26+X23+X22+X16+X12+X11+X10+X8+X7+X5+X4+X2+X+1 | 4 bytes |
| CRC-32C | K5 | X32+X28+X27+X26+X25+X23+X22+X20+X19+X18+X14+X13+X11+X10+X9+X8+X6+1 | 4 bytes |
The computed checksum will follow at the end of the data.
For example, there is a data segment of 12 34 56 78 (hexadecimal) stored in registers starting with D0. So D0=0x3412, D1=0x7856, with a length of 4 bytes.
After executing CRC D0 K4 K0, the CRC checksum will be saved to D2, which is 0x107B.
Attention:
When the data length is odd, the checksum will immediately follow the high bit of the last register.
Please note that the input parameter is the byte length of the original data, and the length of the final communication data should be added with the length of the subsequent checksum.
1.2. The valid operands of the instruction#
| Input/Output | Data Type | operand | Description |
|---|
1.3. Example#
Instruction table:
NETWORK 000
LD M0
MOV H3412 D0
MOV H7856 D1
CRC D0 K4 K0
POP
图1 CRC
อ่านเพิ่มเติม
- สอนใช้ Modbus RS485 Master-Slaveสอนใช้ Modbus RS485 กับ Samkoon PLC 3 ตัวแบบ Master-Slave ต่อสาย 485A/485B แบบ Multi-Drop ตั้งค่า COM1(485) ใน Project Setting สร้าง Modbus Table อ่าน/เขียน และเรียกด้วยคำสั่ง MBUS ใน SamSoar2022
- วิธีใช้ Modbus Poll กับ PLC FAs - การเชื่อมต่อและอ่านข้อมูลต่อโปรแกรม Modbus Poll กับ PLC Samkoon FAs ผ่าน Modbus TCP/IP (IP 192.168.1.200 Port 2000) แล้วอ่านเขียน Output Y ตามตารางตำแหน่งข้อมูล Modbus ของ Samkoon พร้อมสาเหตุที่ขึ้น Illegal Data Address
- วิธีแก้ปัญหาการสื่อสาร Modbus บน PLC | ตรวจสอบสถานะเชื่อมต่อเช็คว่าการสื่อสาร Modbus ของ PLC Samkoon หลุดหรือไม่ จาก Code ในคำสั่ง MBUSTCP/MBUS — Code 16 คือสื่อสารหลุด (Timeout) แล้วใช้เงื่อนไขเปรียบเทียบสั่ง Output แจ้ง Alarm
- Modbus RTU Simulatorจำลอง Master/Slave ในเบราว์เซอร์ หรือต่อ PLC จริงผ่าน USB-RS485 · ≥ 1024 px

