Reciprocating motion integer pulse control method and system with off-line calibration

CN122993518APending Publication Date: 2026-10-27SOUTH CHINA UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611441520.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-17
Publication Date
2026-10-27

AI Technical Summary

Technical Problem

[0006]其一,连续轨迹独立取整可能导致累计漂移:连续位移换算得到的相邻脉冲需求通常为非整数,若每个采样间隔独立四舍五入而不携带余数,取整误差可能在多个采样点或多个周期内累积;其二,理想延时不等于实际周期:数字输入输出翻转、循环判断、程序存储器读取和函数调用均占用处理器时间,若只按理论半脉冲周期延时,实际周期会系统性变长;其三,名义齿轮半径不能完全代表有效运动尺度:齿条齿轮有效节圆半径、安装误差、传动间隙和传感器比例误差可能共同表现为幅值尺度偏差;其四,重复数据占用程序存储空间:当长时试验由相同周期重复组成时,逐点保存完整设计时域会重复存储相同的指令;其五,参数和代码容易失配:若参数散落在多个位置,或缺失参数时静默采用默认值,生成的程序可能与拟定试验条件不一致;其六,运行前缺少闭合和一致性检查:仅观察生成曲线而不从整数指令反算累计脉冲和直线位移,难以及时发现符号错误、残差未闭合、饱和、错误列选择或终点不归零;其七,将离线校准误写为实时反馈会造成控制边界不清

Benefits of technology

[0042](1)降低累计量化漂移:误差反馈整数累加器把每个采样点未执行的分数脉冲带到后续采样点,并对周期净残差进行闭合检查;(2)提高周期一致性:把实测周期误差换算为每脉冲软件执行开销τ并在高、低电平延时中补偿,减少由数字输出和循环执行造成的系统性延长;(3)提高幅值尺度一致性:以实测幅值与目标幅值之比更新有效齿轮节圆半径rp,使传动和测量链中的系统性尺度偏差在周期间得到修正;(4)保持执行确定性和可重复性:运行中采用前馈开环执行,不根据传感器数据改变当前指令,相同指令表在相同硬件设置下产生相同数字输出序列;(5)降低微控制器存储占用:对严格周期轨迹只存储一个周期并循环执行,实施例中仅需400字节,约为完整40周期表的四十分之一;(6)提高参数可追溯性:参数按名称从同一来源读取,必要参数缺失时中止,τ缺失时明确警告并标记未校准回退来源;(7)提高运行前可发现性:烧录前从最终整数脉冲表反算累计位置和直线位移,能够发现残差、符号、饱和、列选择和终点闭合问题;(8)明确数字闭合与物理回归的证据边界:指令空间零残差由离线重构证明,机械实际回归由位移测量独立确认。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122993518A_ABST
    Figure CN122993518A_ABST
Patent Text Reader

Abstract

The present application relates to a kind of reciprocating motion integer pulse control method and system with offline calibration, method includes before operation, the reciprocating displacement trajectory is converted into signed integer pulse and delay instruction table: with the error feedback accumulator carrying fractional remainder, complete integerization;Only when net residual is not zero, additional closed correction is added;When meeting periodic condition, only a single cycle is stored and cyclically executed;Half of each pulse software execution overhead is deducted from high and low level delay and minimum delay protection is set;Before burning, from instruction table, the accumulated pulse and displacement are calculated back and the terminal closure is verified.Operation does not use position feedback;Displacement measurement is only used to update software execution overhead according to measured period, update effective gear pitch circle radius according to measured amplitude between two operations, and is regenerated and burned after updating.The present application reduces accumulated quantization drift and cycle deviation, reduces storage occupation, and improves the traceability and repeatability of motion reproduction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of electromechanical motion control, stepper motor digital drive, programmable reciprocating motion generation and offline calibration of experimental devices, specifically a reciprocating motion integer pulse control method and system with offline calibration. Background Technology

[0002] Experimental evaluation of reciprocating electromechanical systems, power output devices, and energy conversion components often requires the drive end to repeat motion according to known amplitude, frequency, and phase relationships. Traditional approaches can be categorized into numerical simulation, hardware-in-the-loop (HIL) testing with real-time dynamic coupling, dry forced motion testing, multi-degree-of-freedom robot motion reproduction, and tank or field testing. The boundaries of each method differ: hardware-in-the-loop typically forms a closed loop between the real-time numerical model, the physical actuator, and the component under test; dry forced motion uses known motion as the component boundary, and is used for repeatable testing before entering the tank or field stage.

[0003] Publicly available literature reports include test benches for dry power output devices with real-time hydrodynamic reaction, hardware-in-the-loop test rigs for wave energy systems, devices that use six-DOF robots to reproduce recorded wave and floating body motions, and technical routes that combine dry electromechanical performance testing with wet tank testing as continuous verification phases. These approaches demonstrate that laboratory motion generators can employ real-time closed-loop coupling or predetermined motion boundaries; these two methods are not mutually exclusive. The former forms a real-time closed loop during operation, while the latter executes according to a predetermined command sequence in a single run, representing feedforward open-loop execution. This invention belongs to the latter category and corrects systematic deviations through offline calibration between runs.

[0004] The closest implementation idea to this invention is to provide sinusoidal displacement parameters before operation, generate a stepper motor pulse sequence by a computer, and then have a microcontroller output pulses and direction signals to the driver to drive the stepper motor and rack and pinion mechanism to produce reciprocating linear motion. A typical hardware chain includes parameter files, trajectory and instruction generation programs, a microcontroller, a microstepping driver, a two-phase stepper motor, a mechanical transmission mechanism, and a displacement sensor. If only the continuous pulses at each sampling point are required to be independently rounded, executed directly with an ideal delay, or if a whole segment of repetitive data is stored in each cycle, then cumulative position error, cycle deviation, and program storage usage problems will arise respectively.

[0005] The existing technologies have the following technical problems:

