STM32-based triaxial ball screw functional expression motion system and method
The STM32-based three-axis ball screw functional motion system solves the problems of high price and poor flexibility of traditional three-axis motion control systems, realizes low-cost, high-precision three-axis motion control, supports user-defined function trajectories and graphical interface operations, and is suitable for a variety of application scenarios.
Patent Information
- Application Number
- CN202510952247.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-10
- Publication Date
- 2025-09-12
AI Technical Summary
Existing three-axis motion control systems are expensive, have high development barriers, are not flexible enough in control methods, lack the ability to express mathematical function trajectories, are difficult to implement user-customized paths, and have low accuracy.
A three-axis ball screw functional motion system based on STM32 is adopted, including a main control module, a trajectory generation and function analysis module, a drive and actuator module, a battery and power supply management module, a safety and status detection module, and a human-computer interaction module. The STM32F103C8T6 microcontroller coordinates each module, supports user input of function expressions, generates pulse control signals, achieves three-axis high-precision linear displacement, and monitors the system status in real time.
It realizes low-cost, high-precision three-axis motion control, supports diversified applications, and the system is miniaturized, easy to carry, and user-friendly. It supports function trajectory description and graphical interface, which improves the flexibility and precision of the control system.
Smart Images

Figure CN120630835A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of mechanical control technology, and in particular relates to a three-axis ball screw functional motion system and method based on STM32. Background Art
[0002] With the advancement of manufacturing automation and precision control technologies, three-axis motion control platforms are widely used in CNC machine tools, 3D printing, laser engraving, robotic end effectors, and other fields. Traditional control systems often rely on industrial-grade controllers, such as PLCs or motion control cards. These systems are typically expensive, have high development barriers, and often rely on imperative, point-by-point planning for path control, lacking flexibility and mathematical expressiveness.
[0003] As ball screws are widely used as precision transmission devices, the flexibility and precision requirements of the control system that matches them are also increasing. Existing systems generally have problems such as inflexible control methods, low trajectory control accuracy, difficulty in user-customized paths, and lack of functional programming interfaces. This is particularly prominent in the fields of education, scientific research, rapid prototyping, etc. Therefore, it is urgent to develop a control system that has the ability to express mathematical function trajectories, is based on low-cost control chips, and has an expandable multi-axis structure. Summary of the Invention
[0004] The present invention aims to solve the problems raised in the background technology and proposes a three-axis ball screw functional motion system and method based on STM32.
[0005] In order to achieve the purpose of the present invention, the present invention discloses a three-axis ball screw functional motion system based on STM32, including a main control module, a trajectory generation and function analysis module, a drive and actuator module, a battery and power supply management module, a safety and status detection module, and a human-computer interaction module; the human-computer interaction module is used to receive three-axis displacement parameters input by a user; the main control module initializes and verifies the input content, the trajectory generation and function analysis module generates trajectory points, and the main control module converts pulse and direction signals; the drive and actuator module drives the motor to achieve displacement and feedback status; the safety and status detection module is used to monitor the status and shut down in the event of an abnormality; the operating status is transmitted to the human-computer interaction module for display via the main control module; and the battery and power supply management module is used to provide stable power supply.
[0006] Furthermore, the main control module is based on the STM32F103C8T6 microcontroller, which is responsible for overall system coordination, connecting various functional modules, executing control algorithms, and exchanging data with the human-computer interaction module; the drive and actuator module is composed of an Emm42_V4.x stepper closed-loop driver and a ball screw, which receives the pulse signal generated by the main control module, controls the rotation speed and direction of the three groups of stepper motors on the X-axis, Y-axis, and Z-axis, and converts the rotational motion of the stepper motor into precise linear displacement of each axis; the trajectory generation and function analysis module is embedded in the main control module, receives the function expression input by the user, calculates the sampling point coordinate sequence, and generates the corresponding pulse control signal; the human-computer interaction module includes a serial port debugging interface and a TFT touch screen for users to input function parameters, preview trajectories, and monitor the operating status; the battery and power supply management module includes a lithium battery pack, a buck-stabilizing circuit, and a charging protection circuit, which provides a stable power supply for the system and supports portable use; the safety and status detection module includes a limit switch, an emergency stop circuit, and a power monitoring circuit, which monitors the system operating status in real time to ensure safe system operation.
[0007] Furthermore, the user inputs the displacement function expression and operating parameters of the X, Y, and Z axes through the TFT touch screen of the human-computer interaction module; the system completes the GPIO, timer, and serial port initialization by the main control module, and performs syntax and logic verification on the input content; after the verification is passed, the trajectory generation and function analysis module generates a time series according to the set sampling frequency, and the analysis function calculates the three-axis target coordinates to form discrete trajectory points, and the main control module combines the screw lead and motor parameters to convert the step pulse sequence and direction signal; during the trajectory execution process, the main control module outputs a trapezoidal speed pulse according to the preset acceleration and deceleration algorithm, and the pulse signal is transmitted. The overdrive and actuator module uses a closed-loop driver to control three sets of stepper motors to drive the ball screw, achieving high-precision linear displacement on three axes and feeding back the motor operating status to the main control in real time to avoid loss of step and error accumulation, thereby ensuring accuracy. At the same time, the safety and status detection module continuously monitors the limit, emergency stop and power status. If any abnormality is detected, the movement will be stopped immediately to ensure the safety of equipment and personnel. The trajectory, coordinates, speed and other status during operation are transmitted to the human-machine interaction module through the main control for real-time display. The user can also adjust parameters or pause / resume operation at any time. The entire system is powered by a battery and power management module, providing stable power supply and supporting portable applications.
[0008] In order to achieve the purpose of the present invention, the present invention also discloses a three-axis ball screw functional motion method based on STM32, comprising the following steps:
[0009] S1, system initialization;
[0010] S2, trajectory parameter input and expression verification;
[0011] S3. The system samples the function expression entered by the user to generate trajectory points, then calculates the number and direction of pulses per axis through coordinate difference, and derives the corresponding pulse frequency in combination with the speed planning algorithm to realize the conversion of function trajectory into synchronous pulse control instructions;
[0012] S4. The system uses multiple timers to output three-axis synchronous pulse signals to drive the ball screw to complete the path movement. At the same time, it combines closed-loop feedback to achieve error compensation, and ensures safe operation through limit protection and power monitoring mechanisms;
[0013] S5. Real-time monitoring and interactive adjustment.
[0014] Furthermore, S1 is specifically as follows: after the system is powered on, the main control module completes the basic configuration, including clock system initialization, GPIO port setting, timer configuration and serial communication initialization; at the same time, the safety and status detection module activates limit detection, emergency stop response and voltage status monitoring functions to ensure that the system starts and runs in a controlled and safe environment.
[0015] Furthermore, S2 is specifically as follows: the user inputs the function expression of the X, Y, and Z axes in three-dimensional space changing with time, as well as control parameters such as running time, sampling frequency, initial velocity, and acceleration through the TFT touch screen of the human-computer interaction module; the trajectory generation and function parsing module automatically verifies the expression syntax, including variable symbols, bracket nesting, and function validity judgment. If there is a format error, the user will be prompted to correct it through the human-computer interface feedback.
[0016] Furthermore, S3 is specifically:
[0017] S31, trajectory point sampling and coordinate generation; after the expression is verified, the trajectory generation and function analysis module generates an equally spaced time series {t0, t1, ..., t n}, and each t i Substitute the user-defined function to calculate the three-axis target coordinates (x i ,y i ,z i ), forming a discrete trajectory point array P n =(X(t n ),Y(t n ),Z(t n )), as the basis for path control;
[0018] S32, pulse parameter conversion and direction command generation; trajectory generation and function analysis module performs differential calculation on the coordinate difference between continuous trajectory points, assuming Δx i =x i+1 -x i ,Δy i =y i+1-y i ,Δz i =z i+1 -z i , combined with the linear displacement d corresponding to each step of the stepper motor step , convert the number of pulses required for each axis in this time slice:
[0019]
[0020] At the same time, the displacement sign is determined and the direction control signal DIR is generated; the pulse quantity and direction pair are cached in the instruction queue for subsequent execution module to call;
[0021] S33, speed planning and pulse frequency calculation; To ensure smooth motion, the trajectory generation and function analysis module adopts a segmented trapezoidal acceleration and deceleration algorithm, dividing the entire operation process into acceleration, uniform speed and deceleration segments; let the target speed be v(t), combined with the unit step length d step , the target pulse frequency can be obtained:
[0022]
[0023] The main control module dynamically updates the timer automatic reload value ARR according to f(t), thereby adjusting the output frequency of the step pulse to achieve continuously variable speed.
[0024] Furthermore, S4 is specifically:
[0025] S41, pulse output and multi-axis synchronization execution; the system allocates independent timers TIM1, TIM2, and TIM3 to each axis, and synchronously outputs pulse signals through output comparison mode or DMA control mode; the closed-loop driver in the drive and actuator module receives pulse and direction signals, drives the stepper motor to rotate at the corresponding speed and direction, and converts the rotation into linear displacement through the ball screw structure, realizing three-axis coordinated spatial motion;
[0026] S42, state feedback and error compensation: The closed-loop stepper driver collects motor position feedback signals in real time. If a step-out or load interference is detected, the driver automatically performs error compensation and feeds back the operating status to the main control module to improve operating accuracy and trajectory consistency.
[0027] S43. Abnormal detection and safety response: If the system detects that the limit switch is triggered, the emergency stop button is pressed, or the power supply is abnormal, the main control module immediately stops all pulse outputs, turns off the driver control level, and issues a warning message through the screen; the battery and power supply management module monitors the voltage status and automatically switches to protection mode when undervoltage or low battery is detected to prevent damage to the mechanism or circuit.
[0028] Furthermore, S5 is specifically as follows: During the execution of the movement, the user can view the current coordinates, speed, running progress and trajectory image in real time through the human-computer interaction module; the system supports parameter adjustment during operation, such as dynamic acceleration and deceleration, pause / resume operations, forming a controllable closed-loop interactive process.
[0029] Compared with the existing technology, the significant improvements of the present invention are: 1) through the rational layout of the control board, motor, and transmission structure, the close integration of electronic control and mechanics is achieved, the system volume is reduced, and a miniaturized design is realized to adapt to limited space and portability requirements; 2) the use of a programmable STM32 microcontroller supports a variety of control strategies, peripheral interfaces and communication protocols (such as serial ports, I2C, SPI), and users can flexibly configure and expand according to needs to achieve diversified applications; 3) the introduction of a function trajectory description mechanism, users can directly define the motion trajectory using mathematical function expressions (such as sine, parabola, etc.), and the system parses the expression to generate the path, eliminating the path point editing and interpolation steps and simplifying program design; 4) a graphical interface is provided through a TFT touch screen or serial port debugging assistant, supporting menu configuration, trajectory preview, parameter adjustment and operation status monitoring, making user operation more convenient and intuitive.
[0030] In order to more clearly illustrate the functional characteristics and structural parameters of the present invention, further description is given below with reference to the accompanying drawings and specific embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0032] Figure 1 It is a structural block diagram of a three-axis ball screw functional motion system based on STM32;
[0033] Figure 2 It is a flow chart of the three-axis ball screw functional motion method based on STM32. DETAILED DESCRIPTION
[0034] The technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments; based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0035] A three-axis ball screw functional motion system based on STM32 comprises a main control module, a trajectory generation and function analysis module, a drive and actuator module, a battery and power supply management module, a safety and status detection module, and a human-computer interaction module; the human-computer interaction module is used to receive three-axis displacement parameters input by a user; the main control module initializes and verifies the input content, the trajectory generation and function analysis module generates trajectory points, and the main control module converts pulse and direction signals; the drive and actuator module drives a motor to achieve displacement and feedback status; the safety and status detection module is used to monitor the status and shut down in the event of an abnormality; the operating status is transmitted to the human-computer interaction module for display via the main control module; and the battery and power supply management module is used to provide stable power supply.
[0036] Specifically, the main control module is based on the STM32F103C8T6 microcontroller, which is responsible for overall system coordination, connecting various functional modules, executing control algorithms, and exchanging data with the human-computer interaction module; the drive and actuator module is composed of an Emm42_V4.x stepper closed-loop driver and a ball screw, which receives the pulse signals generated by the main control module, controls the rotation speed and direction of the three groups of stepper motors on the X, Y, and Z axes, and converts the rotational motion of the stepper motors into precise linear displacement of each axis; the trajectory generation and function analysis module is embedded in the main control module, receives the function expression input by the user, calculates the sampling point coordinate sequence, and generates the corresponding pulse control signal; the human-computer interaction module includes a serial port debugging interface and a TFT touch screen for users to input function parameters, preview trajectories, and monitor the operating status; the battery and power supply management module includes a lithium battery pack, a buck-stabilization circuit, and a charging protection circuit, which provides a stable power supply for the system and supports portable use; the safety and status detection module includes a limit switch, an emergency stop circuit, and a power monitoring circuit, which monitors the system operating status in real time to ensure safe system operation.
[0037] Specifically, the user inputs the displacement function expression and operating parameters of the X, Y, and Z axes through the TFT touch screen of the human-computer interaction module; the system completes the GPIO, timer, and serial port initialization by the main control module, and performs syntax and logic verification on the input content; after the verification is passed, the trajectory generation and function analysis module generates a time series according to the set sampling frequency, and the analysis function calculates the three-axis target coordinates to form discrete trajectory points, and the main control module combines the screw lead and motor parameters to convert the step pulse sequence and direction signal; during the trajectory execution process, the main control module outputs a trapezoidal speed pulse according to the preset acceleration and deceleration algorithm, and the pulse signal is transmitted through the The drive and actuator module uses a closed-loop driver to control three sets of stepper motors to drive ball screws, achieving high-precision linear displacement on three axes and feeding back the motor operating status to the main control in real time to avoid loss of step and error accumulation, thereby ensuring accuracy. At the same time, the safety and status detection module continuously monitors the limit, emergency stop and power status. If an abnormality is detected, the movement will be stopped immediately to ensure the safety of equipment and personnel. The trajectory, coordinates, speed and other status during operation are transmitted to the human-computer interaction module through the main control for real-time display. The user can also adjust parameters or pause / resume operation at any time. The entire system is powered by a battery and power management module, providing stable power supply and supporting portable applications.
[0038] like Figure 2 As shown, in order to achieve the purpose of the present invention, the present invention also discloses a three-axis ball screw functional motion method based on STM32, comprising the following steps:
[0039] S1, system initialization;
[0040] S2, trajectory parameter input and expression verification;
[0041] S3. The system samples the function expression entered by the user to generate trajectory points, then calculates the number and direction of pulses per axis through coordinate difference, and derives the corresponding pulse frequency in combination with the speed planning algorithm to realize the conversion of function trajectory into synchronous pulse control instructions;
[0042] S4. The system uses multiple timers to output three-axis synchronous pulse signals to drive the ball screw to complete the path movement. At the same time, it combines closed-loop feedback to achieve error compensation, and ensures safe operation through limit protection and power monitoring mechanisms;
[0043] S5. Real-time monitoring and interactive adjustment.
[0044] Specifically, S1 is as follows: after the system is powered on, the main control module completes the basic configuration, including clock system initialization, GPIO port setting, timer configuration and serial communication initialization; at the same time, the safety and status detection module activates limit detection, emergency stop response and voltage status monitoring functions to ensure that the system starts and runs in a controlled and safe environment.
[0045] Specifically, S2 is as follows: the user inputs the function expression of the X, Y, and Z axes in the three-dimensional space that changes with time, as well as control parameters such as running time, sampling frequency, initial velocity, and acceleration through the TFT touch screen of the human-computer interaction module; the trajectory generation and function parsing module automatically verifies the expression syntax, including variable symbols, bracket nesting, and function legitimacy judgment. If there is a format error, the user will be prompted to correct it through the human-computer interface feedback.
[0046] Specifically, S3 is:
[0047] S31, trajectory point sampling and coordinate generation; after the expression is verified, the trajectory generation and function analysis module generates an equally spaced time series {t0, t1, ..., t n}, and each t i Substitute the user-defined function to calculate the three-axis target coordinates (x i ,y i ,z i ), forming a discrete trajectory point array P n =(X(t n ),Y(t n ),Z(t n )), as the basis for path control;
[0048] S32, pulse parameter conversion and direction command generation; trajectory generation and function analysis module performs differential calculation on the coordinate difference between continuous trajectory points, assuming Δx i =x i+1 -x i ,Δy i =y i+1 -y i ,Δz i =z i+1 -z i , combined with the linear displacement d corresponding to each step of the stepper motor step , convert the number of pulses required for each axis in this time slice:
[0049]
[0050] At the same time, the displacement sign is determined and the direction control signal DIR is generated; the pulse quantity and direction pair are cached in the instruction queue for subsequent execution module to call;
[0051] S33, speed planning and pulse frequency calculation; To ensure smooth motion, the trajectory generation and function analysis module adopts a segmented trapezoidal acceleration and deceleration algorithm, dividing the entire operation process into acceleration, uniform speed and deceleration segments; let the target speed be v(t), combined with the unit step length d step , the target pulse frequency can be obtained:
[0052]
[0053] The main control module dynamically updates the timer automatic reload value ARR according to f(t), thereby adjusting the output frequency of the step pulse to achieve continuously variable speed.
[0054] Specifically, S4 is:
[0055] S41, pulse output and multi-axis synchronization execution; the system allocates independent timers TIM1, TIM2, and TIM3 to each axis, and synchronously outputs pulse signals through output comparison mode or DMA control mode; the closed-loop driver in the drive and actuator module receives pulse and direction signals, drives the stepper motor to rotate at the corresponding speed and direction, and converts the rotation into linear displacement through the ball screw structure, realizing three-axis coordinated spatial motion;
[0056] S42, state feedback and error compensation: The closed-loop stepper driver collects motor position feedback signals in real time. If a step-out or load interference is detected, the driver automatically performs error compensation and feeds back the operating status to the main control module to improve operating accuracy and trajectory consistency.
[0057] S43. Abnormal detection and safety response: If the system detects that the limit switch is triggered, the emergency stop button is pressed, or the power supply is abnormal, the main control module immediately stops all pulse outputs, turns off the driver control level, and issues a warning message through the screen; the battery and power supply management module monitors the voltage status and automatically switches to protection mode when undervoltage or low battery is detected to prevent damage to the mechanism or circuit.
[0058] Specifically, S5 is as follows: During the execution of the movement, the user can view the current coordinates, speed, running progress and trajectory image in real time through the human-computer interaction module; the system supports parameter adjustment during operation, such as dynamic acceleration and deceleration, pause / resume operations, forming a controllable closed-loop interactive process.
[0059] like Figure 1As shown in the figure, the system consists of a main control module, a trajectory generation and function parsing module, a drive and actuator module, a battery and power management module, a safety and status detection module, and a human-computer interaction module. The main control module includes an STM32 processor and a timer; the trajectory generation and function parsing module includes a function parser and a sampling unit; the drive and actuator module includes a stepper motor driver and a ball screw actuator; the battery and power management module includes a lithium battery and a step-down module; the safety and status detection module includes limit switches and an emergency stop switch; and the human-computer interaction module includes a TFT touch screen and a serial port debugging assistant. After the system is powered on and initialized, the user first enters the desired motion trajectory expression and related parameters through the human-computer interaction interface (TFT touch screen). This includes a mathematical function representing the time-varying displacement of the X, Y, and Z axes in three-dimensional space, as well as key control variables such as runtime, sampling frequency, and speed. The system format-checks the input expression to ensure syntax validity and checks logical relationships such as variable symbols and nested brackets. If errors are found, the user will be prompted to correct them through the interface.
[0060] Once the expression passes verification, the control system enters the trajectory generation phase. The main control module (STM32F103C8T6) generates a series of time points at equal intervals based on the set sampling frequency. These time points are then substituted into the user-provided function expression, sequentially calculating the target coordinates of the three axes at each time point. The entire trajectory is stored as an array of coordinate points, forming a discrete representation of the spatial path.
[0061] The system then enters the coordinate differential calculation phase. The controller analyzes the coordinate differences between adjacent sampling points and, based on the ball screw lead, the step angle of the stepper motor, and the microstepping factor, calculates the required number of pulses and the corresponding direction signal. The step spacing used in the conversion formula incorporates motor parameters and screw characteristics to ensure accurate linear displacement for each step. At this point, the system completes the critical transformation from mathematical expression to actual motion command.
[0062] To ensure smooth motor operation, the controller must perform acceleration and deceleration planning before outputting pulse signals. The system uses a standard trapezoidal speed control curve, dividing the entire motion process into acceleration, constant speed, and deceleration stages. At each sampling point, the controller calculates the target speed based on the current stage and adjusts the output frequency of the stepper pulses accordingly. Frequency control is implemented via a timer peripheral. Specifically, the controller dynamically modifies the timer's reload value (ARR) to ensure that the pulse interval matches the target speed, achieving a smooth, continuous speed transition.
[0063] Throughout the entire motion process, the system uses the STM32's multi-channel timer resources to synchronize pulse control for the X, Y, and Z axes. Timer outputs can be driven via interrupts or DMA, improving accuracy and efficiency. Based on preprocessed data, the controller precisely controls the pulse quantity, frequency, and output timing in each timer, ensuring trajectory synchronization among the three axes and preventing the accumulation of mechanical errors.
[0064] During motion execution, the motor driver module receives pulse and direction signals from the main control output and drives the stepper motor to rotate. A ball screw structure converts this rotation into precise linear motion, driving the actuator along a set path in three dimensions. The closed-loop stepper driver monitors the motor status in real time, collects position feedback signals, and automatically compensates for errors in the event of lost steps or abnormal loads, ensuring displacement accuracy and trajectory reproducibility.
[0065] Throughout operation, the system continuously reads the status signals of the limit switches and emergency stop button. If any axis triggers a limit or the emergency stop button is pressed, the main control unit immediately interrupts pulse output, shuts off the drive power, and issues a warning on the screen to prevent damage to the mechanism or safety accidents. Simultaneously, the power supply monitoring unit continuously monitors the voltage status. In the event of undervoltage, overvoltage, or low battery, it automatically triggers a protection program and displays an alarm on the screen.
[0066] The TFT touchscreen interface allows users to view trajectory progress, execution status, current coordinate values, and motor operating parameters in real time. During operation, the interface allows dynamic adjustment of speed, pause / resume commands, and real-time observation of system responses. All settings, inputs, and execution feedback form a complete closed-loop interactive process, significantly improving operational convenience and system controllability.
[0067] Example
[0068] This embodiment relates to a three-axis ball screw motion control system based on an STM32F103C8T6 single-chip microcomputer. The system adopts a modular design structure and combines a function trajectory planning algorithm to achieve synchronous and precise control of three sets of stepper motors. The entire control system consists of a main control module, a trajectory generation and function analysis module, a drive and actuator module, a battery and power supply management module, a safety and status detection module, and a human-computer interaction module. The main control module includes an STM32 processor and a timer; the trajectory generation and function analysis module includes a function analyzer and a sampling unit; the drive and actuator module includes a stepper motor driver and a ball screw actuator; the battery and power supply management module includes a lithium battery and a step-down module; the safety and status detection module includes limit switches and an emergency stop switch; and the human-computer interaction module includes a TFT touch screen and a serial port debugging assistant. The system is suitable for motion control scenarios that require high path execution accuracy and flexibility. The system has a built-in function path generation module. Users can enter function expressions and parameters through the serial port or graphical interface. The system samples the expression, generates the corresponding coordinate sequence, and generates three-axis synchronous pulse signals through a timer or DMA to achieve coordinated motion of the corresponding path. The system also integrates limit protection, acceleration and deceleration curve control, and an emergency stop module to ensure that mechanical shock and safety accidents are avoided during high-speed operation. In terms of human-computer interaction, the system supports a serial port debugging assistant and a TFT LCD screen interface. By entering the corresponding function expression, speed and other parameters, the user can quickly configure the path and preview the motion process.
[0069] After the system is powered on, the main control module completes basic initialization, including clock configuration, GPIO pin mode settings, timer initialization, and establishing communication with peripherals. Simultaneously, the human-computer interaction module's TFT touchscreen displays direct the user to the parameter input interface. Users can use a graphical interface or command input to set the 3D trajectory function expression and required parameters, such as run time, sampling frequency, starting point position, maximum velocity, and acceleration.
[0070] The trajectory expression entered by the user usually uses the time variable as the independent variable to describe the displacement changes of the X, Y, and Z axes in the time domain. For example, to set a 3D spiral trajectory:
[0071] X(t)=A x sin(2πft)
[0072] Y(t)=A y ·cos(2πft)
[0073] Z(t)=V z ·t
[0074] Among them, A x , A yis the amplitude, f is the frequency, V z is the Z-axis moving speed, and t is the running time.
[0075] The trajectory generation and function path analysis module is based on the set total running time T and sampling frequency f s , automatically calculate the sampling interval And based on this, generate in the [0,T] time period The main control module takes each time point t n =n·Δt, n=0,1,...,N is substituted into the function expressed by the user, and the three-axis space P at each time point is calculated point by point n =(X(t n ),Y(t n ),Z(t n )), and save it in the trajectory array as the reference path for subsequent motion control.
[0076] Then the trajectory generation and function path analysis module calculates the displacement increment Δx for all continuous coordinate points n =X(t n+1 )-X(t n ), by dividing the displacement difference of each axis by the linear displacement d corresponding to each step of the stepper motor step The number of pulses required for the X-axis in the current time slice is:
[0077]
[0078] direction:
[0079] DIR x =sign(Δx n )
[0080] The Y-axis and Z-axis are calculated in the same way, and P is obtained respectively. y (n) and P z (n) and the corresponding direction signal. The system generates a complete pulse quantity sequence and direction identification table and stores it in the motion instruction buffer. At this point, the motion path planning of the function trajectory in digital logic is complete.
[0081] During the motion execution phase, to avoid mechanical shock during motor start-up and stop, the trajectory generation and function path analysis module uses a trapezoidal velocity control algorithm, dividing the entire motion process into three phases: acceleration, constant speed, and deceleration. The step pulse frequency is dynamically adjusted in each phase, allowing the motor to complete the set path with gradual speed changes. Its velocity function v(t) can be described in the following segmented form:
[0082]
[0083] The system determines the target speed v(t) in real time according to the current operating stage, and the linear displacement d corresponding to each step of the motor step , the system can derive the corresponding pulse frequency function as: The STM32 timer TIMx module is configured in output compare mode, and its auto-reload register (ARR) value is updated in real time according to this frequency, thereby achieving continuous adjustment of the motor pulse output frequency, ultimately forming a motion rhythm with smooth speed changes and no mechanical oscillation.
[0084] During the actual pulse output process, each axis independently utilizes a set of timers (such as TIM1 / TIM2 / TIM3). Each timer generates a pulse when the counter matches the value, and stepping is achieved by flipping the logic level of the corresponding GPIO port. The corresponding direction pin DIR is set in advance before each pulse sequence. To ensure consistent and synchronized trajectory among the three axes, the system uses hardware synchronization mechanisms or software time-slicing scheduling for multi-axis coordinated control.
[0085] To ensure safe operation, the system is equipped with a safety and status detection module. First, limit switches are installed at both ends of each axis. When any limit switch is triggered, the system immediately stops the output pulse of the corresponding axis and issues a prompt to prevent the device from running off-limits. Second, an emergency stop switch is provided, connected to the STM32 via an interrupt pin. Once pressed, it immediately stops all timers and disconnects the driver control level, achieving a full axis stop. Furthermore, the battery and power supply management module continuously monitors the system voltage, battery charge, and abnormal power supply status. If overvoltage, undervoltage, or communication anomalies are detected, the system will issue an alarm and switch to protection mode to prevent damage to the circuit or mechanism due to power supply anomalies.
[0086] During the entire operation process, the user can observe the current operating status of the system through the TFT display screen of the human-computer interaction module, including the current coordinate value (x n ,y n ,z n ), speed status, running progress, trajectory graphic preview and other information. The system interface supports dynamic adjustment of running status during operation, such as pause, resume and other operation instructions.
[0087] Through the coordinated execution of the above operating processes, the system can accurately, efficiently and smoothly convert the user's abstractly defined mathematical function trajectory into the physical motion of the three-axis ball screw platform, achieving precise trajectory reproduction and dynamic adjustment, reflecting a high degree of flexibility and engineering practicality.
[0088] The application scenarios of this application are:
[0089] (1) Motion control experimental platform for colleges and universities and scientific research institutions
[0090] Motion control experimental platforms are essential engineering training equipment for teaching and research in fields like electrical automation, mechatronics, and embedded systems. Traditional platforms often rely on expensive industrial controllers, which have high development barriers, redundant functions, and struggle to balance teaching flexibility and cost control.
[0091] The functional three-axis motion device provided by the present invention has core features such as mathematical expression trajectory input, three-axis synchronous control, and graphical human-computer interaction, and is particularly suitable for the experimental teaching needs of colleges and universities. Teachers can let students observe the device performing actual motion by setting trajectory functions (such as spirals, sinusoidal paths, and parabolic curves), corresponding to course content such as control theory, digital modeling, and speed planning algorithms, greatly improving the teaching intuitiveness and students' engineering perception ability. In addition, the device can be used to carry out control strategy research (such as PID parameter adjustment, speed-trajectory response comparison), precision measurement experiments (path error analysis), and scientific and technological innovation competition platforms (such as intelligent robotic arms or function drawing robots), and has broad scientific research expansion value and teaching promotion potential.
[0092] (2) Path precision motion actuator for medical rehabilitation equipment
[0093] In the field of rehabilitation medicine, particularly with smart devices for upper and lower limb functional training, doctors often require patients to perform repetitive movements along pre-set trajectories. These trajectories often consist of periodic, function-modeled paths, such as circular motion, arm circles, and elbow-wrist spirals.
[0094] The functional trajectory control mechanism of the present invention can directly accept such rehabilitation path expressions without manual point-by-point entry. Doctors can flexibly adjust function parameters according to the patient's recovery stage to achieve dynamic configuration of exercise intensity and frequency. The system uses a ball screw to achieve smooth and high-precision linear displacement, acceleration and deceleration algorithms ensure smooth movement, and closed-loop drive feedback improves reliability. It is particularly suitable for arm / finger / ankle rehabilitation training platforms. With the help of a graphical interface, rehabilitation personnel can observe the execution status of the movement in real time and adjust the training plan. If expansion modules such as integrated electromyography sensors and grip feedback devices are used, a closed-loop rehabilitation feedback mechanism can be further constructed to achieve intelligent rehabilitation evaluation and auxiliary treatment functions.
[0095] It should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that includes a list of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus.
[0096] While embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions, and variations may be made to these embodiments without departing from the principles and spirit of the invention, and that the scope of the invention is defined by the appended claims and their equivalents.
Claims
1. A three-axis ball screw functional motion system based on STM32, characterized in that: It includes a main control module, a trajectory generation and function analysis module, a drive and actuator module, a battery and power supply management module, a safety and status detection module, and a human-computer interaction module; the human-computer interaction module is used to receive three-axis displacement parameters input by the user; the main control module initializes and verifies the input content, the trajectory generation and function analysis module generates trajectory points, and the main control module converts pulse and direction signals; the drive and actuator module drives the motor to achieve displacement and feedback the status; the safety and status detection module is used to monitor the status and shut down in case of abnormality; the operating status is transmitted to the human-computer interaction module for display via the main control module; the battery and power supply management module is used to provide stable power supply.
2. A three-axis ball screw functional motion system based on STM32 according to claim 1, characterized in that, The main control module, based on an STM32F103C8T6 microcontroller, is responsible for overall system coordination, connecting various functional modules, executing control algorithms, and exchanging data with the human-computer interaction module. The drive and actuator module, consisting of an Emm42_V4.x stepper closed-loop driver and a ball screw, receives pulse signals generated by the main control module and controls the rotation speed and direction of three sets of stepper motors on the X, Y, and Z axes, converting the stepper motors' rotational motion into precise linear displacements of each axis. The trajectory generation and function analysis module, embedded in the main control module, receives function expressions entered by the user, calculates the coordinate sequence of sampling points, and generates corresponding pulse control signals. The human-computer interaction module includes a serial debugging interface and a TFT touch screen for user input of function parameters, trajectory preview, and operation status monitoring. The battery and power management module, consisting of a lithium battery pack, a buck-stabilization circuit, and a charging protection circuit, provides a stable power supply for the system, supporting portable use. The safety and status detection module, including limit switches, an emergency stop circuit, and a power monitoring circuit, monitors the system's operating status in real time to ensure safe operation.
3. A three-axis ball screw functional motion system based on STM32 according to claim 1, characterized in that, The user inputs the displacement function expression and operating parameters of the X, Y, and Z axes through the TFT touch screen of the human-computer interaction module; the system is initialized by the main control module to complete the GPIO, timer, and serial port, and perform syntax and logic verification on the input content; after the verification is passed, the trajectory generation and function analysis module generates a time series according to the set sampling frequency, and the analysis function calculates the three-axis target coordinates to form discrete trajectory points. The main control module combines the screw lead and motor parameters to convert the step pulse sequence and direction signal; during the trajectory execution process, the main control module outputs a trapezoidal speed pulse according to the preset acceleration and deceleration algorithm, and the pulse signal is driven by the driver. Together with the actuator module, a closed-loop driver controls three sets of stepper motors to drive the ball screws, achieving high-precision linear displacement along three axes and feeding back the motor operating status to the main control in real time to avoid step loss and error accumulation, thus ensuring accuracy. At the same time, the safety and status detection module continuously monitors the limit, emergency stop, and power status. If any abnormality is detected, movement will be stopped immediately to ensure the safety of equipment and personnel. The trajectory, coordinates, speed, and other status during operation are transmitted to the human-machine interaction module through the main control for real-time display. Users can also adjust parameters or pause / resume operation at any time. The entire system is powered by a battery and power management module, providing a stable power supply and supporting portable applications.
4. A three-axis ball screw functional motion method based on STM32, the method being based on a three-axis ball screw functional motion system based on STM32 according to any one of claims 1 to 3, characterized in that: The following steps are involved: S1, system initialization; S2, trajectory parameter input and expression verification; S3. The system samples the function expression entered by the user to generate trajectory points, then calculates the number and direction of pulses per axis through coordinate difference, and derives the corresponding pulse frequency in combination with the speed planning algorithm to realize the conversion of function trajectory into synchronous pulse control instructions; S4. The system uses multiple timers to output three-axis synchronous pulse signals to drive the ball screw to complete the path movement. At the same time, it combines closed-loop feedback to achieve error compensation, and ensures safe operation through limit protection and power monitoring mechanisms; S5. Real-time monitoring and interactive adjustment.
5. A three-axis ball screw functional motion method based on STM32 according to claim 4, characterized in that, S1 specifically: After the system is powered on, the main control module completes basic configuration, including clock system initialization, GPIO port settings, timer configuration, and serial communication initialization; at the same time, the safety and status detection module activates limit detection, emergency stop response, and voltage status monitoring functions to ensure that the system starts and runs in a controlled and safe environment.
6. A three-axis ball screw functional motion method based on STM32 according to claim 4, characterized in that, Specifically, S2 involves the user inputting a function expression showing the time-varying X, Y, and Z axes in three-dimensional space, as well as control parameters such as run time, sampling frequency, initial velocity, and acceleration, through the TFT touch screen of the human-computer interaction module. The trajectory generation and function parsing module automatically verifies the syntax of the expression, including variable symbols, bracket nesting, and function validity. If there are any format errors, the user will be prompted to correct them through feedback on the human-computer interface.
7. A three-axis ball screw functional motion method based on STM32 according to claim 4, characterized in that, S3 specifically: S31, trajectory point sampling and coordinate generation; after the expression is verified, the trajectory generation and function analysis module generates an equally spaced time series {t0, t1, ..., t n }, and each t i Substitute the user-defined function to calculate the three-axis target coordinates (x i ,y i ,z i ), forming a discrete trajectory point array P n =(X(t n ),Y(t n ),Z(t n )), as the basis for path control; S32, pulse parameter conversion and direction command generation; trajectory generation and function analysis module performs differential calculation on the coordinate difference between continuous trajectory points, assuming Δx i =x i+1 -x i ,Δy i =y i+1 -y i ,Δz i =z i+1 -z i , combined with the linear displacement d corresponding to each step of the stepper motor step , convert the number of pulses required for each axis in this time slice: At the same time, the displacement sign is determined and the direction control signal DIR is generated; The pulse quantity and direction pairs are cached in the instruction queue for subsequent execution module calls; S33, speed planning and pulse frequency calculation; To ensure smooth motion, the trajectory generation and function analysis module adopts a segmented trapezoidal acceleration and deceleration algorithm, dividing the entire operation process into acceleration, uniform speed and deceleration segments; let the target speed be v(t), combined with the unit step length d step , the target pulse frequency can be obtained: The main control module dynamically updates the timer automatic reload value ARR according to f(t), thereby adjusting the output frequency of the step pulse to achieve continuously variable speed.
8. A three-axis ball screw functional motion method based on STM32 according to claim 4, characterized in that, S4 is specifically: S41, pulse output and multi-axis synchronization execution; the system allocates independent timers TIM1, TIM2, TIM3 for each axis, and synchronously outputs pulse signals through output comparison mode or DMA control mode; The closed-loop driver in the drive and actuator module receives pulse and direction signals, drives the stepper motor to rotate at the corresponding speed and direction, and converts the rotation into linear displacement through the ball screw structure to achieve three-axis coordinated spatial motion; S42, state feedback and error compensation: The closed-loop stepper driver collects motor position feedback signals in real time. If a step-out or load interference is detected, the driver automatically performs error compensation and feeds back the operating status to the main control module to improve operating accuracy and trajectory consistency. S43. Abnormal detection and safety response: If the system detects that the limit switch is triggered, the emergency stop button is pressed, or the power supply is abnormal, the main control module immediately stops all pulse outputs, turns off the driver control level, and issues a warning message through the screen; the battery and power supply management module monitors the voltage status and automatically switches to protection mode when undervoltage or low battery is detected to prevent damage to the mechanism or circuit.
9. A three-axis ball screw functional motion method based on STM32 according to claim 4, characterized in that, S5 specifically means: during the motion execution process, users can view the current coordinates, speed, running progress and trajectory images in real time through the human-computer interaction module; the system supports parameter adjustment during operation, such as dynamic acceleration and deceleration, pause / resume operations, forming a controllable closed-loop interactive process.