Direct current brush motor control method based on angle encoder feedback and related device
By using angle encoder feedback technology to convert magnetic field change signals into quadrature pulse signals and perform level conversion and frequency determination, the problem of speed and direction control accuracy of DC brushed motors in complex environments is solved, and stable motor control is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GUANG DONG RUI LIN ZHI NENG KE JI YOU XIAN GONG SI
- Filing Date
- 2026-03-30
- Publication Date
- 2026-06-19
AI Technical Summary
In applications with long signal transmission distances or strong electromagnetic interference, the steering and speed control accuracy of brushed DC motors decreases, and the communication link status identification becomes inaccurate, increasing the risk of control failure.
The magnetic field change signal is obtained by the angle encoder and converted into an orthogonal pulse signal. After level conversion, it is transmitted to the control terminal. The direction information is obtained by decoding and the pulse frequency is determined by the timer to realize the real-time determination of the communication link status, trigger the protection control strategy or generate drive commands to stabilize the motor speed and direction.
In complex environments, it enables rapid identification and secure control of communication link status, improves motor speed control accuracy, avoids misjudgment and control failure, and ensures stable motor operation.
Smart Images

Figure CN122247251A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of electrical data processing, and more specifically, to a DC brushed motor control method and related equipment based on angle encoder feedback. Background Technology
[0002] DC brushed motors are widely used in household appliances, industrial actuators, power tools, and automotive auxiliary systems due to their advantages such as simple structure, low cost, and wide speed range. In these applications, precise control of the motor's speed and direction is typically required, along with maintaining operational stability and safety under complex operating conditions or long-distance wiring environments. Therefore, real-time acquisition and reliable control of the motor's operating status are critical technical challenges.
[0003] Among the relevant technical means, Hall sensors or photoelectric encoders are often set at the motor end to obtain rotation signals, and the signals are transmitted to the control end for processing. The control end calculates the motor speed based on the collected pulse signals by counting or timing, and combines PWM drive to control the speed of the motor, so as to realize real-time detection and speed control of the motor operating status.
[0004] Although motor speed and direction can be controlled by sensor feedback signals, in application environments with long signal transmission distances or strong electromagnetic interference, the pulse signals transmitted to the control end are prone to distortion, loss, or abnormal fluctuations. This makes it difficult for the control end to identify the communication link status in a timely and accurate manner, posing a risk of misjudgment or control failure, and reducing the accuracy of motor direction and speed control. Summary of the Invention
[0005] The embodiments of this application provide a DC brushed motor control method and related equipment based on angle encoder feedback, which can improve the problem of inaccurate communication link status identification in application environments with long signal transmission distances or strong electromagnetic interference, which leads to a decrease in the accuracy of motor steering and speed control.
[0006] Other features and advantages of this application will become apparent from the following detailed description, or may be learned in part from practice of this application.
[0007] According to one aspect of the embodiments of this application, a DC brushed motor control method based on angle encoder feedback is provided, comprising: acquiring a magnetic field change signal generated by the rotation of the DC brushed motor through an angle encoder, and converting the magnetic field change signal into an orthogonal pulse signal; performing level conversion on the orthogonal pulse signal, and sending the converted orthogonal pulse signal to a control terminal; decoding the converted orthogonal pulse signal at the control terminal to obtain direction information; acquiring the pulse frequency of the converted orthogonal pulse signal through a timer at the control terminal, and determining the communication link status based on the pulse frequency; if the pulse frequency is abnormal, determining it as a communication fault or sensor fault, and triggering a corresponding protection control strategy; if the pulse frequency is not abnormal, generating a motor speed signal based on the pulse frequency, and generating a drive command according to the direction information and the motor speed signal to control the speed and direction of the DC brushed motor.
[0008] In some embodiments of this application, based on the foregoing scheme, the step of acquiring the magnetic field change signal generated by the rotation of the DC brushed motor through an angle encoder and converting the magnetic field change signal into an orthogonal pulse signal includes: setting an angle encoder based on the AMR magnetoresistive effect at the output shaft of the DC brushed motor, acquiring the magnetic field change signal generated by the rotation of the DC brushed motor through the angle encoder; inputting the magnetic field change signal into the Wheatstone bridge inside the AMR magnetoresistive sensor chip to obtain a sine signal and a cosine signal with a phase difference of 90°; and shaping the sine signal and the cosine signal to obtain a square wave digital signal with a 90° phase difference as an orthogonal pulse signal.
[0009] In some embodiments of this application, based on the foregoing scheme, the angle encoder includes a permanent magnet fixedly mounted on the end of the output shaft and an AMR magnetoresistive sensor chip arranged opposite to the permanent magnet. The permanent magnet rotates synchronously with the output shaft so that the direction of the external magnetic field at the location of the AMR magnetoresistive sensor chip changes periodically.
[0010] In some embodiments of this application, based on the aforementioned scheme, the step of level-converting the quadrature pulse signal and sending the converted quadrature pulse signal to the control terminal, and decoding the converted quadrature pulse signal at the control terminal to obtain direction information, includes: converting the voltage amplitude of the quadrature pulse signal through a level-conversion circuit to convert the quadrature pulse signal from a first voltage domain on the encoder side to a second voltage domain on the control terminal side, and sending the converted quadrature pulse signal to the control terminal through a signal transmission cable; performing edge detection on the A-phase pulse signal and B-phase pulse signal in the received quadrature pulse signal through the quadrature decoder in the control terminal, counting the rising and falling edges of the A-phase pulse signal and the B-phase pulse signal, and determining the counting direction based on the phase relationship of the A-phase pulse signal and the B-phase pulse signal to obtain direction information.
[0011] In some embodiments of this application, based on the aforementioned scheme, the step of obtaining the pulse frequency of the converted quadrature pulse signal through the timer of the control terminal and determining the communication link status based on the pulse frequency includes: capturing two adjacent rising edges of the A-phase pulse signal or the B-phase pulse signal of the quadrature pulse signal through the capture timer in the control terminal, recording the timer count value corresponding to the capture time, calculating the time interval between adjacent pulses based on the difference between the two count values, and calculating the pulse frequency based on the time interval; comparing the pulse frequency with a preset effective range interval, and if the pulse frequency exceeds the effective range interval, or if no pulse signal is detected within a preset time, then determining that the current communication link status is abnormal.
[0012] In some embodiments of this application, based on the foregoing scheme, the protection control strategy includes: when a communication failure or sensor failure is determined, using the control terminal to output a stop drive command to cut off the drive signal to the DC brushed motor, or outputting a limiting drive command to limit the operating speed of the DC brushed motor; and / or, using the control terminal to maintain the current drive state unchanged and stop updating the drive command to prevent malfunctions caused by abnormal signals; and / or, using the control terminal to output fault indication information to indicate that there is an abnormality in the communication link or sensor.
[0013] In some embodiments of this application, based on the aforementioned scheme, the step of generating a motor speed signal based on the pulse frequency and generating a drive command to control the speed and direction of the DC brushed motor according to the direction information and the motor speed signal includes: calculating the motor speed signal based on the pulse frequency and the number of pulses per revolution of the angle encoder; inputting the motor speed signal and a preset speed target value to a speed closed-loop controller to generate a drive adjustment amount according to the speed deviation and generate a corresponding PWM drive signal; and jointly controlling the speed and direction of the DC brushed motor based on the direction information and the PWM drive signal.
[0014] According to another aspect of the embodiments of this application, a DC brushed motor control device based on angle encoder feedback is provided, comprising: a signal acquisition module, configured to acquire a magnetic field change signal generated by the rotation of the DC brushed motor through an angle encoder, and convert the magnetic field change signal into an orthogonal pulse signal; a signal conversion module, configured to perform level conversion on the orthogonal pulse signal, and send the converted orthogonal pulse signal to a control terminal, wherein the control terminal decodes the converted orthogonal pulse signal to obtain direction information; a frequency acquisition module, configured to acquire the pulse frequency of the converted orthogonal pulse signal through a timer of the control terminal, and determine the communication link status based on the pulse frequency, wherein if the pulse frequency is abnormal, it is determined to be a communication fault or a sensor fault, and a corresponding protection control strategy is triggered; and a motor control module, configured to generate a motor speed signal based on the pulse frequency if the pulse frequency is not abnormal, and generate a drive command according to the direction information and the motor speed signal to control the speed and direction of the DC brushed motor.
[0015] According to another aspect of the embodiments of this application, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program that can run on the processor, and the processor executes the computer program to implement the DC brushed motor control method based on angle encoder feedback as described above.
[0016] According to another aspect of the embodiments of this application, a computer-readable storage medium is provided having a computer program stored thereon, which, when run by a processor, causes the processor to perform the DC brushed motor control method based on angle encoder feedback as described above.
[0017] Compared with the prior art, this application has the following advantages: It acquires the magnetic field change signal generated by the rotation of the DC brushed motor through an angle encoder, converts it into an orthogonal pulse signal with a fixed phase difference, and transmits it to the control terminal for decoding after level conversion to obtain direction information and pulse frequency. Based on the comparison result of the pulse frequency with a preset effective range, it realizes real-time determination of the communication link status. When a communication fault or sensor fault is determined, a protection control strategy is triggered. When the communication link status is normal, the motor speed signal is calculated based on the pulse frequency, and combined with the direction information, the speed and direction of the DC brushed motor are jointly controlled. This ensures speed control accuracy while achieving rapid identification and safe control of communication link anomalies, improving the problem of inaccurate communication link status identification in application environments with long signal transmission distances or strong electromagnetic interference, which leads to a decrease in the accuracy of motor direction and speed control. Attached Figure Description
[0018] Figure 1 This is a flowchart illustrating the DC brushed motor control method based on angle encoder feedback provided in an embodiment of the present invention. Figure 2 This is a schematic diagram illustrating the principle of AMR angle encoder signal conversion provided in an embodiment of the present invention; Figure 3 This is a schematic diagram of the voltage signal waveform provided in an embodiment of the present invention; Figure 4 This is a schematic block diagram of the orthogonal pulse signal level conversion circuit provided in an embodiment of the present invention; Figure 5 This is a schematic diagram of orthogonal decoding and direction determination provided in an embodiment of the present invention; Figure 6 This is a logic diagram of pulse frequency acquisition and communication link fault judgment provided in an embodiment of the present invention; Figure 7 This is a schematic block diagram of the structure of the DC brushed motor control device based on angle encoder feedback provided in an embodiment of the present invention; Figure 8 This is a schematic block diagram of the structure of the electronic device provided in the embodiment of the present invention.
[0019] Explanation of reference numerals in the attached figures: 10. DC brushed motor control device based on angle encoder feedback; 11. Signal acquisition module; 12. Signal conversion module; 13. Frequency acquisition module; 14. Motor control module; 20. Electronic equipment; 21. Memory; 22. Processor. Detailed Implementation
[0020] Exemplary embodiments will now be described in a more comprehensive manner with reference to the accompanying drawings. However, the exemplary embodiments can be implemented in various forms and should not be construed as limited to these examples; rather, these embodiments are provided so that this application will be more comprehensive and complete, and will fully convey the concept of the exemplary embodiments to those skilled in the art.
[0021] Furthermore, the features, structures, or characteristics described in this application can be combined in any suitable manner in one or more embodiments. Numerous specific details are provided in the following description to provide a full understanding of the embodiments of this application. However, those skilled in the art will recognize that when implementing the technical solutions of this application, not all the detailed features in the embodiments may be used, one or more specific details may be omitted, or other methods, elements, devices, steps, etc., may be employed.
[0022] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0023] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all content and operations / steps, nor do they necessarily have to be performed in the described order. For example, some operations / steps can be broken down, while others can be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.
[0024] It should be noted that "multiple" in this article refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.
[0025] The technical solution of the present invention will be further described below with reference to the accompanying drawings and specific embodiments.
[0026] like Figure 1 As shown, this application provides a DC brushed motor control method based on angle encoder feedback. This method enables stable control of the DC brushed motor's speed and direction in application environments with long signal transmission distances and electromagnetic interference, and allows for real-time assessment of the communication link status. The method specifically includes the following steps: Step S100: Obtain the magnetic field change signal generated by the rotation of the DC brushed motor through the angle encoder, and convert the magnetic field change signal into an orthogonal pulse signal.
[0027] The magnetic field change signal is acquired by an angle encoder located near the output shaft of a DC brushed motor. The magnetic field change signal is a magnetic flux density vector change signal whose direction changes with the rotation of the output shaft. The angle encoder internally acquires the magnetic field change signal as an analog signal and outputs a continuously changing electrical signal corresponding to the rotation angle. Then, the continuously changing electrical signal is phase separated and shaped to convert it into two digital pulse signals with a phase difference of 90°, which are output as orthogonal pulse signals. The two orthogonal pulse signals are denoted as phase A and phase B, respectively, and the phase relationship between phase A and phase B is used to characterize the rotation direction.
[0028] like Figure 2 and Figure 3 As shown, when the angle encoder detects the rotation of the output shaft, it converts the magnetic field change signal into two analog voltage signals, V_sin and V_cos, which are orthogonal. A comparator compares V_sin with a reference voltage V_ref to obtain the A-phase pulse signal, and a comparator compares V_cos with the reference voltage V_ref to obtain the B-phase pulse signal. The reference voltage V_ref is half the power supply voltage. When V_sin is higher than V_ref, the output is high; when it is lower than V_ref, the output is low, resulting in a square wave signal with a duty cycle close to 50%. The phase difference between the A-phase and B-phase pulse signals is 90°. When the A-phase pulse signal leads the B-phase pulse signal, the rotation is clockwise; when the A-phase pulse signal lags the B-phase pulse signal, the rotation is counterclockwise.
[0029] In another example, step S100 can also be implemented as follows: An angle encoder based on the AMR magnetoresistive effect is installed at the output shaft of a DC brushed motor to acquire the magnetic field change signal generated by the rotation of the DC brushed motor. The angle encoder includes a permanent magnet fixedly mounted at the end of the output shaft and an AMR magnetoresistive sensor chip arranged opposite to the permanent magnet. The permanent magnet rotates synchronously with the output shaft, so that the direction of the external magnetic field at the location of the AMR magnetoresistive sensor chip changes periodically.
[0030] The permanent magnet adopts a radial magnetization structure, so that its magnetic poles are distributed along the circumference. The AMR magnetoresistive sensor chip is fixedly mounted on the motor housing, and its sensitive direction forms an angle with the path of change of the magnetic field direction of the permanent magnet. As the output shaft rotates, the direction of the magnetic field generated by the permanent magnet changes periodically at the AMR magnetoresistive sensor chip, thereby causing a change in the internal resistance value of the AMR magnetoresistive sensor chip, and then outputting the corresponding analog voltage signal.
[0031] For example, the permanent magnet is a two-pole radially magnetized steel with a magnetic induction intensity of 50mT to 100mT; the AMR magnetoresistive sensor chip is installed at a distance of 1mm to 3mm from the permanent magnet to ensure that the magnetic field intensity is within the linear response range of the sensor; when the output shaft rotates at a speed of 1000 revolutions per minute, the frequency of the analog voltage signal output by the AMR magnetoresistive sensor chip changes proportionally to the rotation speed.
[0032] The magnetic field change signal is input into the Wheatstone bridge inside the AMR magnetoresistive sensor chip to obtain a sine signal and a cosine signal with a phase difference of 90°.
[0033] The two sets of Wheatstone bridges each consist of four magnetoresistive elements. The magnetoresistive elements in each set of Wheatstone bridges are arranged at 45° angles to each other, so that the two sets of Wheatstone bridges have a 90° phase difference in response to changes in the direction of the magnetic field. When the direction of the magnetic field changes, the two sets of Wheatstone bridges output sine and cosine signals respectively. The amplitude range of the sine and cosine signals is determined by the supply voltage and bridge parameters.
[0034] For example, the Wheatstone bridge is powered by 5V, and the amplitude of the bridge output signal varies within the range of 2V±1V. When the magnetic field direction angle is 0°, the sine signal output is 0V and the cosine signal output is at its maximum value. When the magnetic field direction angle is 90°, the sine signal output is at its maximum value and the cosine signal output is 0V, thus forming an orthogonal relationship.
[0035] The sine and cosine signals are shaped to obtain square wave digital signals with a 90° phase difference, which are used as orthogonal pulse signals. The phase lead or lag relationship of the orthogonal pulse signals corresponds to the rotation direction of the DC brushed motor.
[0036] By setting comparators or Schmitt triggers to perform waveform shaping on sine and cosine signals, continuously changing analog signals are converted into digital square wave signals; the threshold of the comparator is set to the median voltage of the signal, so that the output signal has stable high and low level switching; the Schmitt trigger is used to enhance the anti-interference capability and avoid false triggering caused by signal jitter.
[0037] For example, an LM393 comparator is used to compare and process sine and cosine signals, with the comparison threshold set to 2.5V. When the input signal is higher than 2.5V, the output is high-level, and when it is lower than 2.5V, the output is low-level. By adding a filter network consisting of a 10kΩ resistor and a 100nF capacitor to the input of the comparator, high-frequency noise is filtered out, thereby obtaining a stable quadrature pulse signal.
[0038] Step S200: The quadrature pulse signal is level-converted and the converted quadrature pulse signal is sent to the control terminal. The converted quadrature pulse signal is decoded at the control terminal to obtain the direction information.
[0039] The quadrature pulse signal output by the angle encoder is level matched to meet the voltage requirements of the control terminal input interface. After level conversion, the converted quadrature pulse signal is sent to the control terminal via a transmission cable. After receiving the converted quadrature pulse signal, the control terminal performs phase relationship analysis on the A-phase pulse signal and the B-phase pulse signal to determine the rotation direction of the DC brushed motor.
[0040] When the angle encoder output level is 5V logic level and the control terminal input interface is 3.3V logic level, the 5V level is converted to 3.3V level through a level conversion circuit. A dual-channel level conversion chip is used to synchronously convert the A-phase pulse signal and the B-phase pulse signal and transmit them to the control terminal through a twisted pair. The control terminal detects the rising edge sequence of the A-phase pulse signal and the B-phase pulse signal. When the A-phase pulse signal rises before the B-phase pulse signal, it is determined to be forward rotation. When the B-phase pulse signal rises before the A-phase pulse signal, it is determined to be reverse rotation.
[0041] like Figure 4 As shown, in another example, step S200 may also preferably be implemented as follows: The quadrature pulse signal is converted into a voltage amplitude by a level conversion circuit, so as to convert the quadrature pulse signal from the first voltage domain on the encoder side to the second voltage domain on the control side, and then the converted quadrature pulse signal is sent to the control end through a signal transmission cable.
[0042] The level conversion circuit includes an input current-limiting resistor, a clamping diode, and a level shifting unit. The input current-limiting resistor is used to limit the input current, the clamping diode is used to prevent overvoltage input from damaging the subsequent circuit, and the level shifting unit uses a transistor or MOSFET to achieve voltage domain conversion. The signal transmission cable adopts a differential transmission structure to improve anti-interference capability.
[0043] For example, when the encoder output is 5V and the control input is 3.3V, the input current limiting resistor is selected as 1kΩ, the clamping diode is a Schottky diode, and the level shifting unit uses an N-channel MOSFET to achieve level conversion; the signal transmission cable is 2 to 10 meters long, and the twisted pair structure reduces the impact of external electromagnetic interference on the signal.
[0044] The quadrature decoder in the control terminal performs edge detection on the A-phase pulse signal and the B-phase pulse signal in the received quadrature pulse signal, counts the rising edge and falling edge of the A-phase pulse signal and the B-phase pulse signal, and determines the counting direction based on the phase relationship between the A-phase pulse signal and the B-phase pulse signal to obtain the direction information.
[0045] like Figure 5As shown, the quadrature decoder uses a quadrature decoding algorithm with four times the frequency to detect both the rising and falling edges of the A-phase pulse signal and the B-phase pulse signal. When an edge change is detected, the counting direction is determined based on the combination relationship between the current state and the previous state, and a direction flag is output. The direction flag is used to characterize the current rotation direction of the DC brushed motor.
[0046] For example, the internal timer of the control terminal is configured in encoder interface mode to detect four state combinations (00, 01, 11, 10) of the A-phase pulse signal and the B-phase pulse signal. When the state changes in the order of 00→01→11→10→00, the counting direction is positive; when the state changes in the order of 00→10→11→01→00, the counting direction is negative. The direction flag bit is high logic level to indicate positive and low logic level to indicate negative.
[0047] In another example, the step of obtaining the pulse frequency of the converted quadrature pulse signal through a timer on the control end and determining the communication link status based on the pulse frequency can preferably be implemented in the following manner: The capture timer in the control terminal captures two adjacent rising edges of the A-phase or B-phase pulse signal of the quadrature pulse signal and records the timer count value corresponding to the capture time. The time interval T between adjacent pulses is calculated based on the difference between the two count values, and the pulse frequency f is calculated based on the time interval; where the pulse frequency f = 1 / T.
[0048] The capture timer operates at a fixed clock frequency, and the timer count increases over time. When the rising edge of the A-phase pulse signal or the B-phase pulse signal is detected, an input capture event is triggered and the current count value is recorded. The time interval T is calculated by calculating the difference between the count values of the two capture events and combining it with the timer clock frequency. The pulse frequency f is then obtained according to the frequency calculation formula.
[0049] For example, if the capture timer clock frequency is set to 1MHz, the corresponding counting resolution is 1μs; if the two rising edge capture count values are 1000 and 2000 respectively, then the time interval T is 1000μs, and the corresponding pulse frequency f is 1kHz; when the motor speed increases, the time interval T decreases, and the pulse frequency f increases.
[0050] The control terminal pre-stores the effective range interval of the pulse frequency [f_min, f_max] and compares the pulse frequency with the preset effective range interval. If the pulse frequency exceeds the effective range interval, or if no pulse signal is detected within the preset time, the current communication link status is determined to be abnormal.
[0051] The effective range is determined based on the rated speed range of the DC brushed motor, the number of pulses per revolution of the angle encoder, and the sampling period of the control terminal. By continuously sampling the pulse frequency, when the pulse frequency exceeds the effective range for multiple consecutive sampling periods, it is determined to be an abnormal state. When no pulse signal is detected within the preset timeout period, it is determined to be a signal loss.
[0052] For example, if the rated speed of a DC brushed motor is 3000 rpm and the number of pulses per revolution of the angle encoder is 1000, then the corresponding pulse frequency range is 0 Hz to 50 kHz; the effective range is set to [10 Hz, 55 kHz], where 10 Hz is the minimum detection threshold and 55 kHz is the upper limit tolerance; if the pulse frequency is less than 10 Hz or greater than 55 kHz for 5 consecutive sampling periods, it is determined that the communication link is abnormal; if no pulse signal is detected within 10 ms, it is determined that the sensor is faulty.
[0053] Step S300: Obtain the pulse frequency of the converted quadrature pulse signal through the timer on the control terminal, and determine the communication link status based on the pulse frequency. If the pulse frequency is abnormal, it is determined to be a communication fault or a sensor fault, and the corresponding protection control strategy is triggered. The protection control strategy includes: when a communication fault or sensor fault is determined, using the control terminal to output a stop drive command to cut off the drive signal to the DC brushed motor, or outputting a limiting drive command to limit the operating speed of the DC brushed motor; and / or, using the control terminal to maintain the current drive state and stop updating the drive command to prevent malfunctions caused by abnormal signals; and / or, using the control terminal to output fault indication information to indicate that there is an abnormality in the communication link or sensor.
[0054] like Figure 6 As shown, the control terminal generates a link status flag bit based on the pulse frequency obtained in step S200 and its comparison result with the effective range interval. When the link status flag bit indicates an abnormality, the control terminal directly controls the drive signal output path through the internal logic control unit. Specifically, this includes shutting down the PWM output channel or adjusting the PWM duty cycle to a preset limit value, while latching the current drive status register value to prevent the drive signal from being overwritten by abnormal data. The stop drive instruction is implemented by setting the PWM signal duty cycle to 0, and the limit drive instruction is implemented by limiting the PWM signal duty cycle to below a preset maximum duty cycle threshold. At the same time, the control terminal sets the fault flag register and drives the external indicator interface to output fault indication information. The fault indication information includes level signals or communication data frames, which are used to indicate the abnormal status of the communication link or sensor.
[0055] When the pulse frequency is detected to be outside the effective range for 5 consecutive sampling cycles, the control terminal sets the link status flag to an abnormal state and directly sets the PWM duty cycle to 0, thereby stopping the operation of the DC brushed motor. When the pulse frequency fluctuates briefly but does not continuously exceed the threshold, the PWM duty cycle is limited to below 30% to reduce the motor speed. In another case, when the control terminal detects that the pulse signal has not appeared within 10ms, the current PWM duty cycle is kept unchanged and updates are stopped to avoid sudden changes in the drive signal due to signal loss. At the same time, the drive indicator light is lit by pulling the GPIO output pin high, or a data frame containing a fault code is sent through the serial communication interface to indicate that there is an abnormality in the communication link or sensor.
[0056] Step S400: If the pulse frequency is not abnormal, a motor speed signal is generated based on the pulse frequency, and a drive command is generated based on the direction information and the motor speed signal to control the speed and direction of the DC brushed motor.
[0057] When the link status flag indicates a normal state, the control terminal uses the pulse frequency as the input for speed calculation and combines it with the direction information to generate drive control parameters. The direction information is used to determine the polarity of the drive signal or the switching control logic, and the motor speed signal is used to adjust the duty cycle of the PWM signal. The control terminal internally calculates the drive adjustment amount based on the difference between the current motor speed signal and the target speed, and outputs the corresponding PWM drive signal to the drive circuit, thereby realizing the control of the speed and direction of the DC brushed motor.
[0058] When the direction information indicates positive, the control terminal controls the first set of switching devices in the drive circuit to turn on and the second set of switching devices to turn off; when the direction information indicates negative, the control terminal controls the first set of switching devices to turn off and the second set of switching devices to turn on; at the same time, the PWM duty cycle is adjusted according to the difference between the motor speed signal and the target speed. When the actual speed is lower than the target speed, the duty cycle is increased, and when the actual speed is higher than the target speed, the duty cycle is decreased, thereby realizing closed-loop speed regulation control.
[0059] In another example, the steps of generating a motor speed signal based on the pulse frequency and generating a drive command based on the direction information and the motor speed signal to control the speed and direction of the DC brushed motor can also be preferably performed as follows: Under normal communication link conditions, the control terminal calculates the motor speed signal n based on the pulse frequency f and the number of pulses per revolution PPR of the angle encoder according to the formula n=60×f / PPR.
[0060] Pulses per revolution (PPR) is the total number of pulses generated by the angle encoder in one revolution. This parameter is stored as a parameter in the control terminal. The control terminal calculates the pulse frequency f based on the capture timer and substitutes it into the speed calculation formula to obtain the motor speed signal n, where the unit of n is revolutions per minute. This calculation process is executed in the timer interrupt or periodic task of the control terminal to ensure the real-time update of the speed signal.
[0061] When the number of pulses per revolution (PPR) of the angle encoder is 1000 and the measured pulse frequency (f) is 2000Hz, the motor speed signal (n) is calculated to be 120rpm according to the formula n=60×f / PPR. When the pulse frequency (f) increases to 10000Hz, the corresponding motor speed signal (n) is 600rpm, thus realizing a linear mapping relationship between speed and pulse frequency.
[0062] The control terminal inputs the motor speed signal n and the preset speed target value to the speed closed-loop controller. The speed closed-loop controller generates a drive adjustment amount based on the speed deviation, and the PWM signal generation module generates the corresponding PWM drive signal.
[0063] The speed closed-loop controller adopts a proportional-integral-derivative control algorithm, i.e., PID control algorithm, which generates the drive adjustment amount by calculating the speed deviation, the integral value of the deviation, and the rate of change of the deviation. The preset speed target value is set by external input or internally by the control terminal and stored in the register. The PWM signal generation module calculates the corresponding duty cycle according to the drive adjustment amount and outputs a fixed frequency PWM drive signal.
[0064] For example, if the preset target speed is set to 500 rpm, when the actual motor speed signal n is 400 rpm, the speed closed-loop controller calculates the speed deviation as 100 rpm and outputs the drive adjustment amount according to the PID control algorithm, so that the PWM duty cycle is increased from 40% to 55%; when the actual motor speed signal n is 520 rpm, the speed deviation is -20 rpm, and the controller reduces the PWM duty cycle to 45%, thereby stabilizing the motor speed.
[0065] The speed and direction of a brushed DC motor are jointly controlled based on direction information and PWM drive signals.
[0066] The control unit combines the PWM drive signal with the direction information, and controls the polarity switching and amplitude adjustment of the armature voltage by controlling the conduction state of the switching devices in the drive circuit. The PWM drive signal determines the average value of the motor input voltage, thereby controlling the speed, and the direction information determines the polarity of the motor armature voltage, thereby controlling the direction. The two work together to achieve joint control of the speed and direction of the DC brushed motor.
[0067] When the PWM duty cycle is 60% and the direction information is positive, the control terminal makes the motor run in the forward direction at a higher speed; when the PWM duty cycle is 30% and the direction information is reverse, the control terminal makes the motor run in the reverse direction at a lower speed; by continuously adjusting the PWM duty cycle and direction information, the stable operation of the DC brushed motor under different operating conditions can be achieved.
[0068] In this embodiment, an angle encoder acquires the magnetic field change signal generated by the rotation of the DC brushed motor and converts the magnetic field change signal into an orthogonal pulse signal. Subsequently, the orthogonal pulse signal is level-converted and sent to the control terminal. The control terminal decodes the converted orthogonal pulse signal to obtain direction information. Based on this, the pulse frequency of the converted orthogonal pulse signal is acquired by a timer on the control terminal, and the communication link status is judged based on the pulse frequency. When the pulse frequency is abnormal, it is determined to be a communication fault or sensor fault, and the corresponding protection control strategy is triggered. When the pulse frequency is not abnormal, a motor speed signal is generated based on the pulse frequency, and a drive command is generated according to the direction information and the motor speed signal to realize the speed and direction control of the DC brushed motor, thereby completing a complete closed-loop process from signal acquisition, signal transmission, status judgment to control execution.
[0069] The magnetic field change signal is acquired by an angle encoder and converted into an orthogonal pulse signal. While ensuring the availability of direction information, the level conversion of the converted orthogonal pulse signal improves the anti-interference capability of the signal during transmission. Furthermore, the pulse frequency of the converted orthogonal pulse signal is acquired by a timer at the control end, and the communication link status is judged based on the pulse frequency. This allows the system to promptly identify communication faults or sensor faults and trigger protection control strategies when the signal is abnormal, thereby preventing abnormal signals from participating in control. When the communication link status is normal, the motor speed signal is generated based on the pulse frequency, and drive commands are generated in combination with the direction information to achieve stable control of the speed and direction of the DC brushed motor. Through the above method, the problem of difficulty in judging communication link abnormalities during signal transmission is effectively solved, improving the reliability and safety of system control. It also improves the problem of inaccurate communication link status identification, which leads to a decrease in the accuracy of motor direction and speed control, in application environments with long signal transmission distances or strong electromagnetic interference.
[0070] like Figure 7 As shown, this application also provides a DC brushed motor control device 10 based on angle encoder feedback, comprising: The signal acquisition module 11 is used to acquire the magnetic field change signal generated by the rotation of the DC brushed motor through the angle encoder, and convert the magnetic field change signal into an orthogonal pulse signal.
[0071] The signal conversion module 12 is used to perform level conversion on the quadrature pulse signal and send the converted quadrature pulse signal to the control terminal. The control terminal decodes the converted quadrature pulse signal to obtain direction information.
[0072] The frequency acquisition module 13 is used to acquire the pulse frequency of the converted quadrature pulse signal through the timer of the control terminal, and to determine the communication link status based on the pulse frequency. If the pulse frequency is abnormal, it is determined to be a communication fault or a sensor fault, and the corresponding protection control strategy is triggered.
[0073] The motor control module 14 is used to generate a motor speed signal based on the pulse frequency if there is no abnormality in the pulse frequency, and generate drive commands based on the direction information and the motor speed signal to control the speed and direction of the DC brushed motor.
[0074] In this embodiment, the control process of the DC brushed motor is divided into a signal acquisition module 11, a signal conversion module 12, a frequency acquisition module 13, and a motor control module 14. Data is transmitted between the modules according to the processing link of "magnetic field change signal, orthogonal pulse signal, direction information and pulse frequency, motor speed signal, and drive command". The magnetic field change signal can be stably acquired and converted into an orthogonal pulse signal with a clear phase relationship after being converted by an angle encoder. After level conversion, it is transmitted to the control terminal for decoding to obtain direction information. At the same time, a timer is used to periodically measure the orthogonal pulse signal to obtain the pulse frequency and compare it with a preset effective range to determine the communication link status. When the pulse frequency is abnormal, the drive signal is stopped or limited by triggering a protection control strategy. When the pulse frequency is normal, the motor speed signal is calculated based on the pulse frequency and combined with the direction information to generate a drive command. This achieves stable control of the speed and direction of the DC brushed motor and avoids malfunction or loss of control in the case of abnormal signals, thereby improving the reliability and safety of the overall control process.
[0075] It should be noted that although several modules or units for the device of action execution have been mentioned in the detailed description above, this division is not mandatory. In fact, according to the embodiments of this application, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.
[0076] like Figure 8 As shown, this application example also provides an electronic device 20, including a memory 21 and a processor 22. The memory 21 stores a computer program that can run on the processor 22. When the processor 22 executes the computer program, it implements the above-described DC brushed motor control method based on angle encoder feedback.
[0077] In this embodiment, by setting a memory 21 and a processor 22 in the electronic device 20, and storing a computer program in the memory 21 for implementing a DC brushed motor control method based on angle encoder feedback, the processor 22 can sequentially complete the acquisition of magnetic field change signals, conversion of quadrature pulse signals, level conversion and decoding to obtain direction information, pulse frequency calculation, and communication link status determination when executing the computer program. Based on this, it generates motor speed signals and drive commands according to the pulse frequency and direction information. Thus, the control process that originally relied on discrete hardware logic is implemented in a programmatic way in the electronic device 20, so that the control flow has a clear execution order and parameter processing logic. At the same time, when the pulse frequency is abnormal, the protection control strategy is triggered by the program control, and the speed closed-loop control is executed when the pulse frequency is normal, thereby improving the configurability, maintainability and operational stability of the control process.
[0078] This application also provides a computer-readable storage medium having a computer program stored thereon, which, when run by a processor, causes the processor to execute the aforementioned DC brushed motor control method based on angle encoder feedback.
[0079] In this embodiment, by storing a computer program for implementing a DC brushed motor control method based on angle encoder feedback in a computer-readable storage medium, the processor, when reading and running the computer program, can complete the conversion processing from magnetic field change signal to orthogonal pulse signal, level conversion and decoding to obtain direction information, pulse frequency calculation based on timer, and communication link status determination according to a preset processing flow. When the pulse frequency is determined to be abnormal, the corresponding protection control strategy is executed. When the pulse frequency is determined to be normal, the motor speed signal is generated based on the pulse frequency and the drive command is generated by combining the direction information. Thus, the control method is deployed and reused by using the storage medium as a carrier, so that the control method can be loaded and executed in different electronic devices, ensuring the consistency of control logic and improving the stability and reliability of the DC brushed motor control process.
[0080] From the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this application can be embodied in the form of a software product, which can be stored on a non-volatile storage medium (such as a CD). The method is contained in or on a ROM (such as a USB flash drive, a portable hard drive, etc.) and includes several instructions to cause an electronic device (such as a personal computer, a server, a touch terminal, or a network device, etc.) to perform the method according to the embodiments of this application.
[0081] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the embodiments disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein.
[0082] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.
Claims
1. A DC brushed motor control method based on angle encoder feedback, characterized in that, include: The magnetic field change signal generated by the rotation of the DC brushed motor is obtained by an angle encoder, and the magnetic field change signal is converted into an orthogonal pulse signal. The orthogonal pulse signal is level-converted, and the converted orthogonal pulse signal is sent to the control terminal. The control terminal decodes the converted orthogonal pulse signal to obtain direction information. The pulse frequency of the converted quadrature pulse signal is obtained by the timer of the control terminal, and the communication link status is determined based on the pulse frequency. If the pulse frequency is abnormal, it is determined to be a communication failure or a sensor failure, and the corresponding protection control strategy is triggered. If the pulse frequency is not abnormal, a motor speed signal is generated based on the pulse frequency, and a drive command is generated according to the direction information and the motor speed signal to control the speed and direction of the DC brushed motor.
2. The DC brushed motor control method based on angle encoder feedback according to claim 1, characterized in that, The step of acquiring the magnetic field change signal generated by the rotation of the DC brushed motor through an angle encoder and converting the magnetic field change signal into an orthogonal pulse signal includes: An angle encoder based on the AMR magnetoresistive effect is installed at the output shaft of a DC brushed motor to acquire the magnetic field change signal generated by the rotation of the DC brushed motor. The magnetic field change signal is input into the Wheatstone bridge inside the AMR magnetoresistive sensor chip to obtain a sine signal and a cosine signal with a phase difference of 90°. The sine and cosine signals are shaped to obtain a square wave digital signal with a 90° phase difference, which is then used as an orthogonal pulse signal.
3. The DC brushed motor control method based on angle encoder feedback according to claim 2, characterized in that, The angle encoder includes a permanent magnet fixedly mounted on the end of the output shaft and an AMR magnetoresistive sensor chip arranged opposite to the permanent magnet. The permanent magnet rotates synchronously with the output shaft so that the direction of the external magnetic field at the location of the AMR magnetoresistive sensor chip changes periodically.
4. The DC brushed motor control method based on angle encoder feedback according to claim 1, characterized in that, The steps of level conversion of the orthogonal pulse signal, sending the converted orthogonal pulse signal to the control terminal, and decoding the converted orthogonal pulse signal at the control terminal to obtain direction information include: The quadrature pulse signal is converted into voltage amplitude through a level conversion circuit to convert the quadrature pulse signal from the first voltage domain on the encoder side to the second voltage domain on the control side, and the converted quadrature pulse signal is sent to the control end through a signal transmission cable; The quadrature decoder in the control terminal performs edge detection on the A-phase pulse signal and the B-phase pulse signal in the received quadrature pulse signal, counts the rising edge and falling edge of the A-phase pulse signal and the B-phase pulse signal, and determines the counting direction based on the phase relationship of the A-phase pulse signal and the B-phase pulse signal to obtain direction information.
5. The DC brushed motor control method based on angle encoder feedback according to claim 1, characterized in that, The step of acquiring the pulse frequency of the converted quadrature pulse signal through the timer of the control terminal and determining the communication link status based on the pulse frequency includes: The capture timer in the control terminal captures two adjacent rising edges of the A-phase pulse signal or the B-phase pulse signal of the quadrature pulse signal, records the timer count value corresponding to the capture time, calculates the time interval between adjacent pulses based on the difference between the two count values, and calculates the pulse frequency based on the time interval. The pulse frequency is compared with a preset effective range. If the pulse frequency exceeds the effective range, or if no pulse signal is detected within a preset time, the current communication link status is determined to be abnormal.
6. The DC brushed motor control method based on angle encoder feedback according to claim 1, characterized in that, The protection and control strategy includes: When a communication failure or sensor failure is detected, the control terminal outputs a stop drive command to cut off the drive signal to the DC brushed motor, or outputs a limit drive command to limit the running speed of the DC brushed motor. And / or, use the control terminal to maintain the current drive state unchanged and stop updating drive instructions to prevent malfunctions caused by abnormal signals; And / or, use the control terminal to output fault indication information to indicate that there is an abnormality in the communication link or sensor.
7. The DC brushed motor control method based on angle encoder feedback according to claim 1, characterized in that, The step of generating a motor speed signal based on the pulse frequency, and generating a drive command based on the direction information and the motor speed signal to control the speed and direction of the DC brushed motor includes: The motor speed signal is calculated based on the pulse frequency and the number of pulses per revolution of the angle encoder; The motor speed signal and the preset speed target value are input to the speed closed-loop controller to generate a drive adjustment amount based on the speed deviation and generate a corresponding PWM drive signal; The speed and direction of the DC brushed motor are jointly controlled based on the direction information and the PWM drive signal.
8. A DC brushed motor control device based on angle encoder feedback, characterized in that, include: The signal acquisition module is used to acquire the magnetic field change signal generated by the rotation of the DC brushed motor through the angle encoder, and convert the magnetic field change signal into an orthogonal pulse signal. The signal conversion module is used to perform level conversion on the orthogonal pulse signal and send the converted orthogonal pulse signal to the control terminal, where the control terminal decodes the converted orthogonal pulse signal to obtain direction information; The frequency acquisition module is used to acquire the pulse frequency of the converted quadrature pulse signal through the timer of the control terminal, and to determine the communication link status based on the pulse frequency. If the pulse frequency is abnormal, it is determined to be a communication fault or a sensor fault, and the corresponding protection control strategy is triggered. The motor control module is used to generate a motor speed signal based on the pulse frequency if the pulse frequency is not abnormal, and to generate a drive command based on the direction information and the motor speed signal to control the speed and direction of the DC brushed motor.
9. An electronic device, characterized in that, The device includes a memory and a processor, the memory storing a computer program that can run on the processor, and the processor executing the computer program to implement the DC brushed motor control method based on angle encoder feedback as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, It stores a computer program that, when executed by a processor, causes the processor to perform the DC brushed motor control method based on angular encoder feedback as described in any one of claims 1 to 7.