Goodrive350 IP54 high-ingress protection series VFDs use the RTU mode provided by the Modbus protocol, and RS485 interfaces are used.
9.3.1 RS485
RS485 interfaces work in half-duplex mode and transmit data signals in the differential transmission way, which is also referred to as balanced transmission. An RS485 interface uses a twisted pair, where one wire is defined as A (+), and the other B (-). Generally, if the positive electrical level between the transmission drives A and B ranges from +2 V to +6 V, the logic is "1"; and if it ranges from -2 V to -6 V, the logic is "0".
The 485+ terminal on the terminal block of the VFD corresponds to A, and 485- corresponds to B.
The communication baud rate (P14.01) indicates the number of bits transmitted in a second, and the unit is bit/s (bps). A higher baud rate indicates faster transmission and poorer anti-interference capability. When a twisted pair of 0.56 mm (24 AWG) is used, the maximum transmission distance varies according to the baud rate, as described in the following table.
Baud rate (bps) | Max. transmission distance | Baud rate (bps) | Max. transmission distance |
2400 | 1800 m | 9600 | 800 m |
4800 | 1200 m | 19200 | 600 m |
When RS485 interfaces are used for long-distance communication, it is recommended that you use shielded cables, and use the shield layer as the ground wires.
When there are fewer devices and the transmission distance is short, the whole network works well without terminal load resistors. The performance, however, degrades as the distance increases. Therefore, it is recommended that you use a 120 Ω terminal resistor when the transmission distance is long.
Figure 9–1 is the Modbus wiring diagram of one VFD and a PC. Generally, PCs do not provide RS485 interfaces, so you need to convert an RS232 interface or USB port of a PC to an RS485 interface. Connect end A of the RS485 interface to the 485+ port on the terminal block of the VFD, and connect end B to the 485- port. It is recommended that you use shielded twisted pairs. When an RS232-RS485 converter is used, the cable used to connect the RS232 interface of the PC and the converter cannot be longer than 15 m. Use a short cable when possible. It is recommended that you insert the converter directly into the PC. Similarly, when a USB-RS485 converter is used, use a short cable when possible.
Figure 9–1 Wiring of RS485 applied to one VFD
In practical application to multiple VFDs, chrysanthemum connection and star connection are commonly used.
According to the requirements of the RS485 industrial bus standards, all the devices need to be connected in chrysanthemum mode with one 120 Ω terminal resistor on each end, as shown in Figure 9–2. Figure 9–3 is the simplified wiring diagram, and Figure 9–4 is the practical application diagram.
Figure 9–2 On-site chrysanthemum connection diagram
Figure 9–3 Simplified chrysanthemum connection diagram
Figure 9–4 Practical application diagram of chrysanthemum connection
Figure 9–5 shows the start connection diagram. When this connection mode is adopted, the two devices that are farthest away from each other on the line must be connected with a terminal resistor (in Figure 9–5, the two devices are devices 1# and 15#).
Figure 9–5 Star connection
Use shielded cable, if possible, in multi-device connection. The baud rates, data bit check settings, and other basic parameters of all the devices on the RS485 line must be set consistently, and addresses cannot be repeated.
9.3.2 RTU mode
When a controller is set to use the RTU communication mode on a Modbus network, every byte (8 bits) in the message includes 2 hexadecimal characters (each includes 4 bits). Compared with the ASCII mode, the RTU mode can transmit more data with the same baud rate.
Code system
1 start bit
7 or 8 data bits; the minimum valid bit is transmitted first. Each frame domain of 8 bits includes 2 hexadecimal characters (0–9, A–F).
1 odd/even check bit; this bit is not provided if no check is needed.
1 end bit (with check performed), 2 bits (without check)
Error detection domain
Cyclic redundancy check (CRC)
The following table describes the data format.
11-bit character frame (Bits 1 to 8 are data bits)
Start bit | BIT1 | BIT2 | BIT3 | BIT4 | BIT5 | BIT6 | BIT7 | BIT8 | Check bit | End bit |
10-bit character frame (Bits 1 to 7 are data bits)
Start bit | BIT1 | BIT2 | BIT3 | BIT4 | BIT5 | BIT6 | BIT7 | Check bit | End bit |
In a character frame, only the data bits carry information. The start bit, check bit, and end bit are used to facilitate the transmission of the data bits to the destination device. In practical applications, you must set the data bits, parity check bits, and end bits consistently.
In RTU mode, the transmission of a new frame always starts from an idle time (the transmission time of 3.5 bytes). On a network where the transmission rate is calculated based on the baud rate, the transmission time of 3.5 bytes can be easily obtained. After the idle time ends, the data domains are transmitted in the following sequence: slave address, operation command code, data, and CRC check character. Each byte transmitted in each domain includes 2 hexadecimal characters (0–9, A–F). The network devices always monitor the communication bus. After receiving the first domain (address information), each network device identifies the byte. After the last byte is transmitted, a similar transmission interval (the transmission time of 3.5 bytes) is used to indicate that the transmission of the frame ends. Then, the transmission of a new frame starts.
The information of a frame must be transmitted in a continuous data flow. If there is an interval greater than the transmission time of 1.5 bytes before the transmission of the entire frame is complete, the receiving device deletes the incomplete information, and mistakes the subsequent byte for the address domain of a new frame. Similarly, if the transmission interval between two frames is shorter than the transmission time of 3.5 bytes, the receiving device mistakes it for the data of the last frame. The CRC check value is incorrect due to the disorder of the frames, and thus a communication fault occurs.
The following table describes the standard structure of an RTU frame.
START (frame header) | T1-T2-T3-T4 (transmission time of 3.5 bytes) |
ADDR (slave address domain) | Communication address: 0–247 (decimal system) (0 is the broadcast address) |
CMD (function domain) | 03H: read slave parameters 06H: write slave parameters |
DATA (N-1) ... DATA (0) (data domain) | Data of 2×N bytes, main content of the communication as well as the core of data exchanging |
CRC CHK (LSBs) | Detection value: CRC (16 bits) |
CRC CHK high bit (MSBs) | |
END (frame tail) | T1-T2-T3-T4 (transmission time of 3.5 bytes) |
During the transmission of data, errors may occur due to various factors. Without check, the data receiving device cannot identify data errors and may make a wrong response. The wrong response may cause severe problems. Therefore, the data must be checked.
The check is implemented as follows: The transmitter calculates the to-be-transmitted data based on a specific algorithm to obtain a result, adds the result to the rear of the message, and transmits them together. After receiving the message, the receiver calculates the data based on the same algorithm to obtain a result, and compares the result with that transmitted by the transmitter. If the results are the same, the message is correct. Otherwise, the message is considered wrong.
The error check of a frame includes two parts, namely, bit check on individual bytes (that is, odd/even check using the check bit in the character frame), and whole data check (CRC check).
Bit check on individual bytes (odd/even check)
You can select the bit check mode as required, or you can choose not to perform the check, which will affect the check bit setting of each byte.
Definition of even check: Before the data is transmitted, an even check bit is added to indicate whether the number of "1" in the to-be-transmitted data is odd or even. If it is even, the check bit is set to "0"; and if it is odd, the check bit is set to "1".
Definition of odd check: Before the data is transmitted, an odd check bit is added to indicate whether the number of "1" in the to-be-transmitted data is odd or even. If it is odd, the check bit is set to "0"; and if it is even, the check bit is set to "1".
For example, the data bits to be transmitted are "11009.30", including five "1". If the even check is applied, the even check bit is set to "1"; and if the odd check is applied, the odd check bit is set to "0". During the transmission of the data, the odd/even check bit is calculated and placed in the check bit of the frame. The receiving device performs the odd/even check after receiving the data. If it finds that the odd/even parity of the data is inconsistent with the preset information, it determines that a communication error occurs.
CRC check mode
A frame in the RTU format includes an error detection domain based on the CRC calculation. The CRC domain checks all the content of the frame. The CRC domain consists of two bytes, including 16 binary bits. It is calculated by the transmitter and added to the frame. The receiver calculates the CRC of the received frame, and compares the result with the value in the received CRC domain. If the two CRC values are not equal to each other, errors occur in the transmission.
During CRC, 0xFFFF is stored first, and then a process is invoked to process a minimum of 6 contiguous bytes in the frame based on the content in the current register. CRC is valid only for the 8-bit data in each character. It is invalid for the start, end, and check bits.
During the generation of the CRC values, the "exclusive or" (XOR) operation is performed on the each 8-bit character and the content in the register. The result is placed in the bits from the least significant bit (LSB) to the most significant bit (MSB), and 0 is placed in the MSB. Then, LSB is detected. If LSB is 1, the XOR operation is performed on the current value in the register and the preset value. If LSB is 0, no operation is performed. This process is repeated 8 times. After the last bit (8th bit) is detected and processed, the XOR operation is performed on the next 8-bit byte and the current content in the register. The final values in the register are the CRC values obtained after operations are performed on all the bytes in the frame.
The calculation adopts the international standard CRC check rule. You can refer to the related standard CRC algorithm to compile the CRC calculation program as required.
The following is a simple CRC calculation function for your reference (using the C programming language):
unsigned int crc_cal_value(unsigned char×data_value,unsigned char data_length)
{
int i;
unsigned int crc_value=0xffff;
while(data_length--)
{
crc_value^=×data_value++;
for(i=0;i<8;i++)
{
if(crc_value&0x0001)
crc_value=(crc_value>>1)^0xa001;
else
crc_value=crc_value>>1;
}
}
return(crc_value);
}
In the ladder logic, CKSM uses the table look-up method to calculate the CRC value according to the content in the frame. The program of this method is simple, and the calculation is fast, but the ROM space occupied is large. Use this program with caution in scenarios where there are space occupation limits on programs.