The perfect choice of one-stop service for diversification of architecture.
1.1 software
A PC with STEP7 micro / win smart software (including Modbus protocol library) installed. In this example, STEP7 micro win smart v2.0 is used.
1.2 hardware
G120 is equipped with one frequency converter of cu240e-2 control unit, one asynchronous motor, one S7-200 smartplc, one standard drive-cliq cable and one twisted pair shielded cable. In this example, the firmware version v4.6 of the control unit cu240e-2 of G120 is used.
Note: before using microwin software to create a project, confirm that the Modbus library file already exists.
Figure 1-1 S7-200 smart interface
2. Hardware wiring 2.1 cu240e-2 control unit interface
The terminal block of cu240e-2 control unit is shown in Figure 2-1. The RS485 interface is at the bottom of the control unit. There are five wiring terminals, from left to right. Terminal 2 is rs485p and terminal 3 is rs485n. These two terminals are used for transmitting and receiving communication data.
Figure 2-1 terminal diagram of control unit
2.2 G120 and S7-200 smart wiring
Figure 2-2 wiring diagram of PLC and controller
S7-200 smart serves as the Modbus communication master station, and the wiring of its communication port and frequency converter slave station is shown in Figure 2-2. Terminal resistors need to be used at the head and end of the communication network. For S7-200 smart, a resistance of 120 ohms needs to be connected between communication port terminals 3 and 8. For the frequency converter, turn the cu240e-2 terminal resistance dial switch at the end of the communication network to the on position (the position is in Figure 2-1, label â¨); For cu240e-2 in the middle position, the terminal resistance dial switch must be turned to the off position. In this example, S7-200 smart uses the CPU's own communication port to communicate with the frequency converter.
3. Communication settings
3.1 setting communication interface
This routine uses PLC Ethernet interface and drive-cliq cable to set communication interface, as shown in Figure 3-1 below.
Step 1: double click communication to open the communication setting window;
Step 2: select the network interface card and set it to "ICP / IP. Auto. 1", and the system will automatically collect the CPU.
Figure 3-1 setting communication interface
3.2 establish the connection between PC and PLC
After selecting "network interface", the CPU is automatically searched, as shown in Figure 3-2.
Step 1: after searching the CPU, select the searched CPU and click "IP address" of the CPU.
Step 2: click "OK" to complete the network connection.
Figure 3-2 establishing S7-200 CPU and controller connection
4. Frequency converter parameter setting
4.1 frequency converter address setting
The Modbus communication address of the frequency converter can be set through the bus address dial switch on the control unit, as shown in Figure 4-1. When the positions of address dial switches are off, it can also be set with parameter p2021. (Note: after changing the address, it can take effect only after power on again)
Figure 4-1 address switch setting
4.2 frequency converter parameter setting
Modbus communication can only be carried out after setting some basic communication parameters of the frequency converter, as shown in Table 4-2:
Table 4-2 parameter setting of frequency converter
4.3 description of G120 common registers
The common registers of G120 frequency converter are also the registers used in this example, as shown in table 4-3. For more G120 register information, see the G120 operator's manual.
Table 4-3 description of common registers
5. PLC programming
5.1 initialization procedure
Initialization module MBus using Modbus Protocol_ CTRL, initialize the CPU port of S7-200 smart, which is dedicated to MODBUS master station communication, as shown in Figure 5-1.
Figure 5-1 initialization
Function block Description:
Note: the "function block description" here and below only introduces the main pin functions in the function block. For the pin functions not described, please refer to the help document of STEP7 micro win smart v2.0 software.
EN enable: it must be ensured that each scanning cycle is enabled (sm0.0 is used)
Mode mode: when it is 1, the Modbus protocol function is enabled; when it is 0, it is restored to the system PPI Protocol. Baud baud rate: the supported communication baud rate is 4800960019200, and 9600 is set here. Parity verification: verification mode selection (G120 adopts even verification)
0 = no verification
1 = odd comparison test
2 = even comparison
Port port: set the physical communication port (0 = RS-485 integrated in the CPU, 1 = RS-485 or RS-232 on the optional CM01 signal board).
Timeout: the time that the master station waits for the response from the slave station, in milliseconds. The typical setting value is 1000 milliseconds (1 second), and the allowable setting range is 1-32767. Note: this value must be set large enough to ensure that the slave station has time response.
Done bit: after initialization, this bit will be automatically set to 1.
Error: initialization error code.
5.2 master station read / write function block
5.2.1 write control word
Figure 5-2 write control word
Function block Description:
Note: the "function block description" here and below only introduces the main pin functions in the function block. For the pin functions not described, please refer to the help document of STEP7 micro win smart v2.0 software.
EN enable: only one read-write function (i.e. mbus_msg) can be enabled at the same time. Note: G120 only operates on one holding register for write instructions at the same time; 125 holding registers are allowed to be operated at the same time for read instructions.
First read / write request bit: each new read / write request must be triggered by a pulse.
Slave slave address: selectable range 1-247
RW request mode: 0 = read, 1 = write
Count data number: the number of data (bits or words) for communication. Note: the maximum amount of data read / written by MODBUS master station is 120 words (referring to each mbus_msg instruction).
Dataptr data pointer:
If it is a read instruction, the read back data is placed in this data area;
2. If it is a write instruction, the written data is placed in this data area.
Done completion bit: read / write function completion bit.
Error code: the error code is valid only when the done bit is 1.
Common control words:
047e: preparation for operation
047f: forward start
0c7f: reverse start
04fe: fault confirmation
5.2.2 write speed setting
Figure 5-3 write speed value
5.2.3 read status word and actual speed value
Figure 5-4 read status word 1 and actual speed value
5.2.4 read ramp time
Figure 5-5 reading parameters p1120 and p1121
5.2.5 write ramp down time
Figure 5-6 write parameter p1121
6. Allocate inventory storage
Before compiling the program, first assign the available global V memory address to the Modbus library, as shown in Figure 6-1.
Step 1: select "program block" - > "library", right-click and select "inventory storage area";
Step 2: click "suggested address" and select the address of V memory;
Step 3: click "OK" to exit.
Figure 6-1 allocation of inventory storage area
7. Debugging program
After editing the program, debug the program, as shown in Figure 7-1 below.
Step 1: click "save" to save the edited program;
Step 2: click "compile" to compile the program;
Step 3: click "download" to download the program to the CPU of PLC; step 4: click "run" to start the program.
Figure 7-1 commissioning procedure
8. Monitoring status table
Through the monitoring status table, you can modify the process data and the change status of monitoring process data, as shown in Figure 8-1.
Figure 8-1 status table
Control word: vw100 = 16#047f indicates that the start command has been given.
Status word: vw300 = 16#ef37 indicates the status of the frequency converter, see r0052.
Main setting value: vw200 = 16#1000 indicates that the speed setting value has been given, and 16#0-4000 corresponds to the value of speed 0-p2000.
Actual speed value: vw302 = 16#1000 indicates that the actual speed of the motor has run to 375 rpm. Ramp rise time: vw400 = 1000. From the register list, we can see that the calibration coefficient of the register of 40322 is 100, so parameter p1120 = 1000 / 100 = 10.
Ramp down time: vw402 = 2000, the read down time; vw500 = 2000, the set down time; vw402 = vw500, indicating that the write instruction has taken effect. From the register list, you can see that the calibration coefficient of the register of 40323 is 100, so the parameter p1121 = 2000 / 100 = 20.
9. Modbus error codes
Done completion bit: the completion bit of Modbus function block, which is used to determine whether the operation of the function block is completed;
Error code: the error code is valid only when the done bit is 1. The Modbus error code and its meaning are shown in table 9-1.
Table 9-1 MODBUS error codes