Dual protocol communication device and method
Patent Information
- Application Number
- CN202410071039.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-17
- Publication Date
- 2026-10-27
- Estimated Expiration
- 2044-01-17
AI Technical Summary
[0002]目前,随着智能电表的逐渐普及以及电力控制终端设备更新换代后,智能电表的相关协议模块也需要进行相应的更换,然而,现有的电表由于装配结构复杂,其内部的协议模块无法快速更换,甚至有些电表的协议模块与其他模块直接焊在同一块电路板上,无法进行更换,进而使得电表难以兼容对接不同通信协议的设备或系统,导致其通讯性能单一,通讯灵活度较差
[0037]本申请实施例提供了一种双协议通讯装置,包括:RS485通讯电路,用于接收并转发来自上位机的请求数据;处理器,包括两组配置不同的串口收发管脚,用于分别接收并解析请求数据,得到两组解析数据;对两组解析数据分别进行校验,若任一组解析数据的校验通过,则通过RS485通讯电路向上位机发送应答数据。本申请实施例通过一个RS485通讯电路连接两组不同的串口收发管脚,实现两组不同配置的串口收发管脚的自动识别双协议通讯;进而,本实施例可以适用于不同串口配置参数组合的串口收发管脚来进行不同通信协议的自动识别,突破对串口参数的设置局限,且无需增加相应的RS485接口,即可实现低硬件成本的双协议通讯,提高了装置通讯性能和通讯灵活度,且提高了多协议识别的多样性、稳定性,进而可以在不切换物理通道的情况下,正确识别多种不同配置的串口数据,且基于电子硬件设计支持,从通讯的物理层面处理数据,减少了高速通讯时因软件程序对串口数据的解析错误导致的丢帧率,提高了协议通讯的可靠性。此外,本实施例的双协议通讯装置,能广泛应用于多协议通讯场景,进而更好地满足日益增长的客户需求以及适应市场运用场景,并且也能更好的兼容多个软件系统,提高通讯效率和性能。
Smart Images

