H-bridge driving real-time monitoring and dynamic control method and system based on CAN bus

By dynamically adjusting the H-bridge control parameters and monitoring them in real time via the CAN bus, the problems of poor flexibility and low reliability in the traditional H-bridge control method are solved. This achieves efficient real-time monitoring and fault protection, and improves the control efficiency and reliability of the electric drive system of new energy vehicles.

CN121907633APending Publication Date: 2026-04-21BEIJING NEW ENERGY VEHICLE TECH INNOVATION CENT CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING NEW ENERGY VEHICLE TECH INNOVATION CENT CO LTD
Filing Date
2025-12-19
Publication Date
2026-04-21

AI Technical Summary

Technical Problem

Traditional H-bridge control methods suffer from poor parameter configuration flexibility, insufficient real-time status monitoring capabilities, limited control mode adaptability, and difficulty in achieving closed-loop control, resulting in low control efficiency, difficult diagnosis, and low reliability.

Method used

The system receives configuration messages from the host computer via the CAN bus, dynamically adjusts control parameters, monitors the H-bridge status in real time, constructs a real-time closed-loop control process, and supports seamless switching between multiple control modes and fault protection.

Benefits of technology

It achieves millisecond-level parameter adjustment and fault protection, improves control efficiency and system safety and intelligence, shortens development cycle and reduces costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121907633A_ABST
    Figure CN121907633A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of data transmission, and discloses an H-bridge drive real-time monitoring and dynamic control method and system based on a CAN bus, and the method comprises the steps: achieving the online issuing of control parameters through a CAN ID 0 * 700 message, carrying out the atomization writing configuration after analysis and verification, and carrying out the instant output of a PWM task according to an updated mode, a duty ratio and a dead zone value obtained through table look-up; and meanwhile, current, voltage, temperature and duty ratio are acquired in a configurable feedback period and are packaged into a CAN ID 0x701 state message to be transmitted back. And if over-current or over-temperature is detected, immediately setting a fault mask, turning off the PWM and keeping the turn-off until a new starting command. According to the system, a multi-task framework is adopted, the priority of PWM tasks is highest, the priority of state tasks is subordinate, online feedback period modification and seamless waveform switching modes in operation are supported, a'parameter-state-fault 'closed loop is formed, and the real-time performance, flexibility and safety of H-bridge driving are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data transmission technology, and in particular to a method and system for real-time monitoring and dynamic control of H-bridge drivers based on CAN bus. Background Technology

[0002] In power conversion applications such as electric drive systems for new energy vehicles, DC / DC converters, and on-board chargers, H-bridge circuits are widely used as execution-stage power units due to their ability to operate in four quadrants, simple topology, and low cost.

[0003] However, current traditional H-bridge control methods have significant technical bottlenecks and are difficult to meet the control requirements in complex scenarios. The specific shortcomings are as follows: 1. Lack of flexibility in parameter configuration: Control parameters are mostly hard-coded into the firmware. Each time parameters are adjusted, the control process must be interrupted, the code must be recompiled, the firmware must be flashed, and the system must be restarted. Real-time dynamic configuration and adjustment during the control process cannot be achieved, resulting in a longer parameter adjustment cycle and a significant reduction in the efficiency of multi-parameter combination control. 2. Insufficient real-time status monitoring capability: The control process lacks a real-time acquisition and visualization feedback mechanism for the core working status of the H-bridge, making it impossible to obtain key parameters such as dynamic changes in PWM duty cycle, instantaneous current of bridge arm, bus voltage fluctuations, and power chip temperature in real time. This not only makes it difficult to quickly locate the root cause of control anomalies, but also makes it impossible to perform real-time analysis of the dynamic response characteristics of the H-bridge. 3. Limited control mode adaptability: It only supports preset fixed control modes and cannot flexibly switch modes according to different control objectives or control requirements. This results in low coverage of control scenarios and difficulty in adapting to diverse application needs. 4. Difficulty in implementing closed-loop control: Due to the lack of a real-time parameter feedback link, it is impossible to dynamically adjust the control conditions based on the status data collected during the control process. It is difficult to construct an intelligent closed-loop control process of "parameter output - status feedback - condition correction", which limits the control accuracy and automation level. Summary of the Invention

[0004] The purpose of this invention is to provide a method and system for real-time monitoring and dynamic control of H-bridge drivers based on CAN bus, so as to overcome the defects of existing technologies, such as the need to stop the system to burn parameters, the inability to sense the status online, the fixed control mode and lack of closed loop, resulting in poor flexibility, difficult diagnosis and low reliability.

