Modbus Agile
02/2011
40
Protocol
Example: program sequence (C#)
Private int
Modbus_CRC(
string
frame)
{
int
poly = 0xA001;
// polynom
int
CRC = 0xFFFF;
// start CRC
for
(
int
i = 0; i < (
int
)(frame.Length); i++)
// for each char
{
CRC ^=
Convert
.ToInt16(frame[i]);
// ExOR
for
(
int
j = 0; j < 8; j++)
// eight times
{
if
((CRC& 0x01) == 0x01)
// lsb == 1 ?
{
CRC>>= 1;
// shift left
CRC ^= poly;
// ExOR
}
else
{
CRC>>= 1;
// shift left
}
}
}
Return
CRC;
}
Call the function for the frame "0x02 0x07"
string
temp_s =
Convert
.ToString((
char
)(0x2))+
Convert
.ToString((
char
)(0x7));
Console
.WriteLine(Modbus_CRC(temp_s));
Result:
4673
= 0x1241
CRC Low Byte
= 0x41
CRC High Byte
= 0x12
The Modbus CRC sequence is:
⇒
CRC
Low Byte/High Byte
0x41
0x12
7.3.10.2
ASCII Transmission
When devices are setup to communicate on a MODBUS serial line using 7-bit ASCII (American Stan-
dard Code for Information Interchange) mode, each 8 bit character in a message is sent as two ASCII
characters. This mode is used when the physical communication link or the capabilities of the device
does not allow the conformance with RTU mode requirements regarding the management of timers.
Note:
This mode is less efficient than RTU since each byte needs two characters.
Example: The byte 0x5B is encoded as two characters: 0x35 and 0x42 ( 0x35 ="5", and 0x42 ="B" in
ASCII ).
Содержание Agile
Страница 1: ...Agile Modbus Communication manual Frequency inverter 230V 400V ...
Страница 2: ......
Страница 5: ...Modbus Agile 5 02 2011 13 2 Warning Messages Application 76 13 3 Error Messages 76 INDEX 77 ...
Страница 44: ...Modbus Agile 02 2011 44 Handling of Data Sets Cyclic Writing ...
Страница 69: ...Modbus Agile 69 02 2011 10 2 1 Statemachine diagram ...
Страница 78: ......
Страница 79: ......