A method and system for driving control for respiratory motion simulation
By generating multimodal respiratory waveforms through a semi-cosine interpolation algorithm and a multidimensional dynamic compensation mechanism, the problem that existing respiratory motion simulation devices cannot reproduce real respiratory characteristics is solved, achieving high-precision respiratory motion simulation and improving the quality control effect of radiotherapy and medical imaging.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHANGHAI ZHUOLIN MEDICAL EQUIPMENT CO LTD
- Filing Date
- 2026-04-13
- Publication Date
- 2026-07-10
AI Technical Summary
Existing respiratory motion simulation devices have a single motion trajectory, which cannot reproduce the non-linear characteristics of real patient breathing. Furthermore, traditional mechanical structures are prone to impact and vibration at the inspiratory-exhalation phase switching point, resulting in a serious disconnect between the quality control verification scenario and the actual clinical situation.
A piecewise breathing function is constructed using a half-cosine interpolation algorithm. Combined with a multi-dimensional dynamic compensation mechanism and an S-shaped smoothing mapping algorithm, multi-modal waveforms are generated. Through a dual-core distributed architecture that separates upper-computer interaction and lower-computer control, real-time monitoring of breathing parameters and precise control of the motor are achieved, eliminating mechanical shock and vibration and ensuring a smooth transition of the motion trajectory.
It improves the clinical precision of radiotherapy and medical imaging, meets the needs of all scenarios from routine quality control to extreme performance testing, and enhances the system's real-time response capability and industrial-grade reliability under long-term operation and complex command interaction.
Smart Images

