Preface: Siemens S7-1200 PLC is an excellent programmable controller widely used in the field of industrial control. It is a high-performance and stable controller. This time, we will connect the S7-1200 PLC to the EMCP IoT Cloud Platform (EMCP) through Modbus driver, enabling remote monitoring of the registers of the S7-1200 PLC (MW1000, MW1002, I0.0) and remote reading and writing of MW1004 and Q0.0 through computer web pages, mobile apps, and WeChat.
1) One Siemens S7-1200 PLC and RJ45 Ethernet cable for communication.
2) Siemens CB 1241 RS485 module.
3) One EG20 gateway, antenna, and power adapter from Hebei Blue Bee Technology (using EG20 as an example below).
4) One SIM card with data, large card (China Mobile, China Unicom or Telecom card).
5) One networked computer (WinXP/Win7/Win8/Win10 operating system).
6) Electrical tools, communication cables, etc.
The technical parameters and usage instructions related to the gateway can refer to the EG20 User Manual.
1. Ensure that the gateway can be connected to the internet normally, either through a 4G card (China Mobile/China Unicom/Telecom data card, large card) (with the antenna attached to the gateway) or through a network cable (with the router's network cable connected to the gateway's WAN port);
2. Connect the gateway to a 12V or 24V DC power supply and power it on. (Note that the positive and negative terminals of the power supply should not be reversed).
All devices are not connected to the power supply. Remove the two movable protective plates on the S7-1200 panel and insert CB1241 into the CB slot. Insert the Ethernet cable into the PROFINET port of the PLC and the other end into the computer port. Connect CB1241 to EG20 as shown in the diagram below, short-circuit the T/RA and TA of CB1241, and connect them together to RS485B of EG20; CB1241's T/RB and TB are short circuited and connected together to EG20's RS485. PLC powered on (220VAC), EG20 powered on (12VDC or 24VDC).
Step OneUsing Siemens' TIA Portal software, the software version used in this article is V14. Configure the S7-1200 and CB1241 devices as shown in the following figure:
Select S7-1200 in the device configuration, set the "System and Clock Memory" in the properties, and enable the system memory byte, which will be used later, as shown in the following figure:
Step twoIn the main [OB1] of the program block, add the Modbus communication enable instruction block "MB_CMM_LOAD-DB" and the slave function instruction block "MB_SLAVE-DB". During the creation process, a prompt will be given to generate the corresponding instruction block's background data block. Click confirm to proceed with the generation.
Attention: Please use the instructions in the "MODBUS" folder of the instructions, and do not use the instructions in "MODBUS (RTU)".
The parameters set by the instructions in the two figures above are: communication via RS485, baud rate of 9600, no parity check, data bit size of 8, stop bit size of 1; The PLC slave station number is 2, and the starting address of the register area is kept at MW1000, with a length of 10 words, which is from MW1000 to MW1018.
Note 1: For detailed instructions on the use of the MB_CMM_LOAD-DB instruction block and MB_SLAVE-DB instruction block, please refer to the Botu help document, as shown in the following figure. The path of the information system is: "Program PLC" → "Instructions" → "Communication (S7-1200, S7-1500)" → "Communication Processor (S7-1200, S7-1500)" → "MODBUS (RTU) (S7-1200)"
Note 2: If you want to try MODBUS to access global data blocks (DBs), you need to meet the following two conditions:
Firstly, the optimization access in the attributes of the data block DB must be cancelled;
Then, in the register pointer of MB_SLAVE-DB, use a pointer to point to the address of the DB, as shown in the following figure:
The MODBUS slave parameters set in the above figure are: communication via RS485, baud rate of 9600, no parity check, data bits of 8, stop bit of 1; The PLC slave station number is 2, and the starting address of the register area is kept as DB3.DBW0, with a length of 10 words, which is from DB3.DBW0 to DB3.DBW9.
Step threeDownload the modified program to the PLC. Please note that you must use the "Download and Reset PLC Program" option in the "Online (O)" section, as shown in the figure:
Log in to the EMCP platform with an administrator account (it is recommended to use 360 Browser Speed Mode, Chrome browser, or a browser that supports Chromium kernel), and set up the EMCP cloud platform. Please refer to the "EMCP IoT Cloud Platform User Manual" for specific operations. After logging into EMCP, the first step is to enter the device list display page. As we have not created any devices, it is an empty page. We need to follow the steps below to proceed.
Step: Click on (only management accounts have this permission) → → [EG Device Management] → [+Add] → Fill in device information → Click [Save]. Among them, is required, and all other options can be optional.
The two main areas that need to be configured in the EG device management gateway configuration are configuring serial communication parameters and creating Modbus drivers. The following will explain this function step by step. Note: The gateway can only be remotely configured after it is online.
Step: Click on [Step 2: Gateway and Instrument Management] → → Fill in and → [Confirm].
The SN and verification code are on the chassis label of the gateway. The SN is a 12 digit pure Arabic numeral, and the verification code is a 6-digit English letter. [Note] can be filled in according to the requirements. After editing, click [OK].
(with * required fields)
At this point, in the "Gateway Basic Information" section, you can see whether the bound gateway is connected to the platform (if you successfully log in to the platform, you can see the green word "Online"; if not, the gray word "Offline" will be displayed. Please check the network or network signal at this time).
To use serial port RS485 communication, RS485 communication parameters need to be set.
Each device connected to the gateway needs to establish a corresponding device driver. Just like inserting a mouse into a computer, only when the driver for this mouse is installed in the computer system can the computer recognize it. Add drivers to the communication port through which the device is connected to the gateway. As shown in the figure, click on "Add Driver" after "RS485" to display the basic configuration table on the right for configuration.
Note: After configuration is complete, click save.
Basic configuration introduction:
: Required field, customizable, differentiate when there are multiple drivers.
【 Brand 】: Required field, select 'Universal Modbus Device'.
[Model]: Required field, select "Modbus RTU".
: Required field. The equipment address is filled in according to the slave station number set by the 1200PLC. In this case, the PLC slave station number is "2", so "2" is filled in here.
【 Minimum Collection Cycle 】: It is the time interval for the gateway to collect device data, measured in milliseconds. If set to 1000ms, the gateway will collect device data once every 1 second.
[Communication waiting time]: The waiting time for the gateway to receive communication data. Adjustments can be made as needed, with a default of 1000ms.
[16 bit integer], [32-bit integer], [32-bit floating-point type]: Refers to the decoding order of the corresponding data type. Default settings are sufficient
[Block Collection Method]: 0- Block by Maximum Length: The collection block is processed according to the maximum block length, and multiple blocks with discontinuous but similar addresses are divided into one block and read at once to optimize the collection efficiency; 1- Block by continuous address: Collect blocks based on address continuity, and for multiple blocks with discontinuous addresses, only collect continuous addresses at a time without optimization processing. Simply select the default option.
[4-zone 16 digit write function code]: Select the function code when writing single characters in zone 4. Simply select the default option.
Step: Click on [Step 3: Variable Management] ->[+Add Variable] ->Fill in variable information ->[Save].
Variable introduction:
【 Instrumentation, PLC 】: Required, select the driver just created. Choose according to the actual situation.
: Required, customizable. Be careful not to have duplicate names.
[Unit]: Not required, can be customized. When displaying in a list, variables will be displayed with units.
【 Register Type 】: Required. In Siemens PLC, point Q corresponds to 【 Coil (0x) 】, point I corresponds to 【 Discrete Input (1x) 】, M area or DB block corresponds to 【 Hold Register (4x) 】, and AI area corresponds to 【 Input Register (3x) 】.
: Required, the address should be filled in without the storage area identifier. Please refer to the image below for specific settings.
: Required, select according to actual needs.
[Number of decimal places]: Not required, fill in according to requirements.
[Dead Zone Setting]: Not required, default is sufficient. Fill in as needed. For a more detailed explanation, please refer to the "?" help section later.
: Not required. Numerical values can be directly mapped to text. If the value is "10" and the mapping field is "device failure", then when the value of the collected variable is "10", "device failure" will be directly displayed in the device monitoring and historical reports.
: Not required. The collected data can be calculated according to the formula filled in. For more detailed instructions, please refer to the "?" help section below.
[Read/Write Method]: You can modify the read/write method of this register according to your needs, and it defaults to read-only.
The example of adding and filling in variables for each storage area of PLC on the platform is shown in the following figure:
After adding, the 'Variable Management' is shown in the following figure. At this point, you can click the 'Data Testing' button to check whether the variable values can be collected or whether the values are correct.
Open the Botu software, turn the PLC online, and monitor the current PLC data from the monitoring table, as shown in the following figure:
Users can log in to the EMCP platform and click on the image or device name of the "S7-1200" device to view and modify relevant data.
We have rich experience in system integration solutions and can provide users with embedded hardware, server software platforms, and mobile APP softwareIoT products. The involved fields include remote online management of industrial equipment, online management of complete systems, online management of environmental detection, agricultural smart greenhouse monitoring systems, and remote SCADA systems for agricultural product traceability.
Siemens 1200PLC remote intelligent industrial gateway,Siemens 1200PLC remote intelligent industrial gateway
What we care more about is the user experience of each platform. Thank you for your trust!
For more technical information, please search for Blue Bee IoT! You can also apply for a free prototype!