Figure CN117914969B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communications, and more particularly to a dual-protocol communication device and a dual-protocol communication method. Background Technology
[0002] Currently, with the gradual popularization of smart meters and the upgrading of power control terminal equipment, the relevant protocol modules of smart meters also need to be replaced accordingly. However, due to the complex assembly structure of existing meters, their internal protocol modules cannot be replaced quickly. In some cases, the protocol modules of some meters are directly soldered on the same circuit board as other modules, making them impossible to replace. This makes it difficult for the meters to be compatible with devices or systems with different communication protocols, resulting in limited communication performance and poor communication flexibility. Summary of the Invention
[0003] In a first aspect, the present invention provides a dual-protocol communication device, comprising:
[0004] The RS485 communication circuit is used to receive and forward request data from the host computer.
[0005] The processor includes two sets of serial port transceiver pins with different configurations, used to receive and parse the request data respectively to obtain two sets of parsed data; the two sets of parsed data are verified respectively, and if the verification of either set of parsed data passes, the processor sends response data to the host computer through the RS485 communication circuit.
[0006] In an optional implementation, the step of verifying the two sets of parsed data includes:
[0007] The data formats of the two sets of parsed data are verified to be consistent with the data formats corresponding to the preset communication protocol. Each set of serial port transceiver pins corresponds to a different preset communication protocol, and each set of serial port transceiver pins parses data with different data formats based on the different preset communication protocols.
[0008] If the data format of the parsed data is consistent with the data format corresponding to the preset communication protocol, then the verification of the parsed data is determined to be successful.
[0009] In an optional implementation, the step of verifying the two sets of parsed data respectively, and if the verification of either set of parsed data passes, then sending response data to the host computer through the RS485 communication circuit, includes:
[0010] The two sets of parsed data are verified sequentially.
[0011] If the verification of the first set of parsed data is successful, then response data is sent directly to the host computer through the RS485 communication circuit.
[0012] If the first set of parsed data fails the verification, the second set of parsed data is verified. If the second set of parsed data passes the verification, response data is sent to the host computer through the RS485 communication circuit.
[0013] If it is determined that the verification of the second set of parsed data fails, no response data will be sent to the host computer.
[0014] In an optional embodiment, the RS485 communication circuit includes an RS485 interface chip, and a data receiving circuit, a data transmitting circuit, a switch control circuit, and a differential signal transmission circuit connected to the RS485 interface chip.
[0015] The switch control circuit is used to control the working state of the RS485 interface chip so that the RS485 interface chip enters the data receiving state or the data sending state.
[0016] The differential signal transmission circuit is used to receive request data output by the host computer when the RS485 interface chip enters the data receiving state. The request data is converted by the RS485 interface chip and then transmitted to the processor through the data receiving circuit. The request data output by the host computer is transmitted in the form of a differential signal.
[0017] The data transmission circuit is used to receive the response data output by the processor when the RS485 interface chip enters the data transmission state. The response data is converted by the RS485 interface chip and then transmitted to the host computer in the form of a differential signal through the differential signal transmission circuit.
[0018] In an optional embodiment, the switch control circuit includes a first optocoupler, a first current-limiting resistor, and a first pull-down resistor;
[0019] The first pin of the first optocoupler is used to connect to a reference voltage; the second pin of the first optocoupler is connected to the first current-limiting resistor and is used to receive a control signal, which is used to control the working state of the RS485 interface chip.
[0020] The third pin of the first optocoupler is connected to the receiver output enable terminal and the driver output enable terminal of the RS485 interface chip, respectively, and is grounded through the first pull-down resistor; the fourth pin of the first optocoupler is used to connect to the operating voltage.
[0021] In an optional implementation, the differential signal transmission circuit includes a bidirectional transient voltage suppression diode, a thermistor, a first pull-up resistor, and a second pull-down resistor;
[0022] The first terminal of the bidirectional transient voltage suppressor diode is connected to the driver output terminal and the output terminal of the first differential signal line of the RS485 interface chip, respectively. The second terminal of the bidirectional transient voltage suppressor diode is connected to the receiver input terminal of the RS485 interface chip and the output terminal of the second differential signal line, respectively.
[0023] The receiver input terminal is used to connect to the operating voltage through the first pull-up resistor; the driver output terminal is used to be grounded through the second pull-down resistor.
[0024] The power supply terminal of the RS485 interface chip is used to connect to the operating voltage, and the ground terminal of the RS485 interface chip is grounded.
[0025] In an optional implementation, the data receiving circuit includes a second optocoupler, a second pull-up resistor, and a third pull-up resistor;
[0026] The first pin of the second optocoupler is connected to the receiver output of the RS485 interface chip to receive the request data after signal conversion by the RS485 interface chip; the second pin of the second optocoupler is used to connect the operating voltage through the second pull-up resistor.
[0027] The third pin of the second optocoupler is used to connect to a reference voltage through a third pull-up resistor and output the request data;
[0028] The fourth pin of the second optocoupler is grounded.
[0029] In an optional implementation, the data transmission circuit includes a third optocoupler, a fourth pull-up resistor, and a second current-limiting resistor.
[0030] The first pin of the third optocoupler is used to connect to a reference voltage; the second pin of the third optocoupler is connected to the second current-limiting resistor and is used to receive the response data output by the processor.
[0031] The third pin of the third optocoupler is grounded; the fourth pin of the third optocoupler is connected to the driver input of the RS485 interface chip and is used to access the operating voltage through the fourth pull-up resistor.
[0032] In an optional implementation, the dual-protocol communication device is an electricity meter or an electronic device with communication identification function.
[0033] Secondly, the present invention provides a dual-protocol communication method, applied to the aforementioned dual-protocol communication device, the method comprising:
[0034] Receive and forward request data from the host computer via RS485 communication circuit;
[0035] The processor uses two sets of serial port transceiver pins with different configurations to receive and parse the request data, resulting in two sets of parsed data. The two sets of parsed data are then verified. If either set of parsed data passes the verification, a response data is sent to the host computer via the RS485 communication circuit.
[0036] The embodiments of this application have the following beneficial effects:
[0037] This application provides a dual-protocol communication device, including: an RS485 communication circuit for receiving and forwarding request data from a host computer; a processor including two sets of serial port transceiver pins with different configurations for receiving and parsing the request data respectively to obtain two sets of parsed data; and verifying the two sets of parsed data respectively. If the verification of either set of parsed data passes, the processor sends response data to the host computer through the RS485 communication circuit. This embodiment connects two different sets of serial port transceiver pins via an RS485 communication circuit, enabling automatic identification and dual-protocol communication for two sets of serial port transceiver pins with different configurations. Furthermore, this embodiment can be applied to serial port transceiver pins with different configuration parameter combinations to automatically identify different communication protocols, overcoming the limitations of serial port parameter settings. It achieves low-hardware-cost dual-protocol communication without the need for additional RS485 interfaces, improving device communication performance and flexibility, and enhancing the diversity and stability of multi-protocol identification. It can correctly identify various serial port data configurations without switching physical channels. Based on electronic hardware design support, it processes data at the physical communication level, reducing frame loss caused by software program errors in parsing serial port data during high-speed communication, thus improving the reliability of protocol communication. In addition, the dual-protocol communication device of this embodiment can be widely used in multi-protocol communication scenarios, better meeting the growing customer needs and adapting to market application scenarios. It also offers better compatibility with multiple software systems, improving communication efficiency and performance. Attached Figure Description
[0038] To more clearly illustrate the technical solutions of this application, the accompanying drawings used in the embodiments will be briefly described below. It should be understood that the following drawings only show some embodiments of this application and should not be considered as a limitation on the scope of protection of this application. In the various drawings, similar components are numbered similarly.
[0039] Figure 1 This paper shows a schematic diagram of a first structure of a dual-protocol communication device in an embodiment of this application;
[0040] Figure 2This paper shows a schematic diagram of a first structure of an RS485 communication circuit according to an embodiment of this application;
[0041] Figure 3 A schematic diagram of a second structure of the RS485 communication circuit in an embodiment of this application is shown;
[0042] Figure 4 A flowchart illustrating a dual-protocol communication method in an embodiment of this application is shown. Detailed Implementation
[0043] The technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments.
[0044] The components of the embodiments of this application described and illustrated in the accompanying drawings can be arranged and designed in a variety of different configurations. Therefore, the following detailed description of the embodiments of this application provided in the drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0045] In the following, the terms “comprising,” “having,” and their cognates, which may be used in various embodiments of this application, are intended only to indicate a particular feature, number, step, operation, element, component, or combination thereof, and should not be construed as excluding, firstly, the presence of one or more other features, numbers, steps, operations, elements, components, or combinations thereof, or adding the possibility of one or more features, numbers, steps, operations, elements, components, or combinations thereof.
[0046] Furthermore, the terms "first," "second," and "third" are used only to distinguish descriptions and should not be interpreted as indicating or implying relative importance.
[0047] Unless otherwise specified, all terms used herein (including technical and scientific terms) shall have the same meaning as commonly understood by one of ordinary skill in the art to which the various embodiments of this application pertain. Terms (such as those defined in commonly used dictionaries) shall be interpreted as having the same meaning as in their contextual meaning in the relevant technical field and shall not be construed as having an idealized or overly formal meaning, unless clearly defined in the various embodiments of this application.
[0048] In general, dual-protocol meters typically employ the following methods to switch between two different protocols: 1. Switching between different serial port parameters (such as baud rate, parity, and stop bits) requires using the switching command of the currently configured serial port, or using a human-machine interface screen in conjunction with buttons for protocol switching; 2. Dual protocols for dual data channels, physically switching the protocol communication module using a dual-slider method; 3. Automatic switching between dual protocols with the same baud rate but different parity bits; 4. Switching between different protocols with the same communication serial port parameters, etc. However, these dual-protocol switching methods have several limitations. First, they restrict the setting of serial port parameters, requiring all serial ports to communicate at the same baud rate. Second, they require two physical RS485 buses, resulting in the meter needing multiple RS485 interfaces, increasing hardware costs, interface size and number, and user wiring operations.
[0049] Based on this, this application provides a dual-protocol communication device. Optionally, the dual-protocol communication device can be an electricity meter or other electronic devices with communication identification functions (such as power distribution equipment with communication identification functions, specifically low-voltage electrical appliances with RS485 communication functions). This application connects two different sets of serial port transceiver pins through an RS485 communication circuit 100 to achieve automatic identification of dual-protocol communication for two sets of serial port transceiver pins with different configurations. Furthermore, this embodiment can be applied to serial port transceiver pins with different serial port configuration parameter combinations to automatically identify different communication protocols, breaking through the limitations of setting serial port parameters. It achieves low-hardware-cost dual-protocol communication without adding corresponding RS485 interfaces, improving the device's communication performance and flexibility, and enhancing the diversity and stability of multi-protocol identification. Furthermore, it can correctly identify multiple serial port data configurations without switching physical channels. Based on electronic hardware design support, it processes data at the physical level of communication to identify and parse dual-protocol communication data, reducing frame loss caused by software program errors in parsing serial port data during high-speed communication and improving the reliability of protocol communication.
[0050] Exemplary, such as Figure 1 As shown, the dual-protocol communication device includes a connected RS485 communication circuit 100 and a processor 200 (such as an MCU chip). The processor 200 includes two sets of serial port transceiver pins with different configurations, which are used to synchronously receive data or signals sent by the RS485 communication circuit 100.
[0051] Specifically, the detailed process of the dual-protocol communication device performing dual-protocol communication can be found in the following embodiments of the dual-protocol communication method.
[0052] In some examples, the dual-protocol communication device performs the dual-protocol communication process as follows: the RS485 communication circuit 100 is used to receive and forward request data from the host computer; the processor 200 is used to receive and parse the request data through two different sets of serial port transceiver pins to obtain two sets of parsed data; the two sets of parsed data are verified respectively, and if the verification of either set of parsed data passes, the response data is sent to the host computer through the RS485 communication circuit 100.
[0053] In one embodiment, the RS485 communication circuit 100 includes a set of transceiver control pins, which are connected to two sets of serial port transceiver pins of the processor 200. The RS485 communication circuit 100 then sends request data to the two sets of serial port transceiver pins simultaneously through the transceiver control pins, so that the two sets of serial port transceiver pins can simultaneously receive and parse the same request data.
[0054] It is worth noting that in this embodiment, serial port parameters are pre-configured for the two sets of serial port transceiver pins of the processor 200, and then the same data is received by configuring different serial port transceiver pins. The serial port parameters configured for each set of serial port transceiver pins are different; these parameters include communication protocol, baud rate, parity bit, and stop bits, etc. The specific type of serial port parameters can be set according to actual needs and is not limited here.
[0055] For example, the host computer forwards request data via RS485 communication circuit 100. This request data is simultaneously sent via RS485 bus to two sets of serial port transceiver pins with different configurations. Then, the processor 200 parses the request data transmitted by the two sets of serial port transceiver pins and responds. One set of serial port transceiver pins is configured with the DL / T 645_2007 communication protocol, and the other set is configured with the Modbus communication protocol. Furthermore, the DL / T 645_2007 communication protocol matches serial port parameters of 9600bps baud rate and even parity, while the Modbus communication protocol matches serial port parameters of 9600bps baud rate and no parity.
[0056] Specifically, since each set of serial port transceiver pins corresponds to a different preset communication protocol, different sets of serial port transceiver pins can parse the same request data according to different preset communication protocols, resulting in parsed data with different formats. That is, due to the different configurations of the two sets of serial port transceiver pins, two different frames of request data will be parsed. The processor 200 can verify these two frames of request data and respond after successful verification. The verification method can be set according to the parity bits configured on the different serial port transceiver pins.
[0057] Furthermore, in this embodiment, the RS485 communication circuit 100 connects two sets of serial port transceiver pins through a set of transceiver control pins to achieve dual-protocol communication between two different serial port transceiver pins.
[0058] As an example, the process by which the processor 200 verifies the parsed data obtained from the two sets of serial port transceiver pins is as follows: it verifies whether the data format of the two sets of parsed data is consistent with the data format corresponding to the preset communication protocol; if the data format of the parsed data is consistent with the data format corresponding to the preset communication protocol, it is determined that the verification of the parsed data has passed.
[0059] In some examples, the processor 200 sequentially verifies two sets of parsed data to check whether the parsed data is consistent with the data format corresponding to the communication protocol used by the corresponding serial port transceiver pins. If the first set of parsed data passes verification, response data is directly sent to the host computer via the RS485 communication circuit 100. If the first set of parsed data fails verification, the second set of parsed data is verified. If the second set of parsed data passes verification, response data is sent to the host computer via the RS485 communication circuit 100. If the second set of parsed data fails verification, no response data is sent to the host computer. Optionally, if both sets of parsed data fail verification, the request data is discarded.
[0060] It is understood that the processor 200 sequentially verifies the parsed data obtained from different serial port transceiver pins. At most one of the two sets of parsed data conforms to the correct data format corresponding to the communication protocol. If the first set of parsed data passes verification, response data is directly generated. This response data is output from the corresponding serial port transceiver pin and then input to the host computer via the RS485 communication circuit 100. The host computer can then obtain the response data corresponding to the sent request data.
[0061] Based on this, this embodiment overcomes the limitation of setting fixed serial port parameters when switching between dual protocols by using the aforementioned dual-protocol communication method. It does not require two physical RS485 buses to achieve dual-protocol communication as in general technologies, nor does it require communication at the same baud rate. As a result, this embodiment can be applied to serial port transceiver pins with different serial port parameter combinations, thereby achieving automatic identification and enabling seamless communication with serial port transceiver pins configured with different baud rates, parity bits, and stop bits.
[0062] Furthermore, this embodiment processes data frames (i.e. request data) at the physical level of communication, which greatly reduces the difficulty and time of software processing data frames transmitted by serial port transceiver pins, improves the response time of the processor 200 to parsing multi-protocol data, and correspondingly reduces the frame loss rate caused by parsing errors, thereby improving the reliability of dual-protocol communication.
[0063] It should be noted that the circuit structure of the RS485 communication circuit 100 and the circuit structure of the processor 200 in this dual-protocol communication device can be set according to actual needs, and this embodiment does not limit them.
[0064] Exemplary, such as Figure 2 As shown, the RS485 communication circuit 100 includes an RS485 interface chip 110, and a data receiving circuit 120, a data transmitting circuit 130, a switch control circuit 140, and a differential signal transmission circuit 150 connected to the RS485 interface chip 110.
[0065] The switch control circuit 140 is used to control the working state of the RS485 interface chip 110 so that the RS485 interface chip 110 enters the data receiving state or the data sending state.
[0066] The differential signal transmission circuit 150 is used to receive request data output by the host computer when the RS485 interface chip 110 enters the data receiving state. The request data is converted by the RS485 interface chip 110 and then transmitted to the processor 200 through the data receiving circuit 120.
[0067] The data transmission circuit 130 is used to receive the response data output by the processor 200 when the RS485 interface chip 110 enters the data transmission state. After the response data is converted by the RS485 interface chip 110, it is transmitted to the host computer in the form of a differential signal through the differential signal transmission circuit 150.
[0068] It is understood that the request data output by the host computer is transmitted in the form of differential signals. When the RS485 interface chip 110 enters the data receiving state, the request data transmitted in the form of differential signals is converted by the RS485 interface chip 110 and then input to the two sets of serial port transceiver pins of the processor 200 through the data receiving circuit 120. The processor 200 parses and verifies the received request data and then generates response data corresponding to the request data. When the RS485 interface chip 110 enters the data sending state, the response data is transmitted to the RS485 interface chip 110 through the data sending circuit 130 for signal conversion and then transmitted to the host computer in the form of differential signals from the differential signal transmission circuit 150.
[0069] like Figure 3As shown, in some examples, the switch control circuit 140 includes a first optocoupler D1, a first current-limiting resistor R1, and a first pull-down resistor R2; the first pin of the first optocoupler D1 is used to connect to a reference voltage (i.e., VCC); the second pin of the first optocoupler D1 is connected to the first current-limiting resistor R1 and is used to receive a control signal (i.e., 485_Ctrl), which is used to control the switching of the operating state of the RS485 interface chip 110 (i.e., U1 in the figure); the third pin of the first optocoupler D1 is connected to the receiver output enable terminal (i.e., RE pin) and the driver output enable terminal (i.e., DE pin) of the RS485 interface chip 110, respectively, and is grounded through the first pull-down resistor R2; the fourth pin of the first optocoupler D1 is used to connect to the operating voltage (i.e., VDD).
[0070] For example, the switch control circuit 140 is used to receive control signals sent by the processor 200 or other software programs or hardware devices, and then send a level signal to the RS485 interface chip 110 through the control signal to control the RS485 interface chip 110 to switch the current working state accordingly, so that the RS485 interface chip 110 enters the data transmission state or the data reception state accordingly.
[0071] In one implementation, such as Figure 3 As shown, the differential signal transmission circuit 150 includes a bidirectional transient voltage suppressor diode VD1, a thermistor R3, a first pull-up resistor R4, and a second pull-down resistor R5. The first end of the bidirectional transient voltage suppressor diode VD1 is connected to the driver output terminal (i.e., pin B) and the output terminal of the first differential signal line (i.e., the output terminal of the A1 signal line) of the RS485 interface chip 110, respectively. The second end of the bidirectional transient voltage suppressor diode VD1 is connected to the receiver input terminal (i.e., pin A) and the output terminal of the second differential signal line (i.e., the output terminal of the B1 signal line) of the RS485 interface chip 110, respectively. The receiver input terminal is used to access the operating voltage through the first pull-up resistor R4. The driver output terminal is used to ground through the second pull-down resistor R5. The power supply terminal (i.e., pin VCC) of the RS485 interface chip 110 is used to access the operating voltage, and the ground terminal (i.e., pin GND) of the RS485 interface chip 110 is grounded.
[0072] In some examples, such as Figure 3As shown, the data receiving circuit 120 includes a second optocoupler D2, a second pull-up resistor R6, and a third pull-up resistor R7. The first pin of the second optocoupler D2 is connected to the receiver output terminal (i.e., the RO pin) of the RS485 interface chip 110, and is used to receive request data after signal conversion by the RS485 interface chip 110. The second pin of the second optocoupler D2 is used to connect to the operating voltage through the second pull-up resistor R6. The third pin of the second optocoupler D2 is used to connect to the reference voltage through the third pull-up resistor R7 and output request data. The fourth pin of the second optocoupler D2 is grounded.
[0073] In one implementation, such as Figure 3 As shown, the data transmission circuit 130 includes a third optocoupler D3, a fourth pull-up resistor R8, and a second current-limiting resistor R9. The first pin of the third optocoupler D3 is used to connect to a reference voltage. The second pin of the third optocoupler D3 is connected to the second current-limiting resistor R9 and is used to receive the response data output by the processor 200. The third pin of the third optocoupler D3 is grounded. The fourth pin of the third optocoupler D3 is connected to the driver input terminal (i.e., the DI pin) of the RS485 interface chip 110 and is used to connect to the operating voltage through the fourth pull-up resistor R8.
[0074] The specific composition and structure of the first optocoupler D1, the second optocoupler D2, and the third optocoupler D3 can be set according to actual needs, and this embodiment does not limit them.
[0075] For example, the first optocoupler D1, the second optocoupler D2, and the third optocoupler D3 each include a diode and a transistor, respectively.
[0076] Specifically, in the first optocoupler device D1, the anode of the first diode is used to connect to the reference voltage, and the cathode of the first diode is used to connect to the control signal through the first current-limiting resistor R1; the collector of the first transistor in the first optocoupler device D1 is used to connect to the working voltage, and the emitter of the first transistor is connected to the receiver output enable terminal and the driver output enable terminal of the RS485 interface chip 110 respectively, and is grounded through the first pull-down resistor R2.
[0077] In the second optocoupler D2, the anode of the second diode is connected to the operating voltage via the second pull-up resistor R6, and the cathode of the second diode is connected to the receiver output of the RS485 interface chip 110. The collector of the second transistor in the second optocoupler D2 is connected to the reference voltage via the third pull-up resistor R7 and outputs request data (i.e., RX485). The emitter of the second transistor is grounded. The anode of the diode in the second optocoupler D2 is connected to the reference voltage via the second pull-up resistor R6 to prevent the reference voltage from directly affecting the second diode of the second optocoupler D2 and causing damage to the device.
[0078] In the third optocoupler device D3, the anode of the third diode is used to connect to the reference voltage, and the cathode of the third diode is used to connect to the response data (i.e., TX485) through the second current-limiting resistor R9; the collector of the third transistor in the third optocoupler device D3 is connected to the driver input terminal of the RS485 interface chip 110, and is used to connect to the working voltage through the fourth pull-up resistor R8; the emitter of the third transistor is grounded.
[0079] It is important to note that the model and resistance value of the pull-up resistors, pull-down resistors, and current-limiting resistors connected to each optocoupler can be adjusted to match the model of the different optocouplers and the different ambient temperatures to ensure the reliability of signal transmission within the device. Furthermore, the pin positions and corresponding connection relationships of each pin in each optocoupler can be adjusted according to actual needs; this embodiment does not impose any limitations on this.
[0080] It is understood that in this embodiment, the RS485 communication circuit 100 is connected to the processor 200 via RX and TX signal lines, and the transmit / receive control pins of the RS485 communication circuit 100 are connected to its network bus via differential signal lines to receive data or signals sent by the host computer. Specifically, the processor 200 and the RS485 communication circuit 100 generally use TTL signal format to transmit data, while the RS485 communication circuit 100 and the host computer use differential signal format to transmit data.
[0081] Specifically, when the device is in the data transmission state, the processor 200 transmits request data in TTL signal form via the TX signal line, which is then converted into differential signal form by the RS485 communication circuit 100 and transmitted to the bus; while when the device is in the data reception state, the RS485 communication circuit 100 converts the differential signal form data on the bus into TTL signal form and transmits it to the processor 200 via the RX signal line.
[0082] Furthermore, in this embodiment, the transceiver control pin of an RS485 communication circuit 100 is used to connect the serial transceiver pins of two processors 200, thereby enabling automatic identification and dual-protocol communication between the two serial transceiver pins with different configurations. The two serial transceiver pins with different configurations can receive data synchronously, achieving synchronous communication between the two protocols. This allows the device to be compatible with devices using two different communication protocols, improving communication performance.
[0083] Optionally, this embodiment can also configure multiple sets of serial port transceiver pins with different serial port parameters according to different needs. The number of serial port transceiver pins configured here is not limited. Similar to the dual-protocol communication process described above, multiple external devices or application systems using different communication protocols are matched through the transceiver control pin of an RS485 communication circuit 100 to achieve multi-protocol communication, thereby being compatible with different application scenarios, expanding the application scope, and improving the flexibility of compatibility with multiple external devices or application systems.
[0084] Please refer to Figure 4 This application provides a dual-protocol communication method, which specifically includes the following steps:
[0085] S10 receives and forwards request data from the host computer via RS485 communication circuit 100.
[0086] S20: The processor 200 receives and parses the request data through two sets of serial port transceiver pins with different configurations, and obtains two sets of parsed data. The two sets of parsed data are verified separately. If the verification of either set of parsed data passes, the response data is sent to the host computer through the RS485 communication circuit 100.
[0087] It is understood that the dual-protocol communication method in this embodiment corresponds to the dual-protocol communication device in the above embodiments, and the options in the above embodiments are also applicable to this embodiment, so they will not be described again here.
[0088] Furthermore, the dual-protocol communication method in this embodiment can be widely applied to dual-protocol products and multi-protocol communication scenarios, thereby better meeting the growing customer needs and adapting to market application scenarios, and improving the flexibility and reliability of protocol communication.
[0089] In this embodiment, an RS485 communication circuit 100 connects two different sets of serial port transceiver pins, enabling automatic identification and dual-protocol communication of the two sets of serial port transceiver pins with different configurations. Furthermore, this embodiment can be applied to serial port transceiver pins with different configuration parameter combinations to automatically identify different communication protocols, overcoming the limitations of setting serial port parameters. It achieves low-hardware-cost dual-protocol communication without adding corresponding RS485 interfaces, improving device communication performance and flexibility, and enhancing the diversity and stability of multi-protocol identification. It can correctly identify various serial port data configurations without switching physical channels. Based on electronic hardware design support, it processes data at the physical level of communication to identify and parse dual-protocol communication data, reducing frame loss caused by software program errors in parsing serial port data during high-speed communication and improving the reliability of protocol communication. In addition, the dual-protocol communication device and method of this embodiment can be widely applied in multi-protocol communication scenarios, better meeting the growing customer needs and adapting to market application scenarios. It also provides better compatibility with multiple software systems, improving communication efficiency and performance.
[0090] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.
Claims
1. A dual-protocol communication device, characterized in that, include: The RS485 communication circuit is used to receive and forward request data from the host computer. The processor includes two sets of serial port transceiver pins with different configurations, used to receive and parse the request data respectively to obtain two sets of parsed data; the two sets of parsed data are verified respectively, and if the verification of either set of parsed data passes, the processor sends response data to the host computer through the RS485 communication circuit. The step of verifying the two sets of parsed data includes: verifying whether the data format of the two sets of parsed data is consistent with the data format corresponding to the preset communication protocol; wherein each set of serial port transceiver pins corresponds to a different preset communication protocol, and each set of serial port transceiver pins parses data with different data formats based on different preset communication protocols; if the data format of the parsed data is consistent with the data format corresponding to the preset communication protocol, then the verification of the parsed data is determined to be successful; The RS485 communication circuit includes an RS485 interface chip, and a data receiving circuit, a data transmitting circuit, a switch control circuit, and a differential signal transmission circuit connected to the RS485 interface chip. The switch control circuit is used to control the working state of the RS485 interface chip so that the RS485 interface chip enters the data receiving state or the data sending state. The differential signal transmission circuit is used to receive request data output by the host computer when the RS485 interface chip enters the data receiving state. The request data is converted by the RS485 interface chip and then transmitted to the processor through the data receiving circuit. The request data output by the host computer is transmitted in the form of a differential signal. The data transmission circuit is used to receive the response data output by the processor when the RS485 interface chip enters the data transmission state. The response data is converted by the RS485 interface chip and then transmitted to the host computer in the form of a differential signal through the differential signal transmission circuit.
2. The dual-protocol communication device according to claim 1, characterized in that, The two sets of parsed data are verified respectively. If either set of parsed data passes the verification, a response data is sent to the host computer through the RS485 communication circuit, including: The two sets of parsed data are verified sequentially. If the verification of the first set of parsed data is successful, then response data is sent directly to the host computer through the RS485 communication circuit. If the first set of parsed data fails the verification, the second set of parsed data is verified. If the second set of parsed data passes the verification, response data is sent to the host computer through the RS485 communication circuit. If it is determined that the verification of the second set of parsed data fails, no response data will be sent to the host computer.
3. The dual-protocol communication device according to claim 1, characterized in that, The switch control circuit includes a first optocoupler, a first current-limiting resistor, and a first pull-down resistor; The first pin of the first optocoupler is used to connect to a reference voltage; the second pin of the first optocoupler is connected to the first current-limiting resistor and is used to receive a control signal, which is used to control the working state of the RS485 interface chip. The third pin of the first optocoupler is connected to the receiver output enable terminal and the driver output enable terminal of the RS485 interface chip, respectively, and is grounded through the first pull-down resistor; the fourth pin of the first optocoupler is used to connect to the operating voltage.
4. The dual-protocol communication device according to claim 1, characterized in that, The differential signal transmission circuit includes a bidirectional transient voltage suppression diode, a thermistor, a first pull-up resistor, and a second pull-down resistor; The first terminal of the bidirectional transient voltage suppressor diode is connected to the driver output terminal and the output terminal of the first differential signal line of the RS485 interface chip, respectively. The second terminal of the bidirectional transient voltage suppressor diode is connected to the receiver input terminal of the RS485 interface chip and the output terminal of the second differential signal line, respectively. The receiver input terminal is used to connect to the operating voltage through the first pull-up resistor; the driver output terminal is used to be grounded through the second pull-down resistor. The power supply terminal of the RS485 interface chip is used to connect to the operating voltage, and the ground terminal of the RS485 interface chip is grounded.
5. The dual-protocol communication device according to claim 1, characterized in that, The data receiving circuit includes a second optocoupler, a second pull-up resistor, and a third pull-up resistor; The first pin of the second optocoupler is connected to the receiver output of the RS485 interface chip to receive the request data after signal conversion by the RS485 interface chip; the second pin of the second optocoupler is used to connect the operating voltage through the second pull-up resistor. The third pin of the second optocoupler is used to connect to a reference voltage through a third pull-up resistor and output the request data; The fourth pin of the second optocoupler is grounded.
6. The dual-protocol communication device according to claim 1, characterized in that, The data transmission circuit includes a third optocoupler, a fourth pull-up resistor, and a second current-limiting resistor; The first pin of the third optocoupler is used to connect to a reference voltage; the second pin of the third optocoupler is connected to the second current-limiting resistor and is used to receive the response data output by the processor. The third pin of the third optocoupler is grounded; the fourth pin of the third optocoupler is connected to the driver input of the RS485 interface chip and is used to access the operating voltage through the fourth pull-up resistor.
7. The dual-protocol communication device according to any one of claims 1-6, characterized in that, The dual-protocol communication device is an electricity meter or an electronic device with communication identification function.
8. A dual-protocol communication method, characterized in that, Applied to a dual-protocol communication device as described in any one of claims 1-7, the method comprises: Receive and forward request data from the host computer via RS485 communication circuit; The processor receives and parses the request data using two sets of serial port transceiver pins configured differently, resulting in two sets of parsed data. The two sets of parsed data are then verified. If either set of parsed data passes the verification, a response is sent to the host computer via the RS485 communication circuit. The step of verifying the two sets of parsed data includes: verifying whether the data format of the two sets of parsed data is consistent with the data format corresponding to the preset communication protocol; wherein each set of serial port transceiver pins corresponds to a different preset communication protocol, and each set of serial port transceiver pins parses data with different data formats based on different preset communication protocols; if the data format of the parsed data is consistent with the data format corresponding to the preset communication protocol, then the verification of the parsed data is determined to be successful; The RS485 communication circuit includes an RS485 interface chip, and a data receiving circuit, a data transmitting circuit, a switch control circuit, and a differential signal transmission circuit connected to the RS485 interface chip; sending response data to the host computer through the RS485 communication circuit includes: The working state of the RS485 interface chip is controlled by the switch control circuit so that the RS485 interface chip enters the data receiving state or the data sending state. When the RS485 interface chip enters the data receiving state, it receives the request data output by the host computer through the differential signal transmission circuit. The request data is converted by the RS485 interface chip and then transmitted to the processor through the data receiving circuit. The request data output by the host computer is transmitted in the form of a differential signal. When the RS485 interface chip enters the data transmission state, the response data output by the processor is received through the data transmission circuit. After the response data is converted by the RS485 interface chip, it is transmitted to the host computer in the form of a differential signal through the differential signal transmission circuit.
Citation Information
Patent Citations
Access method of external equipment, client peripheral access device and electronic equipment
CN115905065A
Adaptive circuit compatible with multi-serial port protocol and communication equipment
CN216596246U