Intelligent electric meter communication system based on M-BUS
By using an MCU with ADC module in the main station of the M-BUS bus smart meter communication system, the bus current signals are collected and processed in real time, and the problems of high demand for analog devices and complex signal reception circuits in the existing system are solved, thus achieving system simplification and efficiency improvement.
Patent Information
- Application Number
- CN202510403652.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-01
- Publication Date
- 2025-05-16
AI Technical Summary
In the existing M-BUS bus smart meter communication system, the main station has a high demand for analog devices and the signal receiving circuit is complex.
The MCU with ADC module is used as the M-BUS master station. Through software logic and ADC hardware, the bus current is collected in real time and converted into digital signals to judge the status of the smart meter and feedback transmission.
It reduces the complexity of signal receiving circuits in the M-BUS master station, reduces the demand for analog devices, and improves the reliability and efficiency of the system.
Smart Images

Figure CN120017440A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of electric power communication, and in particular to an intelligent electric meter communication system based on an M-BUS bus. Background Art
[0002] M-Bus (Meter Bus) is designed to meet the needs of network systems and remote meter reading. It has the advantages of simple wiring, topology independence, non-polarity, anti-interference, and power supply. Therefore, it is often used in passive meter products. M-Bus is a half-duplex communication mode with a master-slave structure, that is, there can only be one host in a single network, and all communication requests need to be initiated by the host. Currently, there is a single chip option for the slave on the market, which can be achieved by simply building a circuit; while the host has not yet found an optional chip, it can only be achieved by circuit construction. The host sends a common dual power supply method, and the receiving circuit is more troublesome. The conventional one is implemented through a comparator circuit, but it has obvious disadvantages, and the circuit parameters need to be adjusted in the adaptation of the number of devices. Summary of the invention
[0003] The technical problem to be solved by the present invention is to provide a smart meter communication system based on an M-BUS bus, which can reduce the demand of an M-BUS master station for analog devices.
[0004] In order to solve the above technical problems, the technical solution adopted by the present invention is:
[0005] A smart meter communication system based on the M-BUS bus includes an application terminal, an M-BUS master station, a transmission line and a smart meter group connected in sequence;
[0006] The M-BUS master station includes an MCU and a power control module and a communication interface module respectively connected to the MCU; the MCU is provided with an ADC module; the ADC module is connected to the transmission line; the power control module is connected to the transmission line; the communication interface module is connected to the application end;
[0007] The ADC module is configured to regularly collect the current on the transmission line after the MCU turns on the bus current monitoring, and send the collected bus current to the MCU;
[0008] The MCU is configured to determine that the smart meter initiates a response when an increment of the received bus current compared to the static current value is greater than a first threshold.
[0009] Optionally, the communication interface module includes a UART interface and an IO interface; the UART interface of the application end is connected to the UART interface or the IO interface;
[0010] The MCU is further configured to enter UART mode when recognizing that the application end is accessed through the UART interface; and enter IO mode when recognizing that the application end is accessed through the IO interface;
[0011] The UART mode includes: after the MCU receives the request data sent by the application end, it determines whether the request data is normal. If it is abnormal, it matches the communication parameters; if it is normal, it locks the current communication parameters, starts the baud rate timer to forward the received request data to the power control module, and converts the request data into a bus voltage signal through the power control module and sends it to the transmission line, and then immediately enters the waiting response state;
[0012] The IO mode includes: after the MCU receives the request data sent by the application end, it outputs the request data to the power control module in a follow-up manner and then immediately enters a waiting for response state.
[0013] Optionally, the communication parameter matching includes: initializing a baud rate timer and an application-side input interrupt; collecting a current minimum pulse width of the UART interface; confirming a current UART parameter of the UART interface based on the minimum pulse width; and updating the default UART parameters of the UART interface based on the current UART parameters.
[0014] Optionally, the MCU is further configured to perform application-side access confirmation;
[0015] The application-side access confirmation includes: initializing the IO interface; determining whether the IO interface has input, if so, initializing the baud rate timer and the application-side input interrupt, turning on the bus power supply, and turning on the bus current monitoring; if not, initializing the UART interface, turning on the bus power supply, and turning on the bus current monitoring.
[0016] Optionally, the MCU is also configured to monitor the bus current changes within the slip time interval through slip statistics after turning on the bus current monitoring. If the bus current change in the current slip time interval is less than the second threshold, the static current value is updated according to the average value of the bus current in the current slip time interval.
[0017] Optionally, the MCU is further configured to, after determining that the smart meter initiates a response, periodically collect bus current through the ADC module, convert the collected bus current into a corresponding digital voltage signal, and then feed it back to the application end through the communication interface module.
[0018] Optionally, the MCU is further configured to immediately enter a waiting-for-response state in the UART mode, and then further include:
[0019] The bus current is collected periodically; a digital logic 0 is defined as an increment of the collected bus current compared to the static current value being greater than a first threshold, and a digital logic 1 is defined as an increment of the collected bus current compared to the static current value being greater than a third threshold. After the collected bus current is converted into a corresponding digital signal, it is sent to the application end through the UART interface.
[0020] Optionally, the MCU is further configured to immediately enter a waiting-for-response state in the IO mode, and then further include:
[0021] The bus current is periodically collected; if the increment of the collected bus current compared to the static current value is greater than a first threshold, a low level is output to the application end through the IO interface; if the increment of the collected bus current compared to the static current value is less than the first threshold, a high level is output to the application end through the IO interface.
[0022] Optionally, the MCU is further configured to control cutting off the power supply to the transmission line through the communication interface module and enter overcurrent protection when the received bus current exceeds a third threshold.
[0023] Optionally, the MCU is further configured to, after receiving application data sent from the application end through the communication interface module, convert the application data into a corresponding bus voltage signal through the power control module and send the signal to the transmission line.
[0024] Optionally, the smart meter is an electricity meter, a water meter or a natural gas meter.
[0025] The beneficial effect of the present invention is that the M-BUS master station of the present invention adopts an MCU with an ADC module, and can realize the acquisition of bus current and the conversion of M-Bus current signal to voltage signal in a manner of coordinating software logic with ADC hardware, thereby realizing the judgment of smart meter signals by the M-BUS master station and the transmission of smart meter feedback. Compared with the prior art, the complexity of the signal receiving circuit in the M-BUS master station can be reduced, thereby reducing the demand for analog devices in the M-BUS master station. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 An architecture diagram of a smart meter communication system based on the M-BUS bus provided by an embodiment of the present invention;
[0027] Figure 2 A schematic diagram of a flow chart of the MCU confirming the access mode of the application end in a specific implementation mode of the present invention;
[0028] Figure 3It is a flow chart of entering UART mode after the application end is connected by UART interface in a specific implementation mode of the present invention;
[0029] Figure 4 It is a flow chart of the application end entering the IO mode after being connected by the IO interface in a specific implementation mode of the present invention;
[0030] Figure 5 It is a schematic diagram of the response flow of a smart meter in UART mode in a specific implementation manner of the present invention;
[0031] Figure 6 It is a schematic diagram of the response flow of a smart meter in IO mode in a specific implementation manner of the present invention. DETAILED DESCRIPTION
[0032] In order to explain the technical content, achieved objectives and effects of the present invention in detail, the following is an explanation in conjunction with the implementation modes and the accompanying drawings.
[0033] The key concept of the present invention is to use the ADC module of the MCU to collect the bus current in real time, and then judge the real-time collected bus current through software logic to realize the judgment of the smart meter signal and the transmission of the smart meter feedback.
[0034] Embodiment 1
[0035] Please refer to Figure 1 This embodiment provides a smart meter communication system based on M-BUS bus, such as Figure 1 As shown, it includes an application end, an M-BUS master station, a transmission line, and a group of smart meters (i.e., smart meter 1, smart meter 2, and smart meter 3 in the figure) connected in sequence. According to the M-Bus bus specification, more than two smart meters can be connected to the transmission line to form the smart meter group.
[0036] like Figure 1 As shown, the M-BUS master station includes an MCU and a power control module and a communication interface module respectively connected to the MCU; the MCU has an ADC module; the ADC module is connected to the transmission line; the power control module is connected to the transmission line; and the communication interface module is connected to the application end.
[0037] The ADC module is configured to regularly collect the current on the transmission line after the MCU starts bus current monitoring, and send the collected bus current to the MCU;
[0038] The MCU is configured to determine that the smart meter initiates a response when an increment of the received bus current compared to the static current value is greater than a first threshold.
[0039] The static current value is used as a criterion for judging bus current changes. Here, it is assumed that the bus current fluctuation within a certain range is regarded as network stability, and the average value of the range is the static current value.
[0040] In some specific implementations, the first threshold may be about 7 mA.
[0041] According to the M-Bus protocol, the bit string sent from the slave to the master is encoded by modulating the current consumption of the bus loop. A constant current of up to 1.5mA represents a logic 1, and an additional 11-20mA through the loop meter represents a logic 0. Therefore, when the smart meter responds, it will obtain an additional current of about 11-20mA from the master. When the bus current suddenly increases by 11-20mA, the smart meter responds to logic 0. The above encoding rules are all incremental and do not specify the actual number of slaves.
[0042] In the actual use environment, this embodiment adopts the method of ADC continuously collecting loop current (based on the premise that the loop current is stable when the bus is idle). In the process of judging the static current of the bus loop, the static current is defined as the judgment of logic 1, and the current increment of the loop current relative to the static current is used as the judgment of logic 0. Due to factors such as line impedance in actual use, the slave cannot accurately control the current acquisition above 11mA. Therefore, this embodiment adopts a 70% margin design, and uses the current increment of 7mA as the judgment of logic 0, that is, when the sampled current is compared with the static current, the increment is 7mA, it is judged as logic 0; when the sampled current is compared with the static current, the increment is less than 0.5mA, it is judged as logic 1.
[0043] Therefore, when it is monitored that the bus current suddenly increases by a first threshold value (ie, increases by 7 mA) compared to the static current value, it is considered that the smart meter initiates a response.
[0044] In some specific implementations, the MCU may be a HC32F005 controller with a SARADC function, and the ADC function with a sampling rate of 1Msps is used in conjunction with the computer software program based on the present invention to implement bus current monitoring and identification.
[0045] The communication interface module is configured as an interface module for the application end to access the M-BUS master station, and is capable of receiving data sent by the application end and transmitting information fed back by the smart meter to the application end;
[0046] In some specific implementations, the communication interface module specifically includes a UART interface and an IO interface; the UART interface of the application end is connected to the UART interface or the IO interface. In other words, the application end can access the M-BUS master station through the UART interface, and can also access the M-BUS master station through the IO interface.
[0047] The power control module is configured to control the voltage outputted from the M-BUS master station to the transmission line, that is, to control the voltage of the transmission line. Optionally, the power control module is a DCDC boost power module.
[0048] The MCU is further configured to, upon receiving application data sent from the application end through the communication interface module, convert the application data into a corresponding bus voltage signal through the power control module and then send the signal to the transmission line.
[0049] In this embodiment, the M-BUS master station communicates with the external application through the communication interface module (also called the application interface), converts the data sent from the application end into the corresponding M-Bus bus voltage signal through the power control module and sends it to the transmission line, completing the information transmission from the application end to the transmission line. When a smart meter is connected to the M-Bus bus network, or when the smart meter responds after receiving the data from the application end, the M-BUS master station will obtain confirmation from the current monitoring of the bus loop through its ADC module, and can convert the bus current into a corresponding digital voltage signal, transmit and feedback to the application end, and complete the feedback from the smart meter to the application end. In this way, data interaction in the entire M-Bus bus network is realized, and it plays a bridge role in data interaction.
[0050] In particular, the M-BUS master station can use its own ADC module to collect bus current in real time, and identify and judge the collected bus current in conjunction with software logic, thereby confirming the state of the smart meter, and using software to convert and transmit the current signal when confirming that the smart meter initiates a response. This will greatly reduce the complexity of the signal receiving circuit in the M-BUS master station, thereby reducing the demand for analog devices in the M-BUS master station.
[0051] The M-BUS-based smart meter communication system provided in this embodiment can use its own ADC module in conjunction with software logic to realize smart meter status judgment and response feedback; and can reduce the complexity of the signal receiving circuit of the M-BUS master station.
[0052] Embodiment 2
[0053] See also Figures 2 to 4This embodiment is further expanded based on the first embodiment, specifically for the communication interaction between the application end and the M-BUS master station, which can also be understood as the application access initialization.
[0054] In this embodiment, two methods are provided for the application end to access the M-BUS master station: (1) the application end accesses the M-BUS master station through the UART interface; (2) the application end accesses the M-BUS master station through the IO interface.
[0055] For the M-BUS master station, the access mode of the application end will be confirmed through the MCU, that is, the MCU is also configured to perform the access confirmation of the application end.
[0056] like Figure 2 As shown, in some specific implementations, the process of the MCU confirming the access method of the application end includes:
[0057] Initialize the IO interface; detect the status of the IO interface and determine whether the IO interface has input; if the IO interface has input, that is, the application end is connected to the M-BUS master station through the IO interface, then initialize the baud rate timer and the application end input interrupt, turn on the bus power supply, turn on the bus current monitoring, and the initialization is completed. The M-BUS master station enters the receiving state; if the IO interface has no input, the application end is connected to the M-BUS master station through the UART interface, then initialize the UART interface, turn on the bus power supply, turn on the bus current monitoring, and the initialization is completed. The M-BUS master station enters the receiving state.
[0058] Here, the initialization of the baud rate timer refers to initialization of the MCU's timer for the purpose of retiming; the initialization of the application-side input interrupt refers to initialization of the communication interface between the application-side and the M-BUS master station.
[0059] It can be understood that when both the IO interface and the UART interface detect application access at the same time, the IO interface access method is preferably used. This is because the interaction logic of the IO interface access is simpler and does not require communication parameter matching compared to the UART interface access method.
[0060] The following describes the interaction logic of the two different access modes in detail:
[0061] (1) The application end accesses the M-BUS master station through the UART interface
[0062] Here, the MCU is configured to enter the UART mode when it is recognized that the application end is accessed through the UART interface.
[0063] In UART mode, it is necessary to ensure that the communication parameters between the application and the M-BUS master match in order to communicate based on the UART interface. If the communication parameters between the M-BUS master and the application do not match, that is, the UART parameters are different, the application will inevitably cause communication abnormalities (baud rate abnormalities, checksum abnormalities, etc.) when trying to communicate with the M-BUS master, causing this communication failure. After the communication fails, the M-BUS master will try to adaptively match the communication parameters. At the same time, if the communication fails in a short period of time, the application will not get a response from the smart meter. When the application does not receive a response, it will use characteristic data such as 0xAA or 0x55 to optimize the speed of the M-BUS master to synchronously adjust the UART parameters.
[0064] like Figure 3 As shown, the UART mode includes:
[0065] After receiving the request data sent by the application, the MCU determines whether the request data is normal;
[0066] If abnormal, it can be determined that the communication link is abnormal and communication parameter matching is required; and after the communication parameter matching is completed, return to the previous step to determine whether the request data sent by the application end is received;
[0067] If it is normal, further determine whether the received request data has a frame timeout. If so, lock the current communication parameters, that is, the UART parameters, and then start the baud rate timer, and trigger it according to the communication parameters to forward the received request data to the power control module, and then convert the request data into a bus voltage signal through the power control module and send it to the transmission line. After the sending is completed, enter the waiting for response state.
[0068] In some specific implementations, the default communication baud rate of the M-BUS master station, ie, the UART parameter, is 2400 bps.
[0069] In some specific implementations, the MCU forwards the request data sent by the application end, and specifically forwards it to the DCDC control pin of the power control module. Here, the power control module also adopts a DCDC boost power module. The DCDC boost power module converts the request data into a corresponding bus voltage signal, outputs it to the transmission line, and then reaches the smart meter. Preferably, in order to achieve the overall communication delay, when the MCU receives the single-byte data transmitted from the application end, it immediately triggers data forwarding, which can reduce the communication response delay on the one hand, and reduce the consumption of FIFO resources on the other hand.
[0070] like Figure 3 As shown, the process of adaptively matching communication parameters of the M-BUS master station includes:
[0071] Initialize the baud rate timer and the application-side input interrupt to initialize the communication interface module accessed by the application-side; collect the current minimum pulse width of the UART interface (excluding the start bit and stop bit of UATR), which can also be understood as collecting the edge interrupt interval sequence based on the data currently sent by the application-side; then confirm the current UART parameters of the UART interface based on the minimum pulse width; and then update the default UART parameters of the UART interface to the determined UART parameters.
[0072] (2) The application end is connected to the M-BUS master station through the IO interface
[0073] Here, the MCU is configured to enter the IO mode when it recognizes that the application end is connected through the IO interface.
[0074] In the IO mode, there is no need to match communication parameters between the application end and the M-BUS master station.
[0075] The IO modes include:
[0076] After receiving the request data sent by the application end, the MCU outputs the request data to the power control module in a follow-up manner and immediately enters a state of waiting for a response.
[0077] In some specific implementations, the MCU specifically outputs the request data to the DCDC control pin of the power control module. Here, the power control module also uses a DCDC boost power module. The DCDC boost power module converts the request data into a corresponding bus voltage signal, outputs it to the transmission line, and then reaches the smart meter.
[0078] In some specific implementations, the current fluctuation signal on the M-Bus bus transmission loop will also be directly fed back to the UART receiving pin of the application end in the form of IO level.
[0079] In some specific embodiments, Figure 4 As shown, the software logic of the IO mode is:
[0080] Enable falling edge interrupt; determine whether the interrupt is triggered, that is, whether the request data sent by the application is received. If so, control the reduction of the bus output voltage and turn off the bus current monitoring of the ADC module; enable rising edge interrupt; determine whether the interrupt is triggered. If so, restore the bus output voltage and restore the bus current monitoring of the ADC module; enter the waiting response state after forwarding is completed; if not, determine whether there is a timeout; if not, return to the previous step and continue to determine whether the interrupt is triggered. If so, restore the bus output voltage and restore the bus current monitoring of the ADC module; enter the waiting response state after forwarding is completed.
[0081] In this embodiment, after the application initiates a request and the M-BUS master completes forwarding, the M-BUS master will immediately return to the receiving state, thereby ensuring that it can instantly determine whether to receive a request from the application or a response from the smart meter.
[0082] In addition, the output of the request data initiated by the application end is controlled by the IO port of the M-BUS master station to control the working state of the DCDC control pin of the power control module, thereby realizing the conversion of the application end request data to the transmission line voltage.
[0083] Embodiment 3
[0084] See also Figure 5 and Figure 6 This embodiment is further expanded based on the above-mentioned embodiment 2, specifically for the communication interaction between the M-BUS master station and the smart meter group, which can also be understood as an explanation of the initialization of the bus network by the M-BUS master station.
[0085] In this embodiment, when the transmission line network power supply is turned on, the ADC module also turns on the bus current monitoring to sample the bus current of the transmission line.
[0086] In some specific implementations, the conventional baud rate ranges from 300 to 9600 bps. If the MCU uses the HC32F005 controller, its 1Msps SARADC module can be designed to work in a 50kHz periodic measurement state, thereby meeting the sampling requirements of the highest baud rate.
[0087] In this embodiment, by turning on the bus current monitoring to continuously sample the bus current of the transmission line, the change of the bus current can be further counted; and then it can be determined whether there is a new smart meter connected to the bus network (the M-BUS master station does not know the number of smart meters in the bus network during actual use) or whether the smart meter initiates a response.
[0088] The following is a detailed description of the implementation of bus current monitoring:
[0089] First, the MCU is configured to monitor the bus current change within the slip time interval through slip statistics after turning on the bus current monitoring. If the bus current change in the current slip time interval is less than the second threshold, the static current value is updated according to the average value of the bus current in the current slip time interval.
[0090] It can be understood that in this embodiment, the static current value used as the increment judgment reference is not a fixed value, but is dynamically updated according to the overall change of the real-time bus current. The bus current change trend within the preset time interval is monitored by the slip statistics method, and the static current value is dynamically updated accordingly; then, the bus current increment judgment will be based on the dynamically updated static current value, which can significantly improve the accuracy of bus current monitoring.
[0091] In some specific implementations, the slip time interval may be 500ms, and the second threshold may be set to 0.1mA. Thus, if the bus current fluctuation in the most recent 500ms is less than 0.1mA, the bus current may be defined as being stable in the network in the time interval, and the average current in the time interval may be defined as the static current.
[0092] In some specific implementations, it is inevitable that a smart meter may be disconnected after being connected to the bus network, which will also cause the static current of the bus loop to fluctuate. According to the characteristics of the M-Bus master-slave structure, when there is no request from the smart meter, the bus will remain silent; when a smart meter is disconnected, the static current of the bus loop will decrease, and the decrease in static current will not be judged as a smart meter response, but due to the decrease in static current, the smart meter response cannot trigger the smart meter response judgment process of the M-BUS master station; and when a new smart meter is connected, the static current of the bus loop increases, and when it is necessary to enter the smart meter response judgment process, the entire bus will be judged as a receiving state for a long time because the static current is not updated in time, that is, the bus is occupied and has been in a receiving state.
[0093] In view of the above situation where the smart meter response judgment cannot be performed due to the disconnection of the smart meter, a static current update timeout judgment mechanism can be added during the process of the M-BUS master station performing bus current monitoring (i.e., judging whether the waiting update time of the static current exceeds the fourth threshold, such as 1000ms), and triggering the reception abnormal timeout when the update timeout occurs, forcing the current loop static current value to be updated, forcing the M-BUS master station to exit the receiving state, and ensuring that the bus will not be occupied and restored to the idle state; in this way, the smart meter response judgment process can be entered when a new smart meter is connected.
[0094] In some other specific embodiments, combined with the half-duplex characteristics of the M-Bus bus, the MCU is also configured to control the ADC module to turn off bus current monitoring when receiving request data sent by the application end, and immediately control the ADC module to turn on bus current monitoring when the application end's request ends, thereby avoiding loop current fluctuations caused by bus voltage changes and causing false detection.
[0095] Secondly, the MCU is further configured to determine that the smart meter initiates a response when an increment of the received bus current compared to the static current value is greater than a first threshold.
[0096] Here, according to the M-Bus bus protocol, when the smart meter responds, it will take about 11 to 20 mA of current from the M-BUS master station. Therefore, when the bus current suddenly increases by 11 mA, it is considered that the smart meter has initiated a response. In actual use environments, since the smart meter cannot accurately obtain 11 mA current. Therefore, in some specific implementations, a 70% margin design can be adopted, that is, when the sampled bus current is calibrated to the static current and an 11 mA increment occurs, it is determined that the smart meter has initiated a response. In other words, the first threshold can be set to 7 mA to more accurately determine the situation in which the smart meter initiates a response.
[0097] In some specific implementations, the MCU is further configured to control the power supply to the transmission line through the communication interface module to be cut off when the bus current is detected to exceed a third threshold value, thereby entering overcurrent protection. In other words, the M-BUS master station also has control over the bus output, and can immediately shut down the power supply to the bus when the supply reaches the limit, thereby achieving overcurrent protection and preventing short-circuit damage.
[0098] Next, in this embodiment, when the MCU, based on the bus current regularly collected and uploaded by its ADC module, determines that the increment of the received bus current compared to the static current value is greater than the first threshold value, and judges that a smart meter has initiated a response, the bus current periodically collected and uploaded by the ADC module is converted into a corresponding digital voltage signal, and then fed back to the application end through the communication interface module.
[0099] Here, corresponding to the two different application end access methods described in the second embodiment, the M-BUS master station will respectively use the corresponding transmission methods to transmit to the application end.
[0100] Corresponding to (1) the smart meter response transmission mode in which the application end accesses the M-BUS master station through the UART interface, that is, the smart meter response process in UART mode:
[0101] Here, the MCU is configured to enter the waiting response state immediately in the UART mode, and then further include:
[0102] The bus current is collected periodically; a digital logic 0 is defined as an increment of the collected bus current compared to the static current value being greater than a first threshold, and a digital logic 1 is defined as an increment of the collected bus current compared to the static current value being greater than a third threshold. After the collected bus current is converted into a corresponding digital signal, it is sent to the application end through the UART interface.
[0103] In some specific embodiments, Figure 5 As shown in the figure, the smart meter response process in UART mode specifically includes:
[0104] The bus current is collected regularly through the ADC module; it is determined whether the increment of the collected bus current compared with the static current value is greater than the first threshold value (assuming 7mA); if the increment does not reach the first threshold value, the static current update timeout judgment mechanism is executed, that is, whether the waiting update time of the static current (the time from the last update) exceeds the fourth threshold value (assuming 100ms); if not, it returns to continue collecting the bus current; if so, the M-BUS master station is forced to exit the UART mode and resume the receiving state; if the increment reaches the first threshold value, the static current before the increase is locked; thereafter, while the bus current is collected regularly through the ADC module, that is The baud rate timer is started at the moment, and the current sequence is continuously collected according to the matched UART parameters in Example 2, that is, the matched baud rate interval. After that, the collected current sequence is converted into corresponding digital information according to the bus current>quiescent current+7mA as logic 0, and the bus current is less than the static current+3mA as logic 1; the data legitimacy of the converted digital information is then judged, that is, the response signal on the transmission line is verified in combination with the start bit, data bit, check bit, and stop bit in the transmission frame format; if the verification fails, the UART mode is exited; if it passes, the digital data is sent to the application end through the UART interface.
[0105] Preferably, in order to reduce transmission delay, each time the MCU of the M-BUS master station receives and verifies the data, it will pass it to the application end through the UART interface.
[0106] Corresponding to (2) the smart meter response transmission mode in which the application end accesses the M-BUS master station through the IO interface, that is, the smart meter response process in the IO mode:
[0107] Here, the MCU is configured to enter the waiting response state immediately in the IO mode, and then further include:
[0108] The bus current is periodically collected; if the increment of the collected bus current compared to the static current value is greater than a first threshold, a low level is output to the application end through the IO interface; if the increment of the collected bus current compared to the static current value is less than the first threshold, a high level is output to the application end through the IO interface.
[0109] It can be seen that in the IO mode, the M-BUS master station does not need to match the communication parameters, but can directly convert the real-time bus current into the corresponding logic level, and then directly transmit it to the UART interface of the application end through the IO data interface output, and the frame format verification is also left to the application end to verify.
[0110] In some specific embodiments, Figure 6 As shown in the figure, the smart meter response process in IO mode specifically includes:
[0111] The bus current is collected regularly through the ADC module; it is determined whether the increment of the collected bus current compared with the static current value is greater than the first threshold value (assuming 7mA); if the increment does not reach the first threshold value, the static current update timeout judgment mechanism is executed, that is, whether the waiting update of the static current (the time from the last update) exceeds the fourth threshold value (assuming 100ms); if not, it returns to continue collecting the bus current; if so, the M-BUS master station is forced to exit the IO mode and restore the receiving state; if the increment reaches the first threshold value, the static current before the increase is locked; then, the bus current collected regularly through the ADC module is output to the application end through the digital IO port according to the bus current> static current+7mA as logic 0; the bus current is less than the static current+3mA as logic 1, and the high level is output to the application end through the digital IO port; after the digital IO port outputs a low level / high level, it is determined whether the duration of the IO port outputting a low level / high level exceeds 100ms (which can be flexibly adjusted according to the actual scenario), if not, the bus current is continued to be collected, if so, the IO port is controlled to output a high level, and then the IO mode is exited. The purpose of doing this is to force the IO port to return to the state before control.
[0112] In summary, the M-BUS-based smart meter communication system provided by the present invention has an M-BUS master station that uses an MCU with a built-in ADC module to collect bus current in real time, and cooperates with software logic to identify and judge the collected bus current, so as to judge the state of the smart meter, which can reduce the complexity of the signal receiving circuit in the M-BUS master station, and thus reduce the demand for analog devices of the M-BUS master station; at the same time, it can also correspond to different access methods of the application end, and use appropriate processing logic to convert the application request data into a voltage signal and output it to the transmission line, so as to realize the self-adaptation of communication parameters, reduce the demand for hardware parameter adjustment, and increase reliability; furthermore, it can also evaluate the bus load power consumption according to the bus current detection situation, and perform power limitation and overload protection when necessary.
[0113] From the above description, it can be known that a person skilled in the art can understand that all or part of the processes in the above technical solutions can be realized by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the above methods. After being executed by the processor, the program can also achieve the beneficial effects of the corresponding methods.
[0114] The storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM).
[0115] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent transformations made using the contents of the present invention's specification and drawings, or directly or indirectly applied in related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. The smart meter communication system based on M-BUS is characterized by: It includes application end, M-BUS master station, transmission line and smart meter group connected in sequence; The M-BUS master station includes an MCU and a power control module and a communication interface module respectively connected to the MCU; the MCU is provided with an ADC module; the ADC module is connected to the transmission line; the power control module is connected to the transmission line; the communication interface module is connected to the application end; The ADC module is configured to regularly collect the current on the transmission line after the MCU starts bus current monitoring, and send the collected bus current to the MCU; The MCU is configured to determine that the smart meter initiates a response when an increment of the received bus current compared to the static current value is greater than a first threshold.
2. The M-BUS-based smart meter communication system according to claim 1, characterized in that: The communication interface module includes a UART interface and an IO interface; the UART interface of the application end is connected to the UART interface or the IO interface; The MCU is further configured to enter UART mode when recognizing that the application end is accessed through the UART interface; and when it is recognized that the application end is accessed through the IO interface, entering the IO mode; The UART mode includes: after the MCU receives the request data sent by the application end, it determines whether the request data is normal. If it is abnormal, it matches the communication parameters; if it is normal, it locks the current communication parameters, starts the baud rate timer to forward the received request data to the power control module, and converts the request data into a bus voltage signal through the power control module and sends it to the transmission line, and then immediately enters the waiting response state; The IO mode includes: after the MCU receives the request data sent by the application end, it outputs the request data to the power control module in a follow-up manner and then immediately enters a waiting for response state.
3. The M-BUS-based smart meter communication system according to claim 2, characterized in that: The communication parameter matching includes: initializing a baud rate timer and an application input interrupt; collecting a current minimum pulse width of the UART interface; confirming a current UART parameter of the UART interface based on the minimum pulse width; and updating a default UART parameter of the UART interface based on the current UART parameter.
4. The M-BUS-based smart meter communication system according to claim 2, characterized in that: The MCU is further configured to perform application-side access confirmation; The application end access confirmation includes: initializing the IO interface; determining whether the IO interface has input, and if so, initializing the baud rate timer and the application end input interrupt, starting the bus power supply, and starting the bus current monitoring; If not, the UART interface is initialized, bus power supply is turned on, and bus current monitoring is turned on.
5. The M-BUS-based smart meter communication system according to claim 1, characterized in that: The MCU is also configured to monitor the bus current change within the slip time interval through slip statistics after turning on the bus current monitoring. If the bus current change in the current slip time interval is less than the second threshold, the static current value is updated according to the average value of the bus current in the current slip time interval.
6. The M-BUS-based smart meter communication system according to claim 2, characterized in that: The MCU is also configured to periodically collect bus current through the ADC module after determining that the smart meter initiates a response, and after converting the collected bus current into a corresponding digital voltage signal, feed it back to the application end through the communication interface module.
7. The M-BUS-based smart meter communication system according to claim 6, characterized in that: The MCU is further configured to immediately enter a waiting-for-response state in the UART mode, and then further comprises: The bus current is collected periodically; a digital logic 0 is defined as an increment of the collected bus current compared to the static current value being greater than a first threshold, and a digital logic 1 is defined as an increment of the collected bus current compared to the static current value being greater than a third threshold. After the collected bus current is converted into a corresponding digital signal, it is sent to the application end through the UART interface.
8. The M-BUS-based smart meter communication system according to claim 6, characterized in that: The MCU is further configured to immediately enter a waiting-for-response state in the IO mode, and then further includes: The bus current is periodically collected; if the increment of the collected bus current compared to the static current value is greater than a first threshold, a low level is output to the application end through the IO interface; if the increment of the collected bus current compared to the static current value is less than the first threshold, a high level is output to the application end through the IO interface.
9. The M-BUS-based smart meter communication system according to claim 1, characterized in that: The MCU is further configured to control cutting off the power supply to the transmission line through the communication interface module and enter overcurrent protection when the received bus current exceeds a third threshold.
10. The M-BUS-based smart meter communication system according to claim 1, characterized in that: The MCU is further configured to, upon receiving application data sent from the application end through the communication interface module, convert the application data into a corresponding bus voltage signal through the power control module and then send the signal to the transmission line.