SINAMICS G120C: Speed Control with S7-1200 via Modbus RTU
Entry-ID: 109764623, V1.0, 02/2019
Siemens Industry Online Support
URL: https://support.industry.siemens.com/cs/ww/en/view/109764623
Legal Information
Use of Application Examples
Application examples illustrate the solution of automation tasks through an interaction of several components in the form of text, graphics and/or software modules. The application examples are a free service by Siemens AG and/or a subsidiary of Siemens AG ("Siemens"). They are non-binding and make no claim to completeness or functionality regarding configuration and equipment. The application examples merely offer help with typical tasks; they do not constitute customer-specific solutions. You yourself are responsible for the proper and safe operation of the products in accordance with applicable regulations and must also check the function of the respective application example and customize it for your system. Siemens grants you the non-exclusive, non-sublicensable and non-transferable right to have the application examples used by technically trained personnel. Any change to the application examples is your responsibility. Sharing the application examples with third parties or copying the application examples or excerpts thereof is permitted only in combination with your own products. The application examples are not required to undergo the customary tests and quality inspections of a chargeable product; they may have functional and performance defects as well as errors. It is your responsibility to use them in such a manner that any malfunctions that may occur do not result in property damage or injury to persons.
Disclaimer of Liability
Siemens shall not assume any liability, for any legal reason whatsoever, including, without limitation, liability for the usability, availability, completeness and freedom from defects of the application examples as well as for related information, configuration and performance data and any damage caused thereby. This shall not apply in cases of mandatory liability, for example under the German Product Liability Act, or in cases of intent, gross negligence, or culpable loss of life, bodily injury or damage to health, non-compliance with a guarantee, fraudulent non-disclosure of a defect, or culpable breach of material contractual obligations. Claims for damages arising from a breach of material contractual obligations shall however be limited to the foreseeable damage typical of the type of agreement, unless liability arises from intent or gross negligence or is based on loss of life, bodily injury or damage to health. The foregoing provisions do not imply any change in the burden of proof to your detriment. You shall indemnify Siemens against existing or future claims of third parties in this connection except where Siemens is mandatorily liable. By using the application examples you acknowledge that Siemens cannot be held liable for any damage beyond the liability provisions described.
Other Information
Siemens reserves the right to make changes to the application examples at any time without notice. In case of discrepancies between the suggestions in the application examples and other Siemens publications such as catalogs, the content of the other documentation shall have precedence. The Siemens terms of use (https://support.industry.siemens.com) shall also apply.
Security Information
Siemens provides products and solutions with industrial security functions that support the secure operation of plants, systems, machines and networks. In order to protect plants, systems, machines and networks against cyber threats, it is necessary to implement – and continuously maintain – a holistic, state-of-the-art industrial security concept. Siemens' products and solutions constitute one element of such a concept. Customers are responsible for preventing unauthorized access to their plants, systems, machines and networks. Such systems, machines and components should only be connected to an enterprise network or the Internet if and to the extent such a connection is necessary and only when appropriate security measures (e.g. firewalls and/or network segmentation) are in place. For additional information on industrial security measures that may be implemented, please visit https://www.siemens.com/industrialsecurity. Siemens' products and solutions undergo continuous development to make them more secure. Siemens strongly recommends that product updates are applied as soon as they are available and that the latest product versions are used. Use of product versions that are no longer supported, and failure to apply the latest updates may increase customer's exposure to cyber threats. To stay informed about product updates, subscribe to the Siemens Industrial Security RSS Feed at: https://www.siemens.com/industrialsecurity.
1 Task
NOTICE: This reference only can be used in China and India.
Introduction
SINAMICS G120C drives are able to exchange data via the RS485 interface and via Modbus RTU with a SINAMICS S7-1200 controller.
Overview of the Automation Task
The figure below provides an overview of the automation task.
2 Solution
Solution Overview
The following figure displays the most important components of the solution.
Delimitation
This application does not include a description of:
- SINAMICS G120C version
- BOP-2 operation of SINAMICS G120C
Basic knowledge of these topics is assumed.
Required Knowledge
Basic knowledge on TIA Portal is assumed.
2.2 Hardware and Software Components
2.2.1 Validity
This application example is valid for:
- TIA Portal V15 Professional
- S7-1200 CPU V4.1
- SINAMICS G120C Modbus RTU V4.7.6
2.2.2 Used Components
The application was generated with the following components:
Hardware Components
Component | No. | Article number | Note |
---|---|---|---|
SIMATIC S7-1200 1217C DC/DC/DC | 1 | 6ES7217-1AG40-0XB0 | V4.1 |
CM1241 RS422/RS485 | 1 | 6ES7 241-1CH32-0XB0 | V2.1 |
SINAMICS G120C | 1 | 6SL3210-1KE15-8UB1 | V4.7.6 |
Standard Software Components
Component | No. | Article number | Note |
---|---|---|---|
TIA Portal Professional | 1 | 6AV2103-0AA05-0AA7 | V15 |
Startdrive | 1 | 6SL3072-4FA02-0XA0 | V15 |
Sample Files and Projects
The following list includes all files and projects that are used in this example.
Component | Note |
---|---|
109764623_G120C_Modbus-communication_PROJ_V10.zip | Project file |
109764623_G120C_Modbus-communication_DOC_V10_en.pdf | Reference document |
3 Basics of Modbus Introduction
Overview of Communication using Modbus RTU Communication
Modbus RTU (Remote Terminal Unit) is a standard protocol for communication in the network and uses the RS232 or RS422/485 connection for serial data transmission between Modbus devices in the network.
Modbus RTU uses a master/slave network in which all communication is triggered by a single master device while the slaves can only respond to the request of the master. The master sends a request to a slave address and only the slave with this slave address responds to the command.
NOTE: Exception: Modbus slave address 0 sends a broadcast frame to all slaves (without slave response).
Implementation with SIMATIC S7-1200
The application uses the following system instructions:
- MB_Comm_Load: To configure port for Modbus
- MB_Master: To communicate as Modbus master
3.1 Overview Modbus RTU System Instruction
3.1.1 MB_Comm_Load (S7-1200)
Description
The MB_Comm_Load instruction configures a communication module for communication by means of the Modbus protocol. An instance data block is automatically assigned when you add the MB_Comm_Load instruction in your program.
Parameter
The following table shows the parameters of MB_Comm_Load:
Parameter | IN / OUT | Data type | Default | Description |
---|---|---|---|---|
REQ | IN | Bool | False | Starts the instruction upon a positive edge of this input. |
PORT | IN | PORT | 0 | Specifies the communication module which is used for the communication: For S7-1500/S7-1200 the "HW identifier" from the device configuration will be used. The symbolic port name is assigned in the "System constants" tab of the PLC tag table and can be applied from there. |
BAUD | IN | UDInt | 9600 | Selection of the data transmission rate. Valid values are: 300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 76800, 115200 bit/s. |
PARITY | IN | UInt | 0 | Selection of parity: 0 - None, 1 - Odd, 2 - Even |
MB_DB | IN/OUT | MB_BASE | - | A reference to the instance data block of the MB_Master or MB_Slave instructions. The MB_DB parameter must be connected with the (static and therefore not visible in the instruction) MB_DB parameter of the MB_Master or MB_Slave instruction. |
DONE | OUT | Bool | False | The DONE bit is TRUE for one cycle after the last request has been completed without errors. |
ERROR | OUT | Bool | False | The ERROR bit is TRUE for one cycle after the last request has been completed with errors. The error code in the STATUS parameter is only valid in the cycle in which ERROR = TRUE. |
STATUS | OUT | Word | 16#7000 | Error code |
3.1.2 MB_Master (S7-1200)
Description
The MB_Master instruction communicates as Modbus master via a port configured by the MB_Comm_Load instruction. An instance data block is automatically assigned when you add the MB_Master instruction in your program. The MB_DB parameter of the MB_Comm_Load instruction must be connected to the (static) MB_DB parameter of the MB_Master instruction.
Parameter
The following table shows the parameters of MB_Master:
Parameters | Declaration | Data type | Standard | Description |
---|---|---|---|---|
REQ | IN | Bool | FALSE | FALSE = no request TRUE = request to send data to the Modbus slave |
MB_ADDR | IN | UInt | - | Modbus RTU station address: The value 0 is reserved for the broadcast of a frame to all Modbus slaves. Only the Modbus function codes 05, 06, 15 and 16 are supported for the broadcast. |
MODE | IN | USInt | 0 | Mode selection: Specifies the type of request (read, write or diagnostics). |
DATA_ADDR | IN | UDInt | 0 | Start address in the slave: Specifies the start address of the data that is accessed in the Modbus slave. |
DATA_LEN | IN | Word | 0 | Data length: Specifies the number of bits or words this instruction is to access. The valid lengths are listed in the table of Modbus functions below. |
DATA_PTR | IN/OUT | Variant | - | Data pointer: Points to the flag or DB address for the data to be written or read. As of instruction version V3.0: The parameter may point to an optimized memory area. In the optimized memory area, a single element or an array is permitted with the following data types: Bool, Byte, Char, Word, Int, DWord, DInt, Real, USInt, UInt, UDInt, SInt, WChar. Every other data type results in error message 16#818C. |
DONE | OUT | Bool | FALSE | The DONE bit is TRUE for one cycle after the last request has been completed without errors. |
BUSY | OUT | Bool | - | FALSE - no command active for Modbus Master TRUE - command for Modbus_Master in progress |
ERROR | OUT | Bool | FALSE | The ERROR bit is TRUE for one cycle after the last request has been completed with errors. The error code in the STATUS parameter is only valid in the cycle in which ERROR = TRUE |
STATUS | OUT | Bool | 0 | Error code |
NOTE: The input value used in this application will described in chapter 4.
3.1.3 Drive Parameters for Drive Control via Modbus RTU
Modbus RTU is used to transfer cyclic process data and acyclic parameter data between precisely one master and up to 247 slaves.
Settings for Modbus RTU
Parameter | Explanation |
---|---|
p2020=8 | Fieldbus interface baudrate (Factory setting: 7) 5: 4800 baud 6: 9600 baud 7: 19200 baud 8: 38400 baud 9: 57600 baud 10: 76800 baud 11: 93750 baud 12: 115200 baud 13: 187500 baud |
p2021 | Fieldbus interface address (Factory setting: 1) Valid addresses: 1 ... 247. The parameter is only active if address 0 is set at the Control Unit address switch. A change only becomes effective after the inverter power supply has been switched off and switched on again. |
p2024 | Fieldbus interface times (Factory setting: [0] 1000 ms, [2] 0 ms) [0] Maximum permissible telegram processing time of the Modbus slave [2] dead time between two telegrams |
p2029 | Fieldbus interface error statistics [0] number of error-free telegrams [1] number of rejected telegrams [2] number of framing errors [3] number of overrun errors [4] number of parity errors [5] number of starting character errors [6] number of checksum errors [7] number of length errors |
p2030=2 | Fieldbus interface protocol selection: Modbus RTU |
p2031 | Fieldbus interface Modbus parity (Factory setting: 2) 0: No parity 1: Odd parity 2: Even parity |
p2040 | Fieldbus interface monitoring time (Factory setting: 10 s) p2040 = 0: The monitoring is deactivated |
NOTE: The input value used in this application will described in chapter 4.2.
3.2 Details of G120C Modbus Function
3.2.1 Control Word 1 (STW1)
Bit | Significance | Explanation | Signal interconnection in the inverter |
---|---|---|---|
0 | 0 = OFF1 | The motor brakes with the ramp-down time p1121 of the ramp-function generator. The inverter switches off the motor at standstill. | p0840[0]=r2090.0 |
1 = ON | The inverter goes into the "ready" state. If, in addition bit 3 = 1, then the inverter switches on the motor. | ||
1 | 0 = OFF2 | Switch off the motor immediately, the motor then coasts down to a standstill | p0844[0]=r2090.1 |
1 = No OFF2 | The motor can be switched on (ON command). | ||
2 | 0 = Quick stop (OFF3) | Quick stop: The motor brakes with the OFF3 ramp-down time p1135 down to standstill. | p0848[0]=r2090.2 |
1 = No quick stop (OFF3) | The motor can be switched on (ON command) | ||
3 | 0 = Inhibit operation | Immediately switch-off motor (cancel pulses). | p0852[0]=r2090.3 |
1 = Enable operation | Switch-on motor (pulses can be enabled). | ||
4 | 0 = Disable RFG | The inverter immediately sets its ramp-function generator output to 0. | p1140[0]= r2090.4 |
1 = Do not disable RFG | The ramp-function generator can be enabled. | ||
5 | 0 = Stop RFG | The output of the ramp-function generator stops at the actual value. | p1141[0]=r2090.3 |
1 = Enable RFG | The output of the ramp-function generator follows the setpoint. | ||
6 | 0 = Inhibit setpoint | The inverter brakes the motor with the ramp-down time p1121 of the ramp-function generator | p1142[0]=r2090.6 |
1 = Enable setpoint | Motor accelerates with the ramp-up time p1120 to the setpoint. | ||
7 | 0-1 = Acknowledge faults | Acknowledge fault. If the ON command is still active, the inverter switches to the "switching on inhibited" state. | p2103[0]=r2090.7 |
8,9 | Reserved | ||
10 | 0 = No control via PLC | Inverter ignores the process data from the fieldbus. | p0854[0]=r2090.10 |
1 = Control via PLC | Control via fieldbus, inverter accepts the process data from the fieldbus. | ||
11 | 1 = Direction reversal | Invert setpoint in the inverter. | p1113[0]=r2090.11 |
12 | Reserved | ||
13 | 1 = MOP up | Increase the setpoint saved in the motorized potentiometer. | p1035[0]=r2090.13 |
14 | 1 = MOP down | Reduce the setpoint saved in the motorized potentiometer | p1036[0]=r2090.14 |
15 | Reserved |
3.2.2 Status Word 1 (ZSW1)
Bit | Significance | Remarks | Signal interconnection in the inverter |
---|---|---|---|
0 | 1 = Ready for switching on | Power supply switched on; electronics initialized; pulses locked. | p2080[0]=r0899.0 |
1 | 1 = Ready | Motor is switched on (ON/OFF = 1), no fault is active. With the command "Enable operation” (STW1.3), the inverter switches on the motor. | p2080[1]=r0899.1 |
2 | 1 = Operation enabled | Motor follows setpoint. See control word 1, bit 3. | p2080[2]=r0899.2 |
3 | 1 = Fault active | The inverter has a fault. Acknowledge fault using STW1.7. | p2080[3]=r2139.3 |
4 | 1 = OFF2 inactive | Coast down to standstill is not active. | p2080[4]=r0899.4 |
5 | 1 = OFF3 inactive | Quick stop is not active. | p2080[5]=r0899.5 |
6 | 1 = Switching on inhibited active | It is only possible to switch on the motor after an OFF1 followed by ON. | p2080[6]=r0899.6 |
7 | 1 = Alarm active | Motor remains switched on; no acknowledgement is necessary. | p2080[7]=r2139.7 |
8 | 1 = Speed deviation within the tolerance range | Setpoint / actual value deviation within the tolerance range. | p2080[8]=r2197.7 |
9 | 1 = Master control requested | The automation system is requested to accept the inverter control. | p2080[9]=r0899.0 |
10 | 1 = Comparison speed reached or exceeded | Speed is greater than or equal to the corresponding maximum speed. | p2080[0]=r2199.1 |
11 | 1 = Torque limit not reached | Comparison value for current or torque has been fallen below. | p2080[11]=r0056.13 /r1407.7 |
12 | Reserved | p2080[12]=r0899.12 | |
13 | 0 = Alarm, motor over temperature | Internal inverter actual value > 0 | p2080[13]=r2135.14 |
14 | 1 = Motor rotates clockwise 0 = Motor rotates counterclockwise | Internal inverter actual value < 0 | p2080[14]=r2197.3 |
15 | 0 = Alarm, inverter thermal overload | p2080[15]=r2135.15 |
3.3 Installation
The figure below shows the hardware configuration of the application:
CAUTION: Wrong wiring can damage the drive! In this application, the three phase 400V power supply is used. It is a must for you to check the supply voltage; otherwise, the drive can be damaged!
NOTE: The position of the bus termination switch for the frame sizes FSD – FSF can be found in the G120C manual [3].
4 Configuration
4.1 Configure PLC Project
The screenshots in the following tables are from G120C_Modbus RTU at S7-1200 project.
Table 4-1: Creation of new project and configuration of the PLC
Step 1: Open TIA Portal V15 in your PC and then click Create new project.
Step 2: Assign the new project a name G120C_ModbusatS7-1200.
Step 3: Click Create to finish the creation of a new project.
Step 4: Click Project view to change to project view.
Step 1: In the project tree, go to Devices & Network view.
Step 2: In the Hardware catalog task card, locate the available SIMATIC CPU (for example S7-1217 DC/DC/DC), select the right firmware and use drag and drop to move it to the graphic area of the Network view. In this area and in the project tree, it will be created as PLC_1.
Step 3: Select the CPU with a suitable version (for example V4.2 (S7-1200)).
Step 1: In the graphic area, select the SIMATIC controller and go to the Device view.
Step 2: In the Hardware catalog task card, locate the CM1241 (RS422/RS485) communication module, version V2.2 and use drag and drop to move it to an allowed slot left to the CPU in the graphic area of the network view.
If necessary, change the Ethernet address. To do this, double-click the CPU to open its properties.
Step 1: In the Device view double click on the CM1241 to configure the property.
Step 2: Go to the IO-Link in the RS422/485 interface card.
Step 3: Change the Baud rate to 38.4kbps.
Create your user program or if you want to use the supplied sample program – copy the following objects from the sample program to your new project.
Step 1: Compile the PLC_1 device in order to detect possible errors.
Step 2: Save the project.
4.2 G120C Configuration
Table 4-2: Quick Commissioning via Startdrive in TIA Portal V15
Step 1: Select network view.
Step 2: In the Hardware catalog task card, select the suitable G120C USS IP20, (for example 2.2kW UF) and use drag and drop to move it to the graphic area of the Network view. In this area, it will be created as G120C USS/MB.
Step 3: Select the drive with a suitable version (for example V4.7.9).
Step 1: In the project tree, go to the Commissioning under G120C USS/MB.
Step 2: Click the Commissioning Wizard function to open Commissioning Wizard dialog.
Step 1: Choose Expert at the Application class card.
Step 2: Click Next.
NOTICE: This application also can be finished in Standard Drive Control or Dynamic Drive Control application class.
Step 1: Choose U/f control with linear characteristic at the Open-loop/close-loop control type card.
Step 2: Click Next.
Step 1: Choose USS Fieldbus at the defaults of the setpoints/command sources card.
Step 2: Click Next.
Step 1: Choose IEC-Motor (50 Hz, SI units) for Standard.
Step 2: Input 400 V for the drive unit line supply voltage.
Step 3: Choose Load duty cycle with high overload for vector drives for the power unit application.
Step 4: Click Next.
Step 1: Choose No filter at the drive options card.
Step 2: Click Next.
Step 1: Choose Enter motor data for the Motor configuration.
Step 2: Choose Induction motor for the motor type.
Step 3: Choose Star for the connection type.
Step 4: Input the required motor data accordingly.
Step 5: Choose No sensor for the temperature sensor.
Step 6: Click Next.
Step 1: Choose No motor holding brake available at the motor holding brake card.
Step 2: Click Next.
Step 1: Input important parameters accordingly at the important parameters card.
Step 2: Click Next.
Step 1: Choose Standard drive for the Technology application.
Step 2: Choose Inhibited for the motor identification.
Step 3: Choose Complete calculation for the Calculation of the motor parameters.
Step 4: Click Next.
Click Finish.
4.3 Programming the PLC Logic
In this application example, the SINAMICS G120C drive is controlled by S7-1217 CPU via Modbus communication. To achieve this control, the following instructions have been added to the program:
- MB_COMM_LOAD
- MB_MASTER
These FBs are called in the user defined "Modbus_Com"(FB1) function block. The figure 4-1 shows the program structure.
Table 4-3 is the details about the PLC logic programming.
Table 4-3 PLC Program
Step 1: Double-click Add new block in the program blocks.
Step 2: Select to create a new FB and give a name as Modbus_Comm.
Step 3: Click OK.
Configure the input and output as the table.
Configure the MB_Comm_Load function block as the table.
Configure the MB_Master function block as the table.
Open the Default tag table, and create the variables as the table.
Open OB1 and insert the FB1 to OB1, connect the input and output as the table.
Create a watch table as the table.
Step 1: Compile the program.
Step 2: Compiling is finished.
Step 3: Click download.
Click Load to load the program into PLC.
Click Finish and Save project.
4.4 Operating the Application
Table 4-2 Operation
Step 1: Go to Watch and force table: Modbus_Operation.
Step 2: Go Online.
Communication load enable:
1. Modify "Start Communication" with "True" (1).
2. When "Communication Done" is True,
3. Modify "Start Communication" "False" (0).
Start motor:
1. Set "Mode W/R" to 1.
2. Set "Master Address" to 40101.
3. Set "DATA_W/R" to 10.
1. Set "Master Address" to 40100.
2. Set "Data W/R" to 047E.
1. Set "Data W/R" to 047F.
Stop motor:
1. Set "Data W/R" to 047E.
5 Related Literature
Reference | Topic |
---|---|
[1] | Siemens Industry Online Support http://support.industry.siemens.com |
[2] | Download page of this entry https://support.industry.siemens.com/cs/ww/en/view/109764623 |
[3] | G120C manual FW 4.7.10 https://support.industry.siemens.com/cs/ww/en/view/109757226 |
6 Contact
Siemens Ltd., China
DF MC GMC-G
No. 18 Siemens Road
Jiangning Development Zone
Nanjing, 211100
China
mailto: mc_gmc_mp_asia.cn@siemens.com
7 History
Version | Date | Modifications |
---|---|---|
V1.0 | 12/2018 | First version |