[0005] To achieve the above technical objectives and effects, this invention discloses a method for real-time monitoring and dynamic control of an H-bridge driver based on a CAN bus, the method comprising at least the following steps: S1. Receive configuration messages sent by the host computer via the CAN bus, parse and verify the validity of the configuration messages, and obtain a set of dynamic control parameters. The set of dynamic control parameters includes at least the control mode, minimum duty cycle, maximum duty cycle, duty cycle step, dwell time, dead time index, and feedback cycle. S2. The verified set of dynamic control parameters is atomically written into the configuration structure and takes effect immediately. The reload of dynamic control parameters is completed without interrupting the current output of the H-bridge. The dead time index is used to query the pre-stored dead time schedule and obtain the actual dead time value to accurately control the switching dead time of the H-bridge power devices. S3. Based on the control mode after it takes effect, call the corresponding PWM waveform generation algorithm and output the PWM signal to the H-bridge power stage to achieve dynamic control; S4. During the operation of the H-bridge, real-time monitoring data is periodically collected according to the feedback cycle. The real-time monitoring data includes at least instantaneous current, bus voltage, power chip temperature and current duty cycle. S5. Compare the real-time monitoring data with the preset safety threshold. If at least one data exceeds the limit, immediately set the fault mask bit, turn off the PWM output, and send the status message containing the fault mask bit back to the host computer to achieve fault protection. S6. If all real-time monitoring data are within limits, the real-time monitoring data is encapsulated into a status message and transmitted back to the host computer via the CAN bus to complete the real-time monitoring closed loop. S7. Based on the received status message, the host computer can update the dynamic control parameter set online and repeat steps S1-S6 to form a real-time closed-loop control process of "parameter issuance - status monitoring - data feedback - parameter readjustment".

[0006] Specifically, step S1 includes: S11. In the CAN receive interrupt, determine whether the message ID is 0x700. If it is, extract 8 bytes of data. S12. Parse the 8-byte data by bit field to obtain the control mode, minimum duty cycle, maximum duty cycle, duty cycle step, dwell time, dead time index and feedback cycle in sequence, and perform limiting processing on each parameter to ensure that the minimum duty cycle is ≥1%, the maximum duty cycle is ≤99% and the maximum duty cycle is ≥ the minimum duty cycle. S13. When the parsed command code is a query command, the contents of the current configuration structure are encapsulated into a configuration message and sent to the host computer via the CAN bus to complete the configuration readback.

[0007] The control modes in step S3 include: The triangular wave scanning mode is characterized by a linear reciprocating duty cycle between a minimum and a maximum value. A sine wave mode, wherein the duty cycle varies continuously according to a sine function; Square wave mode, wherein the duty cycle switches stepwise between a minimum and a maximum value; A step response mode, wherein the duty cycle jumps from the minimum value to the maximum value in a single step and holds before returning to the minimum value; The four modes share the same configuration structure and can be seamlessly switched during operation via steps S1-S2.

[0008] Specifically, step S4 includes: S41. The H-bridge output current is sampled by the current sensor and ADC and converted into a milliampere-level current value; S42. The bus voltage is sampled by a voltage divider circuit and an ADC and converted into a millivolt-level voltage value. S43. Obtain the power chip temperature through a temperature sensor and convert it to degrees Celsius; S44. Read the current duty cycle from the PWM register and store it together with the current, voltage, and temperature data into the real-time status structure for subsequent encapsulation.

[0009] In step S5, the fault mask bit adopts a bit mask structure, and simultaneously sets the overcurrent flag bit, overtemperature flag bit, and other extended fault bits. When any flag bit is set, the H-bridge duty cycle is forcibly set to 0 and maintained until the host computer issues a new start command.

[0010] Furthermore, the status message in step S6 uses CAN ID 0x701, and the message data field is in 8-byte little-endian format, encapsulated sequentially; wherein, Byte 0 is the status flag bit, containing the running flag, overcurrent flag, and overtemperature flag; Byte 1 represents the current duty cycle, 0-99. Bytes 2 and 3 represent the current value, with the least significant byte first. Bytes 4 and 5 represent the voltage value, with the least significant byte first. Byte 6 is the temperature value; Byte 7 controls the lower 8 bits of the loop counter; Furthermore, the feedback cycle can be modified online by the host computer through configuration messages during the operation of the H-bridge, and will take effect in the next feedback cycle.