[0006] First, independent rounding of continuous trajectories may lead to cumulative drift: the adjacent pulse requirements obtained from continuous displacement conversion are usually non-integers. If each sampling interval is independently rounded without carrying the remainder, the rounding error may accumulate over multiple sampling points or multiple periods. Second, the ideal delay is not equal to the actual period: digital input / output switching, loop judgment, program memory reading, and function calls all consume processor time. If only the theoretical half-pulse period is used for delay, the actual period will systematically become longer. Third, the nominal gear radius cannot fully represent the effective motion scale: the effective pitch circle radius of the rack and pinion gear, installation error, transmission clearance, and sensor proportional error may all contribute to the amplitude. Fourth, repetitive data occupies program storage space: when long-term experiments consist of repeated cycles of the same period, saving the complete design time domain point by point will repeatedly store the same instructions; fifth, parameters and code are prone to mismatch: if parameters are scattered in multiple locations, or if default values ​​are silently used when parameters are missing, the generated program may be inconsistent with the proposed experimental conditions; sixth, lack of closure and consistency checks before running: only observing the generated curve without calculating the cumulative pulse and linear displacement from the integer instructions makes it difficult to detect sign errors, unclosed residuals, saturation, incorrect column selection, or non-zero endpoints in a timely manner; seventh, miswriting offline calibration as real-time feedback will cause unclear control boundaries. Summary of the Invention

[0007] The purpose of this invention is to provide a reciprocating motion integer pulse control method and system with offline calibration, so as to overcome the shortcomings of the prior art, such as cumulative quantization drift during the conversion from continuous trajectory to integer pulse, period deviation caused by microcontroller instruction overhead, amplitude deviation caused by effective transmission scale error, storage occupation of repetition period, and lack of traceable verification before execution.

[0008] To achieve the above objectives, the present invention adopts the following technical solution:

[0009] A reciprocating motion integer pulse control method with offline calibration, used to enable a stepper motor to reproduce a specified reciprocating displacement trajectory via a rotary-linear conversion mechanism, includes the following steps:

[0010] S1. Read the target amplitude A, excitation frequency f, and effective gear pitch circle radius r from the parameter workbook by parameter name. p The motor step angle α, microstepping factor M, design time domain D, command interval Δt, and software execution overhead τ per pulse;

[0011] S2. The continuous incremental pulse requirement ΔN for each sampling interval is obtained from the specified displacement trajectory. i Alternatively, the continuous incremental pulse requirement can be read from a specified data column in the parameter workbook;

[0012] S3. The continuous incremental pulse demand is converted point by point into integers using an error feedback integer accumulator to obtain the signed integer pulse instruction S.i The remainder of the fractional pulse that was not executed at the previous sampling point is passed to the next sampling point for integerization;

[0013] S4. Calculate the execution delay for each signed integer pulse instruction, form an integer pulse and a timing table consisting of the number of signed integer pulses and the delay, and generate a control program for the embedded controller to execute.

[0014] S5. During operation, the embedded controller outputs pulses and direction signals one by one according to the integer pulses and the timer table, which drive the stepper motor through the microstepping driver. During operation, the current instruction is not changed according to the displacement measurement value, thus forming a feedforward open-loop execution.

[0015] S6. After one run, the measured period T is obtained offline from the displacement sensor recording. meas Compared with the measured amplitude A meas Update the software execution overhead τ per pulse according to the actual measurement cycle, and update the effective gear pitch circle radius r according to the actual measured amplitude. p Write the updated parameters back to the parameter workbook, regenerate and re-burn the control program, and then run it again.

[0016] Furthermore, integerization is performed as follows: Let the remainder after the previous sampling point be... First calculate Then for acc i S is obtained by rounding down the nearest integer and limiting it to a 16-bit signed integer. i Then press The unexecuted fractional remainder is carried over to the next sampling point. When saturation is not triggered, the nearest integer rounding keeps the carried remainder within ±0.5 pulses.

[0017] Furthermore, the present invention also includes a net residual closure mechanism: calculating the net residual R for the selected instruction sequence. S =∑S i When R S When =0, no instruction is appended; only when R = 0, no instruction is appended. S ≠ Add at 0 As a closure correction instruction, and this closure correction instruction occupies an additional execution interval, it is not implicitly included in the nominal cycle.

[0018] Furthermore, the present invention also includes a periodic detection and single-cycle storage mechanism: simultaneously verifying whether the number of samples T / Δt per cycle and the design number of time-domain cycles D / T are integers within a set tolerance, and whether the incremental sequence length is not less than the number of samples per cycle; if the conditions are met, only one cycle of instructions is stored and executed cyclically by the embedded controller; otherwise, the complete sequence is stored; when the overlay data column is enabled, single-cycle storage is prohibited unless it is confirmed that the overlay data itself is a complete cycle, so as to avoid mistaking measurement or experience sequences as periodic data.

[0019] Furthermore, the pulse timing is compensated for by software execution overhead: for non-zero instructions S i The nominal half-cycle delay is based on B. i nz =max[2,min(65535,round(Δt×10 6 / (2|S i |)))] Microsecond calculation, executing B on zero instructions i pause =min[65535,round(Δt×1000)] milliseconds pause; the actual programmed high and low level delays are... microseconds, of which The overhead is an integer half-cost, and 2 microseconds is the minimum delay protection value.

[0020] Furthermore, offline calibration updates employ: and T target =1 / f is the target period, A target For the target amplitude, N period τ is the number of pulse paths per cycle for continuous approximation. old With r p,old The old parameters actually used when this record was generated; and with a configurable periodic error threshold δ T With amplitude error threshold δ A Determining the termination of the iteration, where the periodic error is... Amplitude error The measured period and amplitude are obtained primarily from the displacement records with timestamps through three-point median filtering and coarse and fine least-squares sine fitting. When there are no timestamp records, they are manually input from the average extreme values ​​of multiple periods.

[0021] Furthermore, the present invention also includes pre-execution instruction space verification: calculating the cumulative pulse pos from the final integer pulse and the timing table. pulses,i With reconstructed linear displacement The process checks whether the terminal's cumulative pulse is zero and compares the reconstructed displacement with the ideal trajectory at the same discrete moment; if the verification fails, it returns to the instruction generation step without entering the running process.

