Articulated motor module layered control system
Patent Information
- Application Number
- CN202611246098.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-17
- Publication Date
- 2026-10-16
AI Technical Summary
在位置控制过程中,容易在接近目标位置时产生冲击、过冲或者往复振荡等问题
[0020]本发明至少具有以下有益效果:本发明通过硬件同步触发ADC注入采样,确保了电流反馈值的实时性和一致性,避免了软件异步采样带来的误差。位置规划环、速度环和电流环按照不同频率分频执行,既保证了电流环对实时性的严苛要求,又合理分配了主控制器的运算资源,防止了高频率位置计算导致的算力过载,使得关节电机在带载运行时响应迅速且稳定可靠。本发明主要用于电机技术领域。
Smart Images

Figure CN122932504A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of motor technology, specifically to a layered control system for a joint motor module. Background Technology
[0002] In brushless motor control systems, the FOC (Field-Oriented Control) framework is primarily used. However, this control method is prone to issues such as significant low-speed jitter, heavy computational burden, chaotic response hierarchy, and improper inter-loop coupling. During position control, it is susceptible to problems like impacts, overshoot, or reciprocating oscillations when approaching the target position. Therefore, improving the control quality of motors is a crucial technical issue that urgently needs research in the industry. Summary of the Invention
[0003] The present invention provides a layered control system for a joint motor module to solve one or more technical problems existing in the prior art, and to at least provide an advantageous option or create conditions.
[0004] This invention provides a layered control system for a joint motor module, comprising: a main controller, a three-phase inverter drive circuit, an ADC sampling module, a position detection module, and a communication module;
[0005] The main controller is connected to a three-phase inverter drive circuit, an ADC sampling module, a position detection module, and a communication module. The three-phase inverter drive circuit is used to drive the controlled brushless motor according to the three-phase PWM output by the main controller. The ADC sampling module is used to collect the phase current, bus voltage, and temperature parameters of the controlled brushless motor. The position detection module is used to obtain the rotor angle and mechanical speed of the controlled brushless motor. The communication module is used to receive external configuration commands and transmit operating status.
[0006] The main controller is used to execute control methods including: determining that the system is powered on, performing interface initialization, performing effective parameter calibration, and entering the running state;
[0007] In operation, the two-phase current is obtained by PWM-triggered ADC injection sampling, and the bus voltage and temperature parameters are collected by DMA cycle. The position detection module updates the mechanical angle and mechanical speed at the first preset frequency, and automatically switches different low-pass filter coefficients according to the real-time mechanical speed range.
[0008] Hierarchical closed-loop control is executed during the interrupt generated by the ADC sampling module. The hierarchical closed-loop control includes: the position planning loop is executed with a first preset frequency division, the speed loop is executed with a second preset frequency division, and the current loop is executed during each interrupt. The speed loop outputs the target q-axis current, fixes the target d-axis current to 0, and obtains the direct-axis voltage Ud and quadrature-axis voltage Uq after PI regulation. After passing through SVPWM, three-phase PWM is output.
[0009] The input speed value of the speed loop is processed by adaptive filtering. The position planning loop calculates the braking distance based on the error between the target position and the current position, the current actual speed and the preset deceleration, and generates a speed command based on the braking distance constraint.
[0010] Furthermore, the adaptive filtering process includes: dynamically switching the speed low-pass filter coefficient according to the range of mechanical speed detected in real time by the position detection module;
[0011] When the mechanical speed is less than a preset speed threshold, a strong smoothing process is performed using a first filtering coefficient; when the mechanical speed is greater than or equal to the speed threshold, a weak smoothing process is performed using a second filtering coefficient, wherein the first filtering coefficient is less than the second filtering coefficient.
[0012] Furthermore, the specific method by which the position planning loop generates speed commands based on braking distance constraints is as follows: The braking distance is calculated based on the position error between the target position and the current position, the current actual speed, and a preset deceleration; when the remaining distance is less than the braking distance, the currently allowed speed command value is reduced, causing the speed to gradually decrease according to the preset deceleration; when the remaining distance is greater than or equal to the braking distance, the loop operates at a preset maximum speed; the position planning loop limits the change in speed commands within each planning cycle, and the limit value is the product of the preset acceleration value and the planning cycle.
[0013] Furthermore, the position planning loop also introduces a position stop threshold, a speed stop threshold, and a braking margin parameter to enhance the stability of the arrival judgment; when the position error is less than the position stop threshold and the speed error is less than the speed stop threshold, it is determined that the target position has been reached; the braking margin parameter is added as an additional compensation distance when calculating the braking distance.
[0014] Furthermore, the communication module adopts the CAN application layer protocol.
[0015] Furthermore, the CAN application layer shares the operating status, protection status, target instructions, and calibration parameters with the main control loop.
[0016] Furthermore, the main controller is also used to: receive external configuration commands through the CAN application layer of the communication module; the CAN application layer manages configuration information including: motor ID, rated voltage, operating mode, loop parameters, protection threshold, position control parameters and reporting parameters; supports switching between speed mode, current mode and position mode, and supports modifying the maximum position speed, acceleration and deceleration and the position window through the bus.
[0017] Furthermore, the main controller is also used to: immediately deactivate the enable and clear the target value when an overvoltage or overtemperature fault is detected, while retaining the fault history.
[0018] Furthermore, the interface initialization specifically includes the main controller initializing GPIO, PWM, ADC, encoder, and communication interface.
[0019] Furthermore, the effective parameter calibration specifically includes: reading the historically saved zero electrical angle and sensor orientation from Flash; if the calibration parameters are valid, directly entering the running state; if invalid, executing the automatic alignment process, identifying the sensor orientation, estimating the number of pole pairs, calculating the zero electrical angle, and then writing it back to Flash.
[0020] This invention offers at least the following advantages: By synchronously triggering ADC injection sampling through hardware, it ensures the real-time performance and consistency of the current feedback value, avoiding errors caused by asynchronous software sampling. The position planning loop, speed loop, and current loop are executed at different frequencies, ensuring both the stringent real-time requirements of the current loop and the rational allocation of the main controller's computing resources. This prevents computational overload caused by high-frequency position calculations, resulting in a rapid and stable response of the articulated motor under load. This invention is primarily applicable to the field of motor technology. Attached Figure Description
[0021] The accompanying drawings are provided to further understand the technical solutions of the present invention and constitute a part of the specification. They are used together with the embodiments of the present invention to explain the technical solutions of the present invention, and do not constitute a limitation on the technical solutions of the present invention.
[0022] Figure 1 This is a schematic diagram of the system structure of the articulated motor module layered control system;
[0023] Figure 2 This is a flowchart of the steps the main controller takes when executing the control method;
[0024] Figure 3 This is a schematic diagram of the speed adaptive filtering strategy logic in one embodiment;
[0025] Figure 4 This is a schematic diagram of the location planning in one embodiment. Detailed Implementation
[0026] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0027] It should be noted that although functional modules are divided in the system diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the system or the order in the flowchart. The terms "first," "second," etc., in the specification, claims, and the aforementioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0028] refer to Figure 1 and Figure 2 ; Figure 1 This is a schematic diagram of the system structure of the articulated motor module layered control system; Figure 2 This is a flowchart of the steps the main controller takes when executing the control method.
[0029] To address the problems existing in the prior art, this application discloses a layered control system for a joint motor module. The layered control system for the joint motor module includes: a main controller, a three-phase inverter drive circuit, an ADC sampling module, a position detection module, and a communication module.
[0030] The main controller is connected to the three-phase inverter drive circuit, the ADC sampling module, the position detection module, and the communication module, respectively.
[0031] The three-phase inverter drive circuit is used to drive the controlled brushless motor according to the three-phase PWM output by the main controller. The ADC sampling module is used to collect the phase current, bus voltage, and temperature parameters of the controlled brushless motor. The position detection module is used to obtain the rotor angle and mechanical speed of the controlled brushless motor. The communication module is used to receive external configuration commands and transmit operating status.
[0032] The main controller is used to execute control methods including: determining that the system is powered on, performing interface initialization, performing effective parameter calibration, and entering the running state; in the running state, it obtains two-phase current by PWM-triggered ADC injection sampling, acquires bus voltage and temperature parameters by DMA cycle, and the position detection module updates the mechanical angle and mechanical speed at the first preset frequency beat, and automatically switches different low-pass filter coefficients according to the real-time mechanical speed range.
[0033] Hierarchical closed-loop control is executed during the interrupt generated by the ADC sampling module. The hierarchical closed-loop control includes: the position planning loop is executed with a first preset frequency division, the speed loop is executed with a second preset frequency division, and the current loop is executed during each interrupt. The speed loop outputs the target q-axis current, fixes the target d-axis current to 0, and obtains the direct-axis voltage Ud and quadrature-axis voltage Uq after PI regulation. After passing through SVPWM, the three-phase PWM is output.
[0034] The input speed value of the speed loop is processed by adaptive filtering. The position planning loop calculates the braking distance based on the error between the target position and the current position, the current actual speed and the preset deceleration, and generates a speed command based on the braking distance constraint.
[0035] In specific applications, the main controller uses the STM32F4 series chip. The three-phase inverter drive circuit consists of a full-bridge structure composed of six MOSFETs. The ADC sampling module incorporates three sample-and-hold circuits. The position detection module uses a magnetic encoder IC. The communication module is a CAN transceiver.
[0036] After the system powers on, the main controller first completes clock and peripheral initialization. Then, it executes the parameter calibration process. After successful calibration, it enters the running state. In the running state, when the timer of the main controller's PWM module reaches a specific matching point, the hardware triggers the ADC injection channel to sample the two-phase current. Simultaneously, the main controller's DMA controller acquires bus voltage and temperature data at fixed intervals.
[0037] The position detection module updates the rotor's mechanical angle and speed at a frequency of 8kHz. This frequency is the first preset frequency. The main controller automatically switches the filter coefficient based on the current mechanical speed.
[0038] In the interrupt service function generated upon ADC conversion completion, the main controller executes hierarchical closed-loop control. The current loop executes once per interrupt cycle. The speed loop executes with a frequency division of 8, meaning it performs speed loop calculations every 8 interrupt cycles. The position planning loop executes with a frequency division of 40, meaning it performs position planning calculations every 40 interrupt cycles. After the speed loop calculation, the target q-axis current value is output. The target d-axis current is fixed at zero. After PI regulation by the current loop, the direct-axis voltage Ud and quadrature-axis voltage Uq are obtained. These voltage values are then processed by the space vector pulse width modulation module to generate a three-phase PWM signal and output to the inverter circuit.
[0039] That is, the first preset frequency division is 40, the second preset frequency division is 8, that is, the position planning loop is executed once every 40 ADC interrupt cycles, the speed loop is executed once every 8 ADC interrupt cycles, and the current loop is executed in every ADC interrupt cycle.
[0040] The present technical solution will be further explained below from the perspective of more specific implementation methods, so as to facilitate understanding of the present technical solution.
[0041] Assume that this articulated motor module layered control system is applied to the elbow joint of a six-axis collaborative robot. The main controller uses an STM32F405RGT6 chip, which has a built-in floating-point unit to accelerate trigonometric function calculations in Park and Clarke transforms. The three-phase inverter drive circuit uses IRFS4115 MOSFETs, and the gate driver chip is an IRS21867, which has undervoltage lockout and interlock protection functions.
[0042] The ADC sampling module uses three 12-bit successive approximation analog-to-digital converters within the main controller. Its three injection channels are connected to the motor U-phase current sampling resistor, V-phase current sampling resistor, and bus voltage divider resistor, respectively. Temperature sampling is connected to the regular group channel via a separate thermistor voltage divider circuit. The position detection module uses a TLE5012B giant magnetoresistive angle sensor, which communicates with the main controller via an SPI interface, outputting a 14-bit absolute angle value with an update frequency set to 8kHz. The communication module uses a TJA1050 high-speed CAN transceiver.
[0043] After the system powers on, the main controller first enables the internal high-speed external crystal oscillator and, after the crystal oscillator stabilizes, configures the system clock to 168 MHz. Then, it sequentially calls the GPIO initialization function, PWM initialization function, ADC initialization function, encoder SPI interface initialization function, and CAN initialization function. After the clock and peripheral initialization are complete, the main controller reads the calibration flag bit from the specified address in Flash.
[0044] If the calibration flag displays valid parameters, the zero electrical angle value and sensor direction value are directly loaded, and the running state machine is switched to running mode. If the flag is invalid, an automatic alignment algorithm is executed. This algorithm involves applying six basic voltage vectors to the motor stator windings to identify the initial position, then estimating the number of pole pairs by continuously rotating and detecting the sensor output transition edges, and finally subtracting the estimated electrical angle from the sensor angle to obtain the zero electrical angle offset. After calibration, the data is packaged and written back to Flash.
[0045] After entering the running state, the PWM module's timer adopts a center-aligned mode with a counting period set to 100 microseconds, corresponding to a PWM carrier frequency of 10kHz. When the timer's increment reaches half of the period value, the hardware automatically triggers the ADC injection group's conversion start signal. Upon receiving the trigger signal, the ADC injection group immediately converts the two-phase current sampling channels, and the conversion result is moved to the memory buffer via direct memory access, simultaneously triggering an ADC interrupt. The DMA controller periodically acquires bus voltage and temperature parameters at 10ms intervals. This interval is independent of the PWM period and is triggered by an independent timer.
[0046] The position detection module reads the raw angle value from the angle sensor at a frequency of 8kHz via SPI and performs differential calculations with the angle value from the previous cycle to obtain the instantaneous mechanical speed. The main controller internally defines a speed range judgment function, which returns the corresponding filter coefficient index based on the current instantaneous mechanical speed value. This index value is used to update the coefficients of the first-order low-pass digital filter.
[0047] In the interrupt service function triggered upon completion of the ADC conversion, the main controller performs hierarchical control according to the preset frequency divider counter. At the entry point of the current loop interrupt service function, the two-phase current values in the injection group conversion result register are immediately read, and the pre-stored current bias value is subtracted from these values to complete zero-point correction.
[0048] Subsequently, a Clark transform is performed to convert the two-phase stationary coordinate system currents into three-phase stationary coordinate system currents. Then, a Park transform is performed to convert the three-phase stationary coordinate system currents into direct-axis and quadrature-axis currents in a rotating coordinate system. The difference between the direct-axis current and zero is used to generate a direct-axis voltage Ud via a proportional-integral (PI) controller. The difference between the quadrature-axis current and the target current value output by the speed loop is used to generate a quadrature-axis voltage Uq via another PPI controller. Ud and Uq are then subjected to inverse Park and inverse Clark transforms to obtain the target three-phase voltage values, which are finally fed into a space vector pulse width modulation (PWM) module to generate six PWM duty cycle signals.
[0049] The speed loop executes once every 8 interrupt cycles, or once every 800 microseconds. During execution, the speed loop reads the latest mechanical speed value from the position detection module, subtracts the target speed value from the position planning loop or external communication command from this value to obtain the speed error, and outputs the target q-axis current value after passing through the proportional-integral regulator.
[0050] The position planning loop executes once every 40 interrupt cycles, or once every 4ms. During execution, the position planning loop reads the current actual position value and the target position value to calculate the position error, and simultaneously reads the current actual speed value. Combining this information, it calculates the speed command value for the current planning cycle and outputs this value to the speed loop as the target speed.
[0051] During system operation, the CAN communication module receives external messages via interrupts. Upon receiving an enable message, the main controller checks the current protection status; if healthy, it enables PWM output. Upon receiving a mode switching message, the main controller updates the internal mode flag and resets the corresponding integral accumulator to prevent sudden output changes during switching. Upon receiving a parameter modification message, the main controller writes the value in the message to the corresponding parameter storage area and marks this storage area as pending synchronization. The main control loop checks this mark at the beginning of each control cycle to load the new parameters.
[0052] This invention ensures the real-time performance and consistency of the current feedback value by synchronously triggering ADC injection sampling in hardware, avoiding errors caused by asynchronous software sampling. The position planning loop, speed loop, and current loop are executed at different frequencies, which not only guarantees the stringent real-time requirements of the current loop but also rationally allocates the computing resources of the main controller, preventing computational overload caused by high-frequency position calculations. This results in the articulated motor responding quickly and reliably under load.
[0053] refer to Figure 3 This is a schematic diagram of the speed adaptive filtering strategy in one embodiment.
[0054] In some further specific embodiments, the adaptive filtering process includes: dynamically switching the speed low-pass filter coefficient according to the range of mechanical speed detected in real time by the position detection module; when the mechanical speed is less than a preset speed threshold, using a first filter coefficient for strong smoothing; when the mechanical speed is greater than or equal to the speed threshold, using a second filter coefficient for weak smoothing, wherein the first filter coefficient is less than the second filter coefficient.
[0055] This specific embodiment limits the specific strategy of adaptive filtering. Specifically, the raw mechanical velocity value output in real time by the position detection module is first fed into a first-order low-pass filter. The main controller has a pre-stored velocity threshold, assumed to be set to 30 revolutions per minute. When the real-time mechanical velocity is less than 30 revolutions per minute, i.e., falling into the preset low-speed region, the main controller sets the filter coefficient to 0.1, which is the first filter coefficient, performing strong smoothing on the velocity value. When the real-time mechanical velocity is greater than or equal to 30 revolutions per minute, the main controller switches the filter coefficient to 0.6, which is the second filter coefficient, at which point the filtering effect is weakened. The first filter coefficient of 0.1 is significantly smaller than the second filter coefficient of 0.6.
[0056] Research revealed that when the joint motor starts or operates in the low-speed range, the encoder output pulse interval is relatively long, which easily leads to significant discrete jitter in the speed calculation value. Using a smaller first filter coefficient can effectively filter out these random jitters, smoothing the speed loop input and thus suppressing back-and-forth oscillations in the motor during low-speed operation. When the motor enters the medium-to-high-speed range, switching to a larger second filter coefficient ensures that the speed feedback quickly follows actual changes, preventing system dynamic response lag caused by over-filtering, and balancing low-speed stability with high-speed responsiveness.
[0057] In some further specific embodiments, the adaptive filtering process uses a hysteresis comparison method to switch the filter coefficients: a low-speed entry threshold and a low-speed exit threshold are preset, wherein the low-speed exit threshold is greater than the low-speed entry threshold; when the real-time mechanical speed is lower than the low-speed entry threshold, the filter coefficient is switched to the first filter coefficient; when the real-time mechanical speed is higher than the low-speed exit threshold, the filter coefficient is switched to the second filter coefficient; when the real-time mechanical speed is between the low-speed entry threshold and the low-speed exit threshold, the current filter coefficient remains unchanged.
[0058] The recursive formula for the first-order low-pass digital filter is adopted. The form is: where x[n] is the original velocity sample value, y[n] is the filtered output value, and K is the filtering coefficient.
[0059] The filter coefficients range from 0 to 1. The main controller has two pre-stored speed switching thresholds: the first is the low-speed entry threshold, for example, set to 25 revolutions per minute; the second is the low-speed exit threshold, for example, set to 35 revolutions per minute. This hysteresis comparison method prevents frequent switching of the filter coefficients near the critical speed range, which could lead to system instability.
[0060] When the real-time mechanical speed is below 25 revolutions per minute, the system determines that it has entered the low-speed region and sets the filter coefficient K to 0.08. When the real-time mechanical speed is above 35 revolutions per minute, the system determines that it has left the low-speed region and sets the filter coefficient K to 0.5. If the real-time mechanical speed is between 25 and 35 revolutions per minute, the system maintains the current filter coefficient and does not perform a switching action. The hysteresis interval is 10 revolutions per minute.
[0061] In the low-speed region, a filter coefficient of 0.08 produces a filter time constant of approximately 25 ms. This time constant is obtained by dividing the sampling period of 0.125 ms by the filter coefficient, effectively filtering out speed noise components with frequencies higher than 40 Hz. In the high-speed region, a filter coefficient of 0.5 produces a filter time constant of approximately 0.25 ms, and the frequency response bandwidth is broadened to approximately 640 Hz, enabling rapid tracking of speed changes during acceleration and deceleration.
[0062] The main controller also monitors the rate of change of speed error. When the absolute value of the rate of change of speed error exceeds a preset threshold, such as when the motor is experiencing a sudden load increase or decrease, the system temporarily adjusts the filter coefficient upward by 1.5 times the current coefficient value for 20 control cycles. This prevents the filter output from lagging excessively behind the actual speed under large disturbances. After the disturbance subsides, the filter coefficient automatically returns to its original set value.
[0063] The introduction of hysteresis comparison effectively avoids frequent oscillations in the filter coefficient near the switching point caused by encoder quantization noise or slight speed fluctuations. When encoder resolution is limited, the speed measurement value in the low-speed region itself exhibits a pulse-cycle fluctuation. If a single threshold switching method is used, the speed value may jump back and forth between the threshold values, causing the filter coefficient to switch frequently between the two values, introducing additional speed feedback disturbances. The hysteresis interval provides a safety buffer, ensuring that the filter coefficient remains stable after switching, preventing sudden changes in speed loop input and current surges caused by filter parameter jumps, and enhancing the system's operational stability in the critical speed region. The configurable size of the hysteresis interval allows the system to be optimized and adjusted according to different encoder resolutions and mechanical inertia.
[0064] refer to Figure 4 , Figure 4 This is a schematic diagram of the location planning in one embodiment.
[0065] In some further specific embodiments, the position planning loop generates speed commands based on braking distance constraints in the following ways: The braking distance is calculated based on the position error between the target position and the current position, the current actual speed, and a preset deceleration. When the remaining distance is less than the braking distance, the currently allowed speed command value is reduced, causing the speed to gradually decrease according to the preset deceleration. In some embodiments, the speed command is calculated according to the uniform deceleration kinematics formula, so that the speed approaches 0 when it reaches the target position again. When the remaining distance is greater than or equal to the braking distance, the operation proceeds at a preset maximum speed. The position planning loop limits the change in speed commands within each planning cycle, with the limit value being the product of a preset acceleration value and the planning cycle. By limiting the maximum change in speed commands per unit time, acceleration and deceleration constraints are achieved.
[0066] This specific embodiment provides limitations and explanations regarding the execution strategy of the position planning loop. The main controller acquires the current target position and the current position, and calculates the position error. Simultaneously, it reads the current actual mechanical velocity. The system presets a deceleration parameter, for example, a value of 100 rev / s. 2 .
[0067] The main controller uses the formula: square of the current speed divided by twice the deceleration. The theoretical braking distance is calculated. The main controller compares the remaining distance with the braking distance. When the remaining distance is less than the braking distance, the controller actively reduces the currently allowed speed command value, causing the speed to gradually decrease according to the preset deceleration. When the remaining distance is still greater than the braking distance, the controller allows the speed command to increase to the preset maximum speed. In addition, the main controller sets a speed change rate limit value per unit time, which is 500 revolutions per second. Each time the speed command is updated, the new command cannot exceed the previous cycle command plus the change rate limit value, nor can it be lower than the previous cycle command minus the change rate limit value.
[0068] The present technical solution will be further explained below from the perspective of more specific implementation methods, so as to facilitate understanding of the present technical solution.
[0069] The core algorithm of the position planning loop employs a trapezoidal velocity curve planning method, dividing the entire motion process into three stages: acceleration, constant velocity, and deceleration. The main controller constructs this trapezoidal curve based on preset maximum velocity, acceleration, and deceleration values. The position planning loop executes every 4ms, and each execution first calculates the remaining distance from the current position to the target position. .
[0070] Braking distance The calculation formula is: ,in This is the current actual speed value. This is the preset deceleration parameter. The default setting for this deceleration parameter is 200 rev / s. 2 (revolutions per square second), which the user can modify to 50 rev / s via the CAN bus. 2 Up to 200 rev / s 2 Any value between these ranges can be used to accommodate joints with different load inertia.
[0071] When the remaining distance Less than or equal to braking distance At this time, the system enters the deceleration phase. The planned speed command is then issued. According to the formula Assigning values to the kinematic formula for uniform deceleration ensures that the speed drops to zero just as the target position is reached with a constant deceleration over the remaining distance. The planning module simultaneously detects the difference between the current speed and the commanded speed. If the current speed is already less than the commanded speed, forced deceleration is no longer enforced to prevent negative speed commands.
[0072] When the remaining distance Greater than braking distance At this time, the system determines the motion phase based on the relationship between the current actual speed and the maximum speed. If the current speed is less than the preset maximum speed and has not yet entered the deceleration phase, the system is in the acceleration phase, and the speed command gradually increases according to the acceleration parameters until the maximum speed is reached. If the current speed has already reached the maximum speed, the system is in the constant speed phase, and the speed command maintains the maximum speed unchanged.
[0073] In the position planning calculation every 4ms, the velocity change limit is set to the acceleration value multiplied by the time step of 4ms. For example, if the acceleration is 100 rev / s... 2 Within each planning cycle, the speed command can increase or decrease by a maximum of 0.4 revolutions per second. This limit is effective during acceleration and deceleration phases to prevent drastic jumps in the speed command due to sudden changes in position error or target position. The planning cycle is 4 ms, and the maximum change in the speed command within each cycle is the product of the acceleration value and 4 ms.
[0074] When the target position is changed by external commands during movement, the position planning loop immediately recalculates the braking distance based on the new target position. If the current speed exceeds the safe braking speed corresponding to the new target, the system immediately enters the deceleration phase to adapt to the new target.
[0075] In this embodiment, the specific execution strategy of the position planning loop avoids the end-effector impact problem caused by relying solely on the proportional mapping of position error to speed commands in traditional position control. By calculating the braking distance in advance and decelerating in a timely manner, the joint module can smoothly decelerate when approaching the target position, effectively reducing the overshoot caused by mechanical inertia. At the same time, the rate of change limiting mechanism prevents sudden acceleration changes, significantly improving the compliance and positioning accuracy of the joint module in the point-to-point positioning process.
[0076] Using formula The optimal deceleration speed command is calculated directly based on the remaining distance, so that the speed decreases smoothly according to the square root law when approaching the target point. This is smoother and has a shorter effective deceleration time compared to linear deceleration.
[0077] A dual protection mechanism is constructed through speed change rate limiting and braking distance calculation. Braking distance calculation constrains speed from a "spatial dimension," ensuring that the speed has decreased to a safe range upon reaching the target point; speed change rate limiting constrains speed from a "temporal dimension," ensuring that the speed command does not undergo abrupt changes under any circumstances. This dual spatiotemporal constraint ensures that the joint module's motion trajectory strictly conforms to the trapezoidal velocity curve characteristics, with acceleration and deceleration controlled throughout the entire process, significantly reducing mechanical shock and vibration. In critical scenarios where the target position changes abruptly midway, speed change rate limiting effectively prevents speed command abrupt changes caused by position errors abruptly changing from zero to a large value, avoiding the resulting severe mechanical shock and overcurrent risks, and improving the safety of human-machine collaborative operations.
[0078] To reduce jitter, in some further specific embodiments, the position planning loop also introduces a position stop threshold, a speed stop threshold, and a braking margin parameter to enhance the stability of the arrival judgment; when the position error is less than the position stop threshold and the speed error is less than the speed stop threshold, it is determined that the target position has been reached; the braking margin parameter is added as an additional compensation distance when calculating the braking distance.
[0079] Specifically, the main controller's internal memory contains a position stop threshold of 0.5 degrees. It also contains a speed stop threshold of 2 revolutions per minute. Furthermore, a braking margin of 2 degrees is set as an additional compensation distance. When calculating the braking distance, the main controller adds this braking margin to the theoretical braking distance to obtain the final effective braking distance. When the main controller detects that the absolute value of the current position error is less than 0.5 degrees and the absolute value of the current mechanical speed is less than 2 revolutions per minute, the system determines that it has stably reached the target position and terminates the position adjustment process.
[0080] The present technical solution will be further explained below from the perspective of more specific implementation methods, so as to facilitate understanding of the present technical solution.
[0081] For example, the position stop threshold is set to 0.3 degrees. This value is selected based on the nominal backlash value of the harmonic reducer connected to the joint module output, which is usually between 0.2 and 0.4 degrees. Setting the stop threshold to 0.3 degrees just covers the reducer backlash error and leaves a safety margin. The speed stop threshold is set to 1.5 revolutions per minute. This value corresponds to the minimum resolvable speed of the encoder in a single cycle at an 8kHz sampling frequency. Speed measurement results below this value no longer have physical reliability.
[0082] The braking margin parameter is set to 2.5 degrees. This margin is directly added to the theoretical braking distance during braking distance calculation, which is the actual effective braking distance. ;
[0083] in This is the braking margin. This margin value can be adjusted by the user via the CAN bus within the range of 1 to 10 degrees, according to the load inertia of the joint module.
[0084] The positioning determination employs a strategy where three consecutive samples meet the conditions before final confirmation of positioning, preventing false judgments caused by single-shot noise interference. Specifically, the main controller maintains a counter variable, performing a positioning condition check during each position planning loop execution. If the detected position error is less than 0.3 degrees and the speed error is less than 1.5 revolutions per minute, the counter is incremented by 1. If the counter value reaches 3, it is determined to be a true positioning, and this status is reported to the master station via the CAN bus. If any detection fails to meet the conditions during the accumulation process, the counter is immediately reset to zero.
[0085] Furthermore, this judgment condition is also incorporated into the position holding mechanism after the target position is reached. When the system determines that the target position is reached, the speed command output by the position planning loop is forcibly locked to 0, while the current loop continues to maintain active torque output to counteract gravity or external disturbances. If the external disturbance causes the position deviation to exceed 0.3 degrees or the speed to exceed 1.5 revolutions per minute, the system immediately clears the target position flag and restarts the position planning process to pull the joint back to the target position.
[0086] Braking margin parameters are also used for motion continuity optimization in multi-point continuous positioning scenarios. In the continuous trajectory motion of a robot, if the distance between the current target position and the next target position is less than the sum of the braking margin value and the current braking distance, the system plans in advance to decelerate to zero and then accelerate again, avoiding unexpected non-zero speed situations in trajectory planning.
[0087] By introducing dual judgment conditions of position stop threshold and speed stop threshold, premature stopping or repeated overshoot can be effectively prevented due to unilateral position error meeting the conditions but the speed still being too large. The addition of the braking margin parameter provides a safety margin for the deceleration process, overcomes the influence of encoder quantization error and mechanical transmission backlash, and enables the joint module to lock accurately when it reaches the target point, significantly reducing the phenomenon of back-and-forth jitter.
[0088] In some further specific embodiments, the communication module employs the CAN application layer protocol. The communication module follows the CAN application layer protocol, which interacts with data based on the CAN 2.0B standard frame format. The CAN controller built into the main controller is responsible for sending and receiving messages. The physical layer of the communication module uses twisted-pair differential signal transmission. An external host computer or master station sends message frames conforming to the protocol specifications through this CAN bus. The main controller parses the instruction codes and data fields in the messages to identify external configuration commands and assembles and replies to operational status according to the format specified in the protocol.
[0089] The CAN application layer shares operating status, protection status, target commands, and calibration parameters with the main control loop. Data exchange between the CAN application layer and the main control loop occurs through a shared memory area. This shared area includes an operating status field indicating whether the motor is currently enabled or disabled; a protection status field recording current overcurrent, overvoltage, or overtemperature flags; a target command field storing the target speed, target position, or target current value received from the CAN bus; and a calibration parameter field storing the zero-angle and sensor direction recognition results. The main control loop reads these fields and performs calculations in each control cycle. The CAN application layer updates the target command field in real time upon receiving a new bus message and packages the current operating status and protection status written by the main control loop, sending them to the bus. Data synchronization via shared memory avoids the time overhead of data copying, ensuring the highest real-time performance of the commands and statuses acquired by the control loop. This sharing mechanism also ensures that when a large number of configuration messages suddenly appear on the bus, the control loop will not be blocked by message processing; the main control loop can still execute motor control according to a fixed rhythm, enhancing the determinism and robustness of the system.
[0090] In some further specific embodiments, the main controller is also used to: receive external configuration commands through the CAN application layer of the communication module; the CAN application layer manages configuration information including: motor ID, rated voltage, operating mode, loop parameters, protection threshold, position control parameters and reporting parameters; supports switching between speed mode, current mode and position mode, and supports modifying the maximum position speed, acceleration and deceleration and the position window through the bus.
[0091] The CAN application layer internally maintains an object dictionary. This dictionary stores motor ID parameters to distinguish different modules on the bus; rated voltage parameters to adapt to different power systems; operating mode parameters, which can be modified to speed mode, current mode, or position mode; loop parameters such as current loop proportional and integral coefficients, speed loop proportional and integral coefficients, and position loop proportional coefficients; overvoltage protection thresholds and overtemperature protection thresholds; position control parameters such as maximum position speed, acceleration / deceleration values, and position window values; and reporting content and periodic reporting parameters. The main controller receives service data object messages for writing to the object dictionary via the CAN bus, modifies the corresponding parameter values according to the message address, and immediately applies the modified parameters to the main control loop.
[0092] The core control parameters of the motor can be remotely modified via the bus without disassembling the casing to connect a debugger, significantly reducing the difficulty of on-site debugging and maintenance. Support for switching between multiple operating modes allows a single module to adapt to different application scenarios, such as handling, assembly, or sorting. The modifiable maximum speed and acceleration / deceleration parameters enable the joint module to flexibly adjust its motion characteristics according to different load weights, enhancing the system's versatility and flexible deployment capabilities.
[0093] To improve the safety and reliability of the system, in some further specific embodiments, the main controller is also used to: immediately deactivate the enable and clear the target value when an overvoltage or overtemperature fault is detected, while retaining the fault history.
[0094] The main controller incorporates a fault detection comparator. This comparator compares the bus voltage value acquired by the ADC sampling module with the internally stored overvoltage protection threshold in real time. It also compares the acquired temperature value with the overtemperature protection threshold. If the bus voltage remains above the overvoltage threshold for 100ms or the temperature remains above the overtemperature threshold for 50ms, the system determines it to be a serious fault. The main controller immediately executes fault response actions, including immediately shutting down all PWM output channels of the three-phase inverter drive circuit to deactivate them, and simultaneously clearing all internal target speed, target position, and target current registers. Finally, the main controller records the fault type code and timestamp in non-volatile memory, forming a fault history record.
[0095] The overvoltage protection threshold is set to 1.2 times the rated voltage by default at the factory. For example, when the rated voltage is 48V, the overvoltage threshold is 57.6V. The overtemperature protection threshold is set to 85℃ by default at the factory. This temperature corresponds to the upper limit of the allowable temperature for motor winding insulation class F. Users can adjust these two thresholds via the CAN bus according to actual operating conditions. The overvoltage threshold can be adjusted from 1.1 to 1.4 times the rated voltage, and the overtemperature threshold can be adjusted from 70℃ to 100℃.
[0096] Fault detection employs a continuous sampling averaging method to avoid false protection triggered by a single noise pulse. During bus voltage detection, the system compares the moving average of the most recent 8 DMA samples with the overvoltage threshold. If the average voltage exceeds the overvoltage threshold for a duration of 100ms (corresponding to 10 bus voltage sampling cycles), an overvoltage fault is triggered. For temperature detection, the system compares the moving average of the most recent 4 temperature samples with the overtemperature threshold. If the average temperature exceeds the overtemperature threshold for a duration of 50ms, an overtemperature fault is triggered.
[0097] Upon the occurrence of a fault, the main controller executes a fault response sequence. First, the enable register of the PWM module is cleared to immediately shut down the drive signals of all power switches; this operation is completed within 1 microsecond. Subsequently, the internal speed loop integrator accumulator, current loop integrator accumulator, target speed register, target position register, and target current register are all cleared. Finally, the system runtime timestamp at the moment of fault triggering is recorded in milliseconds in the fault history buffer, and the fault type code is encoded into a byte and stored in the fault history entry.
[0098] The fault history buffer uses a first-in, first-out (FIFO) queue structure with a depth of 8 records. Each record contains a 1-byte fault type code, a 4-byte timestamp of the fault time, and 2 bytes each of the actual speed and current values at the time of the fault, totaling 9 bytes. When the buffer is full, the newest fault record automatically overwrites the oldest record. The fault history is read via the CAN bus service data object upload command; the master station can read all 8 records at once or read them one by one according to their sequence number.
[0099] After a fault occurs, the system does not automatically attempt to resume operation but instead locks itself into a fault state. The user must send a fault clearing command via the CAN bus, ensuring that the external fault source has been eliminated before sending the command. Upon receiving the fault clearing command, the system re-detects the current bus voltage and temperature values. If both have returned to normal ranges, the system exits the fault state and enters standby mode, awaiting a new enable command from the user.
[0100] This fault protection mechanism can block the drive output within microseconds when an anomaly is detected, preventing power devices from breaking down due to overvoltage or burning out due to overheating, thus greatly improving the safety and reliability of the system. The fault history retention function provides valuable data for later maintenance personnel to analyze the cause of faults and troubleshoot intermittent anomalies, helping to fundamentally solve recurring faults.
[0101] In some further specific embodiments, interface initialization specifically includes the main controller initializing GPIO, PWM, ADC, encoder, and communication interfaces. Specifically, the main controller performs interface initialization in the following order: After the system power supply stabilizes, the main controller first calls the general input / output interface initialization function to configure the direction and level of the motor enable pin and fault indicator pin. Then, it calls the pulse width modulation module initialization function to set the carrier frequency, dead time, and output channel polarity. Next, it calls the analog-to-digital converter initialization function to configure the sampling channel, sampling period, and resolution. Afterward, it calls the encoder interface initialization function to set the counting direction and zeroing operation. Finally, it calls the communication controller initialization function to configure the baud rate, frame format, and filter. Only after all initialization steps are completed and the return status is correct does the main controller proceed to the subsequent parameter calibration stage.
[0102] In some further specific embodiments, effective parameter calibration specifically includes: reading the historically saved zero electrical angle and sensor orientation from Flash memory; if the calibration parameters are valid, directly entering the running state; if invalid, executing an automatic alignment process to identify the sensor orientation, estimate the number of pole pairs, calculate the zero electrical angle, and then write it back to Flash memory. Specifically, the main controller reads data from a preset address area in the Flash memory. This data includes a valid flag bit, the saved zero electrical angle value, and the saved sensor orientation value. The main controller determines whether the valid flag bit is a preset specific value, such as 0x5A5A. If the flag bit is correct, it indicates that the calibration parameters are valid, and the main controller directly loads the saved zero electrical angle and sensor orientation values, skipping the automatic alignment step and immediately entering the running state. If the flag bit is incorrect, it indicates that the parameters are invalid or it is the first power-on. The main controller then executes the automatic alignment process. This process first identifies the sensor orientation by applying a specific voltage vector sequence to the motor windings. Secondly, it estimates the number of pole pairs by counting the number of pulses within the electrical cycle. Finally, it calculates the zero electrical angle by searching for the rotor locking angle. After the calculation is completed, the main controller writes the new zero electrical angle value, sensor direction value, and valid flag bit 0x5A5A together into the corresponding address area of Flash.
[0103] By storing the calibration results in Flash memory, the joint module can enter the running state within seconds upon subsequent power-on or reset, significantly reducing the equipment's startup waiting time. This is particularly suitable for mobile robot joints that require frequent power outages or rapid response. The automatic alignment process eliminates the tedious manual calibration operation, reducing debugging time and the probability of errors during production line assembly.
[0104] In some further specific embodiments, the automatic alignment process is further refined into three sequentially executed steps. The first step is sensor orientation identification: the main controller sequentially applies six basic voltage vectors with angles of 0 degrees, 60 degrees, 120 degrees, 180 degrees, 240 degrees, and 300 degrees to the motor stator, each vector lasting 10 milliseconds. Simultaneously, the rotor angle response after each vector application is read through the position detection module. The sensor's installation orientation (positive or negative) is determined by comparing the cyclic sequence of the six responses. The second step is pole pair estimation: in open-loop mode, the main controller drives the motor to complete two full mechanical rotations, while simultaneously counting the number of electrical cycles output by the position detection module. The total number of electrical cycles is divided by the number of mechanical rotations (2) to obtain the estimated pole pair number. The third step is zero electrical angle calculation: the main controller locks the rotor in the d-axis direction and reads the angle value output by the position detection module at this time. This angle value is the zero electrical angle offset. If any of the three steps fails, the system pauses subsequent steps and outputs an error code containing the failed step number through the communication module.
[0105] The logical sequence of the three steps in the automatic alignment process ensures the correctness of the identification process: first, the sensor orientation is determined; then, the number of pole pairs is estimated based on the correct orientation; and finally, the zero electrical angle is calculated based on the correct orientation and the number of pole pairs. The error code output when any step fails provides clear fault location information for on-site debugging. Operators can quickly determine whether the problem lies with the sensor installation, motor wiring, or alignment algorithm parameter configuration based on the error code.
[0106] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented, for example, in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatuses.
[0107] It should be understood that in this application, "at least one (item)" means one or more, and "more than" means two or more. "And / or" is used to describe the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.
[0108] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be indirect coupling or communication connection through some interfaces, apparatuses, or units, and may be electrical, mechanical, or other forms.
[0109] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0110] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0111] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0112] Although the description of this application has been quite detailed and particularly focused on several of the described embodiments, it is not intended to limit itself to any of these details or embodiments or any particular embodiment. Rather, it should be considered as effectively covering the intended scope of this application by referring to the appended claims and taking into account the prior art, which provides for a broad possible interpretation of these claims. Furthermore, the foregoing description of this application with respect to embodiments foreseeable by the inventors is intended to provide a useful description, and non-substantial modifications to this application that have not yet been foreseen may still represent equivalent modifications.
[0113] It should be noted that in all specific embodiments of this application, when processing data related to user identity or characteristics, such as user information, user behavior data, user historical data, and user location information, user permission or consent is obtained first. Furthermore, the collection, use, and processing of this data comply with relevant laws, regulations, and standards. In addition, when embodiments of this application require access to sensitive personal information of users, separate permission or consent from the user is obtained through pop-ups or redirection to confirmation pages. Only after obtaining the user's separate permission or consent is the necessary user-related data required for the proper functioning of these embodiments acquired.
Claims
1. A layered control system for a joint motor module, characterized in that, include: The system consists of a main controller, a three-phase inverter drive circuit, an ADC sampling module, a position detection module, and a communication module. The main controller is connected to a three-phase inverter drive circuit, an ADC sampling module, a position detection module, and a communication module. The three-phase inverter drive circuit is used to drive the controlled brushless motor according to the three-phase PWM output by the main controller. The ADC sampling module is used to collect the phase current, bus voltage, and temperature parameters of the controlled brushless motor. The position detection module is used to obtain the rotor angle and mechanical speed of the controlled brushless motor. The communication module is used to receive external configuration commands and transmit operating status. The main controller is used to execute control methods including: determining that the system is powered on, performing interface initialization, performing effective parameter calibration, and entering the running state; In operation, the two-phase current is obtained by PWM-triggered ADC injection sampling, and the bus voltage and temperature parameters are collected by DMA cycle. The position detection module updates the mechanical angle and mechanical speed at the first preset frequency, and automatically switches different low-pass filter coefficients according to the real-time mechanical speed range. Hierarchical closed-loop control is executed during the interrupt generated by the ADC sampling module. The hierarchical closed-loop control includes: the position planning loop is executed with a first preset frequency division, the speed loop is executed with a second preset frequency division, and the current loop is executed during each interrupt. The speed loop outputs the target q-axis current, fixes the target d-axis current to 0, and obtains the direct-axis voltage Ud and quadrature-axis voltage Uq after PI regulation. After passing through SVPWM, three-phase PWM is output. The input speed value of the speed loop is processed by adaptive filtering. The position planning loop calculates the braking distance based on the error between the target position and the current position, the current actual speed and the preset deceleration, and generates a speed command based on the braking distance constraint.
2. The articulated motor module layered control system according to claim 1, characterized in that, The adaptive filtering process includes: dynamically switching the speed low-pass filter coefficient according to the range of mechanical speed detected in real time by the position detection module; When the mechanical speed is less than a preset speed threshold, a strong smoothing process is performed using a first filtering coefficient; when the mechanical speed is greater than or equal to the speed threshold, a weak smoothing process is performed using a second filtering coefficient, wherein the first filtering coefficient is less than the second filtering coefficient.
3. The articulated motor module layered control system according to claim 1, characterized in that, The specific method by which the position planning loop generates speed commands based on braking distance constraints is as follows: The braking distance is calculated based on the position error between the target position and the current position, the current actual speed, and a preset deceleration. When the remaining distance is less than the braking distance, the currently allowed speed command value is reduced, causing the speed to gradually decrease according to the preset deceleration. When the remaining distance is greater than or equal to the braking distance, the operation proceeds at a preset maximum speed. The position planning loop limits the change in speed commands within each planning cycle, with the limit value being the product of a preset acceleration value and the planning cycle.
4. A layered control system for a joint motor module according to claim 3, characterized in that, The position planning loop also introduces a position stop threshold, a speed stop threshold, and a braking margin parameter to enhance the stability of the arrival judgment; when the position error is less than the position stop threshold and the speed error is less than the speed stop threshold, it is determined that the target position has been reached; the braking margin parameter is added as an additional compensation distance when calculating the braking distance.
5. A layered control system for a joint motor module according to claim 1, characterized in that, The communication module uses the CAN application layer protocol.
6. A layered control system for a joint motor module according to claim 5, characterized in that, The CAN application layer shares the operating status, protection status, target commands, and calibration parameters with the main control loop.
7. A layered control system for a joint motor module according to claim 6, characterized in that, The main controller is also used to: receive external configuration commands through the CAN application layer of the communication module; the CAN application layer manages configuration information including: motor ID, rated voltage, operating mode, loop parameters, protection threshold, position control parameters and reporting parameters; supports switching between speed mode, current mode and position mode, and supports modifying the maximum position speed, acceleration and deceleration and the position window through the bus.
8. A layered control system for a joint motor module according to claim 1, characterized in that, The main controller is also used to: immediately deactivate the enable and clear the target value when an overvoltage or overtemperature fault is detected, while retaining the fault history.
9. A layered control system for a joint motor module according to claim 1, characterized in that, The interface initialization process specifically includes the main controller initializing GPIO, PWM, ADC, encoder, and communication interface.
10. A layered control system for a joint motor module according to claim 1, characterized in that, The specific steps for effective parameter calibration include: reading the historically saved zero electric angle and sensor orientation from Flash; if the calibration parameters are valid, the system directly enters the running state; if invalid, the system executes an automatic alignment process, identifies the sensor orientation, estimates the number of pole pairs, calculates the zero electric angle, and then writes it back to Flash.