[0011] Furthermore, steps S1-S7 are executed in an embedded multi-tasking environment. The PWM waveform generation task has the highest priority, followed by the status acquisition and feedback task. The two tasks are synchronized by sharing the real-time status structure to ensure the real-time performance and consistency of real-time monitoring and dynamic control.

[0012] This invention also discloses a real-time monitoring and dynamic control system for H-bridge drivers based on a CAN bus. The system, based on the aforementioned method, includes at least the following components: The CAN communication module is used to receive configuration messages from the host computer and send status messages to the host computer via the CAN bus. The CAN ID of the configuration message is 0x700, and the CAN ID of the status message is 0x701. The parameter configuration management module is used to parse and validate the configuration message, obtain the dynamic control parameter set, atomically write the validated dynamic control parameter set into the configuration structure, and encapsulate the contents of the current configuration structure into a configuration message and send it back to the host computer when a query command is received. The PWM waveform generation module is used to call the corresponding PWM waveform generation algorithm according to the control mode after it takes effect, output the PWM signal to the H-bridge power stage, and after querying the pre-stored dead time table according to the dead time index, obtain the actual dead time value to accurately control the switching dead time of the H-bridge power devices. The status acquisition module is used to periodically acquire real-time monitoring data according to the feedback cycle during the operation of the H-bridge. The real-time monitoring data includes at least instantaneous current, bus voltage, power chip temperature and current duty cycle. The feedback control module is used to compare the real-time monitoring data with a preset safety threshold. If at least one data exceeds the limit, it immediately sets a fault mask bit, turns off the PWM output, and sends a status message containing the fault mask bit back to the host computer. If all real-time monitoring data does not exceed the limit, it encapsulates the real-time monitoring data into a status message and sends it back to the host computer via the CAN bus. The main control module coordinates the work of the above modules and runs the PWM waveform generation task with the highest priority in the embedded multi-tasking environment. The status acquisition and feedback task runs with a lower priority than the PWM waveform generation task. The two tasks are synchronized by sharing a real-time status structure to ensure the real-time performance and consistency of real-time monitoring and dynamic control.

[0013] The parameter configuration management module is further used to: when receiving feedback cycle parameters modified online by the host computer, write them into the configuration structure, and perform status acquisition and message sending according to the new feedback cycle starting from the next feedback cycle.

[0014] The feedback control module uses a bitmask structure to store both the overcurrent flag and the overtemperature flag. When either flag is set, the H-bridge duty cycle is immediately forced to 0, and this protection state is maintained until the main control module receives a new start command.

[0015] The present invention has the following beneficial effects: 1. By establishing a complete link of "parameter distribution - status readback - fault protection" through the CAN bus, the host computer can complete the online adjustment of all key parameters such as control mode, duty cycle range, scan step, dwell time, dead time, and feedback cycle in milliseconds without stopping the machine, recompiling, or flashing the firmware. Compared with the traditional cycle of "stopping - modifying code - re-flashing - restarting" which takes several minutes, the debugging efficiency is improved by two orders of magnitude. Moreover, the control strategy can be continuously optimized during bench or vehicle operation, significantly shortening the development cycle of new energy vehicle electric drive systems, while reducing the cost of production line upgrades and after-sales maintenance.

[0016] 2. Utilizing the bidirectional uplink and downlink data channels built with the 0x700 / 0x701 dedicated message protocol, the system can not only package and upload duty cycle, current, voltage, temperature, and multiple fault mask bits in each feedback cycle, achieving true "real-time monitoring + online diagnosis," but also supports the host computer to read back the current configuration at any time and modify the feedback cycle without disruption during operation. When abnormalities such as overcurrent or overtemperature are detected, the fault flag can immediately report multiple fault states simultaneously through the bit mask and automatically shut down the PWM output to prevent damage to power devices. The resulting "observation-decision-execution" closed loop transforms the H-bridge drive from a traditional "black box" into a "transparent, online, and adjustable" unit, significantly improving the safety, reliability, and intelligence level of the electric drive system in new energy vehicles. Attached Figure Description

[0017] Figure 1 This is a flowchart of the real-time dynamic parameter configuration process in Embodiment 1 of the present invention.

[0018] Figure 2 This is a timing flowchart of real-time status acquisition and feedback in Embodiment 1 of the present invention.

[0019] Figure 3 This is a system architecture diagram of Embodiment 2 of the present invention. Detailed Implementation

[0020] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to embodiments. Example