[0022] Furthermore, the linear displacement resolution per pulse is calculated according to r. p ·α eff OK; when the specified data column is unreadable and overwriting data columns are not enabled, use s(t)=A·sin(2πft) and θ(t)=s(t) / r p With per-pulse angular resolution α eff The continuous incremental pulse requirement is synthesized offline.

[0023] Furthermore, parameter integrity is ensured as follows: if any parameter is missing, such as the target amplitude, effective gear pitch circle radius, excitation frequency, motor step angle, microstepping factor, design time domain, or command interval, generation is stopped and an error is reported; if the software execution overhead τ per pulse is missing, a clear warning is issued and a 0 microsecond / pulse backoff value marked as an uncalibrated source is used to avoid mistaking the backoff value for a calibrated value.

[0024] Furthermore, the linear displacement resolution per pulse is calculated according to r. p ·α eff It is determined that the reconstructed linear displacement is determined by the accumulated pulse pos. pulses,i It is obtained by multiplying by the resolution.

[0025] Furthermore, in one implementation of the system, the PUL+, DIR+, and ENA+ terminals of the microstepping driver are all connected to the +5V common positive terminal (common anode connection), and the pulse output pin of the embedded controller is connected to the microstepping driver. End and direction output pin connections end, The end is suspended, and the microstepping driver is powered by a DC power supply; the DC power supply, microstepping settings, and motor phase line wiring constitute the power supply, microstepping, and wiring configuration. This wiring method, in conjunction with the pre-calculated instruction table, facilitates the deterministic transmission of pulse and direction signals.

[0026] A reciprocating motion integer pulse control system with offline calibration, comprising:

[0027] The parameter workbook is used to store parameters, including the target amplitude A, excitation frequency f, and effective gear pitch circle radius r. p The motor step angle α, microstepping factor M, design time domain D, command interval Δt, and software execution overhead τ per pulse;

[0028] The motion and instruction generation module is used to read the parameters from the parameter workbook by name, and use the parameters and the specified reciprocating displacement trajectory to obtain the continuous incremental pulse requirement ΔN. i , will ΔN i Integerization is performed using the signed integer pulse instruction Si, and S is used to... i Generate integer pulses, timing tables, and control programs using Δt and τ;

[0029] Offline command and motion verification module, used to utilize integer pulses and timers, as well as the effective gear pitch circle radius r. p The motor step angle α and microstepping factor M are used to calculate the cumulative pulse and reconstruct the linear displacement. The terminal cumulative pulse is verified to be zero, and the verified integer pulse and timer are output to the embedded controller.

[0030] An embedded controller used to output pulse and direction signals sequentially according to integer pulses and a timer.

[0031] Microstepping driver, stepper motor and rotary-to-linear conversion mechanism are used to receive pulse and direction signals and reproduce a specified reciprocating trajectory;

[0032] The displacement sensor and recording module are used to record the displacement during operation and output the displacement record to the offline parameter calibration module;

[0033] The offline parameter calibration module is used to utilize displacement records and target amplitude A, excitation frequency f, and effective gear pitch circle radius r. p Obtain the measured period T meas Compared with the measured amplitude A meas And update the software execution overhead τ per pulse and the effective gear pitch circle radius r. p ;

[0034] The parameter write-back and redeployment module is used to update the per-pulse software execution overhead τ and effective gear pitch circle radius r. p Write back the parameter workbook and trigger the motion and instruction generation module to regenerate integer pulses, timers, and control programs, as well as reprogram the embedded controller.

[0035] Furthermore, the integer pulses and timer table are stored in the program memory of the embedded controller in the form of a structure array containing 16-bit signed pulse counts and 16-bit unsigned delays for each instruction, and are executed cyclically by the embedded controller.

[0036] Furthermore, the embedded controller is a programmable controller with program memory and general-purpose digital output pins, the microstepping driver is a two-phase microstepping driver with a configurable microstepping subdivision factor, and the stepper motor is a two-phase hybrid stepper motor.

[0037] Furthermore, after the embedded controller completes the execution of a pre-set integer number of instructions, the integer number is determined before the control program is programmed and a cycle count report is output via the serial interface.

[0038] Furthermore, the specified reciprocating trajectory is one of the following: a sinusoidal trajectory of a single frequency; a predefined reciprocating trajectory composed of two or more sinusoidal components with different amplitudes and frequencies; and a predefined reciprocating trajectory given by a discrete sampling sequence.

[0039] Further, the rotary-linear conversion mechanism is one of the following: a rack and pinion mechanism; a lead screw and nut mechanism; a synchronous belt mechanism; a chain drive mechanism; and a rotary-linear conversion mechanism having a defined linear displacement equivalent per revolution; the linear displacement resolution per pulse is determined by the product of the equivalent and the angular resolution per pulse.

[0040] Furthermore, the method is applied to reciprocating motion devices of different scales according to geometric similarity: the target amplitude and the effective gear pitch circle radius are converted according to the same length scaling ratio, the excitation frequency is converted according to the corresponding time scaling ratio, and the generated integer pulses and timing table are changed accordingly while the generation steps remain unchanged.

[0041] In summary, the present invention has the following advantages:

[0042] (1) Reduce cumulative quantization drift: The error feedback integer accumulator carries the fractional pulses that were not executed at each sampling point to the subsequent sampling points and performs a closure check on the net residual of the period; (2) Improve period consistency: The measured period error is converted into software execution overhead τ per pulse and compensated in the high and low level delays to reduce the systematic extension caused by digital output and loop execution; (3) Improve amplitude scale consistency: The effective gear pitch circle radius r is updated with the ratio of the measured amplitude to the target amplitude. p (4) Maintain execution determinism and repeatability: During operation, feedforward open-loop execution is adopted, and the current instruction is not changed according to sensor data. The same instruction table generates the same digital output sequence under the same hardware settings. (5) Reduce microcontroller storage occupation: Only one cycle is stored for the strict periodic trajectory and executed cyclically. In the example, only 400 bytes are needed, which is about one-fortieth of the complete 40-cycle table. (6) Improve parameter traceability: Parameters are read from the same source by name. If necessary parameters are missing, the operation is stopped. If τ is missing, a clear warning is given and the source of uncalibrated rollback is marked. (7) Improve pre-run discoverability: Before burning, the cumulative position and linear displacement are calculated from the final integer pulse table, and residual, sign, saturation, column selection and endpoint closure problems can be found. (8) Clarify the evidence boundary between digital closure and physical regression: Zero residual in the instruction space is proven by offline reconstruction, and mechanical actual regression is independently confirmed by displacement measurement. Attached Figure Description

