STM32-based rectifier PLC control port mapping module
By using an STM32-based PLC control port mapping module, communication between the PLC and STM32 is achieved through RS485 serial port and SP3485 chip. This solves the problem of HMI being unable to recognize port addresses after the PLC model is changed, realizes port address remapping, reduces costs, and simplifies operation.
Patent Information
- Application Number
- CN202323632318.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Utility models(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-28
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2033-12-28
AI Technical Summary
In a PLC control system, when the PLC model is changed, the HMI cannot recognize the port address of the new PLC model, which requires rewriting the HMI configuration software, resulting in high costs and a large workload.
A rectifier PLC control port mapping module based on STM32 is adopted. Communication between PLC and STM32 is realized by adding RS485 serial port and SP3485 chip. STM32 reads the address information of the new model PLC and stores it in STM32 address. HMI reads the address information in STM32 to realize port address remapping.
Without changing the original PLC hardware wiring, the HMI program can still read the information of the new PLC model after the PLC model is changed, which reduces costs, simplifies operation, and has good portability and noise resistance.
Smart Images

Figure CN221765962U
Abstract
Description
Technical Field
[0001] The utility model belongs to the field of controller serial port communication and relates to a rectifier PLC control port mapping module based on STM32. Background Art
[0002] When HMI is used in PLC control system, HMI and PLC communicate through serial port in Direct Link mode. In this mode, HMI directly reads PLC data or writes data into corresponding address of PLC according to requirements. Since communication protocol is built-in, there is no need to compile communication program. As long as the type of PLC used, i.e. communication protocol, is specified, communication can be realized during operation. At the same time, data can be input into corresponding address of PLC by touching HMI.
[0003] The rectifier control system consists of PLC and HMI. There are many communication methods between PLC and HMI. The more common ones are serial communication and Ethernet communication. The corresponding PLC model, baud rate, communication method, etc. are set in HMI to communicate. The configuration software compiles the HMI program to read the determined PLC address information. In the iterative upgrade process of subway rectifier products, even for the same series of PLC products, there are large differences in the port mapping of different models of PLC. Therefore, the port address information read by the HMI connected to the old model PLC can correspond to the address information of the old model PLC. However, after replacing the new PLC model, since the automatic address allocation of the PLC module cannot be changed, the port address information with some changed mapping relationships cannot be recognized by the HMI. At this time, the external HMI configuration software needs to be recompiled, but the early HMI software is ordered externally, and large-scale replacement is not only costly, but also labor-intensive.
[0004] In view of this, the inventor provides a rectifier PLC control port mapping module based on STM32 to solve the above technical problems. Utility Model Content
[0005] The purpose of the utility model is to overcome the shortcomings of the above-mentioned prior art, and propose a rectifier PLC control port mapping module based on STM32. ARM embedded technology is used to add an RS485 serial port to realize the communication between STM32 and PLC. The new port address information of PLC is read through STM32, and then the read information is stored in the STM32 address. At this time, HMI reads the address information in STM32 to realize the remapping of the register address of PLC expansion module.
[0006] In order to achieve the above purpose, the utility model adopts the following technical solutions:
[0007] The utility model provides a rectifier PLC control port mapping module based on STM32, comprising a PLC, an STM32 and an HMI respectively connected to the PLC, and an RS485 serial port connected between the PLC, the STM32 and the HMI and a conversion module for converting levels, wherein the STM32 is also connected to the HMI, and the PLC, the STM32, the HMI, the RS485 serial port and the conversion module jointly realize the remapping of the register address of the PLC expansion module;
[0008] The conversion module is an SP3485 chip;
[0009] RS485 serial ports are connected between the PLC and STM32, and between the STM32 and the HMI, and an SP3485 chip is also connected between the PLC and STM32.
[0010] Furthermore, the STM32 and the PLC communicate with each other using the Modbus protocol via an RS485 serial port.
[0011] Furthermore, after the PLC changes its model, STM32 reads the address information of the new model PLC through the RS485 serial port, and stores the read address information in the STM32 address, and the HMI then reads the address information of the new model PLC stored in the STM32 through the connected RS485 serial port.
[0012] Furthermore, the SP3485 chip is located between the RS485 connecting the PLC and the STM32 and the STM32. When the RS485 signal is transmitted to the STM32, the SP3485 chip converts the level into a TTL level, so that the signal level transmitted by the RS485 is compatible with the level of the STM32.
[0013] Compared with the prior art, the utility model has the following beneficial effects:
[0014] 1. The utility model discloses a rectifier PLC control port mapping module based on STM32. The communication between STM32 and PLC is realized by adding RS485 serial port. The address information of the new port of PLC read by STM32 is stored in the STM32 address. HMI reads the address information stored in STM32. On the basis of not changing the original PLC hardware wiring, the HMI program can still read the information of the new model PLC after the PLC model is replaced. The utility model has simple design principle, low cost, detachable and strong portability.
[0015] 2. The utility model discloses a rectifier PLC control port mapping module based on STM32. On the basis of the original PLC hardware wiring, only the RS485 serial port and the SP3485 chip are added. The information in the STM32 is sent to the HMI through the Modbus protocol communication, and the remapping of the register address of the PLC expansion module is realized. The Modbus protocol communication adopted has few communication nodes and small data volume. According to the Modbus RTU communication, the encoding and decoding process is simple, which occupies less CPU time and memory space, has fast communication speed and good noise resistance.
[0016] 3. The utility model discloses a rectifier PLC control port mapping module based on STM32. It does not change the original PLC hardware wiring. It only needs to add RS485 serial port and SP3485 chip based on STM32 to realize the remapping of PLC expansion module register address. It does not need to replace HMI program. It is not only low-cost, but also simple to operate and has high economic benefits. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The accompanying drawings herein are incorporated into and constitute a part of this specification, and together with the description, are used to explain the principles of the present utility model.
[0018] In order to more clearly illustrate the technical solutions in the embodiments of the utility model or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0019] Figure 1 This is a working principle diagram of the rectifier PLC control port mapping module based on STM32 of the utility model;
[0020] Figure 2 The SP3485 chip pin diagram in the embodiment of the utility model;
[0021] Figure 3 It is the RS485 wiring diagram in the embodiment of the utility model;
[0022] Figure 4 It is the working flow diagram of the STM32 single-chip microcomputer in the embodiment of the utility model;
[0023] Figure 5 The present invention is a flowchart of the STM32 single-chip microcomputer serial port data reception and transmission in the embodiment of the present invention. DETAILED DESCRIPTION
[0024] Here, exemplary embodiments will be described in detail, and the embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present utility model. Instead, they are only examples of devices consistent with some aspects of the present utility model as detailed in the attached claims.
[0025] The old model PLC and HMI can communicate directly through the RS485 serial port connection. At this time, the read address of the HMI corresponds to the address of the old model PLC one by one. However, when the PLC model is changed, the port address of the new model PLC is fixed, but the address of the new model PLC expansion module may change. The read address of the HMI cannot match the address of the PLC expansion module, and some PLC information cannot be read.
[0026] The utility model utilizes ARM embedded technology, aims at the problem that the human-machine interface cannot read information due to the change of port address when replacing new products, designs a rectifier PLC port mapping module based on STM32, establishes a mapping relationship between the physical port of the PLC hardware device and the logical port read by the HMI, and the hardware system in the rectifier PLC port mapping module based on STM32 includes a CPU module, a power module, a debugging interface and a conversion module, one end of the conversion module is connected to the CPU module, and the other end is connected to the RS485 serial port, and one end of the CPU module is connected to the new model PLC expansion module. The analog port of the CPU module is connected through the RS485 serial port, the analog port of the CPU module is also connected to the HMI through the RS485 serial port, the debugging interface is externally connected to the CPU module, and the power module is connected to the CPU module; thereby realizing that when the input port module mapping relationship is changed after the PLC is replaced, on the basis of not changing the human-machine interface program and the original PLC hardware wiring, the communication between the STM32 and the PLC is realized through RS485, the address information of the new expansion module port of the PLC read by the STM32 is stored in the STM32 address, and then the address information in the STM32 is read by the HMI (human-machine interface).
[0027] like Figure 1As shown, the working principle of the rectifier PLC port mapping module based on STM32 is: when the PLC model is changed, since the read address of the HMI corresponds to the address of the old model PLC one-to-one, and cannot correspond to the address of the new model PLC one-to-one, the HMI cannot read some information in the PLC. At this time, Modbus communication is performed between the PLC and the STM32 via RS485. However, STM32 communication is generally TTL level, and the level of the external RS485 communication is 485. The level between STM32 communication and RS485 communication is different. The level of RS485 communication is higher than that of STM32 communication. Generally speaking, the port voltage of STM32 is 3.3V. The RS485 level is directly connected to the STM32 port, which may cause damage. Therefore, the level of the RS485 serial port is converted by a conversion module connected between the RS485 serial port and STM32. The conversion makes the level transmitted to STM32 a TTL level; then STM32 stores the read information of the new model PLC in STM32. It should be noted that the storage address of the information of the new model PLC read by STM32 is the same as the storage address of the information of the old model PLC. Since the address information of STM32 is the same as the address information of the old model PLC, HMI can obtain the stored new information by reading the address of STM32 storing the old information, so that HMI receives the address information of the new model PLC, thereby realizing the remapping of the register address of the PLC expansion module.
[0028] Example 1
[0029] The hardware system in the rectifier PLC port mapping module based on STM32 includes a CPU module, a power module, a debugging interface and a conversion module, one end of the conversion module is connected to the CPU module, and the other end is connected to an RS485 serial port, one end of the CPU module is connected to a new model PLC module through an RS485 serial port, and an analog port of the CPU module is also connected to an HMI through an RS485 serial port, the debugging interface is externally connected to the CPU module, and the power module is connected to the CPU module; the power module is used to power the CPU module so that the CPU module can work normally, the CPU module is an STM32 single-chip microcomputer, and the debugging interface is used to debug a software program, and the conversion module described in the present embodiment is an SP3485 chip, which is connected between PLC and STM32 through RS485 as an RS485 transceiver.
[0030] like Figure 2As shown in the figure, the functions of each pin in the SP3485 chip are as follows: RO is the receiver output pin, RE is the receiver output enable pin (valid at low level), DE is the driver output enable pin (valid at high level), DI is the driver input pin, GND is the ground pin, A is the driver output pin / receiver input pin (in phase), B is the driver output pin / receiver input pin (inverting), and VC is the chip power supply pin; Figure 3 The figure shows the external wiring diagram of RS485. During the operation of STM32, RE and DE are connected together. When STM32 receives an external signal, it is set to 0. When STM32 sends a signal to the outside, it is set to 1.
[0031] The software system in the STM32-based rectifier PLC port mapping module includes a system startup program, a system service program and a system application program, and the STM32 software can be generated by CubeMAX configuration.
[0032] like Figure 4 As shown in the figure, when STM32 is working, since STM32 has many peripherals, in order to reduce power consumption, each peripheral corresponds to a clock. When the chip is just powered on, these clocks are turned off. If you want the peripherals to work, you must turn on the corresponding clock. When the GPIO port reuses USART for communication, first enable the GPIO clock, and then enable the USART clock; then the HAL function library initializes the serial port parameters by calling the initialization function HAL_UART_Init; then complete the setting of the GPIO mode by calling HAL_GPIO_Init, such as the setting of pins, modes, pull-up and pull-down, speed, etc.; use HAL The _UART_ENABLE_IT function enables the receiving interrupt; the HAL_NVIC_EnableIRQ function enables the serial port interrupt, and the HAL_NVIC_SetPriority function sets the interrupt priority; the serial port interrupt service function is: USART_IRQHandler. When an interrupt occurs, the program will execute the interrupt service function, where the received data can be processed; the serial port data is received and sent through the HAL_UART_Receive and HAL_UART_Transmit functions. The specific serial port data receiving and sending process is as follows Figure 5 shown.
[0033] The above description is only a specific embodiment of the present invention, so that those skilled in the art can understand or implement the present invention. Various modifications to these embodiments will be obvious to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present invention.
[0034] It should be understood that the present invention is not limited to the above-described contents, and various modifications and changes can be made without departing from its scope. The scope of the present invention is limited only by the appended claims.
Claims
1. A rectifier PLC control port mapping module based on STM32, characterized in that: The invention comprises a PLC, an STM32 and an HMI respectively connected to the PLC, and an RS485 serial port connected between the PLC, the STM32 and the HMI and a conversion module for converting levels, wherein the STM32 is also connected to the HMI, and the PLC, the STM32, the HMI, the RS485 serial port and the conversion module jointly realize the remapping of the register address of the PLC expansion module; The conversion module is an SP3485 chip; RS485 serial ports are connected between the PLC and STM32, and between the STM32 and the HMI, and an SP3485 chip is also connected between the PLC and STM32.
2. The rectifier PLC control port mapping module based on STM32 according to claim 1, characterized in that, The STM32 and the PLC communicate with each other using the Modbus protocol via the RS485 serial port.
3. The rectifier PLC control port mapping module based on STM32 according to claim 1, characterized in that, After the PLC changes its model, STM32 reads the address information of the new model PLC through the RS485 serial port, and stores the read address information in the STM32 address, and the HMI then reads the address information of the new model PLC stored in the STM32 through the connected RS485 serial port.
4. The rectifier PLC control port mapping module based on STM32 according to claim 1, characterized in that, The SP3485 chip is located between the RS485 connecting the PLC and the STM32 and the STM32. When the RS485 signal is transmitted to the STM32, the SP3485 chip converts the level into a TTL level, so that the signal level transmitted by the RS485 is compatible with the level of the STM32.
Citation Information
Cited By
Modbus communication method and system based on HMI
CN120415943A