[0021] like Figure 1 , 2As shown in the figure, this embodiment discloses a method for real-time monitoring and dynamic control of H-bridge drivers based on CAN bus. The method includes at least the following steps: S1. Receive configuration messages sent by the host computer via the CAN bus, parse and verify the validity of the configuration messages, and obtain a set of dynamic control parameters. The set of dynamic control parameters includes at least the control mode, minimum duty cycle, maximum duty cycle, duty cycle step, dwell time, dead time index, and feedback cycle. Specifically, step S1 includes: S11. In the CAN receive interrupt, determine whether the message ID is 0x700. If it is, extract 8 bytes of data. S12. Parse the 8-byte data by bit field to obtain the control mode, minimum duty cycle, maximum duty cycle, duty cycle step, dwell time, dead time index and feedback cycle in sequence, and perform limiting processing on each parameter to ensure that the minimum duty cycle is ≥1%, the maximum duty cycle is ≤99% and the maximum duty cycle is ≥ the minimum duty cycle. S13. When the parsed command code is a query command, the contents of the current configuration structure are encapsulated into a configuration message and sent to the host computer via the CAN bus to complete the configuration readback.

[0022] In step S1, the system receives a configuration message with ID 0x700 via the CAN bus. Upon receiving an interrupt, the system checks the message ID and extracts 8 bytes of data. Then, it parses the data bit by bit to obtain the control mode, minimum duty cycle, maximum duty cycle, duty cycle step, dwell time, dead time index, and feedback cycle. Simultaneously, it performs limiting processing on each parameter—if the minimum duty cycle is less than 1%, it is set to 1%; if the maximum duty cycle is greater than 99%, it is set to 99%, ensuring that the maximum duty cycle is not less than the minimum duty cycle. If the command code is a query instruction (0x03), the system does not update the parameters but instead encapsulates the contents of the current configuration structure into an 8-byte message using the same bit-field format and transmits it back to the host computer via a frame with ID 0x700, completing the configuration readback. Thus, S1 achieves the conversion from bus data to a trusted parameter set, providing a basis for subsequent non-disruptive reload. S2. The verified set of dynamic control parameters is atomically written into the configuration structure and takes effect immediately. The reload of dynamic control parameters is completed without interrupting the current output of the H-bridge. The dead time index is used to query the pre-stored dead time schedule and obtain the actual dead time value to accurately control the switching dead time of the H-bridge power devices. The core of step S2 is to complete the parameter reload without disturbance during the continuous operation of the H-bridge. After the parsing task confirms the validity of each field, the system atomically writes the verified parameters into the configuration structure, ensuring that the PWM task and the status task read the same frame of data, avoiding the mixing of old and new parameters. Parameter updates can take effect immediately after the end of the current control cycle; the dead time index is only used for table lookup. The system retrieves the corresponding dead time value from the preset dead time table according to the index and loads it into the PWM register to complete the bridge arm switching timing update. This achieves the "online, disturbance-free, millisecond-level" parameter activation as described in the brief. S3. Based on the control mode after it takes effect, call the corresponding PWM waveform generation algorithm and output the PWM signal to the H-bridge power stage to achieve dynamic control; The control modes in step S3 include: The triangular wave scanning mode is characterized by a linear reciprocating duty cycle between a minimum and a maximum value. A sine wave mode, wherein the duty cycle varies continuously according to a sine function; Square wave mode, wherein the duty cycle switches stepwise between a minimum and a maximum value; A step response mode, wherein the duty cycle jumps from the minimum value to the maximum value in a single step and holds before returning to the minimum value; The four modes share the same configuration structure and can be seamlessly switched during operation via steps S1-S2.

[0023] Step S3 takes effect in the first PWM cycle after the configuration structure is refreshed. The waveform generation task enters the corresponding branch according to the "Control Mode" field: Triangle wave scanning mode starts from the minimum duty cycle, increases to the maximum value cycle by cycle according to the set step size, and then decreases back to the minimum value with the same step size, forming a linear reciprocating pattern; Sine wave mode maps the sine function value to the [minimum duty cycle, maximum duty cycle] interval at a fixed angle, outputting a smooth change sequence; Square wave mode directly flips between the minimum and maximum duty cycles, with the hold time given by the configuration register; Step response mode first stabilizes the duty cycle at the minimum value, then jumps to the maximum value in one go and holds, and then returns to the minimum value, completing one step cycle. The four modes share the same set of minimum, maximum, step, and hold parameters. When switching, only the mode variable needs to be written, and the new waveform starts from the next cycle. S4. During the operation of the H-bridge, real-time monitoring data is periodically collected according to the feedback cycle. The real-time monitoring data includes at least instantaneous current, bus voltage, power chip temperature and current duty cycle. Specifically, step S4 includes: S41. The H-bridge output current is sampled by the current sensor and ADC and converted into a milliampere-level current value; S42. The bus voltage is sampled by a voltage divider circuit and an ADC and converted into a millivolt-level voltage value. S43. Obtain the power chip temperature through a temperature sensor and convert it to degrees Celsius; S44. Read the current duty cycle from the PWM register and store it together with the current, voltage, and temperature data into the real-time status structure for subsequent encapsulation.

