Level output control method, device, equipment, medium and product
Through MCU operating status detection and PWM signal adjustment, the burnout problem of MOS tube devices caused by long-term conduction during debugging of motor drive projects is solved, circuit safety is improved, and fire risks caused by excessive current are prevented.
Patent Information
- Application Number
- CN202410979058.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-22
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2044-07-22
AI Technical Summary
During the debugging of motor drive projects, when the MCU pauses the simulation state or runs to a code breakpoint, the PWM output signal remains unchanged, causing the drive bridge MOS transistor to be turned on for a long time, resulting in excessive current, which may cause burning of the drive device and fire.
Receive the emulator operating instructions through the MCU running status detection module, adjust the pulse width modulation signal PWM to the corresponding output mode, control the level output of the MOS device according to the output mode, and ensure that it switches to a safe level in the pause state to avoid long-term failure. Pass.
It effectively prevents MOS tube devices from burning due to long-term conduction, improves the safety of the circuit, and avoids economic losses and fire risks caused by excessive current.
Smart Images

Figure CN118502337B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of motor drive control, and in particular to a level output control method, device, equipment, medium and product. Background Art
[0002] During the development of the motor drive project, it is necessary to use the MCU's online simulation function for software debugging. Currently, similar motor drive MCUs will pause the microcontroller core at the simulation function breakpoint, and the on-chip peripherals will also maintain the current state.
[0003] The motor drive bridge circuit of the driver board uses the MCU's timer (TIM) peripheral to output a pulse width modulation (PWM) signal to control the on and off of the metal-oxide-semiconductor field-effect transistor (MOS).
[0004] However, when the motor is in running state, the MCU enters the pause simulation state or runs to the code breakpoint, and the PWM output signal will remain at a certain level, which will cause the drive bridge to fail to switch phases normally. The drive bridge MOS tube is in the open state for a long time, which will cause the current flowing through the MOS tube to be too high, thereby burning the drive device and causing economic losses, affecting the project development process, and easily causing a fire.
[0005] The above contents are only used to assist in understanding the technical solution of the present invention and do not constitute an admission that the above contents are prior art. Summary of the invention
[0006] The main purpose of the present invention is to provide a level output control method, device, terminal equipment and storage medium, aiming to solve the technical problem that after the microcontroller core is suspended during the debugging of the motor drive control project, the PWM cannot change phase normally, causing the MOS device to be turned on for a long time, thereby burning the MOS tube device.
[0007] To achieve the above object, the present invention provides a level output control method, the level output control method comprising:
[0008] Receive the operation instruction sent by the simulator, perform status detection on the microcontroller MCU through the MCU operation status detection module, and obtain the operation status of the MCU;
[0009] According to the operating state of the MCU, the pulse width modulation signal PWM is adjusted to a corresponding output mode;
[0010] The metal oxide semiconductor transistor (MOS) device is outputted in level according to the output mode.
[0011] Optionally, the operation instruction includes one or more of run, pause and breakpoint, and after the step of receiving the operation instruction sent by the simulator, the step further includes:
[0012] Based on the operation instruction, software debugging is performed through the MCU, and program running status is monitored in real time, where the program running status includes one or more of running status, memory usage, variables, and register values;
[0013] When the operation instruction read is a pause and / or a breakpoint, the program running status before the operation instruction is output, and instruction reading is stopped.
[0014] Optionally, the step of performing status detection on the microcontroller MCU through the MCU running status detection module to obtain the running status of the MCU includes:
[0015] Performing polling detection on the MCU through the MCU running status detection module to obtain the instruction reading status of the MCU;
[0016] When the instruction reading state of the MCU is stopped, analysis is performed according to a preset pause state time threshold;
[0017] If the time during which the MCU stops reading exceeds the pause state time threshold, the running state of the MCU is output as the pause state.
[0018] Optionally, after the step of outputting that the running state of the MCU is a paused state, the step further includes:
[0019] Reading based on a preset counting register, obtaining a counting configuration of a timing counter when the running state of the MCU is a pause state;
[0020] The timing counter is controlled based on the counting configuration.
[0021] Optionally, the step of adjusting the pulse width modulation signal PWM to a corresponding output mode according to the operating state of the MCU includes:
[0022] Optionally, the step of performing level output on the metal oxide semiconductor transistor (MOS) device according to the output mode includes:
[0023] Reading a preset output register based on the output mode to obtain an output configuration;
[0024] Parsing the output configuration to obtain a register configuration value;
[0025] The pulse width modulation signal is adjusted based on the register configuration value, and the level of the MOS tube device is output through a preset driving bridge circuit.
[0026] Optionally, after the step of outputting a level to the metal oxide semiconductor transistor (MOS) device according to the output mode, the step further includes:
[0027] Reading a preset monitor module to obtain a timing configuration in the monitor module;
[0028] Based on the timing configuration, the monitor module detects the instruction reading status of the MCU;
[0029] If the instruction reading state of the MCU is stopped, a restart operation is performed on the MCU.
[0030] The embodiment of the present invention further provides a level output control device, the level output control device comprising:
[0031] The detection module is used to receive the operation instruction sent by the simulator, and perform status detection on the microcontroller MCU through the MCU operation status detection module to obtain the operation status of the MCU;
[0032] An adjustment module, used for adjusting the pulse width modulation signal PWM to a corresponding output mode according to the operating state of the MCU;
[0033] The output module is used to output the level of the metal oxide semiconductor transistor MOS tube device according to the output mode.
[0034] An embodiment of the present invention further proposes a terminal device, which includes a memory, a processor, and a level output control program stored in the memory and executable on the processor, wherein the level output control program implements the steps of the level output control method described above when executed by the processor.
[0035] The embodiment of the present invention further provides a computer-readable storage medium, on which a level output control program is stored. When the level output control program is executed by a processor, the steps of the level output control method described above are implemented.
[0036] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the level output control method described above are implemented.
[0037] The embodiment of the present invention proposes a level output control method, device, terminal equipment and storage medium. By receiving the operation instruction sent by the emulator, the microcontroller MCU is detected by the MCU operation status detection module to obtain the operation status of the MCU; according to the operation status of the MCU, the pulse width modulation signal PWM is adjusted to the corresponding output mode; according to the output mode, the metal oxide semiconductor tube MOS tube device is output at a level. Thus, the MCU is detected by the MCU operation status detection module to obtain the operation status of the MCU, and the output mode is adjusted based on the obtained operation status, and finally the MOS tube device is output at a level according to the output mode. The control of the level output is realized, and the problem that the PWM cannot be normally switched after the microcontroller core is suspended in the debugging of the motor drive control project, resulting in the MOS device being turned on for a long time, thereby burning the MOS tube device, is protected. The safety of the circuit is protected. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 This is a functional module diagram of a terminal device to which the level output control device of the present invention belongs;
[0039] Figure 2 It is a flow chart of an exemplary embodiment of a level output control method of the present invention;
[0040] Figure 3 It is an overall schematic diagram of the level output control method of the present invention;
[0041] Figure 4 is a flow chart of another exemplary embodiment of the level output control method of the present invention;
[0042] Figure 5 is a flow chart of another exemplary embodiment of the level output control method of the present invention;
[0043] Figure 6 The schematic diagram of the level output control method of the present invention involving register value and level output is shown in FIG.
[0044] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0045] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0046] The main solution of the embodiment of the present invention is: based on the operation instruction, the software is debugged through the MCU, and the program running status is obtained by real-time monitoring, and the program running status includes one or more of the running status, memory usage, variables and register values; when the operation instruction is read as a pause and / or breakpoint, the program running status before the operation instruction is output, and the instruction reading is stopped. The MCU is polled and detected by the MCU running status detection module to obtain the instruction reading status of the MCU; when the instruction reading status of the MCU is stopped, it is analyzed according to the preset pause state time threshold; if the time when the MCU stops reading exceeds the pause state time threshold, the running status of the MCU is output as a pause state. Based on the preset counting register, the counting configuration of the timing counter when the running status of the MCU is the pause state is obtained; the timing counter is controlled based on the counting configuration. Based on the output mode, the preset output register is read to obtain the output configuration; the output configuration is parsed to obtain the register configuration value; the pulse width modulation signal is adjusted based on the register configuration value, and the level output of the MOS tube device is performed through the preset driving bridge circuit. The preset monitor module is read to obtain the timing configuration in the monitor module; based on the timing configuration, the instruction reading state of the MCU is detected by the monitor module; if the instruction reading state of the MCU is stopped, the MCU is restarted. Thus, the problem that the PWM cannot normally change phase after the microcontroller core is suspended in the debugging of the motor drive control project, resulting in the MOS device being turned on for a long time, thereby burning the MOS tube device, is solved, the level output is controlled, and the safety of the circuit is protected. Based on the scheme of the present invention, in the actual development process of the motor drive project, the online simulation function of the MCU needs to be used for software debugging. At present, the same type of motor drive MCU will suspend the microcontroller core at the simulation function breakpoint, and the on-chip peripherals will also maintain the current state, but the drive bridge MOS tube is in the open state for a long time, which will make the current flowing through the MOS tube too high, causing the drive device to burn, thereby low safety. Starting from the problem, a level output control method is designed, and the effectiveness of the level output control method of the present invention is verified when the level output is controlled. Finally, the safety of the level output control by the method of the present invention is significantly improved.
[0047] Technical terms involved in the embodiments of the present invention:
[0048] MCU: MCU is the abbreviation of microcontroller unit, which is an integrated circuit chip that integrates functional modules such as processor core, memory (including flash memory and RAM), input / output interface and timer. Microcontrollers are usually used in embedded systems to control the operation of various devices or systems.
[0049] PWM: PWM is the abbreviation of Pulse Width Modulation, which is a commonly used method for regulating analog signals. In PWM, the duty cycle of the signal (the proportion of the high level time in a cycle) is adjusted to control the average power of the output signal. Its working principle is that PWM controls the average voltage value of the output signal by periodically changing the high level time of the signal. When the high level time accounts for a high proportion, the average voltage value of the output signal is larger, and when the high level time is lower, the average voltage value of the output signal is smaller.
[0050] Driver Bridge: A driver bridge is an electronic component that is typically used to control and drive motors, actuators, or other high-power loads. A driver bridge typically contains multiple power transistors or MOSFETs that can provide sufficient current and voltage to drive the target load.
[0051] TIM peripheral: TIM peripheral refers to the timer peripheral, which is one of the common peripherals in embedded systems. The timer peripheral is usually used to generate accurate timing trigger signals, calculate time intervals, and execute timing tasks.
[0052] MOS tube: MOS tube is the abbreviation of Metal-Oxide-Semiconductor Field-Effect Transistor, also known as MOSFET. MOS tube is a commonly used semiconductor device with the advantages of high input resistance, low driving power, fast switching speed, etc., and is widely used in electronic circuits.
[0053] The embodiments of the present invention take into account that when the related technology is developing a motor drive project, since the motor drive bridge circuit of the driver board uses the TIM peripheral of the MCU to output a PWM signal to control the on and off of the MOS tube, if the MCU enters a paused simulation state or runs to a code breakpoint when the motor is in a running state, the PWM output signal will remain at a certain level, which will cause the drive bridge to fail to switch phases normally. If the MOS tube of the drive bridge is in an open state for a long time, the current flowing through the MOS tube will be too high, thereby burning the drive device and causing economic losses. Therefore, this method has the problem of affecting the development progress of the project and easily causing fire.
[0054] Therefore, the embodiments of the present invention are based on the fact that in the development process of a motor drive project, it is necessary to use the online simulation function of the MCU for software debugging. At present, similar motor drive MCUs will pause the microcontroller core at the simulation function breakpoint, and the on-chip peripherals will also maintain the current state. However, the drive bridge MOS tube is in an open state for a long time at this time, which will make the current flowing through the MOS tube too high, causing the drive device to burn out, thereby low safety. A level output control method is designed, and the effectiveness of the level output control method of the present invention is verified when the level output is controlled. Finally, the safety of level output control performed by the method of the present invention is significantly improved.
[0055] Specifically, refer to Figure 1 , Figure 1 The figure is a functional block diagram of the terminal device to which the level output control device of the present invention belongs. The level output control device can be a device that is independent of the terminal device and can perform level output control, and it can be carried on the terminal device in the form of hardware or software. The terminal device can be a smart mobile device with data processing function such as a mobile phone or a tablet computer, and can also be a fixed terminal device or server with data processing function.
[0056] In this embodiment, the terminal device to which the level output control apparatus belongs includes at least an output module 110 , a processor 120 , a memory 130 and a communication module 140 .
[0057] The memory 130 stores an operating system and a level output control program. The level output control device can respond to the pre-acquired operation instructions through the microcontroller MCU, and detect the state of the MCU through the MCU operation state detection module to obtain the operation state of the MCU; according to the operation state of the MCU, the timing counter and the comparison output are adjusted to the corresponding output mode, and the metal oxide semiconductor tube MOS tube device is outputted at a level according to the corresponding output mode. The level output control program is used to control the level output, and the control result and other information are stored in the memory 130; the output module 110 can be a display screen, etc. The communication module 140 can include a WIFI module, a mobile communication module, a Bluetooth module, etc., and communicates with an external device or server through the communication module 140.
[0058] When the level output control program in the memory 130 is executed by the processor, the following steps are implemented:
[0059] Receive the operation instruction sent by the simulator, perform status detection on the microcontroller MCU through the MCU operation status detection module, and obtain the operation status of the MCU;
[0060] According to the operating state of the MCU, the pulse width modulation signal PWM is adjusted to a corresponding output mode;
[0061] The metal oxide semiconductor transistor (MOS) device is outputted in level according to the output mode.
[0062] Furthermore, when the level output control program in the memory 130 is executed by the processor, the following steps are also implemented:
[0063] Based on the operation instruction, software debugging is performed through the MCU, and program running status is monitored in real time, where the program running status includes one or more of running status, memory usage, variables, and register values;
[0064] When the operation instruction read is a pause and / or a breakpoint, the program running status before the operation instruction is output, and instruction reading is stopped.
[0065] Furthermore, when the level output control program in the memory 130 is executed by the processor, the following steps are also implemented:
[0066] Performing polling detection on the MCU through the MCU running status detection module to obtain the instruction reading status of the MCU;
[0067] When the instruction reading state of the MCU is stopped, analysis is performed according to a preset pause state time threshold;
[0068] If the time during which the MCU stops reading exceeds the pause state time threshold, the running state of the MCU is output as the pause state.
[0069] Furthermore, when the level output control program in the memory 130 is executed by the processor, the following steps are also implemented:
[0070] Reading based on a preset counting register, obtaining a counting configuration of a timing counter when the running state of the MCU is a pause state;
[0071] The timing counter is controlled based on the counting configuration.
[0072] Furthermore, when the level output control program in the memory 130 is executed by the processor, the following steps are also implemented:
[0073] Reading a preset output register based on the output mode to obtain an output configuration;
[0074] Parsing the output configuration to obtain a register configuration value;
[0075] The pulse width modulation signal is adjusted based on the register configuration value, and the level of the MOS tube device is output through a preset driving bridge circuit.
[0076] Furthermore, when the level output control program in the memory 130 is executed by the processor, the following steps are also implemented:
[0077] Reading a preset monitor module to obtain a timing configuration in the monitor module;
[0078] Based on the timing configuration, the monitor module detects the instruction reading status of the MCU;
[0079] If the instruction reading state of the MCU is stopped, a restart operation is performed on the MCU.
[0080] This embodiment adopts the above scheme, specifically by receiving the operation instruction sent by the simulator, and performing state detection on the microcontroller MCU through the MCU operation state detection module to obtain the operation state of the MCU; according to the operation state of the MCU, the pulse width modulation signal PWM is adjusted to the corresponding output mode; and the metal oxide semiconductor tube MOS tube device is output at a level according to the output mode. Thus, the MCU is detected at a state through the MCU operation state detection module to obtain the operation state of the MCU, and the output mode is adjusted based on the obtained operation state, and finally the MOS tube device is output at a level according to the output mode, which can solve the problem that the PWM cannot be output normally after the microcontroller core is suspended in the debugging of the motor drive control project, resulting in the MOS device being turned on for a long time, thereby burning the MOS tube device. Based on the scheme of the present invention, in the actual process of motor drive project development, it is necessary to use the online simulation function of the MCU for software debugging. At present, similar motor drive MCUs will pause the microcontroller core at the simulation function breakpoint, and the on-chip peripherals will also maintain the current state, but the drive bridge MOS tube is in the open state for a long time at this time, which will make the current flowing through the MOS tube too high, causing the drive device to burn out, thereby low safety. Starting from the problem, a level output control method is designed, and the effectiveness of the level output control method of the present invention is verified when the level output is controlled. Finally, the safety of level output control performed by the method of the present invention is significantly improved.
[0081] Based on the above terminal device architecture but not limited to the above framework, an embodiment of the method of the present invention is proposed.
[0082] Reference Figure 2 , Figure 2 FIG. 1 is a flow chart of an exemplary embodiment of a level output control method of the present invention. The level output control method comprises:
[0083] Step S01, receiving an operation instruction sent by the simulator, performing a state detection on the microcontroller MCU through the MCU operation state detection module, and obtaining the operation state of the MCU;
[0084] Step S04, adjusting the pulse width modulation signal PWM to a corresponding output mode according to the operating state of the MCU;
[0085] Step S05 , outputting a level to the metal oxide semiconductor transistor (MOS) device according to the output mode.
[0086] Before describing the scheme of this embodiment, it should be clear that the problem addressed by the scheme of this embodiment is that in the process of developing a motor drive project, it is necessary to use the online simulation function of the MCU for software debugging. At present, similar motor drive MCUs will suspend the microcontroller core at the simulation function breakpoint, and the on-chip peripherals will also maintain the current state. Among them, the motor drive bridge circuit of the driver board uses the TIM peripheral of the MCU to output a PWM signal to control the on and off of the MOS tube. However, if the MCU enters a paused simulation state or runs to a code breakpoint when the motor is in a running state, the PWM output signal will remain at a certain level, which will cause the drive bridge to fail to switch phases normally. If the drive bridge MOS tube is in an open state for a long time, the current flowing through the MOS tube will be too high, thereby burning the drive device and causing economic losses, affecting the development process of the project, and easily causing a fire. Therefore, it is necessary to control the level output in the pause state to avoid the above situation.
[0087] In this embodiment, the microcontroller MCU responds to the operation instruction sent by the emulator to perform software testing, and synchronously performs status detection on the microcontroller MCU through the MCU operation status detection module to obtain the operation status of the MCU. In this embodiment, the operation instruction received by the microcontroller MCU is diverse, which can be an actual operation process or a corresponding simulation test through the emulator. In this embodiment, the simulation test of the emulator is used as an example for illustration;
[0088] The MCU operation state obtained in the above may be that the MCU is in a suspended operation state or a normal operation state. The present embodiment mainly targets the suspended operation state of the MCU, but is not limited thereto. In the normal operation state of the MCU, the motor driving bridge circuit of the driving board uses the MCU's TIM peripheral to output a PWM signal to control the MOS tube to be turned on and off, that is, the MCU microcontroller core controls the timing counter and the comparison output device to perform PWM output based on the simulation operation instruction of the simulator, thereby completing the conduction of the MOS tube. When the MCU state detection module learns that the MCU microcontroller core is in a suspended state, it will send the pulse The level conversion output module in the width modulation PWM is adjusted to the corresponding output mode, that is, the pause state output mode, wherein, in the output mode from the normal output state of the MCU to the pause state, the output signal will follow the microcontroller pause and maintain the output level state at the stop time, and the fixed MOS drive signal will cause the drive bridge to be unable to switch phases normally, resulting in excessive current of the MOS tube. If the current carrying capacity of the MOS device is weak, especially the high-voltage full-bridge circuit, the MOS device will be burned within a few seconds after continuous conduction. Therefore, this embodiment can output the level of the MOS tube device after adjusting to the corresponding output mode, thereby avoiding damage to the MOS tube device.
[0089] In the above-mentioned embodiments, it has been explained that in the pause state, if the current carrying capacity of the MOS device is weak, especially the high-voltage full-bridge circuit, the MOS device will be burned within a few seconds after continuous conduction. However, in the actual simulation test, the instruction reading may continue after the operation breakpoint. If it is switched every time, it may also cause the progress of the project to slow down. Therefore, in this embodiment, when the operation state of the MCU is paused, it is judged whether the current output mode of the level conversion output module added to the PWM output module exceeds the current carrying capacity of the MOS tube device. It should be clear that the material and the driving bridge circuit for actual current conduction are different, so the current carrying capacity is different. In the case of current carrying capacity operation, the output mode may not be switched to avoid the need for restarting or reading and other operations during subsequent testing. However, when the initial output mode exceeds the current carrying capacity of the MOS tube device, it is explained that it may cause burning. Therefore, at this time, the level conversion output module is adjusted to the corresponding output mode, that is, the output mode in the pause state.
[0090] More specifically, if Figure 3 As shown, Figure 3 It is an overall schematic diagram of the level output control method of the present invention.
[0091] Firstly, the MCU microcontroller core receives the simulation operation instruction sent by the simulator, and the MCU microcontroller core is tested for the running state through the MCU running state detection module to obtain the current running state of the MCU;
[0092] Then, when the MCU is in normal operation, the MCU microcontroller core controls the TIM peripheral (timing counter) and the comparison output to perform PWM output to turn on the MOS tube device;
[0093] Then, when the MCU running state is the pause state, the MCU running state detection module adjusts the mode of the timing counter and the comparison output, and adjusts them to the pause state output mode accordingly;
[0094] Finally, based on the pause state output mode, PWM output (level output) is performed on the MOS tube device.
[0095] This embodiment adopts the above scheme, specifically by receiving the operation instruction sent by the simulator, and performing status detection on the microcontroller MCU through the MCU operation status detection module to obtain the operation status of the MCU; according to the operation status of the MCU, the pulse width modulation signal PWM is adjusted to the corresponding output mode; according to the output mode, the metal oxide semiconductor tube MOS tube device is output at a level. Thus, the MCU is detected at a state by the MCU operation status detection module to obtain the operation status of the MCU, and the output mode is adjusted based on the obtained operation status, and finally the MOS tube device is output at a level according to the output mode. The control of the level output is realized, and the problem that the PWM cannot be normally switched after the microcontroller core is suspended in the debugging of the motor drive control project, resulting in the MOS device being turned on for a long time, thereby burning the MOS tube device, is solved, and the safety of the circuit is protected.
[0096] Reference Figure 4 , Figure 4 FIG. 4 is a flow chart of another exemplary embodiment of the level output control method of the present invention.
[0097] Based on the above Figure 2 In the embodiment shown, the step S01, after the step of responding to the operation instruction sent by the simulator, further includes:
[0098] Step S02, based on the operation instruction, software debugging is performed through the MCU, and program running status is monitored in real time, where the program running status includes one or more of running status, memory usage, variables, and register values;
[0099] Step S03: when the operation instruction read is a pause and / or a breakpoint, the program running status before the operation instruction is output, and instruction reading is stopped.
[0100] In the simulation test of the simulator, in order to obtain the execution status of the software code, it is necessary to monitor the program running status at a specific time. At this time, the MCU will stop reading instructions by running breakpoints and record the program running status, so that software engineers can analyze and verify the program running status and troubleshoot software bugs.
[0101] In this embodiment, simulation test is used as an example, so the operation instructions (including run instructions, pause instructions and breakpoint instructions) input to the microcontroller need to be designed, which can be specifically:
[0102] (1) Writing source code: Programmers write source code using a preset programming language, which can be a high-level language (such as C, Java, Python, etc.) or a low-level language (such as assembly language). The source code is a text file that describes the required operations and logic.
[0103] (2) Lexical Analysis: The compiler will first perform lexical analysis on the source code. The lexical analyzer will split the source code into lexical units (tokens), such as keywords, identifiers, and operators, and generate the corresponding token stream as an intermediate representation.
[0104] (3) Syntax Analysis: Next, the compiler will perform syntax analysis. The syntax analyzer will check whether the arrangement of lexical units conforms to the grammatical structure according to the grammatical rules of the language, and convert it into an abstract syntax tree (AST) or other intermediate representations.
[0105] (4) Semantic Analysis: After grammatical analysis, the compiler will perform semantic analysis. The semantic analyzer will check whether the grammatical structure is semantically reasonable, and perform type checking, symbol resolution, etc. Semantic analysis also includes the detection and reporting of errors or potential problems in the source code.
[0106] (5) Optimization: After generating a valid intermediate representation, the compiler can also perform an optimization step. The optimizer will try to improve the quality of the intermediate representation to improve the performance of the program or reduce resource consumption.
[0107] (6) Code generation: Finally, the compiler generates target code based on the optimized intermediate representation. The target code can be assembly code, machine code, or other code forms specific to the target platform. This process usually involves addressing mode, instruction selection, register allocation, etc.
[0108] After obtaining the target code, the generation of operation instructions can be realized. In this embodiment, simulation testing is mainly used, so the specific instruction settings can be set to "normal operation", "pause operation" and "pause operation after normal operation for a period of time", etc. The ultimate goal is to complete the simulation test of the MCU. The actual test instructions should be set according to the actual business needs;
[0109] It can be seen from the above instruction design that the simulation test in this embodiment has a running breakpoint, so the burnout protection of the MOS tube device is necessary, and the program running conditions during the simulation test include but are not limited to the running state, memory usage, variables and register values, etc.;
[0110] When it is found that the MCU needs to suspend reading (that is, there is a running breakpoint), the program running status before the running breakpoint is output and the MCU stops instruction reading.
[0111] Specifically, in the above step S01, the step of performing status detection on the microcontroller MCU through the MCU running status detection module to obtain the running status of the MCU includes:
[0112] Step S011, performing polling detection on the MCU through the MCU running status detection module to obtain the instruction reading status of the MCU;
[0113] Step S012, when the instruction reading state of the MCU is stopped, analysis is performed according to a preset pause state time threshold;
[0114] Step S013: if the time during which the MCU stops reading exceeds the pause state time threshold, outputting the running state of the MCU as the pause state.
[0115] Since the operation instruction may have a corresponding operation breakpoint, in which the operation breakpoint in software development usually refers to setting a breakpoint during the debugging process and stopping the program when it reaches the breakpoint, so that the programmer can check the value of the variable, program status and other information. The breakpoint is a function provided by the debugging tool, which can help the programmer track the program execution process, find errors and debug;
[0116] When the simulation test runs to a breakpoint, the MCU may be in the state of stopping reading instructions, so at this time, analysis is performed based on the preset pause state time threshold;
[0117] If the time when the MCU stops reading is within the pause state time threshold, it means that the current MCU is still in normal operation and its level output mode does not need to be adjusted;
[0118] If the MCU stops reading for longer than the pause time threshold, it means that the current MCU may not be able to operate normally, or it has reached the pause state. If the level output is not controlled at this time, it may cause the MOS tube device to burn out. Therefore, the level output should be controlled accordingly in the future.
[0119] Furthermore, after the step S013 of outputting that the running state of the MCU is a paused state, the following step is further included:
[0120] Step S014, reading based on a preset counting register, obtaining a counting configuration of a timing counter when the running state of the MCU is a pause state;
[0121] Step S015: Control the timing counter based on the counting configuration.
[0122] After the MCU is in the pause state, the timing counter and the comparison output are adjusted to the pause output mode. In the pause state, the timing counter can be turned on or off according to actual business needs. Specifically, the technical configuration of the timing counter when the MCU is in the pause state is obtained by reading the pre-set counter register, and the timing counter is controlled based on the technical configuration;
[0123] In this embodiment, the counter is mainly controlled in a pause counter manner, specifically: by adding an additional register inside the MCU, this register can perform conditional judgment according to the value of the corresponding bit inside the register. When the MCU enters the pause state, the conditional judgment of whether the counter stops counting is performed while the forced output control is performed. When the BIT0 bit in the above register is logic 1 and the MCU enters the pause mode, the counter operation switch of the TIM peripheral will be turned off to achieve the function of stopping the counter counting in the pause state.
[0124] This embodiment uses the above scheme, specifically based on the operation instruction, through the MCU to perform software debugging, and real-time monitoring to obtain the program running status, the program running status includes one or more of the running status, memory usage, variables and register values; when the operation instruction is read as a pause and / or breakpoint, the program running status before the operation instruction is output, and the instruction reading is stopped. Thus, the corresponding status detection is performed through the MCU running status detection module, the current MCU running status is obtained, the MCU running status is obtained, the problem of being unable to obtain the MCU running status and unable to adopt the corresponding level control mode for level control is solved, and the safety of the circuit is protected.
[0125] Reference Figure 5 , Figure 5FIG. 4 is a flow chart of another exemplary embodiment of the level output control method of the present invention.
[0126] Based on the above Figure 2 In the embodiment shown, the step S05, the step of performing level output on the metal oxide semiconductor transistor MOS device according to the output mode, comprises:
[0127] Step S051, reading a preset output register based on the output mode to obtain an output configuration;
[0128] Step S052, parsing the output configuration to obtain a register configuration value;
[0129] Step S053, adjusting the pulse width modulation signal based on the register configuration value, and outputting a level to the MOS transistor device through a preset driving bridge circuit.
[0130] Based on the adjusted output mode (i.e., pause state output mode), the preset output register is read to obtain the output configuration that should be adopted at this time, wherein the output register is configured in advance, and the pre-configured PWM forced output polarity is adapted to different types of drive bridge circuits. Compared with the normal output state, when the forced output is performed, the PWM is no longer output by the counter comparison of the timer peripheral, but the set level state is output;
[0131] After obtaining the output configuration, it is parsed to obtain the register configuration value. Since the register configuration value can control the state, function and polarity of the output, the output polarity of the pulse width modulation PWM signal can be obtained at this time. Among them, pulse width modulation (PWM) is a commonly used modulation technology. It realizes the digitization of analog signals by adjusting the width of the pulse signal. PWM signals are usually used in applications such as controlling motor speed, LED brightness adjustment, and audio amplifiers. In the PWM signal, the proportion of the high level time in a cycle is called the duty cycle. The size of the duty cycle determines the average power of the output signal, and the output polarity usually refers to the polarity attribute of the output end of the signal or circuit. The output polarity describes the positive and negative polarity of the signal and the relationship with the ground (or reference voltage);
[0132] It should be noted that in this embodiment, the register value and the level output control are as follows: Figure 6 As shown, when a change in the operating state is detected, the corresponding output mode is switched, and the output register is read to obtain the output configuration corresponding to the output mode, and the output configuration is parsed to obtain the register configuration value, and then the pulse width modulation signal can be adjusted based on the register configuration value, thereby completing the corresponding mode control of the level output;
[0133] Therefore, the MOS tube device can be outputted at a level through the driving bridge circuit. The driving bridge circuit is usually used to control the direction and speed of the motor or other high-power loads. When the driving bridge circuit and the output polarity are previously adapted, in order to ensure that the signal matches the requirements of the motor or other loads, this embodiment provides a simple adaptation process:
[0134] First, determine the load requirements. It is necessary to determine the characteristics of the load connected to the drive bridge circuit, such as the rated voltage, rated current, phase, etc. of the motor;
[0135] Then, analyze the polarity requirements of the output signal. According to the requirements of the load, analyze what the polarity of the output signal should be to ensure that it matches the load. For example, the motor may need a positive pulse to rotate in one direction and a negative pulse to rotate in another direction.
[0136] Then, design the driver bridge circuit to correctly control the direction and speed of the load according to the polarity requirements of the output signal, which may involve selecting appropriate circuit topology, power devices and control logic;
[0137] Then, verify the adaptation results. After designing and building the drive bridge circuit, perform actual tests to verify the matching degree between the output signal and the load, ensure that the motor or other load works as expected, and check whether the polarity of the output signal is correct;
[0138] Finally, adjust and optimize, if necessary, the drive bridge circuit according to the test results to further improve performance and matching;
[0139] It should be clear that the main strategy of the solution of this embodiment is to trigger the adjustment of the pulse width modulation signal when it is determined that the MCU pauses instruction reading, thereby ensuring that the circuit will not be short-circuited and the MOS tube device is protected.
[0140] Specifically, after the step S05 of outputting a level to the metal oxide semiconductor transistor (MOS) device according to the output mode, the step further includes:
[0141] Step S06, reading a preset monitor module to obtain a timing configuration in the monitor module;
[0142] Step S07, based on the timing configuration, performing instruction reading status detection on the MCU through the monitor module;
[0143] Step S08: If the instruction reading state of the MCU is stopped, a restart operation is performed on the MCU.
[0144] It should be clear that the monitor module in this embodiment should be understood as a "watchdog" module. At the operating system level, a "watchdog" is a software component that monitors the operating status of the system, detects anomalies, and takes measures;
[0145] In actual MCU use, you may encounter:
[0146] (1) When running in a strict environment, high reliability and stability need to be guaranteed. If the system encounters an abnormal situation that causes stagnation or deadlock, the monitor module can detect this situation and take measures to recover the system, such as restarting the system or performing other predefined operations to restore the system to normal operation;
[0147] (2) In the event of a system crash or stagnation due to programming errors, memory leaks, or other abnormal conditions, the monitor module can periodically check whether the system is operating normally and take appropriate measures when an abnormality is detected, such as restarting the system or recording error logs for subsequent analysis;
[0148] (3) Due to electromagnetic interference, power fluctuations, etc., the system may operate abnormally or stagnate. The monitor module can detect this situation when the system is subject to external interference and take appropriate measures to ensure the stability and reliability of the system;
[0149] Therefore, the monitor module in this embodiment can read the timing configuration in the monitor module, for example, detect the instruction reading status of the MCU at 12:00 am every day, and restart the MCU when it is detected that the current MCU stops reading instructions. In addition, the monitor system can also be flexibly configured according to the above situation to achieve normal use of the MCU.
[0150] This embodiment adopts the above scheme, specifically by reading the preset output register based on the output mode to obtain the output configuration; parsing the output configuration to obtain the register configuration value; adjusting the pulse width modulation signal based on the register configuration value, and outputting the level of the MOS tube device through the preset driving bridge circuit. Thus, the MCU is detected by the MCU operation status detection module to obtain the operation status of the MCU, and the output mode is adjusted based on the obtained operation status, and finally the MOS tube device is outputted at a level according to the output mode. The control of the level output is realized, and the problem that the PWM cannot be output normally after the microcontroller core is suspended in the debugging of the motor drive control project is solved, resulting in the MOS device being turned on for a long time, thereby burning the MOS tube device, is protected. The safety of the circuit is protected.
[0151] In addition, an embodiment of the present invention further provides a level output control device, the level output control device comprising:
[0152] The detection module is used to receive the operation instruction sent by the simulator, and perform status detection on the microcontroller MCU through the MCU operation status detection module to obtain the operation status of the MCU;
[0153] An adjustment module, used for adjusting the pulse width modulation signal PWM to a corresponding output mode according to the operating state of the MCU;
[0154] The output module is used to output the level of the metal oxide semiconductor transistor MOS tube device according to the output mode.
[0155] In addition, an embodiment of the present invention also proposes a terminal device, which includes a memory, a processor, and a level output control program stored in the memory and executable on the processor, and the level output control program implements the steps of the level output control method described above when executed by the processor.
[0156] Since all the technical solutions of all the aforementioned embodiments are adopted when the level output control program is executed by the processor, it has at least all the beneficial effects brought by all the technical solutions of all the aforementioned embodiments, which will not be described one by one here.
[0157] In addition, an embodiment of the present invention further provides a computer-readable storage medium, on which a level output control program is stored. When the level output control program is executed by a processor, the steps of the level output control method described above are implemented.
[0158] Since all the technical solutions of all the aforementioned embodiments are adopted when the level output control program is executed by the processor, it has at least all the beneficial effects brought by all the technical solutions of all the aforementioned embodiments, which will not be described one by one here.
[0159] In addition, the present application also provides a computer program product, including a computer program, and when the computer program is executed by a processor, the steps of the level output control method as described above are implemented.
[0160] The computer program product provided by the present application can solve the technical problem that the PWM cannot normally change phase after the microcontroller core is suspended during the debugging of the motor drive control project, causing the MOS device to be turned on for a long time, thereby burning the MOS tube device. Compared with the prior art, the beneficial effects of the computer program product provided by the present application are the same as the beneficial effects of the level output control method provided by the above embodiment, and will not be repeated here.
[0161] Compared with the prior art, the level output control method, device, terminal device and storage medium proposed in the embodiment of the present invention receive the operation instruction sent by the emulator, detect the state of the microcontroller MCU through the MCU operation state detection module, and obtain the operation state of the MCU; according to the operation state of the MCU, adjust the pulse width modulation signal PWM to the corresponding output mode; according to the output mode, output the level of the metal oxide semiconductor tube MOS tube device. This solves the problem that the PWM cannot be normally switched after the microcontroller core is suspended during the debugging of the motor drive control project, causing the MOS device to be turned on for a long time, thereby burning the MOS tube device, realizes the control of the level output, and protects the safety of the circuit. Based on the scheme of the present invention, in the actual process of motor drive project development, it is necessary to use the online simulation function of the MCU for software debugging. At present, similar motor drive MCUs will pause the microcontroller core at the simulation function breakpoint, and the on-chip peripherals will also maintain the current state, but the drive bridge MOS tube is in the open state for a long time at this time, which will make the current flowing through the MOS tube too high, causing the drive device to burn out, thereby low safety. Starting from the problem, a level output control method is designed, and the effectiveness of the level output control method of the present invention is verified when the level output is controlled. Finally, the safety of level output control performed by the method of the present invention is significantly improved.
[0162] Compared with the existing technology, the embodiment of the present invention has the following advantages:
[0163] 1. A detection module that detects whether the microcontroller has entered a pause state by parsing the simulator data instructions and detecting the microcontroller's operating status;
[0164] 2. After learning that the microcontroller has entered the pause state, the timing counter and the comparison output are controlled to enter the pause control mode;
[0165] 3. Through the corresponding control register configuration, select whether to continue counting and output forced level status in the timing counter and output comparator pause control mode.
[0166] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.
[0167] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0168] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as above, including a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, a controlled terminal, or a network device, etc.) to execute the method of each embodiment of the present invention.
[0169] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A level output control method, characterized in that: The level output control method comprises the following steps: Receive the operation instruction sent by the simulator, perform status detection on the microcontroller MCU through the MCU operation status detection module, and obtain the operation status of the MCU; The operation instruction includes one or more of a run instruction, a pause instruction and a breakpoint instruction, and after the step of receiving the operation instruction sent by the simulator, the step further includes: Based on the operation instruction, software debugging is performed through the MCU, and program running status is monitored in real time, where the program running status includes one or more of running status, memory usage, variables, and register values; When the operation instruction is read as a pause and / or breakpoint, the program running status before the operation instruction is output, and instruction reading is stopped; The step of performing status detection on the microcontroller MCU through the MCU running status detection module to obtain the running status of the MCU includes: Performing polling detection on the MCU through the MCU running status detection module to obtain the instruction reading status of the MCU; When the instruction reading state of the MCU is stopped, analysis is performed according to a preset pause state time threshold; If the time when the MCU stops reading exceeds the pause state time threshold, outputting the running state of the MCU as the pause state; Wherein, after the step of outputting that the running state of the MCU is a paused state, the step further includes: Reading based on a preset counting register, obtaining a counting configuration of a timing counter when the running state of the MCU is a pause state; controlling the timing counter based on the counting configuration; According to the operating state of the MCU, the pulse width modulation signal PWM is adjusted to a corresponding output mode; The metal oxide semiconductor transistor (MOS) device is outputted in level according to the output mode.
2. The level output control method according to claim 1, characterized in that: The step of performing level output on the metal oxide semiconductor transistor (MOS) device according to the output mode comprises: Reading a preset output register based on the output mode to obtain an output configuration; Parsing the output configuration to obtain a register configuration value; The pulse width modulation signal is adjusted based on the register configuration value, and the level of the MOS tube device is output through a preset driving bridge circuit.
3. The level output control method according to claim 1, characterized in that: After the step of outputting a level to the metal oxide semiconductor transistor (MOS) device according to the output mode, the step further includes: Reading a preset monitor module to obtain a timing configuration in the monitor module; Based on the timing configuration, the monitor module detects the instruction reading status of the MCU; If the instruction reading state of the MCU is stopped, a restart operation is performed on the MCU.
4. A level output control device, characterized in that: The level output control device comprises: The detection module is used to receive the operation instruction sent by the simulator, and perform status detection on the microcontroller MCU through the MCU operation status detection module to obtain the operation status of the MCU; The detection module is further used to perform software debugging through the MCU based on the operation instruction, and to monitor the program running status in real time, wherein the program running status includes one or more of the running status, memory usage, variables and register values; When the operation instruction is read as a pause and / or breakpoint, the program running status before the operation instruction is output, and instruction reading is stopped; Performing polling detection on the MCU through the MCU running status detection module to obtain the instruction reading status of the MCU; When the instruction reading state of the MCU is stopped, analysis is performed according to a preset pause state time threshold; If the time when the MCU stops reading exceeds the pause state time threshold, outputting the running state of the MCU as the pause state; Reading based on a preset counting register, obtaining a counting configuration of a timing counter when the running state of the MCU is a pause state; controlling the timing counter based on the counting configuration; An adjustment module, used for adjusting the pulse width modulation signal PWM to a corresponding output mode according to the operating state of the MCU; The output module is used to output the level of the metal oxide semiconductor transistor MOS tube device according to the output mode.
5. A terminal device, characterized in that: The terminal device includes a memory, a processor, and a level output control method program stored in the memory and executable on the processor. When the level output control method program is executed by the processor, the steps of the level output control method as described in any one of claims 1 to 3 are implemented.
6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a level output control method program, and when the level output control method program is executed by a processor, the steps of the level output control method according to any one of claims 1 to 3 are implemented.
7. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the level output control method according to any one of claims 1 to 3 are implemented.