Figure CN122363383A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of medical device technology, and in particular to a drive control method and system for simulating respiratory movements. Background Technology
[0002] In precision medicine fields such as radiotherapy and medical imaging, imaging artifacts caused by human respiratory motion and radiotherapy dose deviations are key bottlenecks restricting diagnostic and treatment accuracy. Therefore, respiratory motion simulation devices are widely used in clinical practice as standard quality control tools to verify the respiratory gating function of radiotherapy equipment and the effectiveness of motion correction algorithms in imaging equipment. Existing mainstream simulation devices are typically based on mechanical crank-slider mechanisms or motor drive systems with fixed waveform generators, simulating the rise and fall of the human chest and abdomen by generating preset periodic reciprocating motions.
[0003] Existing technologies have a single motion trajectory and can only simulate standard periodic motion. They are unable to reproduce the complex nonlinear characteristics of real patient breathing, such as baseline drift, frequency time variation, and amplitude fluctuation. Furthermore, traditional mechanical structures are prone to impact and vibration at the inspiratory-exhalation phase switching point, resulting in a serious disconnect between the quality control verification scenario and the actual clinical situation. Summary of the Invention
[0004] To overcome the above shortcomings, the present invention provides a drive control method and system for respiratory motion simulation, aiming to improve the problem that the existing technology has a single motion trajectory and cannot reproduce the real respiratory characteristics.
[0005] In a first aspect, the present invention provides the following technical solution: a drive control method for simulating respiratory movements, comprising: S1. Obtain the user-set breathing parameters through the host computer. The breathing parameters include target tidal volume, respiratory rate, inspiratory-expiratory ratio and waveform pattern, and transmit the breathing parameters to the main control unit. S2. The main control unit operates a breathing clock, determines the breathing cycle based on the breathing frequency in the breathing parameters, and divides the breathing cycle into an inhalation phase and an exhalation phase according to the inhalation-exhalation ratio. S3. The main control unit calculates the theoretical tidal volume corresponding to the current moment in real time based on the current moment of the breathing clock, the breathing cycle, and the waveform pattern. S4. The main control unit calculates the reference speed based on the rate of change of the theoretical tidal volume over time, obtains the current mechanical load state of the simulation device and the corresponding compensation coefficient, corrects the reference speed using the compensation coefficient, and generates a target speed command. S5. The main control unit controls the motor to run according to the target speed command, and during the operation, it monitors the current signal or stall signal in real time. When the detected signal exceeds a preset threshold, it controls the motor to stop running or adjusts the output limit.
[0006] Preferably, in step S2, the step of dividing the respiratory cycle into an inspiratory phase and an expiratory phase based on the inspiratory-expiratory ratio includes: A time-slice polling architecture is built within the main control unit, with the main control cycle set to 1ms. The system tasks are divided into periodic tasks, 1ms high-frequency tasks, and multiple low-frequency tasks with different cycles to ensure that the counting accuracy of the breathing clock is not affected by non-real-time tasks. The system maintains a global respiratory clock variable, which accumulates a count according to the user-defined cycle and resets when the count reaches the cycle threshold to maintain a continuous respiratory rhythm. The time thresholds for the duration of the inspiratory and expiratory phases are calculated based on the set inspiratory-expiratory ratio. The current respiratory clock value is mapped to the inspiratory or expiratory state machine in real time, providing a status flag for subsequent waveform function calls.
[0007] Preferably, in step S3, the step of calculating the theoretical tidal volume corresponding to the current moment in real time based on the current moment of the respiratory clock, the respiratory cycle, and the waveform pattern, when the waveform pattern is a sinusoidal breathing pattern, includes: To eliminate the mechanical impact generated by the mechanical cam or standard sine wave at the reversal point, a half-cosine interpolation algorithm is used as the waveform generation logic, and independent function expressions are constructed for the inhalation and exhalation segments respectively. When the respiratory clock is in the inspiratory phase, the theoretical tidal volume is calculated using the transformation logic of the cosine function based on the current time, the total duration of the inspiratory phase, and the preset amplitude. When the respiratory clock is in the expiratory phase, based on the current time, the total duration of the expiratory phase, the duration of the inspiratory phase, and the preset amplitude, the current theoretical tidal volume is calculated using the transformation logic of the cosine function to ensure that the acceleration is continuous and without abrupt changes at the phase transition between the end of inspiration and the end of expiration, thus achieving a smooth transition.
[0008] Preferably, in step S3, the step of calculating the theoretical tidal volume corresponding to the current moment based on the current time of the respiratory clock, the respiratory cycle, and the waveform pattern, when the waveform pattern is a trapezoidal wave pattern, includes: A complete respiratory cycle is further subdivided into four consecutive time intervals: the rising segment, the high plateau segment, the falling segment, and the low plateau segment, which correspond to the inhalation, deep inhalation and breath-holding, exhalation, and end-expiratory pause in the respiratory physiological process, respectively. The theoretical tidal volume output is kept constant at the maximum set value in the high plateau section to simulate the static characteristics of deep inspiration and breath-holding during radiotherapy, and to verify the imaging quality of the imaging equipment in the breath-holding state. Linear interpolation calculations are performed during the ascending and descending phases to control the phantom to complete inhalation and exhalation at a constant speed until a preset plateau time threshold is reached, at which point the process switches to the next phase.
[0009] Preferably, in step S3, the step of calculating the theoretical tidal volume corresponding to the current moment based on the current time of the respiratory clock, the respiratory cycle, and the waveform pattern, when the waveform pattern is a sawtooth wave or a pulse wave pattern, includes: Generate sawtooth waves with linear variation characteristics or pulse waves with transient step characteristics for extreme performance testing of breathing simulation devices or boundary condition verification of motion correction algorithms. By outputting mechanical waveforms that do not follow the natural breathing pattern of the human body, the system response capability and artifact correction performance of imaging or radiotherapy equipment in response to unexpected motion changes are tested. In pulse mode, the motor is controlled to complete a large-scale position switch within a preset transient time to verify the dynamic response bandwidth of the drive system and the rigidity and stability of the mechanical structure.
[0010] Preferably, in step S4, the step of obtaining the current mechanical load state of the simulation device and the corresponding compensation coefficient includes: Establish a functional relationship between the compensation coefficient and multiple input variables, wherein the input variables include at least the target tidal volume, respiratory rate, inspiratory-expiratory ratio, and the physical shell condition of the device; Identify whether the simulation device is currently equipped with a casing, and based on the nonlinear difference in mechanical damping under casing or uncased conditions, call the corresponding preset damping characteristic curve or lookup table. The final speed command is obtained by multiplying the base speed using the determined compensation coefficient. The compensation coefficient is introduced to offset the motion lag or overshoot caused by changes in mechanical load, ensuring that the actual motion trajectory accurately follows the theoretical waveform.
[0011] Preferably, in step S4, the step of correcting the reference speed using the compensation coefficient to generate the target speed command includes: Detect whether the target tidal volume is within a preset large tidal volume range; Call the mapping function to perform an S-shaped smooth mapping on the target tidal volume within the preset large tidal volume range; The S-shaped smooth mapping limits the acceleration of the motor at the moment of commutation, preventing the generation of reverse electromotive force due to excessive acceleration, and implements soft limit protection at the software level.
[0012] Preferably, in step S5, the step of controlling the motor to stop running or adjusting the output limit when the detected signal exceeds a preset threshold by real-time monitoring of the current signal or stall signal includes: In the safety monitoring layer, real-time data acquisition tasks for the drive motor's operating current, operating voltage, module temperature, and stall status are executed in parallel. The collected real-time data is compared with the preset safety threshold. When the current is detected to continuously exceed the rated value, or when the motor is detected to be in a stalled state, an abnormal state flag is triggered. Once the abnormal flag is triggered, the motor drive output is immediately cut off or the speed command is forcibly reset to zero, and an error code is fed back to the main control unit to prevent equipment damage or fire hazards caused by mechanical jamming or electrical overload.
[0013] Secondly, the present invention provides the following technical solution: a drive control system for simulating respiratory movements, the system comprising: The host computer interaction module is used to acquire the respiratory parameters set by the user and transmit the respiratory parameters to the main control unit. The respiratory parameters include target tidal volume, respiratory rate, inspiratory-expiratory ratio and waveform pattern. The timing management module is used to run the breathing clock, determine the breathing cycle based on the breathing frequency in the breathing parameters, and divide the breathing cycle into an inspiratory phase and an expiratory phase according to the inspiratory-expiratory ratio. The waveform generation module is used to calculate the theoretical tidal volume corresponding to the current moment in real time based on the current moment of the respiratory clock, the respiratory cycle and the waveform pattern. The dynamic compensation module is used to calculate the reference speed based on the rate of change of the theoretical tidal volume over time, obtain the current mechanical load state of the simulation device and the corresponding compensation coefficient, and use the compensation coefficient to correct the reference speed to generate a target speed command. The drive monitoring module is used to control the motor to run according to the target speed command, and during the operation, it monitors the current signal or stall signal in real time. When the detected signal exceeds a preset threshold, it controls the motor to stop running or adjusts the output limit.
[0014] The present invention has the following beneficial effects: 1. In this invention, a piecewise breathing function is constructed by using a half-cosine interpolation algorithm, which ensures that the acceleration at the transition point between the inhalation and exhalation phases is continuous without abrupt changes. This effectively eliminates the mechanical shock and vibration caused by traditional mechanical cams or standard sine waves, making the motion trajectory of the breathing phantom highly replicate the smooth transition characteristics of real human breathing, thereby significantly improving the clinical accuracy of radiotherapy respiratory gating verification and medical imaging motion correction.
[0015] 2. In this invention, a multi-dimensional dynamic compensation mechanism including moisture volume, frequency and shell load status is established. It can correct the motor speed command in real time according to the nonlinear change of mechanical damping, and use the S-shaped smoothing mapping algorithm to flexibly reduce the peak in the long stroke condition. While preventing the back electromotive force from being too large and damaging the hardware, it also realizes software limit protection, ensuring the system's operational stability and tracking accuracy under different physical loads and wide dynamic range.
[0016] 3. This invention supports the generation of multimodal waveforms, including trapezoidal waves, sawtooth waves, and pulse waves. It can accurately simulate the critical deep inhalation and breath-holding state in radiotherapy to verify static imaging quality. It also evaluates the dynamic response bandwidth and artifact correction capability of imaging equipment through extreme test waveforms. This solves the pain point of existing equipment having a single motion mode and being unable to reproduce complex clinical respiratory characteristics, and meets the needs of all scenarios from routine quality control to extreme performance testing.
[0017] 4. In this invention, a dual-core distributed architecture is adopted to separate the upper-level computer interaction and the lower-level computer control. The time-slice polling mechanism strictly isolates the real-time motion control task from the human-computer interaction task, ensuring that the millisecond-level high-frequency breathing clock counting and the underlying driving algorithm are not interfered with by the interface operation, which greatly improves the system's real-time response capability and industrial-grade reliability under long-term operation and complex command interaction. Attached Figure Description
[0018] Figure 1 This is a flowchart of a drive control method for simulating respiratory movements proposed in this invention; Figure 2 This is an architecture diagram of a drive control system for respiratory motion simulation proposed in this invention. Figure 3 This is a detailed execution logic diagram of a drive control method and system for simulating respiratory movements proposed in this invention; Figure 4 This is a schematic diagram of the waveform mode and parameter composition; Figure 5 This is a diagram showing a sine wave. Figure 6 This is a trapezoidal waveform display diagram; Figure 7 This is a diagram showing a sawtooth waveform. Figure 8 This is a diagram showing the pulse waveform. Detailed Implementation
[0019] The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0020] Example 1 In a first embodiment of the present invention, the present invention provides a drive control method for simulating respiratory movements, such as... Figure 1 As shown, it includes: S1. Obtain the user-defined respiratory parameters through the host computer. The respiratory parameters include target tidal volume, respiratory rate, inspiratory-expiratory ratio and waveform pattern, and transmit the respiratory parameters to the main control unit. Specifically, the host computer interactive environment is built on a screen assembly hardware platform based on the RK3566 main control chip, and the software system is built using QT5.12. After the system powers on, the host computer loads a user configuration interface on the touch screen, which includes interactive controls for inputting values and selecting modes. Operators set respiratory parameters through this interface according to the specific clinical needs of radiotherapy or medical imaging verification. The specific physical definitions and technical data corresponding to these respiratory parameters are as follows: Target Tidal Volume Respiratory rate is the volume of gas inhaled or exhaled during a single respiratory movement, typically expressed in milliliters; Characterized by the number of respiratory cycles completed per minute; inspiratory-to-expiratory ratio It represents the ratio of inhalation time to exhalation time; the waveform mode is used to select specific motion trajectory types such as sine wave, trapezoidal wave, sawtooth wave or pulse wave.
[0021] The data transmission process relies on an RS485 half-duplex communication link established between the host computer and the main control unit. The host computer software encodes and packages the aforementioned target tidal volume, respiratory rate, inspiratory-expiratory ratio, and waveform pattern parameters according to a predefined communication protocol frame format, and sends them via a serial bus. The main control unit uses an STM32G431RBT6 microcontroller as its core processing unit, receiving data packets from the RS485 bus through its communication interface. The main control unit unpacks and parses the received data packets, verifying the integrity and validity of the data according to a preset parameter range. After successful verification, the main control unit stores these parameters in the input parameter layer of its internal software architecture for subsequent use by the waveform generation engine and motion control algorithms.
[0022] This step, through a dual-core hardware architecture and a dedicated communication protocol, enables the visual configuration and precise transmission of respiratory simulation parameters, ensuring that the upper-level human-computer interaction does not interfere with the real-time performance of the lower-level control system, and providing an accurate data foundation for subsequent high-fidelity respiratory motion simulation.
[0023] S2. The main control unit runs the breathing clock, determines the breathing cycle based on the breathing frequency in the breathing parameters, and divides the breathing cycle into the inhalation phase and the exhalation phase according to the inhalation-exhalation ratio. Furthermore, in step S2, the step of dividing the respiratory cycle into an inspiratory phase and an expiratory phase based on the inspiratory-expiratory ratio includes: constructing a time-slice polling architecture within the main control unit, setting the main control cycle to 1ms, dividing system tasks into periodic tasks, 1ms high-frequency tasks, and multiple low-frequency tasks with different cycles to ensure that the counting accuracy of the respiratory clock is not interfered with by non-real-time tasks; maintaining a global respiratory clock variable, accumulating the count according to the user-defined cycle, and resetting it when the count value reaches the cycle threshold to maintain a continuous respiratory rhythm; calculating the time thresholds for the duration of the inspiratory and expiratory phases based on the set inspiratory-expiratory ratio, and mapping the current respiratory clock value to the inspiratory or expiratory state machine in real time to provide a status flag for subsequent waveform function calls.
[0024] Specifically, the main control unit's hardware core uses an STM32G431RBT6 microcontroller, and the software layer employs a real-time multi-task scheduling architecture based on time-slice polling. The system is configured with a hardware timer to generate a precise 1-millisecond interrupt signal, serving as the heartbeat of the system's main control cycle. Under this architecture, system tasks are strictly divided into execution sequences of different priorities. The breathing clock counting and maintenance, along with the motor motion control algorithm, are defined as high-frequency tasks with 1-millisecond cycles, executed in interrupt service routines or the highest-priority thread to ensure they are not affected by blocking caused by communication processing or interface refresh operations. Non-real-time tasks such as RS485 communication protocol parsing, screen display data updates, and temperature monitoring are allocated to low-frequency task queues with 10-millisecond or 100-millisecond cycles, executing only during idle time slices.
[0025] During the establishment of the timing logic, the main control unit maintains a global variable named `breath_tick` in memory as a breathing clock counter. The system first calculates the total duration of a single breathing cycle based on the user-defined breathing frequency. Let the user-defined breathing frequency be... If the unit is breaths per minute, then the respiratory cycle is... The calculation formula is as follows: ; In the formula, This represents the number of milliseconds corresponding to one minute. Enter the respiratory rate value. This refers to the calculated cycle duration in milliseconds. During system operation, the `breath_tick` variable automatically increments by 1 within each 1-millisecond control cycle. When the accumulated value of `breath_tick` reaches a value greater than or equal to... When the system immediately resets breath_tick to zero, it completes the counting of one respiratory cycle and seamlessly starts the next cycle, maintaining a continuous and stable respiratory rhythm.
[0026] The system divides the above breathing cycle into an inspiratory phase and an expiratory phase in time based on the user-defined inspiratory-expiratory ratio. Let the user-defined inspiratory-expiratory ratio be... ,in Represents the inspiratory proportion factor. The expiratory ratio factor represents the threshold duration of the inspiratory phase. Calculate using the following formula: ; Correspondingly, the duration of the exhalation phase This is the total cycle duration minus the inhalation duration. The system compares the current breath_tick value with the total cycle duration in real time within each control cycle. The size relationship. When the value of breath_tick is less than... When the system maps the current running state flag to the inhalation state machine flag; when the value of breath_tick is greater than or equal to and less than At this time, the system maps the current operating state to exhalation state machine flags. These state flags are directly passed as input parameters to the subsequent waveform generation function to select the corresponding motion control algorithm.
[0027] This step, through strict time slice management and mathematical timing segmentation, eliminates timing jitter in a multi-tasking environment, ensuring millisecond-level accuracy and determinism of the breathing phantom when switching between inhalation and exhalation states.
[0028] S3. The main control unit calculates the theoretical tidal volume corresponding to the current moment in real time based on the current time of the respiratory clock, the respiratory cycle and the waveform pattern. Further, in step S3, the theoretical tidal volume corresponding to the current moment is calculated in real time based on the current moment of the respiratory clock, the respiratory cycle, and the waveform pattern. When the waveform pattern is a sinusoidal breathing pattern, the steps include: in order to eliminate the mechanical impact generated by the mechanical cam or standard sine wave at the reversal point, a half-cosine interpolation algorithm is called as the waveform generation logic to construct independent function expressions for the inspiratory and expiratory phases respectively; when the respiratory clock is in the inspiratory phase, the current theoretical tidal volume is calculated using the transformation logic of the cosine function based on the current moment, the total duration of the inspiratory phase, and the preset amplitude; when the respiratory clock is in the expiratory phase, the current theoretical tidal volume is calculated using the transformation logic of the cosine function based on the current moment, the total duration of the expiratory phase, the duration of the inspiratory phase, and the preset amplitude, ensuring that the acceleration is continuous and without abrupt changes at the phase transition between the end of inspiration and the end of expiration, thus achieving a smooth transition.
[0029] Further, in step S3, the theoretical tidal volume corresponding to the current moment is calculated in real time based on the current moment of the respiratory clock, the respiratory cycle, and the waveform pattern. When the waveform pattern is a trapezoidal wave pattern, the steps include: further subdividing a complete respiratory cycle into four continuous time intervals: the rising segment, the high plateau segment, the falling segment, and the low plateau segment, which correspond to the inhalation, deep inhalation breath-hold, exhalation, and end-expiratory pause states in the respiratory physiological process, respectively; maintaining the theoretical tidal volume output at a constant maximum set value in the high plateau segment to simulate the static characteristics of deep inhalation breath-hold in radiotherapy, used to verify the imaging quality of the imaging equipment in the breath-hold state; performing linear interpolation calculations in the rising and falling segments to control the phantom to complete the inhalation and exhalation actions at a constant speed until the preset plateau time threshold is reached, and then switching to the next stage.
[0030] Further, in step S3, the theoretical tidal volume corresponding to the current moment is calculated in real time based on the current moment of the respiratory clock, the respiratory cycle, and the waveform pattern. When the waveform pattern is a sawtooth wave or a pulse wave, the steps include: generating a sawtooth wave with linear variation characteristics or a pulse wave with transient step characteristics for extreme performance testing of the respiratory simulation device or boundary condition verification of the motion correction algorithm; detecting the system response capability and artifact correction performance of the imaging equipment or radiotherapy equipment in response to unexpected motion changes by outputting mechanical waveforms that do not conform to the natural breathing pattern of the human body; and in pulse mode, controlling the motor to complete a large-scale position switch within a preset transient time to verify the dynamic response bandwidth of the drive system and the rigidity and stability of the mechanical structure.
[0031] Specifically, within each 1-millisecond control cycle, the main control unit reads the current global breathing clock variable breath_tick as the time input. It then enters the corresponding calculation branch based on the waveform mode pre-selected by the user. Modes include pulse waveform, sawtooth waveform, sine waveform, and trapezoidal waveform; specific parameters are as follows... Figure 4 As shown.
[0032] When the system is in sinusoidal breathing mode, to address the acceleration discontinuity issue caused by abrupt curvature changes during the transition between inhalation and exhalation in traditional mechanical cams or standard sine waves, the system employs a semi-cosine interpolation algorithm as the core waveform generation logic. This algorithm mathematically decouples a complete breathing cycle into independent inhalation and exhalation function segments, as shown in the sinusoidal waveform display below. Figure 5 As shown. When the time variable During the inhalation phase, that is At that time, the main control unit calculates the current theoretical tidal volume according to the following formula: ; When time variable During the exhalation phase, that is At this time, the main control unit switches to the following formula for calculation: ; In the above formula, This represents the calculated theoretical tidal volume at the current moment, expressed in milliliters. This indicates the target tidal volume set by the user. Indicates the total duration of the inhalation phase. Indicates the total duration of the exhalation phase. This is the current count value of the breathing clock. The algorithm utilizes the periodicity of the cosine function to ensure that the waveform... , and At the equiphase inflection point, both the first-order derivative velocity and the second-order derivative acceleration change continuously, thus eliminating rigid impact at the physical level.
[0033] When the user selects the trapezoidal waveform mode, the main control unit executes piecewise linear interpolation logic. The system sequentially divides the time axis of a respiratory cycle into four intervals: the rising segment, the high plateau segment, the falling segment, and the low plateau segment. This accurately simulates the deep inspiration and breath-holding state during radiotherapy, and the trapezoidal waveform is displayed as follows: Figure 6 As shown. The formulas for the four intervals are: Ascending segment ( ): Linear increase ; High platform section ( Maintain peak performance ; Descent segment ( ,in ): Linear decrease ; Low plateau segment (remaining time): Keep at 0 ; When the user selects the sawtooth wave or pulse wave mode, it is used for extreme testing.
[0034] Sawtooth waveform display as follows Figure 7 As shown, the sawtooth wave formula is: Ascending phase ( ): ; The descent phase ( ): ; Pulse waveform display as follows Figure 8 As shown, the pulse wave formula is: ; Among them, let The current tidal volume. Target tidal volume.
[0035] This step reconstructs the physical characteristics of respiratory motion through diverse mathematical models, achieving smooth, shock-free control in sinusoidal mode, improving the trajectory reproduction accuracy of radiotherapy gating verification, and taking into account the specific clinical scenario simulation in trapezoidal wave mode and the system robustness self-testing requirements in pulse mode.
[0036] S4. The main control unit calculates the reference speed based on the theoretical rate of change of tidal volume over time, obtains the current mechanical load state of the simulation device and the corresponding compensation coefficient, corrects the reference speed using the compensation coefficient, and generates the target speed command. Further, in step S4, the step of obtaining the current mechanical load state of the simulation device and the corresponding compensation coefficient includes: establishing a functional relationship between the compensation coefficient and multiple input variables, the input variables including at least the target tidal volume, respiratory rate, inspiratory-expiratory ratio, and the physical shell state of the device; identifying whether the simulation device is currently equipped with a shell, and calling the corresponding preset damping characteristic curve or lookup table according to the nonlinear difference in mechanical damping under shell-on or shell-off states; using the determined compensation coefficient to perform multiplication correction calculation on the reference speed to obtain the final speed command, and by introducing the compensation coefficient to offset the motion lag or overshoot caused by changes in mechanical load, ensuring that the actual motion trajectory accurately follows the theoretical waveform.
[0037] Furthermore, in step S4, the step of correcting the reference speed using the compensation coefficient to generate the target speed command includes: detecting whether the target tidal volume is within the preset large tidal volume range; calling the mapping function to perform S-shaped smooth mapping on the target tidal volume within the preset large tidal volume range; limiting the acceleration of the motor at the moment of commutation through S-shaped smooth mapping to prevent the generation of back electromotive force due to excessive acceleration, and implementing soft limit protection at the software level.
[0038] Specifically, the main control unit first processes the theoretical tidal volume at the current moment calculated in step S3. Differential calculations are performed to obtain the rate of change of moisture volume over time, thereby obtaining the reference speed of the motor. This reference speed characterizes the instantaneous rotational speed required for the motor-driven model to reach the target position under the assumptions of an ideal, unloaded system and perfectly linear mechanical transmission. Subsequently, the system enters a dynamic compensation phase to eliminate the nonlinear damping effects of the actual physical system. The compensation coefficients are pre-established in the system's memory. A multidimensional mapping or lookup table with multiple key input variables, including at least the user-defined target tidal volume. respiratory rate Inhalation-exhalation ratio and the current physical casing status of the device .
[0039] In actual operation, the main control unit determines whether the simulation device currently has a casing by detecting through sensors or identifying through user configuration. The value is determined by the significant nonlinear difference in air resistance and mechanical friction torque between the device with and without the casing installed. The system will retrieve the corresponding preset damping characteristic curve based on the identification result. The main control unit will then interpolate or calculate the corresponding compensation coefficient from the characteristic curve based on the current operating parameters. The coefficient is then used to perform a multiplication correction calculation on the reference speed. At this point, the speed command after compensation correction... The calculation formula is as follows: ; In the formula, As the reference speed, This is a dimensionless dynamic compensation coefficient. This is the compensated intermediate speed command. By introducing this compensation coefficient, the system can actively counteract the actual motion lag or overshoot caused by changes in mechanical load and damping nonlinearity.
[0040] Building upon this, to further protect the hardware and ensure the safety of long-stroke motion, the system performs peak shaving and nonlinear mapping processing before generating the final target speed command. The system also monitors the currently set target tidal volume in real time. Is it within the preset tidal volume range? If it is, it indicates that the motor may face extremely high acceleration demands during the breathing reversal. In this case, the system calls the preset MapInputToOutput mapping function to perform an S-curve smoothing mapping on the corrected speed command or tidal volume trajectory. This mapping process limits the angular acceleration of the motor during the transition from inhalation to exhalation or vice versa by reducing the rate of curvature change at the waveform peak, thereby preventing the generation of a huge back electromotive force exceeding the actuator's capacity due to sudden speed changes. Simultaneously, this S-curve mapping implements a soft limit protection function for extreme travel at the software level. The final generated target speed command... It will be used directly for closed-loop control of the drive motor.
[0041] This step, through the combination of multidimensional dynamic compensation and S-shaped flexible constraint algorithm, not only solves the trajectory distortion problem caused by mechanical damping nonlinearity and achieves accurate physical tracking of theoretical waveforms, but also effectively avoids the risk of electrical shock under extreme conditions and improves the operational stability of the system.
[0042] S5. The main control unit controls the motor to run according to the target speed command, and during the operation, it monitors the current signal or stall signal in real time. When the detected signal exceeds the preset threshold, it controls the motor to stop running or adjusts the output limit.
[0043] Furthermore, in step S5, the step of controlling the motor to stop running or adjusting the output limit when the detected signal exceeds a preset threshold by real-time monitoring of the current signal or stall signal includes: in the safety monitoring layer, performing real-time data acquisition tasks for the driving motor's operating current, operating voltage, module temperature, and stall status in parallel; comparing the acquired real-time data with preset safety thresholds; triggering an abnormal status flag when the current continuously exceeds the rated value or the motor is detected to be in a stall state; once the abnormal status flag is triggered, immediately cutting off the motor drive output or forcibly setting the speed command to zero, and feeding back an error code to the main control unit to prevent equipment damage or fire hazards caused by mechanical jamming or electrical overload.
[0044] Specifically, while the main control unit executes the motor drive task, it runs an independent safety monitoring thread in the background, which belongs to the safety monitoring layer. The system is equipped with an STM32G431RBT6 microcontroller with a multi-channel analog-to-digital converter and general-purpose input / output interfaces, performing parallel real-time data acquisition tasks for the drive motor's operating current, operating voltage, module temperature, and stall status. Within each sampling cycle, the system reads the real-time current value fed back from the sensors. Simultaneously, the status register bits fed back by the motor driver are monitored to obtain a logic signal indicating whether the motor is in a stalled state. .
[0045] The system performs logical comparisons between the collected real-time data and preset safety thresholds. The main control unit has an internally set rated current threshold. and duration threshold The monitoring algorithm continuously counts the duration for which the current exceeds the threshold. When the following logical criteria are met, the system is determined to be in an overcurrent abnormal state: ; In the formula, This refers to the real-time acquisition of motor phase current or bus current. The preset safe current upper limit, The cumulative time during which the current continuously exceeds the upper limit value. This is the allowable transient overload time window. Simultaneously, the system monitors stall signals. If the signal is at a valid level, it is directly determined that the motor is in a stalled abnormal state, either mechanically stuck or unable to rotate.
[0046] Once any of the above abnormal states is triggered, the system immediately sets the global abnormal state flag and triggers the highest-priority hardware interrupt or emergency stop callback function. In the emergency stop handling logic, the main control unit immediately cuts off the pulse-width modulation signal output to the motor driver, physically stopping the energy supply, or redirects the target speed command. The value is forcibly set to zero, utilizing the motor's regenerative braking characteristics to achieve rapid shutdown. Simultaneously, the system generates a corresponding fault error code and feeds it back to the upper-level task or host computer interface via the internal communication bus for alarm display.
[0047] This step, through real-time monitoring and multiple fault determination logic in collaboration between software and hardware, achieves millisecond-level response to electrical overload and mechanical faults, effectively preventing fire hazards caused by overheating damage or mechanical jamming due to continuous high current, and ensuring the safe operation of equipment under unattended or high-load conditions.
[0048] Example 2: Conventional respiratory motion simulations typically employ a single trajectory, failing to reproduce the complex nonlinear characteristics of real patient respiration, such as baseline drift, time-varying frequency, and amplitude fluctuations. To address these issues, this invention provides a drive and control system for respiratory motion simulation, the structure of which is as follows: Figure 2 As shown. The specific implementation process of this system is as follows: The host computer interaction module is used to acquire the respiratory parameters set by the user and transmit the respiratory parameters to the main control unit. The respiratory parameters include target tidal volume, respiratory rate, inspiratory-expiratory ratio and waveform pattern. The timing management module is used to run the breathing clock, determine the breathing cycle based on the breathing frequency in the breathing parameters, and divide the breathing cycle into an inspiratory phase and an expiratory phase according to the inspiratory-expiratory ratio. The waveform generation module is used to calculate the theoretical tidal volume corresponding to the current moment in real time based on the current moment of the respiratory clock, the respiratory cycle and the waveform pattern. The dynamic compensation module is used to calculate the reference speed based on the rate of change of the theoretical tidal volume over time, obtain the current mechanical load state of the simulation device and the corresponding compensation coefficient, and use the compensation coefficient to correct the reference speed to generate a target speed command. The drive monitoring module is used to control the motor to run according to the target speed command, and during the operation, it monitors the current signal or stall signal in real time. When the detected signal exceeds a preset threshold, it controls the motor to stop running or adjusts the output limit.
[0049] Specifically, the host computer interaction module builds a visual interactive interface based on the RK3566 main control chip and the QT5.12 system. It sends the packaged respiratory parameters to the main control unit using an STM32G431RBT6 microcontroller via an RS485 half-duplex communication link. The main control unit runs a real-time operating system based on time-slice polling, which executes high-frequency tasks with a 1ms reference period to ensure that the timing management module accurately counts and classifies the respiratory clock. The waveform generation module calls the half-cosine interpolation algorithm or trapezoidal wave segmentation logic according to the current clock state to generate a smooth and mechanically shock-free theoretical tidal volume curve. The dynamic compensation module looks up the compensation coefficient in a table based on the load characteristics such as the physical shell state, dynamically corrects the reference speed and superimposes an S-shaped smooth mapping to prevent excessive back electromotive force. The drive monitoring module collects the motor operating current and stall status in parallel. Once an abnormal value is detected, the emergency stop protection logic is triggered immediately, thereby realizing high-precision and high-reliability respiratory motion simulation through hardware and software collaboration.
[0050] Finally, it should be noted that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A drive control method for simulating respiratory motion, characterized in that, include: S1. Obtain the user-set breathing parameters through the host computer. The breathing parameters include target tidal volume, respiratory rate, inspiratory-expiratory ratio and waveform pattern, and transmit the breathing parameters to the main control unit. S2. The main control unit operates a breathing clock, determines the breathing cycle based on the breathing frequency in the breathing parameters, and divides the breathing cycle into an inhalation phase and an exhalation phase according to the inhalation-exhalation ratio. S3. The main control unit calculates the theoretical tidal volume corresponding to the current moment in real time based on the current moment of the breathing clock, the breathing cycle, and the waveform pattern. S4. The main control unit calculates the reference speed based on the rate of change of the theoretical tidal volume over time, obtains the current mechanical load state of the simulation device and the corresponding compensation coefficient, corrects the reference speed using the compensation coefficient, and generates a target speed command. S5. The main control unit controls the motor to run according to the target speed command, and during the operation, it monitors the current signal or stall signal in real time. When the detected signal exceeds a preset threshold, it controls the motor to stop running or adjusts the output limit.
2. The drive control method for simulating respiratory motion according to claim 1, characterized in that, In step S2, the step of dividing the respiratory cycle into an inspiratory phase and an expiratory phase based on the inspiratory-expiratory ratio includes: A time-slice polling architecture is built within the main control unit, with the main control cycle set to 1ms. The system tasks are divided into periodic tasks, 1ms high-frequency tasks, and multiple low-frequency tasks with different cycles to ensure that the counting accuracy of the breathing clock is not affected by non-real-time tasks. The system maintains a global respiratory clock variable, which accumulates a count according to the user-defined cycle and resets when the count reaches the cycle threshold to maintain a continuous respiratory rhythm. The time thresholds for the duration of the inspiratory and expiratory phases are calculated based on the set inspiratory-expiratory ratio. The current respiratory clock value is mapped to the inspiratory or expiratory state machine in real time, providing a status flag for subsequent waveform function calls.
3. The drive control method for simulating respiratory motion according to claim 1, characterized in that, In step S3, the step of calculating the theoretical tidal volume corresponding to the current moment in real time based on the current moment of the respiratory clock, the respiratory cycle, and the waveform pattern, when the waveform pattern is a sinusoidal breathing pattern, includes: To eliminate the mechanical impact generated by the mechanical cam or standard sine wave at the reversal point, a half-cosine interpolation algorithm is used as the waveform generation logic, and independent function expressions are constructed for the inhalation and exhalation segments respectively. When the respiratory clock is in the inspiratory phase, the theoretical tidal volume is calculated using the transformation logic of the cosine function based on the current time, the total duration of the inspiratory phase, and the preset amplitude. When the respiratory clock is in the expiratory phase, based on the current time, the total duration of the expiratory phase, the duration of the inspiratory phase, and the preset amplitude, the current theoretical tidal volume is calculated using the transformation logic of the cosine function to ensure that the acceleration is continuous and without abrupt changes at the phase transition between the end of inspiration and the end of expiration, thus achieving a smooth transition.
4. The drive control method for simulating respiratory motion according to claim 1, characterized in that, In step S3, the step of calculating the theoretical tidal volume corresponding to the current moment in real time based on the current moment of the respiratory clock, the respiratory cycle, and the waveform pattern, when the waveform pattern is a trapezoidal wave pattern, includes: A complete respiratory cycle is further subdivided into four consecutive time intervals: the rising segment, the high plateau segment, the falling segment, and the low plateau segment, which correspond to the inhalation, deep inhalation and breath-holding, exhalation, and end-expiratory pause in the respiratory physiological process, respectively. The theoretical tidal volume output is kept constant at the maximum set value in the high plateau section to simulate the static characteristics of deep inspiration and breath-holding during radiotherapy, and to verify the imaging quality of the imaging equipment in the breath-holding state. Linear interpolation calculations are performed during the ascending and descending phases to control the phantom to complete inhalation and exhalation at a constant speed until a preset plateau time threshold is reached, at which point the process switches to the next phase.
5. The drive control method for simulating respiratory motion according to claim 1, characterized in that, In step S3, the step of calculating the theoretical tidal volume corresponding to the current moment in real time based on the current moment of the respiratory clock, the respiratory cycle, and the waveform pattern, when the waveform pattern is a sawtooth wave or a pulse wave pattern, includes: Generate sawtooth waves with linear variation characteristics or pulse waves with transient step characteristics for extreme performance testing of breathing simulation devices or boundary condition verification of motion correction algorithms. By outputting mechanical waveforms that do not follow the natural breathing pattern of the human body, the system response capability and artifact correction performance of imaging or radiotherapy equipment in response to unexpected motion changes are tested. In pulse mode, the motor is controlled to complete a large-scale position switch within a preset transient time to verify the dynamic response bandwidth of the drive system and the rigidity and stability of the mechanical structure.
6. The drive control method for simulating respiratory motion according to claim 1, characterized in that, Step S4, the step of obtaining the current mechanical load state of the simulation device and the corresponding compensation coefficient, includes: Establish a functional relationship between the compensation coefficient and multiple input variables, wherein the input variables include at least the target tidal volume, respiratory rate, inspiratory-expiratory ratio, and the physical shell condition of the device; Identify whether the simulation device is currently equipped with a casing, and based on the nonlinear difference in mechanical damping under casing or uncased conditions, call the corresponding preset damping characteristic curve or lookup table. The final speed command is obtained by multiplying the base speed using the determined compensation coefficient. The compensation coefficient is introduced to offset the motion lag or overshoot caused by changes in mechanical load, ensuring that the actual motion trajectory accurately follows the theoretical waveform.
7. The drive control method for simulating respiratory motion according to claim 1, characterized in that, Step S4, the step of correcting the reference speed using the compensation coefficient to generate the target speed command, includes: Detect whether the target tidal volume is within a preset large tidal volume range; Call the mapping function to perform an S-shaped smooth mapping on the target tidal volume within the preset large tidal volume range; The S-shaped smooth mapping limits the acceleration of the motor at the moment of commutation, preventing the generation of reverse electromotive force due to excessive acceleration, and implements soft limit protection at the software level.
8. The drive control method for simulating respiratory motion according to claim 1, characterized in that, In step S5, the step of controlling the motor to stop running or adjusting the output limit when the detected signal exceeds a preset threshold by real-time monitoring of the current signal or stall signal includes: In the safety monitoring layer, real-time data acquisition tasks for the drive motor's operating current, operating voltage, module temperature, and stall status are executed in parallel. The collected real-time data is compared with the preset safety threshold. When the current is detected to continuously exceed the rated value, or when the motor is detected to be in a stalled state, an abnormal state flag is triggered. Once the abnormal flag is triggered, the motor drive output is immediately cut off or the speed command is forcibly reset to zero, and an error code is fed back to the main control unit to prevent equipment damage or fire hazards caused by mechanical jamming or electrical overload.
9. A drive control system for simulating respiratory motion, characterized in that, A drive control method for simulating respiratory movements as described in any one of claims 1-8, the system comprising: The host computer interaction module is used to acquire the respiratory parameters set by the user and transmit the respiratory parameters to the main control unit. The respiratory parameters include target tidal volume, respiratory rate, inspiratory-expiratory ratio and waveform pattern. The timing management module is used to run the breathing clock, determine the breathing cycle based on the breathing frequency in the breathing parameters, and divide the breathing cycle into an inspiratory phase and an expiratory phase according to the inspiratory-expiratory ratio. The waveform generation module is used to calculate the theoretical tidal volume corresponding to the current moment in real time based on the current moment of the respiratory clock, the respiratory cycle and the waveform pattern. The dynamic compensation module is used to calculate the reference speed based on the rate of change of the theoretical tidal volume over time, obtain the current mechanical load state of the simulation device and the corresponding compensation coefficient, and use the compensation coefficient to correct the reference speed to generate a target speed command. The drive monitoring module is used to control the motor to run according to the target speed command, and during the operation, it monitors the current signal or stall signal in real time. When the detected signal exceeds a preset threshold, it controls the motor to stop running or adjusts the output limit.