[0024] During H-bridge operation, step S4 periodically wakes up the status acquisition task according to the feedback cycle, taking a one-time snapshot of electrical, thermal, and control quantities. The current channel obtains millivolt-level analog signals through sampling resistors or Hall sensors connected in series on the bridge arm. After differential sampling by the on-chip ADC of the MCU, it is converted to milliampere values ​​according to the sensor calibration coefficients. The bus voltage is reduced to the ADC's allowable range by a voltage divider circuit, then sampled by the ADC and converted to actual millivolt values ​​according to the voltage division ratio. The power chip temperature is provided by temperature sensors located near the power devices. For analog sensors, the ADC samples the voltage and converts it to degrees Celsius according to the sensor's characteristic curve; for digital sensors, the temperature register is read directly, and the results are written to variables in degrees Celsius. The current duty cycle is automatically updated to shared memory by the PWM generation task after each cycle; the status acquisition task only needs to read it. All channels are simultaneously locked within an ADC sequence conversion completion interrupt and immediately copied to the real-time status structure to ensure a common time reference, providing time-aligned raw data for subsequent fault diagnosis and closed-loop control. S5. Compare the real-time monitoring data with the preset safety threshold. If at least one data exceeds the limit, immediately set the fault mask bit, turn off the PWM output, and send the status message containing the fault mask bit back to the host computer to achieve fault protection. In step S5, the fault mask bit adopts a bit mask structure, and simultaneously sets the overcurrent flag bit, overtemperature flag bit, and other extended fault bits. When any flag bit is set, the H-bridge duty cycle is forcibly set to 0 and maintained until the host computer issues a new start command.

[0025] At the end of each feedback cycle, step S5 compares the newly acquired current, voltage, and temperature with the threshold constants stored in the code area within a single cycle. If the current value exceeds the preset overcurrent threshold or the temperature value exceeds the preset overtemperature threshold, the corresponding bit of the fault flag byte is immediately written to 1 within the same interrupt service routine. Simultaneously, the PWM timer output enable register is disabled, and the hardware automatically pulls the H-bridge duty cycle to 0 to prevent the upper and lower transistors from continuing to switch. The remaining bits of the fault byte are reserved for future expansion of more protection types. After the bit setting is completed, the status encapsulation task no longer waits for the next cycle but immediately packages the set fault byte along with the current current, voltage, temperature, and duty cycle into an 8-byte frame of CAN ID 0x701 and uploads it to the host computer through the transmission queue. Upon receiving the frame, the host computer can determine the specific fault type. The entire protection process, from threshold comparison to PWM shutdown and message transmission, is completed within one run of the feedback task. The fault state is latched, and the H-bridge remains off until the host computer actively sends a new start command frame. Only then does the system clear the fault latch and reopen the PWM, thereby ensuring that abnormalities such as overcurrent and overtemperature are cut off immediately and a safe state is maintained. S6. If all real-time monitoring data are within limits, the real-time monitoring data is encapsulated into a status message and transmitted back to the host computer via the CAN bus to complete the real-time monitoring closed loop. Furthermore, the status message in step S6 uses CAN ID 0x701, and the message data field is in 8-byte little-endian format, encapsulated sequentially; wherein, Byte 0 is the status flag bit, containing the running flag, overcurrent flag, and overtemperature flag; Byte 1 represents the current duty cycle, 0-99. Bytes 2 and 3 represent the current value, with the least significant byte first. Bytes 4 and 5 represent the voltage value, with the least significant byte first. Byte 6 is the temperature value; Byte 7 controls the lower 8 bits of the loop counter; Furthermore, the feedback cycle can be modified online by the host computer through configuration messages during the operation of the H-bridge, and will take effect in the next feedback cycle.