[0043] Figure 1 This is a flowchart of the overall motor control, verification, and offline calibration process of this invention, in which offline updates are performed during the week and there is no position feedback during operation.

[0044] Figure 2 This is a flowchart illustrating the instruction synthesis, integerization, and control program generation of the present invention.

[0045] Figure 3 This is a flowchart of the embedded MotionCmd instruction execution process of the present invention.

[0046] Figure 4 This is a flowchart of the offline calibration process based on displacement measurement according to the present invention.

[0047] Figure 5 This is a diagram of the controller and electromechanical execution architecture of the present invention.

[0048] Figure 6 This is an offline pre-run verification diagram for one cycle in an embodiment of the present invention, where (a) is an integer incremental pulse command, (b) is the cumulative pulse position, and (c) is a comparison between the reconstructed rack displacement and the ideal sine wave.

[0049] Figure 7 This is a wiring diagram for a motor according to an embodiment of the present invention, showing the complete electrical connection between the embedded controller, the microstepping driver, the DC power supply, and the stepper motor.

[0050] Figure 8 This is a schematic diagram of pulse timing compensation according to the present invention, wherein (a) is the uncompensated nominal timing and (b) is the compensated timing.

[0051] Figure 9 This is a schematic diagram of single-cycle storage and cyclic execution according to an embodiment of the present invention.

[0052] Figure 10 This is a single-cycle curve of instruction space reconstruction displacement for three working conditions in an embodiment of the present invention. Detailed Implementation

[0053] The present invention will now be described in further detail.

[0054] I. Technical Boundaries, Terminology and Symbols

[0055] The term "feedforward open-loop execution" in this invention refers to the microcontroller outputting according to a pre-stored instruction table during a single run, without changing the current pulse in real time based on the displacement measurement value. The term "offline calibration" refers to reading the displacement record after completing one run, calculating new parameters, writing the new parameters back to the parameter workbook, regenerating and burning the control program, and then starting the next run. The term "instruction space closure" refers to the integer pulse accumulation value returning to zero at the end of a storage cycle; it cannot replace the independent confirmation of physical position return by the displacement sensor. The abbreviations and terms used in this embodiment are shown in Table 1 below:

[0056] Table 1 Abbreviations and Terms

[0057]

[0058] II. System Composition

[0059] like Figure 1 and Figure 5 As shown, the system in this embodiment includes at least: a parameter workbook; a motion and command generation module running on an offline computing device; an integer pulse and timer; a generated control program; an embedded controller; a pulse / direction output; a microstepping driver; power supply, microstepping, and wiring configuration; a stepper motor; a rotary-linear conversion mechanism; a displacement sensor and recording module; an offline command and motion verification module; an offline parameter calibration module; a parameter write-back, program regeneration, and redeployment module; and a DC power supply for the microstepping driver.

[0060] This embodiment uses the parameter workbook as the authoritative source for command parameters and calibration constants. The generation module reads the name from the name column and the value from the value column of the data table according to the parameter name; if any of the amplitude, effective gear pitch circle radius, frequency, full step angle, microstep subdivision factor, total duration, or time step is missing, the process stops and reports an error. If the per-pulse software execution overhead parameter τ is missing, the program issues a clear warning and uses 0 microseconds / pulse as the uncalibrated backoff value, while marking its source to avoid mistaking the backoff value for a calibrated value. Incremental requirements are usually read from the regular data column; when the coverage flag is set to 1, they are read from the coverage data column. If the regular data column is unavailable and the coverage flag is not enabled, backoff trajectories can be synthesized offline using the same parameter set.

[0061] III. Prescribed trajectory and rack and gear motion mapping

[0062] For a given sinusoidal rack displacement, let A be the target amplitude, f be the excitation frequency, t be the time, and r be the frequency. p The effective gear pitch circle radius is calibrated, α is the motor step angle, and M is the microstepping factor. The specified trajectory, gear angular displacement, and per-pulse angular resolution are as follows:

[0063] (1)

[0064] (2)

[0065] (3)

[0066] The linear displacement resolution per pulse is:

[0067] (4)

[0068] At the i-th sampling time t i =iΔt (where N0=0, ΔN1=0), continuously accumulated pulse position N iThe continuous incremental demand ΔN between adjacent sampling intervals i for:

[0069] ; ; ; (5)

[0070] In this embodiment, A=120mm, f=0.200Hz, r p =14.29mm, α=1.8° / step, M=8, therefore 1600 pulses per revolution. Rad / pulse, linear resolution approximately 0.0561 mm / pulse, peak continuous pulse position approximately 2138.4 pulses. Command interval Δt = 0.050 s, one 5.000 s cycle contains 100 execution intervals.

[0071] IV. Error Feedback Integerization, Saturation Protection, and Residual Closure

[0072] Figure 2 The error feedback integer accumulator in the code processes continuous incremental requests point by point. Let acc i-1 To carry the remainder after the previous sampling, first set ΔN i With acc i-1 Add them together, then perform nearest-neighbor integer rounding and a 16-bit signed range constraint, and finally carry over the unexecuted fractional remainder to the next sampling point:

[0073] (6)

[0074] , (7)

[0075] Where S i For the i-th interval, there is a signed integer pulse actually executed. When saturation is not triggered, the nearest integer is rounded to keep the carry remainder within ±0.5 pulses. The net residual R is calculated after the selected sequence is completed. S =∑S i If R S =0, no append instruction; if R =0, no instruction is appended; S Only add if ≠0. As a closure correction, it is explicitly stated that the append instruction will increase the execution interval and cannot be implicitly included in the nominal cycle.

[0076] V. Periodic Detection and Single-Cycle Storage

