Thread Content
Preface: The Siemens S7-200 PLC is widely used in the field of industrial control; it is a controller with high performance and stable operation. This time, we will connect Siemens’ S7-200 PLC to the EMCP IoT cloud platform (abbreviated as EMCP), in order to enable remote monitoring of the 200 PLC via computer web pages, mobile apps, and WeChat. 1. Preparation work. 1.1 Before the connection, we need to prepare the following items ; One S7-200 (it is recommended to use a PLC with CPU226 or CPU224 that has two serial ports: port 1 is used for program downloading and online monitoring, while port 0 is used for communication as a Modbus-RTU slave with the GM10-DTU module). The Smart200PLC can also be used (the older 200PLC will be used as an example here). 1. One DTU module, along with an antenna and power adapter (herein referred to as GM10-DTU as an example). 2. One SIM card with data plan, a large-size card (from China Mobile or China Unicom). 3. One DP9 male connector. 4. One computer connected to the Internet (with WinXP/Win7/Win8 operating system). 5. Electrical tools and several wires. The material preparation is as follows ; https://attach01.hcbbs.com/forum/201803/06/152246sdh3b37dhd3b037b.png Preparation for 1.2 DTU: Follow the instructions in the \"GM10-DTU User Manual\" for these steps. We need to connect an antenna to the DTU gateway (the settings for the WM10-DTU gateway are similar to those of the GM10; hence, the GM10-DTU gateway will be used as an example here), insert a SIM card (a China Mobile or China Unicom data card, preferably a larger-sized one), and connect it to a 12V or 24V power adapter. 1.3 Preparation for the S7-200 PLC. Connect the 200PLC to the power supply (make sure to note whether it is 24VDC or 220VAC). Prepare a 9-pin serial connector (as shown in the diagram above), and use two wires to solder to pins 3 and 8 respectively (the 200PLC system manual explains that pins 3 and 8 are used for 485 communication). At this point, we connect pin 3 of the PLC prot0 serial port to the “485A” terminal of the GM10 module, and pin 8 to the “485B” terminal of the GM10 module. http://6318546.s21i-6.faiusr.com/4/ABUIABAEGAAguKH4zgUooOGP3AEwrAM4mAI!300x300.png II. Creation of 200 PLC slaves. 1. Connect the 200PLC to a computer using a programming computer, open the Step7-MicroWin programming software, create a new project, and add the Modbus Slave Port0 function blocks (MBUS_INIT, MBUS_SLAVE) to the main program. The library file • Siemens Modbus slave protocol library contains two instructions: the MBUS_INIT instruction and the MBUS_SLAVE instruction. •The MBUS_SLAVE instruction is used to serve requests sent by a Modbus master device. •The MBUS_INIT command is used to enable, initialize, or disable Modbus slave communication. Before using the MBUS_SLAVE instruction, the MBUS_INIT instruction must be executed correctly. The “Complete” bit must be set immediately after an instruction is completed in order to proceed to the next instruction. http://6318546.s21i-6.faiusr.com/4/ABUIABAEGAAguKH4zgUolOj0XzCRAzj-AQ!400x400.png http://6318546.s21i-6.faiusr.com/4/ABUIABAEGAAguKH4zgUom6L5qgcw-gI4kQE.png For instructions on the MBUS_INIT and MBUS_SLAVE commands, please refer to the help documentation in the “STEP 7-MicroWIN” software. Above, we set the Modbus hold register area to start at VB1000 (HoldStart = VB1000), with 100 words of hold registers (MaxHold = 100). Since hold registers are stored in units of words (two bytes), this communication buffer actually occupies 200 bytes from VB1000 to VB1200. 2. Set up the library storage area. Click \"File\" in the menu bar, select \"Library Memory Allocation\" from the drop-down list. In the dialog box that appears, enter the starting address for the library memory area; be careful to ensure that this address does not overlap with any other addresses already in use or planned for use in the program. You can click \"Suggested Address\" to avoid conflicts between the addresses occupied by the Modbus function blocks and the register addresses in the program. http://6318546.s21i-6.faiusr.com/4/ABUIABAEGAAguKH4zgUo_NrwTTDWAjiOAw!300x300.pnghttp://6318546.s21i-6.faiusr.com/4/ABUIABAEGAAguKH4zgUogKuAogEwigM40AI.png3. Compile the program; once compilation is successful, download it to the PLC using a PPI cable (if the PLC has only one serial port and that port is configured as a Modbus port, then we need to set the PLC’s operation switch to the “stop” position during the download process). After the download is complete, turn off the power and check the program monitoring to see whether the “Error” outputs for the MBUS_INIT and MBUS_SLAVE commands are normal (a value of 0 indicates normal operation; any other value indicates an error. Please refer to the Siemens PLC technical manual for a list of errors). Third, EMCP platform settings. Log in to the EMCP platform using an administrator account (a browser such as IE9 or later, or Google Chrome) to configure the EMCP cloud platform. For specific operations, refer to the EMCP IoT Cloud Platform User Manual. After logging in to EMCP, you first arrive at the device list display page; since we have not created any devices, it is an empty page. Click the “Backend Management” button in the upper right corner (this permission is available only to administrative accounts) to access the backend of the EMCP platform. http://6318546.s21i-6.faiusr.com/4/ABUIABAEGAAguKH4zgUo0Iih0QcwgAg4PQ.png 3.1 Remote configuration of DTU: Open the “Backend Management -> Module Management” page, bind the DTU to this administrator account, and then you can use the “Remote Configuration” function to set various communication parameters and functional settings for the DTU. There are two main areas that need to be configured: one is the serial port parameters for communication with the PLC, and the other is the MODBUS channel parameters for setting up timed data collection from the PLC by the DTU. The following explains this functionality step by step. Note: The module can only be remotely configured after it is online; it is also possible to configure the module using the “DTU Configuration Software”. Refer to the documentation titled “DTU Configuration Software User Manual”. 3.1.1 Module binding: http://6318546.s21i-6.faiusr.com/4/ABUIABAEGAAgi_i8zwUo9aLY9wYwrgY4_wI.png. The initial binding password for this module is 111111; simply click to proceed with the binding. 3.1.2 Remote Configuration of Modules It is best to first \"read\" and then \"write\" the parameters of a module; only when writing is successful can it be considered that the parameter has been successfully configured in the DTU. After writing, it is also possible to \"read\" to check whether the previous operation was successful. If module DI alarm points are not used, there is no need to perform “SMS settings”. http://6318546.s21i-6.faiusr.com/4/ABUIABAEGAAguKH4zgUosom33QEwgAg42gM.png http://6318546.s21i-6.faiusr.com/4/ABUIABAEGAAguaH4zgUo-9ix7QIwgAg47AM.png http://6318546.s21i-6.faiusr.com/4/ABUIABAEGAAguaH4zgUovLC7hAQwgAg46AM.png http://6318546.s21i-6.faiusr.com/4/ABUIABAEGAAguqH4zgUo2Yew2gUwgAg46gM.png Device slave address: It is the MODBUS slave address of the device connected to the module (ranging from 1 to 250); this address must be identical to the device’s slave address. It must match the MODBUS slave address set in the PLC. Function code: A flag for the module to read the MODBUS register area of the device. “Function code 01 corresponds to “Coil” (0XXXX), function code 02 corresponds to “Discrete Input” (1XXXX), function code 03 corresponds to “Holding Register” (4XXXX), and function code 04 corresponds to “Input Register” (3XXXX). In Siemens PLCs, Q points correspond to function code 01, I points correspond to function code 02, V areas correspond to function code 03, and AI areas correspond to function code 04. Start address: The starting address for reading the MODBUS registers of the device connected to the module (excluding the register area identifier). In the figure, 1 corresponds to the data length of 40001: it represents the continuous length of data read by the DTU device. The value 10 in the figure indicates that a total of 10 data points are read consecutively, from 40001 to 40010. A standard DTU can be connected to multiple slaves (up to 4). Click \"Create\" to create new sub-device slaves, and follow the instructions above for configuration. Building on the establishment of the PLC slave station mentioned earlier, what is read here are values from 40001 to 40010, which correspond to the data in registers VW1000 to VW1019 within the Siemens 200 PLC. Note: When the DTU experiences abnormalities, such as being unable to connect to the network or communicate properly with the PLC, it is possible to use the configuration port (RS232 by default) to connect to a PC, and the “DTU Configuration Software” can be used to check the status and any error alerts. For more details, refer to the “DTU Configuration Software User Manual”. 3.2 Creating a new data rule: Click on “Data Rules” on the left side of the webpage to access the rule settings page. Click “Add” in the upper right corner, and in the pop-up window, set the name of this data rule to “S7-200PLC” and the display style to “List display”. We can choose between list display or configuration display; with list display, the data we add will be shown in a fixed list format, which is a simple and convenient method (list display can be used during the data testing phase). Configuration display: We can freely design the way in which device data is displayed, by adding elements such as graphics, images, dashboards, bar charts, and text (this function is similar to that of traditional configuration software; refer to the \"EMCP Platform Screen Configuration Instructions\" document for more details). After creating the data rules, click on “Real-time Data” to add real-time data (the Modbus configuration set in 3.1.2), and click on “Read/Write Data” to create data for the platform’s manual read and write operations on devices. The created rules are displayed as follows. Note: Real-time data: This refers to the content displayed on the platform, which is obtained by the DTU reading the data from the slave devices at regular intervals set according to the configured Modbus acquisition channels (refer to section 3.1 above) and uploading it ; Reading and writing data: There is no need to configure Modbus timed acquisition channels on the DTU; data can be manually read from and written to the lower-level devices through the platform ; For all “register address” settings on the EMCP platform, there is no need to include a register area identifier. For example, when reading or writing the data in the “hold register” (function code 03) with address 40019, it is sufficient to enter 19 as the “register address” according to the platform’s data rules. (Note: If the device’s Modbus address counting starts from 0, an addition of 1 is required; in that case, 20 should be entered.) http://6318546.s21i-6.faiusr.com/4/ABUIABAEGAAguqH4zgUoovLfsAMwgAg45AM.png http://6318546.s21i-6.faiusr.com/4/ABUIABAEGAAguqH4zgUo0oasiQEwgAg4lwQ.png http://6318546.s21i-6.faiusr.com/4/ABUIABAEGAAgu6H4zgUo-KDC7wIwgAg4pwQ.png For alarm settings, within the created real-time data, click on the “Alarm” option to access the alarm settings page. We can set the upper and lower limits for alarms related to this data, as well as the alarm message and whether to enable such alarms. After an alarm is set, once the data exceeds the upper or lower limits of the alarm, the platform will automatically record the time and value of the alarm. At the same time, it will send an alarm message to the APP or WeChat account used by the user. http://6318546.s21i-6.faiusr.com/4/ABUIABAEGAAgu6H4zgUolq7PogUwgAg4qgQ.png 3.3 Create a new device: Go to the \"Device Management\" menu and select \"Add\" to create a new device, namely \"Siemens S7-200PLC\". For newly added devices, you need to fill in the basic information of the device: 1) Select an image matching the device (it can be uploaded from local storage, or you can leave it blank – the system will use a default image); 2) Enter the module SN, i.e., the SN code to be associated with the device; if this SN has not been associated with any device before, a window will appear to allow for such association; 3) Choose the data rules that were created earlier; 4) Click the “Map” button to select the geographical location where the device is located. After completion, click “Save”. http://6318546.s21i-6.faiusr.com/4/ABUIABAEGAAgvKH4zgUoxN6ZpQcwgAg4pwQ.png IV. Experimental results. Open the “Program Status Monitoring” and “Status Table Monitoring” functions in the Step7-MicroWin programming software to view the operating status of the program as well as the numerical values of the internal data. Through the status table, we can view the current values of various data and force changes to them. As shown in the figure below. http://6318546.s21i-6.faiusr.com/4/ABUIABAEGAAgvKH4zgUo9KvB0wUw-wU40AM.png http://6318546.s21i-6.faiusr.com/4/ABUIABAEGAAgvKH4zgUoqtTiiQQwgAg46AQ.png Log in to the EMCP platform, and click on the image or device name of the “Siemens S7-200 PLC” device to access it. The first thing that is displayed is the real-time data from the 200PLC’s scheduled data collection. Clicking on “Read/Write Data” allows for reading from and writing to the 200PLC. Clicking on “Historical Data” shows a report of the historical data stored by the device over time. Clicking on “Alarm Records” takes you to the page displaying the records of alarm messages, as shown below. http://6318546.s21i-6.faiusr.com/4/ABUIABAEGAAgvKH4zgUouPy5wwcwgAg4pwQ.png http://6318546.s21i-6.faiusr.com/4/ABUIABAEGAAgvaH4zgUop6n4VjCACDihBA.png http://6318546.s21i-6.faiusr.com/4/ABUIABAEGAAgvaH4zgUoiNDsggYwgAg4pwQ.png Install the “Yunlian Wutong” mobile app on your smartphone, log in using your username and password. Once you’re in the device list, select the “Siemens S7-200 PLC” device; this will take you to either the real-time data page or the configuration interface (in configuration mode). Click on the three-bar button in the upper-right corner of the menu to bring up the function menu. From there, select “Read/Write Data” to perform read and write operations on the data. Click “Historical Reports” to view the historical data stored for the device, click “Historical Trends” to see graphs showing the historical trends of various data values, click “Alarm Information” to view the alarm records for that device, and click “Device Details” to view detailed information about the device or watch video footage related to it. http://6318546.s21i-6.faiusr.com/4/ABUIABAEGAAg6LH4zgUowLz7pwYwlgY4xgU.png