[0026] After confirming that the current, voltage, and temperature have not reached the safety thresholds, step S6 immediately injects the current operating status into the CAN driver transmission queue according to a fixed frame format: the frame ID is fixed at 0x701, and the data field strictly adopts an 8-byte little-endian arrangement—the first byte gives the real-time level of the three flags: operation / overcurrent / overtemperature; the second byte directly places the duty cycle percentage from 0 to 99; the combination of the third and fourth bytes carries the instantaneous value of the milliampere current in the order of the least significant byte first; the fifth and sixth bytes, also with the least significant byte first, express the millivolt-level bus voltage; the seventh byte writes the power chip temperature in Celsius; and the last byte provides the lower 8 bits for controlling the cycle count, which is used by the host computer to determine whether the frame sequence number has been missed. The entire encapsulation process is completed by the status feedback task within a single run, after which the task is suspended and waits for the next feedback cycle that can be modified online. When the host computer needs to change the monitoring cycle, it only needs to write the new cycle value into the 0x700 configuration message. The parameter activation task will directly wake up the feedback task at the start of the next cycle using the new cycle, realizing the monitoring frequency switching of "no downtime and no disturbance", thereby completing the complete real-time monitoring closed loop from data sampling to message feedback. S7. Based on the received status message, the host computer can update the dynamic control parameter set online and repeat steps S1-S6 to form a real-time closed-loop control process of "parameter issuance - status monitoring - data feedback - parameter readjustment".

[0027] In step S7, once the host computer receives the complete 8-byte frame with ID 0x701, it completes the parsing within the same millisecond window: first, it verifies the continuity of the frame sequence number, then extracts the current, voltage, temperature, and duty cycle, and subsequently compares it with its own algorithm or calibration curve. If the deviation is found to exceed the allowable range, the minimum duty cycle, maximum duty cycle, step size, or the entire control mode can be refreshed immediately in the next frame 0x700 and sent down to the node. The node's non-disruptive reload mechanism in S1-S2 ensures that the new parameters take effect immediately in the next PWM cycle, thus forming a rolling closed loop of "parameter issuance - status monitoring - data feedback - parameter readjustment". The entire process does not require shutdown or firmware recompilation, ensuring that the H-bridge always operates at the optimal operating point.

[0028] Furthermore, steps S1-S7 are executed in an embedded multi-task environment. The PWM waveform generation task has the highest priority, followed by the status acquisition and feedback task. The two tasks are synchronized by sharing the real-time status structure to ensure the real-time performance and consistency of real-time monitoring and dynamic control. Example

[0029] like Figure 3 As shown, this embodiment, based on the method design of Embodiment 1, proposes a real-time monitoring and dynamic control system for H-bridge drivers based on the CAN bus. The system, based on the aforementioned method, includes: The CAN communication module is used to receive configuration messages from the host computer and send status messages to the host computer via the CAN bus. The CAN ID of the configuration message is 0x700, and the CAN ID of the status message is 0x701. The parameter configuration management module is used to parse and verify the validity of the configuration message, then atomically write the dynamic control parameter set into the configuration structure. When a query command is received, the current configuration structure is encapsulated into a configuration message and sent back to the host computer. When a feedback cycle parameter is received for online modification, the structure is also atomically updated. Starting from the next feedback cycle, the status acquisition and message sending are performed according to the new beat, so as to realize the online non-disruptive update of the feedback cycle. The PWM waveform generation module is used to call the corresponding PWM waveform generation algorithm according to the control mode after it takes effect, output the PWM signal to the H-bridge power stage, and after querying the pre-stored dead time table according to the dead time index, obtain the actual dead time value to accurately control the switching dead time of the H-bridge power devices. The status acquisition module is used to periodically acquire real-time monitoring data according to the feedback cycle during the operation of the H-bridge. The real-time monitoring data includes at least instantaneous current, bus voltage, power chip temperature and current duty cycle. The feedback control module compares the real-time monitoring data with a preset safety threshold. If at least one data exceeds the limit, it immediately sets a fault mask bit, shuts down the PWM output, and sends a status message containing the fault mask bit back to the host computer. If all real-time monitoring data does not exceed the limit, it encapsulates the real-time monitoring data into a status message and sends it back to the host computer via the CAN bus. The feedback control module uses a bit mask structure to store overcurrent flag, overtemperature flag, and extended fault flag simultaneously. When any flag bit is set, it immediately forces the H-bridge duty cycle to 0 and maintains this protection state until the main control module receives a new start command, thereby supporting concurrent detection of multiple faults and one-time reporting. The main control module coordinates the work of the above modules and runs the PWM waveform generation task with the highest priority in the embedded multi-tasking environment. The status acquisition and feedback task runs with a lower priority than the PWM waveform generation task. The two tasks are synchronized by sharing a real-time status structure to ensure the real-time performance and consistency of real-time monitoring and dynamic control.