[0077] The periodicity criterion uses the number of samples N per period. s With the design time-domain period number N c :

[0078] , , (8)

[0079] Figure 2 In the middle, the periodic detection module simultaneously verifies N s =T / Δt and N c =Is D / T within periodic tolerance? The input is an integer, and the incremental sequence length is verified to be sufficient; where T = 1 / f, and D is the design time domain. When the conditions are met and the overlay data column is not enabled, the sequence retention module retains only one cycle, which is then repeatedly executed by the controller; otherwise, the complete sequence is retained. When the overlay data column is enabled, automatic single-cycle reduction is disabled unless the operator explicitly confirms that the overlay data itself is a complete cycle, thus avoiding misinterpreting measurement or empirical sequences as periodic data.

[0080] Let m be the number of instructions stored per cycle, and each instruction occupy 4 bytes, then the required program memory M data for:

[0081] (9)

[0082] The structure of single-cycle storage and loop execution is as follows Figure 9 As shown: The MotionCmd structure array is stored in the program memory. The embedded controller reads and executes each instruction one by one. After reaching the end of the array, it immediately returns to the first instruction and executes it in a loop.

[0083] In this embodiment, D=200s, T=5.000s, Δt=0.050s, corresponding to 40 complete cycles and 100 execution intervals per cycle. Only 100 MotionCmd structures are stored, each containing a 16-bit signed pulse count (steps) and a 16-bit unsigned delay (delay), totaling 400 bytes, approximately 0.4KB; compared to storing 40 cycles, the program memory usage is reduced to approximately 1 / 40 of the original.

[0084] VI. Pulse Timing and Software Execution Overhead Compensation

[0085] For non-zero integer instruction S i Nominal high and low level half-cycle B i nz Calculations are performed by uniformly distributing pulses within a command interval; for zero instructions, no pulse is generated, and a millisecond-level pause is executed.

[0086] , (10)

[0087] , (11)

[0088] Let τ be the software execution overhead for each complete pulse, and the control program uses an integer half-overhead overhead. The actual high and low level delays in programming (HD) i for:

[0089] (12)