[0030] In the system proposed in this application, the CAN communication module only opens two message channels, 0x700 and 0x701, to achieve downlink configuration and uplink status. Upon receiving the configuration message with CAN ID 0x700, the parameter configuration management module immediately parses it by byte and bit field, and writes the control mode, minimum / maximum duty cycle, step size, dwell time, dead time index, and feedback cycle into the shared configuration structure in one go within the critical section. This ensures that the PWM waveform generation task can read the same frame of parameters in the next cycle, preventing the mixing of old and new parameters. The PWM waveform generation task runs with the highest priority, calling the corresponding algorithm to output PWM based on the current control mode (triangle wave, sine wave, square wave, or step response). Simultaneously, it looks up the actual dead time value using the dead time index and writes it into the PWM register, completing precise control of the bridge arm switching timing. The status acquisition and feedback task runs with a priority lower than the PWM task. During the feedback cycle, the ADC samples the current, voltage, and temperature, and stores them in the real-time status structure along with the current duty cycle in the PWM register. The feedback control module compares the sampled values ​​with preset thresholds. If overcurrent or overtemperature occurs, the corresponding bit of the fault mask is set, the PWM output is turned off, and then a status message containing the fault flag is immediately uploaded via CANID 0x701. This achieves a closed loop at the system level: "online parameter update - real-time status feedback - immediate fault protection". The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for real-time monitoring and dynamic control of H-bridge drivers based on CAN bus, characterized in that, The method includes at least the following steps: S1. Receive configuration messages sent by the host computer via the CAN bus, parse and verify the validity of the configuration messages, and obtain a set of dynamic control parameters. The set of dynamic control parameters includes at least the control mode, minimum duty cycle, maximum duty cycle, duty cycle step, dwell time, dead time index, and feedback cycle. S2. The verified set of dynamic control parameters is atomically written into the configuration structure and takes effect immediately. The reload of dynamic control parameters is completed without interrupting the current output of the H-bridge. The dead time index is used to query the pre-stored dead time schedule and obtain the actual dead time value to accurately control the switching dead time of the H-bridge power devices. S3. Based on the control mode after it takes effect, call the corresponding PWM waveform generation algorithm and output the PWM signal to the H-bridge power stage to achieve dynamic control; S4. During the operation of the H-bridge, real-time monitoring data is periodically collected according to the feedback cycle. The real-time monitoring data includes at least instantaneous current, bus voltage, power chip temperature and current duty cycle. S5. Compare the real-time monitoring data with the preset safety threshold. If at least one data exceeds the limit, immediately set the fault mask bit, turn off the PWM output, and send the status message containing the fault mask bit back to the host computer to achieve fault protection. S6. If all real-time monitoring data are within limits, the real-time monitoring data is encapsulated into a status message and transmitted back to the host computer via the CAN bus to complete the real-time monitoring closed loop. S7. Based on the received status message, the host computer can update the dynamic control parameter set online and repeat steps S1-S6 to form a real-time closed-loop control process of "parameter issuance - status monitoring - data feedback - parameter readjustment".

2. The method for real-time monitoring and dynamic control of H-bridge driver based on CAN bus as described in claim 1, characterized in that, The S1 step specifically includes: S11. In the CAN receive interrupt, determine whether the message ID is 0x700. If it is, extract 8 bytes of data. S12. Parse the 8-byte data by bit field to obtain the control mode, minimum duty cycle, maximum duty cycle, duty cycle step, dwell time, dead time index and feedback cycle in sequence, and perform limiting processing on each parameter to ensure that the minimum duty cycle is ≥1%, the maximum duty cycle is ≤99% and the maximum duty cycle is ≥ the minimum duty cycle. S13. When the parsed command code is a query command, the contents of the current configuration structure are encapsulated into a configuration message and sent to the host computer via the CAN bus to complete the configuration readback.

3. A method for real-time monitoring and dynamic control of H-bridge drivers based on CAN bus as described in claim 1 or 2, characterized in that, The control modes in step S3 include: The triangular wave scanning mode is characterized by a linear reciprocating duty cycle between a minimum and a maximum value. A sine wave mode, wherein the duty cycle varies continuously according to a sine function; Square wave mode, wherein the duty cycle switches stepwise between a minimum and a maximum value; A step response mode, wherein the duty cycle jumps from the minimum value to the maximum value in a single step and holds before returning to the minimum value; The four modes share the same configuration structure and can be seamlessly switched during operation via steps S1-S2.