[0090] In the formula, 2 microseconds is the lower limit protection of the microcontroller delay function. In this embodiment, τ = 17 microseconds / pulse, therefore the integer half-overhead τ half = =8 microseconds; when the instruction pulse count takes the maximum value in the table |S i When |=134 pulses, B i nz =round(50000 / (2×134))=187 microseconds, hd i =187-8=179 microseconds. The nominal half-cycle delay range in the table is 187~6250 microseconds (corresponding to |S... i |=134 and |S i (|=4), all of which are higher than the 2-microsecond protection value.

[0091] Figure 8 The timing relationship of the compensation is as follows: (a) is the uncompensated nominal timing, with a nominal duration of B for each half-cycle. i nz (b) For the compensated timing, each half-cycle is delayed by the programmed delay hd. i With integer half-cost It consists of two parts, the sum of which equals the nominal half-cycle B. i nz This ensures that the actual output cycle matches the design cycle.

[0092] VII. Control Program Generation and Embedded Execution

[0093] The generation module generates each signed pulse number S i and its delay B i nz Write the MotionCmd structure array and generate the control program. Store the array in the program memory. The controller configures the pulse pin as STEP output and the direction pin as DIR output, initially sets STEP low, and sets the serial port rate to 115200 bit / s; after startup, it enters a continuous execution loop.

[0094] Figure 3The detailed control program flow is as follows: Initialize output; enter continuous loop; place table index as the first item; read the current MotionCmd and calculate the compensation delay; determine the signed step count. If the step count is greater than zero, set the direction output high and emit a corresponding pulse; if the step count is equal to zero, pause execution for milliseconds; if the step count is less than zero, set the direction output low and emit pulses equal to the absolute number of steps. The index is then incremented; determine if the current table execution is complete; if not, read the next item; if complete, increment the cycle count and output a report every ten cycles, then immediately begin the next table execution. During execution, displacement values ​​are not read to modify the current instruction.

[0095] 8. Offline calibration of period based on displacement records

[0096] like Figure 4 As shown, the control program is first generated and burned using constants from the current parameter workbook. After the motion is executed, the displacement sensor and recording module record the displacement. If a timestamped record exists, the "hour:minute:second.decimal" time is parsed, the midnight loop is processed, a three-point median filter is applied to the displacement, and then least-squares sine fitting is performed on a coarse-fine two-level frequency grid centered on the command frequency. The fitting model is as follows, where... Let be the displacement after median filtering, c be the offset of the center of motion, and a and b be the amplitudes of the sine and cosine quadrature components, respectively. For the fitted frequencies:

[0097] (13)

[0098] , , (14)

[0099] Among them, the fitted amplitude The fitting frequency represents the maximum offset of the fitted displacement curve relative to the offset c of the center of motion. This represents the reciprocating motion frequency obtained by fitting the measured displacement records. For the fitting branch of the displacement records with timestamps, the fitted amplitude is used as the measured amplitude for this run, i.e. The reciprocal of the fitted frequency is taken as the measurement period for this run, i.e. The corresponding peak-to-peak shift is Therefore, there are also .in, The unit is Hz. The unit is s. , and The units are consistent with the displacement records and are uniformly set to the target amplitude before calibration calculations. The units used. The obtained measured period and measured amplitude are used for offline updates of the software execution overhead per pulse and the effective gear pitch circle radius, respectively.

[0100] The coarse search uses 401 frequency points in the range of 0.5f to 1.5f; the fine search is performed within ±2× of the optimal frequency found in the coarse search. The Hz range uses 201 points. The fitting also provides the center-of-motion bias c and the root mean square of the fitting residuals. And half-cycle asymmetry diagnosis asym. If no available timestamp record is available, the measured period T can be manually entered from the multi-cycle average extreme value. meas With peak-to-peak shift pp meas Take A meas =pp meas / 2, but the accuracy is lower than that of the fitted branch.

[0101] The calibration update must use the old parameter τ that was actually used when this record was generated. old and r p,old Let the target period be T. target =1 / f, the number of pulse paths N per cycle in a continuous approximation period =4A target / (r p,old ·α eff If the software execution overhead and effective gear pitch circle radius are updated as follows:

[0102] (15)

[0103] ; (16)

[0104] The periodic error e used for convergence judgment T With amplitude error e A Calculate using the following formula:

[0105] ; (17)

[0106] τ new It is not required to be an even number, because the control program obtains half the overhead through integer division. p It is an effective calibration constant that can comprehensively absorb gear-scale and other systematic amplitude proportional errors, but does not identify each error source as a definite physical quantity. Convergence is determined using a configurable periodic error threshold δ. T and amplitude error threshold δ A In this embodiment, the values ​​are set to 0.2% and 0.8% respectively. The calibration setting is accepted when the error is less than the corresponding threshold; otherwise, τ is... new and r p,newWrite back the parameter workbook, regenerate and re-burn the data using the parameter write-back and redeployment module, and run it again. The measured displacement is only used for updates within the current week and does not form a closed loop during operation.

[0107] IX. Pre-execution instruction space verification

[0108] Figure 6 The output of the verification module is shown. The verification module calculates the cumulative pulse pos from the final integer instruction table instead of the continuous theoretical trajectory. pulses,i and rack displacement pos linear,i :

[0109] , (18)

[0110] pos linear,i The pulse count is compared with the ideal sinusoidal displacement at the same discrete moment, and the cumulative pulse count at the terminal is checked to see if it is zero. In this embodiment, one cycle contains 100 instructions, and the number of pulses per instruction is S. i The value range is -134 to +134 pulses, the cumulative pulse extreme value is ±2138 pulses, the actual number of pulses emitted per cycle is 8552, and the terminal cumulative value is 0 pulses. The reconstructed peak value is 119.9775mm, the quantization deviation relative to the 120.00mm target is 0.019%, and the terminal command spatial position error is 0.0000mm. Figure 6 In (c), the solid line represents the reconstructed rack displacement, and the dashed line represents the ideal sine wave. The two curves are independent data objects; the maximum difference between them is about 0.0274 mm, so most sections almost overlap.

[0111] The instruction space closure only proves that the digital instruction returns to the origin, but does not independently prove that the mechanical mechanism completely returns to the physical origin under backlash, step loss, or external load. The physical return, period, and amplitude are verified separately by the displacement sensor recording 180°.

[0112] 10. Electrical Connections and Drive Implementation

[0113] The electrical connection in this embodiment is as follows: Figure 7 As shown: The pulse output pin of the embedded controller is connected to the PUL- terminal of the microstepping driver, and the direction output pin is connected to the DIR- terminal; the controller's +5V terminal serves as the common positive terminal (common anode) and is simultaneously connected to the PUL+, DIR+, and ENA+ terminals, while the ENA- terminal is left floating; the DC power supply provides 48V to the microstepping driver 150; the microstepping driver's A+, A-, B+, and... Connect the stepper motor to the red, blue, green, and black phase wires; set the driver DIP switch to 1 / 8 microstep (M=8, corresponding to 1600 pulses per revolution). The above describes the power supply, microstepping, and wiring configuration. The specific terminal correspondences are shown in Table 2 below.

[0114] Table 2 Terminal Correspondence

[0115]

[0116] XI. Verified Implementation Parameters and Operating Conditions

[0117] The parameter combinations verified in this embodiment are shown in the table below. For other specified trajectories, the same steps of parameter reading, continuous demand generation, error feedback integerization, closure check, timing calculation, offline calibration, and instruction space verification can be used. The instruction space reconstructed displacement single-cycle curves obtained by the same generation steps for the three operating conditions are shown below. Figure 10 As shown, these represent working conditions one, two, and three, respectively; all three curves are calculated from the final integer instruction table and are not actual measured displacements.

[0118] Table 3. Parameter Descriptions for Operating Conditions 1, 2, and 3

[0119]

[0120] 12. Comparison with common implementation methods

[0121] Table 4 Comparison Items

[0122]

[0123] Thirteen, Complete Work Process

[0124] The operator fills in the target amplitude A, frequency f, design time domain D, command interval Δt, motor step angle α, microstepping factor M, and current effective gear pitch circle radius r in parameter workbook 100. p And software execution overhead τ. The generation module reads parameters by name; it aborts and reports if amplitude, radius, frequency, step angle, microstep, total duration, or time step is missing. Only when τ is missing, the program explicitly warns and uses a 0 microsecond / pulse backoff value marked as uncalibrated.

[0125] The data column selection module selects either a regular data column or a covered data column based on the coverage flag. The incremental requirement module 212 reads the continuous incremental sequence; when the regular data column is unreadable and coverage is not enabled, it selects the column based on s(t)=A·sin(2πft) and θ=s / r. p Offline synthesis and rollback sequence of motor angular resolution.

[0126] The periodicity detection module calculates T / Δt and D / T. If the integer period condition is met and the coverage safety rules allow it, the sequence retention module retains only one period; otherwise, it retains the complete sequence.

[0127] The error feedback integer accumulator sequentially adds the continuous increment to the remainder of the previous step and rounds it to S. iIt carries the new remainder and checks for 16-bit signed saturation. The net residual check module calculates R. S =∑S i ;R S No append instruction is added when the value is zero; an instruction is added when the value is non-zero. Closure correction.

[0128] The pulse delay / zero pause calculation module calculates non-zero S. i Calculate the nominal half-cycle B i nz , for zero S i Calculate milliseconds pause B i pause and put S i B i nz Write the integer pulse and timing table. The generation module writes this table into the MotionCmd program memory array of the control program.

[0129] The offline verification module starts from the final S i Reconstruct the accumulated pulse and rack displacement to form Figure 6 The algorithm uses an integer increment instruction diagram, a cumulative pulse position diagram, and a displacement comparison diagram to check if the terminal cumulative value is zero, and compares the reconstructed solid line with the ideal sinusoidal dashed line. If the verification fails, it returns to the parameter / sequence generation step and does not proceed to the actual execution.

[0130] After successful verification, the control program is burned into the embedded controller. In this embodiment, the controller generates pulse / direction outputs via digital pins; pressing... Figure 7 Complete the wiring: Connect the pulse pin to the PUL- terminal of the microstepping driver, and the direction pin to the DIR- terminal; connect PUL+, DIR+, and ENA+ to the +5V common positive terminal, and leave ENA- floating; supply the driver with DC power at 48V, and set the microstepping to M=8; connect the motor phase wires as follows: A+ red, A- blue, B+ green, and B- black.

[0131] The controller performs initialization, continuous looping, index initialization, and instruction fetching. The decision maker assigns commands to a forward execution branch, a zero-instruction pause branch, or a reverse execution branch, followed by indexing. Upon completion of the table decision, a cycle count and a report every ten cycles are triggered, and the next cycle begins. The microstepping driver drives the stepper motor based on pulse and direction signals, and the rack and pinion mechanism converts the rotary motion into reciprocating linear motion. Displacement feedback is not used to modify the current pulse during this operation.

[0132] The displacement sensor records the displacement during operation. The offline calibration module first determines the processing path based on the timestamp: if logs are available, it analyzes the time and performs three-point median filtering, followed by coarse-fine least squares fitting; if no logs are available, it inputs the average measured period and peak-to-peak displacement. The measured period T is obtained from these two branches. measAnd measured amplitude A meas .

[0133] The calibration module calculates the non-negative integer τ using the old parameters from this run. new and effective gear pitch circle radius r p,new The convergence judgment checks whether the period error and amplitude error are less than the corresponding set thresholds; in this embodiment, the thresholds are 0.2% and 0.8%, respectively. If they are met, the settings are accepted; if not, the parameter write-back and redeployment module writes back the parameter workbook, regenerates the control program, re-programs it, and repeats the measurement.

[0134] The final accepted instruction list still needs to be verified again through the instruction space of the verification module. Digital closure is proven by the terminal 0 pulse, and physical regression and motion scale are independently proven by displacement records. This completes the entire workflow from parameter definition, instruction generation, execution, measurement to periodic calibration.

[0135] This embodiment uses a single-frequency sinusoidal trajectory and a rack and pinion mechanism as an example. When the specified reciprocating trajectory is changed to a multi-sinusoidal component superposition trajectory or a predefined trajectory given by a discrete sampling sequence, only the continuous incremental pulse obtained in step S2 requires ΔN. i The numerical sequence changes, but the error feedback integerization in step S3, the delay calculation and overhead compensation in step S4, and the execution process in step S5 remain unchanged; the periodic detection step only provides a single-cycle storage result when the trajectory is strictly periodic, while non-periodic trajectories are stored as a complete sequence. When the rotary-linear conversion mechanism is changed to a lead screw nut, synchronous belt, or chain drive mechanism, the equivalent linear displacement per revolution of that mechanism replaces 2πr. p The linear displacement resolution per pulse is correspondingly determined by the equivalent and the angular resolution per pulse α. eff The ratio is determined, and the remaining steps remain unchanged. When the geometric similarity relationship is applied to reciprocating motion devices of different scales, the target amplitude A and the effective gear pitch circle radius r... p After converting the excitation frequency f to the corresponding time scaling ratio and inputting it into step S1, the generated integer pulse and timing table will change accordingly, while the generation method itself remains unchanged.

[0136] The above embodiments are preferred embodiments of the present invention, but the embodiments of the present invention are not limited to the above embodiments. Any changes, modifications, substitutions, combinations, or simplifications made without departing from the spirit and principle of the present invention shall be considered equivalent substitutions and shall be included within the protection scope of the present invention.

Claims

1. A reciprocating motion integer pulse control method with offline calibration, used to enable a stepper motor to reproduce a specified reciprocating displacement trajectory via a rotary-linear conversion mechanism, characterized in that, Includes the following steps: S1. Read parameters from the parameter workbook by parameter name, including target amplitude A, excitation frequency f, and effective gear pitch circle radius r. p The motor step angle α, microstepping factor M, design time domain D, command interval Δt, and software execution overhead τ per pulse; S2. Using the parameters read in step S1, obtain the continuous incremental pulse requirement ΔN for each sampling interval from the specified reciprocating trajectory. i Alternatively, the continuous incremental pulse requirement ΔN can be read from a specified data column in the parameter workbook. i ; S3. The continuous incremental pulse demand ΔN obtained in step S2 is processed by an error feedback integer accumulator. i Point-by-point integerization yields the signed integer pulse instruction S. i The remainder of the fractional pulse that was not executed at the previous sampling point is passed to the next sampling point for integerization; S4. Using the signed integer pulse instruction S obtained in step S3 i The command interval Δt and the software execution overhead per pulse τ are calculated. The execution delay for each signed integer pulse instruction is calculated to form an integer pulse and a timing table consisting of the number of signed integer pulses and the delay. A control program for the embedded controller to execute is generated. S5. During operation, the embedded controller outputs pulses and direction signals one by one according to the integer pulses and timer obtained in step S4. The microstepping driver drives the stepper motor and rotary-linear conversion mechanism to reproduce the specified reciprocating displacement trajectory. During operation, the current instruction is not changed according to the displacement measurement value, thus forming a feedforward open-loop execution. S6. After one run, use the displacement record obtained in step S5 and the target amplitude A, excitation frequency f, and effective gear pitch circle radius r read in step S1. p Offline acquisition of the actual measurement period T meas Compared with the measured amplitude A meas Update the software execution overhead τ per pulse according to the actual measurement cycle, and update the effective gear pitch circle radius r according to the actual measured amplitude. p Write the updated parameters back to the parameter workbook, regenerate and re-burn the control program, and then run it again.

2. The reciprocating motion integer pulse control method according to claim 1, characterized in that, In step S3, let the carry remainder after the previous sampling point be... First calculate Then for acc i The signed integer pulse instruction S is obtained by rounding down the nearest integer and limiting it to the range of a 16-bit signed integer. i Then press The unexecuted fractional remainder is passed to the next sampling point.

3. The reciprocating motion integer pulse control method according to claim 1, characterized in that, It also includes a net residual closure step: The signed integer pulse instruction S obtained in step S3... i The selected instruction sequence is used to calculate the net residual R. S =∑S i When R S When =0, no instruction is appended; only when R = 0, no instruction is appended. S ≠ Add at 0 As a closing correction instruction, the instruction sequence containing the closing correction instruction is used as the input for generating integer pulses and timing tables in step S4, and the closing correction instruction occupies an additional execution interval.

4. The reciprocating motion integer pulse control method according to claim 1, characterized in that, It also includes a periodic detection step: the continuous incremental pulse demand ΔN obtained in step S2. i The sequence simultaneously checks whether the number of samples per cycle T / Δt and the design number of time-domain cycles D / T are integers within the set tolerance, and whether the length of the incremental sequence is not less than the number of samples per cycle, where T=1 / f is the excitation cycle; if satisfied, only one cycle instruction obtained in step S3 and timed by step S4 is written into the integer pulse and timing table, and executed cyclically by step S5; if not satisfied, the complete sequence is processed through steps S3 and S4 to generate the integer pulse and timing table; when the overlay data column is enabled, single-cycle storage is prohibited unless it is confirmed that the overlay data itself is a complete cycle.

5. The reciprocating motion integer pulse control method according to claim 1, characterized in that, In step S4, the non-zero signed integer pulse instruction S obtained in step S3 is processed. i The nominal half-cycle delay is based on B. i nz =max[2,min(65535,round(Δt×10 6 / (2|S i |)))] Microsecond calculation; for zero instructions, the execution time is B. i pause =min[65535,round(Δt×1000)] milliseconds of pause without outputting a pulse, and the B i nz Or the aforementioned B i pause With the corresponding S i Write integer pulses and a timing table for execution in step S5.

6. The reciprocating motion integer pulse control method according to claim 5, characterized in that, In step S4, the integer half-cost is calculated using the τ read in step S1. Then, for the B mentioned above i nz Calculate actual programming delay microseconds, and HD i As the execution delay of the integer pulse and the corresponding instruction in the timer table, it is used for step S5; where 2 microseconds is the minimum delay protection value.

7. The reciprocating motion integer pulse control method according to claim 1, characterized in that, In step S6, let T target =1 / f is the target period, A target To be equal to the target amplitude A read in step S1, τ is the number of pulse paths per cycle for continuous approximation. old With r p,old To use the old parameters actually used when generating this displacement record, according to Update per-pulse software execution overhead, according to Update the effective gear pitch circle radius; and set the configurable periodic error threshold δ. T With amplitude error threshold δ A Determine if the iteration terminates: If both the period error and the amplitude error are less than the corresponding threshold, accept the current parameters; otherwise, write back to the parameter workbook, regenerate, re-burn, and repeat the measurement.

8. The reciprocating motion integer pulse control method according to claim 7, characterized in that, In step S6, the measured period and measured amplitude are obtained as follows: When there are displacement records with timestamps, the timestamps are parsed and the cross-midnight loop is processed. The displacement sequence is subjected to three-point median filtering, and then least-squares sine fitting is performed on coarse and fine frequency grids centered on the excitation frequency. The fitting amplitude and fitting frequency are obtained from the fitting results, and the reciprocal of the fitting frequency is taken as the measured period T. meas The fitted amplitude is taken as the measured amplitude A. meas When no timestamped record exists, the measured period T is manually input from the extreme values ​​of the multi-period average. meas With peak-to-peak shift pp meas and take A meas =pp meas / 2; the obtained T meas and the A meas Used for the update calculation in step S6.

9. The reciprocating motion integer pulse control method according to claim 1, characterized in that, Before step S5 is executed, an instruction space verification step is also included before programming: the cumulative pulse pos is calculated from the integer pulse and timer table generated in step S4. pulses,i With reconstructed linear displacement The process involves checking if the terminal's cumulative pulse count is zero and comparing the reconstructed displacement with the ideal trajectory at the same discrete moment. If the verification passes, the integer pulse and timing table are used in step S5. If the verification fails, the process returns to step S2 to regenerate the continuous incremental pulse requirement. Where α... eff =(α / M)·(π / 180) is the angular resolution per pulse.

10. A reciprocating motion integer pulse control system with offline calibration, used to implement the reciprocating motion integer pulse control method according to any one of claims 1-9, characterized in that, include: The parameter workbook is used to store parameters, including the target amplitude A, excitation frequency f, and effective gear pitch circle radius r. p The motor step angle α, microstepping factor M, design time domain D, command interval Δt, and software execution overhead τ per pulse; The motion and instruction generation module is used to read the parameters from the parameter workbook by name, and use the parameters and the specified reciprocating displacement trajectory to obtain the continuous incremental pulse requirement ΔN. i , will ΔN i Integers are converted into signed integer pulse instructions Si, and then the signed integer pulse instructions S are used. i The command interval Δt and the software execution overhead τ per pulse generate integer pulses, timing tables, and control programs. Offline command and motion verification module, used to utilize integer pulses and timers, as well as the effective gear pitch circle radius r. p The motor step angle α and microstepping factor M are used to calculate the cumulative pulse and reconstruct the linear displacement. The cumulative pulse at the terminal is verified to be zero, and the verified integer pulse and timer are output to the embedded controller. An embedded controller used to output pulse and direction signals sequentially according to integer pulses and a timer. Microstepping driver, stepper motor and rotary-to-linear conversion mechanism are used to receive pulse and direction signals and reproduce a specified reciprocating trajectory; The displacement sensor and recording module are used to record the displacement during operation and output the displacement record to the offline parameter calibration module; The offline parameter calibration module is used to utilize displacement records and target amplitude A, excitation frequency f, and effective gear pitch circle radius r. p Obtain the measured period T meas Compared with the measured amplitude A meas And update the software execution overhead τ per pulse and the effective gear pitch circle radius r. p ; The parameter write-back and redeployment module is used to update the per-pulse software execution overhead τ and the effective gear pitch circle radius r. p Write back the parameter workbook and trigger the motion and instruction generation module to regenerate integer pulses, timers, and control programs, as well as reprogram the embedded controller.