4. The method for real-time monitoring and dynamic control of H-bridge driver based on CAN bus as described in claim 1, characterized in that, The S4 step specifically includes: S41. The H-bridge output current is sampled by the current sensor and ADC and converted into a milliampere-level current value; S42. The bus voltage is sampled by a voltage divider circuit and an ADC and converted into a millivolt-level voltage value. S43. Obtain the power chip temperature through a temperature sensor and convert it to degrees Celsius; S44. Read the current duty cycle from the PWM register and store it together with the current, voltage, and temperature data into the real-time status structure for subsequent encapsulation.

5. The method for real-time monitoring and dynamic control of H-bridge driver based on CAN bus as described in claim 1, characterized in that, The fault mask bit in step S5 adopts a bit mask structure, and simultaneously sets the overcurrent flag bit, overtemperature flag bit, and other extended fault bits. When any flag bit is set, the H-bridge duty cycle is forced to be 0 and maintained until the host computer issues a new start command.

6. The method for real-time monitoring and dynamic control of H-bridge driver based on CAN bus as described in claim 1, characterized in that, The status message in step S6 uses CAN ID 0x701, and the message data field is in 8-byte little-endian format, encapsulated sequentially; among which, Byte 0 is the status flag bit, containing the running flag, overcurrent flag, and overtemperature flag; Byte 1 represents the current duty cycle, 0-99. Bytes 2 and 3 represent the current value, with the least significant byte first. Bytes 4 and 5 represent the voltage value, with the least significant byte first. Byte 6 is the temperature value; Byte 7 controls the lower 8 bits of the loop counter; Furthermore, the feedback cycle can be modified online by the host computer through configuration messages during the operation of the H-bridge, and will take effect in the next feedback cycle.

7. The method for real-time monitoring and dynamic control of H-bridge driver based on CAN bus as described in claim 1, characterized in that, Steps S1-S7 are executed in an embedded multi-task environment. The PWM waveform generation task has the highest priority, followed by the status acquisition and feedback task. The two tasks are synchronized by sharing the real-time status structure to ensure the real-time performance and consistency of real-time monitoring and dynamic control.

8. A real-time monitoring and dynamic control system based on an H-bridge driven by a CAN bus, characterized in that, The system, based on the method of any one of claims 1-7, includes at least the following: The CAN communication module is used to receive configuration messages from the host computer and send status messages to the host computer via the CAN bus. The CAN ID of the configuration message is 0x700, and the CAN ID of the status message is 0x701. The parameter configuration management module is used to parse and validate the configuration message, obtain the dynamic control parameter set, atomically write the validated dynamic control parameter set into the configuration structure, and encapsulate the contents of the current configuration structure into a configuration message and send it back to the host computer when a query command is received. The PWM waveform generation module is used to call the corresponding PWM waveform generation algorithm according to the control mode after it takes effect, output the PWM signal to the H-bridge power stage, and after querying the pre-stored dead time table according to the dead time index, obtain the actual dead time value to accurately control the switching dead time of the H-bridge power devices. The status acquisition module is used to periodically acquire real-time monitoring data according to the feedback cycle during the operation of the H-bridge. The real-time monitoring data includes at least instantaneous current, bus voltage, power chip temperature and current duty cycle. The feedback control module is used to compare the real-time monitoring data with a preset safety threshold. If at least one data exceeds the limit, it immediately sets a fault mask bit, turns off the PWM output, and sends a status message containing the fault mask bit back to the host computer. If all real-time monitoring data does not exceed the limit, it encapsulates the real-time monitoring data into a status message and sends it back to the host computer via the CAN bus. The main control module coordinates the work of the above modules and runs the PWM waveform generation task with the highest priority in the embedded multi-tasking environment. The status acquisition and feedback task runs with a lower priority than the PWM waveform generation task. The two tasks are synchronized by sharing a real-time status structure to ensure the real-time performance and consistency of real-time monitoring and dynamic control.

9. The H-bridge drive real-time monitoring and dynamic control system based on CAN bus as described in claim 8, characterized in that: The parameter configuration management module is further used to: when receiving feedback cycle parameters modified online by the host computer, write them into the configuration structure, and perform status acquisition and message sending according to the new feedback cycle starting from the next feedback cycle.

10. The H-bridge drive real-time monitoring and dynamic control system based on CAN bus as described in claim 8, characterized in that: The feedback control module uses a bitmask structure to store both the overcurrent flag and the overtemperature flag. When either flag is set, the H-bridge duty cycle is immediately forced to 0, and this protection state is maintained until the main control module receives a new start command.