An autofocus control method based on displacement sensor

CN119767140BActive Publication Date: 2025-11-21NANJING DEEPGET INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411919235.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-25
Publication Date
2025-11-21
Estimated Expiration
2044-12-25

AI Technical Summary

Technical Problem

现有的自动聚焦系统在锂电池极片视觉检测中存在检测精度不高、响应滞后、抗干扰能力弱以及控制不稳定的问题,尤其在高速连续采集场景下难以保证聚焦系统的稳定性和可靠性。

Method used

采用基于位移传感器的自动聚焦控制方法,结合卡尔曼滤波算法和状态预测模型,通过运动控制卡进行数据处理和闭环PID控制,实现精确测量和智能补偿,确保镜头组件保持在最佳聚焦状态。

Benefits of technology

提高了自动聚焦系统的控制精度和稳定性,减少了机械振荡,提高了响应速度和抗干扰能力,满足了高速运动目标的检测需求。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119767140B_ABST
    Figure CN119767140B_ABST
Patent Text Reader

Abstract

The application discloses an automatic focusing control method based on a displacement sensor and relates to the technical field of motion control.The method comprises the following steps: collecting a distance signal of a detection target and converting the distance signal into a physical distance value through a calibration coefficient; performing a difference operation on the physical distance value and a standard focusing distance by a motion control card to obtain a position deviation value, performing data smoothing processing on the position deviation value by applying a Kalman filtering algorithm, establishing a state prediction model by using N latest frame buffer data, generating position compensation data, converting the position compensation data into a pulse control amount, and generating a motor driving instruction according to a PID control algorithm when the pulse control amount exceeds a preset threshold; and driving a lens assembly to perform position compensation according to the motor driving instruction by a stepping motor driver, so that the lens assembly and the detection target are kept at the standard focusing distance.The application overcomes the problems of response lag and poor anti-interference capability in a traditional automatic focusing system, and improves the dynamic response characteristics and control precision of the system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of motion control technology, and in particular to an automatic focusing control method based on a displacement sensor. Background Technology

[0002] In the field of machine vision, the working distance between the lens and the target needs to match the lens's nominal working distance, and its variation range cannot exceed the lens's depth of field to ensure image clarity. In practical applications, due to factors such as equipment vibration and product changes, the working distance often fluctuates dynamically. Therefore, an autofocus system is needed to adjust the working distance in real time to maintain it within the ideal range. Generally, higher detection accuracy requires a larger lens magnification and a smaller depth of field, which in turn places higher accuracy requirements on the autofocus system. Similarly, faster detection speeds demand higher response speeds from the autofocus system. In the visual inspection of lithium battery electrodes, the target is typically the edge or surface of the electrode, which is often in a state of dynamic fluctuation and high-speed movement. Therefore, an autofocus system with high precision and fast response capabilities is particularly necessary.

[0003] Traditional autofocus technologies are mainly divided into two types: passive autofocus and active autofocus. Passive autofocus evaluates the focus state by calculating an image sharpness function, but this method is computationally intensive and easily affected by changes in ambient lighting, especially in low-contrast scenes where performance degrades significantly. While active autofocus can directly acquire target distance information, existing technologies generally suffer from insufficient measurement accuracy, slow response speed, and poor anti-interference capabilities. Especially in high-speed continuous acquisition scenarios, factors such as mechanical vibration, ambient temperature changes, and measurement noise make it difficult for traditional PID control algorithms to guarantee the stability and reliability of the focusing system.

[0004] To address the aforementioned problems, this invention proposes an automatic focusing control method based on a displacement sensor. This method effectively solves key technical challenges in the automatic focusing process, such as data smoothing, position prediction compensation, and system stability, by introducing a Kalman filter algorithm and a state prediction model, combined with a closed-loop PID control strategy. Furthermore, it utilizes a motion control card for data reception, processing, and transmission, reducing latency and improving focusing response speed. Summary of the Invention

[0005] In view of the problems of low detection accuracy, slow response, weak anti-interference ability and unstable control in existing automatic focusing control systems, this invention is proposed.

[0006] Therefore, the problem to be solved by this invention is how to achieve accurate measurement, intelligent prediction and smooth compensation of the target distance, so as to ensure that the lens assembly always remains in the best focusing state, thereby improving the control accuracy and stability of the autofocus system.

[0007] To solve the above-mentioned technical problems, the present invention provides the following technical solution:

[0008] In a first aspect, embodiments of the present invention provide an automatic focusing control method based on a displacement sensor, comprising: a motion control card acquiring a distance signal of a detected target through a sensor, and converting the distance signal into a physical distance value through a calibration coefficient; wherein the motion control card acts as a processing center, receiving the sensor signal, performing algorithm processing, and outputting motion control commands to a stepper motor driver; the motion control card performing a difference calculation between the physical distance value and a standard focusing distance to obtain a position deviation value; applying a Kalman filter algorithm to the position deviation value for data smoothing, and establishing a state prediction model using the most recent N frames of cached data to generate corrected position compensation data; converting the position compensation data into a pulse control quantity for the stepper motor driver; when the pulse control quantity is greater than a preset threshold, generating a motor drive command according to a PID control algorithm; the motion control card controlling the stepper motor driver to drive the lens assembly to perform position compensation according to the motor drive command, so that the lens assembly and the detected target are maintained at a standard focusing distance, and continuously acquiring the distance signal for closed-loop control.

[0009] As a preferred embodiment of the automatic focusing control method based on displacement sensors described in this invention, the lens assembly includes a camera, a lens, a coupling, and a lead screw drive mechanism. Controlling the stepper motor driver to drive the lens assembly for position compensation according to the motor drive command includes the following steps: receiving motor drive commands output from the motion control card via the stepper motor driver, converting the motor drive commands into a winding excitation sequence, wherein the winding excitation sequence controls the stepper motor driver to operate in a phase excitation manner; driving the lead screw drive mechanism to rotate via the coupling, converting the rotational motion into linear motion, causing the lens assembly to reciprocate along the optical axis; acquiring the distance signal between the lens assembly and the detection target via a sensor, and feeding it back to the motion control card to form a closed-loop control, wherein the feedback signal of the closed-loop control is filtered in real time and then participates in the next round of position compensation calculation, so that the lens assembly and the detection target are maintained at a standard focusing distance.

[0010] As a preferred embodiment of the automatic focusing control method based on displacement sensors described in this invention, the method for generating motor drive commands is as follows: Position compensation data is converted into pulse control quantities according to the stepper motor driver's subdivision coefficients via the data conversion unit of the motion control card; the positive or negative sign of the pulse control quantity represents the movement direction of the stepper motor driver; a preset threshold for the pulse control quantity is set; when the absolute value of the pulse control quantity is greater than the preset threshold, a PID control algorithm is triggered; when the absolute value of the pulse control quantity is less than or equal to the preset threshold, the current pulse control quantity is maintained; the motion parameters of the stepper motor driver are calculated using trapezoidal acceleration / deceleration programming, and the PID control algorithm is used to generate motor drive commands from the motion parameters and pulse control quantities, wherein the motion parameters include the starting frequency, maximum operating frequency, and acceleration.

[0011] As a preferred embodiment of the automatic focusing control method based on displacement sensors described in this invention, the motor drive command includes a direction signal and a pulse sequence; the method for generating the position compensation data is as follows: a buffer space is set in the motion control card, and N frames of position deviation values ​​are stored according to timestamps to construct a system state vector, wherein the system state vector includes position state components and velocity state components; based on the historical trend of position deviation values ​​and the system state vector, a state prediction model is established, wherein the state prediction model includes system state transition equations and observation equations; the Kalman gain matrix is ​​calculated in real time through the motion control card, and the position deviation values ​​are input into the state prediction model; the optimal estimate is calculated by combining the output predicted state and the Kalman gain matrix. Based on the optimal estimate The above steps are executed iteratively to output the filtered position compensation data.

[0012] As a preferred embodiment of the automatic focusing control method based on displacement sensors described in this invention, the specific formula of the state prediction model is as follows:

[0013] ;

[0014] in, Let k be the position state component at time k. Let k be the velocity state component at time k. The sampling time interval, The velocity attenuation coefficient, The position noise figure, For the standard deviation of position measurement, For the velocity noise figure, For the standard deviation of speed measurement, The measurement noise at time k follows a Gaussian distribution with a mean of 0 and a standard deviation of 0.1. Let be the observation equation at time k.

[0015] The optimal estimate The specific formula is as follows:

[0016] ;

[0017] in, Let be the prior state estimate at time k. Here is the Kalman gain matrix. Let H be the actual observation value at time k, and H be the identity matrix. Let be the estimation error at time k.

[0018] As a preferred embodiment of the automatic focusing control method based on a displacement sensor described in this invention, the method for obtaining the position deviation value is as follows: A preset standard focusing distance value is read from an internal register via a motion control card, and a difference is calculated between the physical distance value and the preset standard focusing distance using a fixed-point arithmetic method. The preset standard focusing distance value is calibrated based on the camera lens optical parameters and depth of field range. The difference is compared with a preset depth of field threshold to determine the compensation direction. When the absolute value of the difference is greater than the preset depth of field threshold, an automatic focusing compensation mechanism is triggered. When the absolute value of the difference is less than or equal to the preset depth of field threshold, the current lens position is maintained. The difference is converted into a position deviation value in micrometers, and the calculation timestamp of the position deviation value is recorded.

[0019] As a preferred embodiment of the automatic focusing control method based on a displacement sensor described in this invention, the method for obtaining the physical distance value is as follows: A displacement sensor emits a beam of light to illuminate the surface of the target object and receives the reflected echo signal, wherein the displacement sensor employs the triangulation principle; based on the reflected echo signal, a distance signal is obtained according to the angle between the incident beam and the reflected beam at the reflection point on the position-sensitive device, wherein the distance signal is output in the form of an analog voltage; a motion control card collects several sampling points of the distance signal to form a sampling data sequence, and uses an analog-to-digital converter to convert the sampling data sequence into a digital signal; calibration coefficients are extracted according to a pre-calibrated sensor linearity curve, and a linear transformation is performed in combination with the calibration coefficients to eliminate the nonlinear error of the sensor and obtain the physical distance value, wherein the calibration coefficients include a zero-point offset and a proportional coefficient; the physical distance value is subjected to digital low-pass filtering, a cutoff frequency is set, high-frequency noise components are filtered out, and the signal-to-noise ratio of the measurement signal is improved.

[0020] Secondly, embodiments of the present invention provide an automatic focusing control system based on a displacement sensor, comprising: a distance signal acquisition module, used by a motion control card to acquire distance signals of a detected target through a sensor, and convert the distance signals into physical distance values ​​through calibration coefficients, wherein the motion control card acts as a processing center, receiving sensor signals, performing algorithm processing, and outputting motion control commands to a stepper motor driver; a position deviation calculation module, used by the motion control card to perform difference calculation between the physical distance value and the standard focusing distance to obtain a position deviation value; a state prediction and compensation data generation module, used to apply a Kalman filter algorithm to the position deviation value for data smoothing, and to establish a state prediction model using the most recent N frames of cached data to generate corrected position compensation data; a pulse control quantity conversion module, used to convert the position compensation data into pulse control quantities of the stepper motor driver, and when the pulse control quantity is greater than a preset threshold, to generate motor drive commands according to a PID control algorithm; and a stepper motor driver driving module, used by the motion control card to control the stepper motor driver to drive the lens assembly to perform position compensation according to the motor drive commands, so that the lens assembly and the detected target are maintained at the standard focusing distance, and to continuously acquire the distance signals for closed-loop control.

[0021] Thirdly, embodiments of the present invention provide a computer device, including a memory and a processor, wherein the memory stores a computer program, wherein: when the computer program instructions are executed by the processor, they implement the steps of the automatic focusing control method based on a displacement sensor as described in the first aspect of the present invention.

[0022] Fourthly, embodiments of the present invention provide a computer-readable storage medium having a computer program stored thereon, wherein: when the computer program instructions are executed by a processor, they implement the steps of the automatic focusing control method based on a displacement sensor as described in the first aspect of the present invention.

[0023] The beneficial effects of this invention are as follows: Distance signals collected by sensors are converted into precise physical distance values ​​by combining calibration coefficients, ensuring the accuracy of measurement data; real-time difference calculations are performed using a motion control card, combined with a Kalman filter algorithm, to achieve intelligent smoothing and dynamic prediction of position deviations; a stepper motor drive scheme based on PID control is adopted to convert position compensation into a precise pulse sequence, effectively avoiding mechanical oscillations; continuous position compensation is performed through a closed-loop control strategy to achieve precise adjustment of the lens assembly; data reception, processing, and transmission are based on the motion control card, reducing latency and improving focusing response speed. Attached Figure Description

[0024] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. Wherein:

[0025] Figure 1 This is a flowchart of the automatic focusing control method based on a displacement sensor in Example 1;

[0026] Figure 2 This is the control logic diagram of the automatic focusing control method based on a displacement sensor in Example 1. Detailed Implementation

[0027] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings.

[0028] Many specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention may also be practiced in other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the spirit of the invention. Therefore, the invention is not limited to the specific embodiments disclosed below.

[0029] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The phrase "in one embodiment" appearing in different places in this specification does not necessarily refer to the same embodiment, nor is it a single or selective embodiment that is mutually exclusive with other embodiments.

[0030] Example 1

[0031] Reference Figures 1-2 This is the first embodiment of the present invention, which provides an automatic focusing control method based on a displacement sensor, including:

[0032] S1: The motion control card collects the distance signal of the target through the sensor and converts the distance signal into a physical distance value through the calibration coefficient. The motion control card acts as the processing center, receives the sensor signal, performs algorithm processing, and outputs motion control commands to the stepper motor driver.

[0033] Specifically, the method for obtaining the physical distance value is as follows: a displacement sensor emits a beam of light to illuminate the surface of the target and receives the reflected echo signal; based on the reflected echo signal, the distance signal is obtained according to the angle relationship between the incident beam and the reflected beam on the position-sensitive device; the motion control card collects several sampling points of the distance signal to form a sampling data sequence, and uses an analog-to-digital converter to convert the sampling data sequence into a digital signal.

[0034] It should be noted that the displacement sensor is a laser displacement sensor, and the displacement sensor adopts the triangulation measurement principle; the distance signal is output in the form of an analog voltage; the quantization accuracy of the digital signal reaches 0.01 micrometers.

[0035] Furthermore, calibration coefficients are extracted based on the pre-calibrated sensor linearity curve, and a linear transformation is performed in combination with the calibration coefficients to eliminate the nonlinear error of the sensor and obtain the physical distance value. The physical distance value is then subjected to digital low-pass filtering, and a cutoff frequency is set to filter out high-frequency noise components and improve the signal-to-noise ratio of the measurement signal.

[0036] It should be noted that the calibration coefficients include zero-point offset and proportional coefficient; the measurement range of physical distance values ​​is 0-5mm, and the measurement accuracy is better than 1 micrometer, which meets the needs of electrode burr detection and other related detection scenarios such as lithium battery electrodes.

[0037] S2: The motion control card performs a difference calculation between the physical distance value and the standard focusing distance to obtain the position deviation value.

[0038] Specifically, the position deviation value is obtained by reading the preset standard focusing distance value from the internal register through the motion control card, and calculating the difference between the physical distance value and the preset standard focusing distance using a fixed-point arithmetic method.

[0039] Furthermore, the difference The specific formulas include:

[0040] ;

[0041] in, Let i be the distance value measured in the i-th sample. This is the time decay factor, with a value range of [0.1, 0.5]. At the current time point, For the i-th sampling time point, This represents the number of sampling points, typically ranging from 5 to 10. To preset the standard focusing distance, This is the temperature compensation coefficient, with a value range of [0.001, 0.005]. This represents the ambient temperature deviation value.

[0042] It should be noted that the preset standard focus distance value is based on the camera lens optical parameters and depth of field range calibration; the preset standard focus distance value is set to 200mm, corresponding to the center position of the camera's depth of field.

[0043] Furthermore, the difference is compared with the preset depth-of-field threshold to determine the compensation direction; when the absolute value of the difference is greater than the preset depth-of-field threshold, the autofocus compensation mechanism is triggered; when the absolute value of the difference is less than or equal to the preset depth-of-field threshold, the current lens position is maintained and no focus adjustment is performed.

[0044] It should be noted that the autofocus compensation mechanism is a closed-loop control system triggered by comparing the difference between the physical distance value and the preset standard focus distance; the preset depth-of-field threshold is calibrated based on the lens optical parameters and depth-of-field range.

[0045] Specifically, the difference is converted into a positional deviation value in micrometers, and the calculation timestamp of the positional deviation value is recorded.

[0046] Furthermore, the positional deviation value The specific formula is as follows:

[0047] ;

[0048] in, This is the position compensation coefficient, with a value range of [0.9, 1.1]. This is the difference between the physical distance value and the preset standard focusing distance. To measure the systematic error coefficient, the value range is [0.01, 0.05]. This is the thermal drift coefficient, with a value range of [0.001, 0.003]. This is the increment for system operating time.

[0049] S3: Apply the Kalman filter algorithm to the position deviation value for data smoothing, and use the most recent N frames of cached data to establish a state prediction model to generate corrected position compensation data.

[0050] Specifically, the method for generating position compensation data is as follows: A buffer space is set up in the motion control card, and N frames of position deviation values ​​are stored according to timestamps to construct a system state vector, which includes position state components and velocity state components. Based on the historical trend of position deviation values ​​and the system state vector, a state prediction model is established, with the following specific formula:

[0051] ;

[0052] in, Let k be the position state component at time k. Let k be the velocity state component at time k. The sampling time interval, The velocity attenuation coefficient has a value range of [0.8, 0.95]. The position noise figure has a value range of [0.01, 0.05]. For the standard deviation of position measurement, The velocity noise figure has a value range of [0.05, 0.1]. For the standard deviation of speed measurement, The measurement noise at time k follows a Gaussian distribution with a mean of 0 and a standard deviation of 0.1. Let be the observation equation at time k.

[0053] It should be noted that the state prediction model includes the system state transition equation and the observation equation; the state transition equation adopts the uniformly accelerated motion model; the uniformly accelerated motion model includes position prediction terms and velocity prediction terms.

[0054] Furthermore, the Kalman gain matrix is ​​calculated in real time using a motion control card, and the position deviation value is input into the state prediction model. The optimal estimate is then calculated by combining the output predicted state and the Kalman gain matrix. The specific formula is as follows:

[0055] ;

[0056] in, Let be the prior state estimate at time k. Here is the Kalman gain matrix. Let H be the actual observation value at time k, and H be the identity matrix. Let be the estimation error at time k.

[0057] Furthermore, based on the optimal estimate The above steps are executed iteratively to output the filtered position compensation data.

[0058] S4: Convert the position compensation data into a pulse control quantity for the stepper motor driver. When the pulse control quantity is greater than a preset threshold, generate a motor drive command according to the PID control algorithm.

[0059] Specifically, the position compensation data is converted into pulse control quantities by the data conversion unit of the motion control card according to the microstepping coefficient of the stepper motor driver.

[0060] It should be noted that the positive or negative value of the pulse control quantity indicates the direction of movement of the stepper motor driver; setting the preset threshold of the pulse control quantity corresponds to an actual displacement of ±2.5 micrometers.

[0061] Furthermore, when the absolute value of the pulse control quantity is greater than the preset threshold, the PID control algorithm is triggered; when the absolute value of the pulse control quantity is less than or equal to the preset threshold, the current pulse control quantity is maintained.

[0062] It should be noted that the proportional coefficient, integral time, and derivative time of the PID control algorithm are obtained through a self-tuning method.

[0063] Furthermore, trapezoidal acceleration and deceleration programming is used to calculate the motion parameters of the stepper motor driver, and PID control algorithm is used to generate motor drive commands from the motion parameters and pulse control quantities;

[0064] It should be noted that the motion parameters include the starting frequency, the maximum operating frequency, and the acceleration; the motor drive commands include the direction signal and the pulse sequence.

[0065] S5: The motion control card controls the stepper motor driver to drive the lens assembly to perform position compensation according to the motor drive command, so that the lens assembly and the detection target are kept at a standard focusing distance, and the distance signal is continuously collected for closed-loop control.

[0066] Specifically, the stepper motor driver receives motor drive commands from the motion control card and converts the motor drive commands into a winding excitation sequence.

[0067] It should be noted that the winding excitation sequence controls the operation of the stepper motor driver in a phase excitation manner; the lens assembly includes a camera, lens, coupling, and lead screw drive mechanism; the lead screw drive mechanism has a self-locking function to suppress position drift caused by external vibration.

[0068] Furthermore, the rotational motion is converted into linear motion by driving the lead screw transmission mechanism through the coupling, causing the lens assembly to reciprocate along the optical axis; the distance signal between the lens assembly and the target is collected by the sensor and fed back to the motion control card, forming a closed-loop control.

[0069] It should be noted that the feedback signal of the closed-loop control is filtered in real time and then used in the next round of position compensation calculation to keep the lens assembly and the detection target at the standard focusing distance.

[0070] Furthermore, this embodiment also provides an automatic focusing control system based on a displacement sensor, including: a distance signal acquisition module, used by a motion control card to acquire distance signals of the detected target through a sensor, and convert the distance signals into physical distance values ​​through calibration coefficients, wherein the motion control card acts as a processing center, receives sensor signals, performs algorithm processing, and outputs motion control commands to a stepper motor driver; a position deviation calculation module, used by the motion control card to perform difference calculation between the physical distance value and the standard focusing distance to obtain a position deviation value; a state prediction and compensation data generation module, used to apply a Kalman filter algorithm to the position deviation value for data smoothing, and to establish a state prediction model using the most recent N frames of cached data to generate corrected position compensation data; a pulse control quantity conversion module, used to convert the position compensation data into pulse control quantities of the stepper motor driver, and when the pulse control quantity is greater than a preset threshold, to generate motor drive commands according to a PID control algorithm; and a stepper motor driver driving module, used by the motion control card to control the stepper motor driver to drive the lens assembly to perform position compensation according to the motor drive commands, so that the lens assembly and the detected target are maintained at the standard focusing distance, and to continuously acquire the distance signals for closed-loop control.

[0071] This embodiment also provides a computer device applicable to the automatic focusing control method based on a displacement sensor, including a memory and a processor; the memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions to realize the automatic focusing control method based on a displacement sensor as proposed in the above embodiment.

[0072] The computer device can be a terminal, comprising a processor, memory, communication interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, carrier networks, NFC (Near Field Communication), or other technologies. The display screen can be an LCD screen or an e-ink screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad on the computer device's casing, or an external keyboard, touchpad, or mouse.

[0073] This embodiment also provides a storage medium storing a computer program. When executed by a processor, the program performs the following steps: a motion control card acquires distance signals of the detected target through sensors and converts the distance signals into physical distance values ​​using calibration coefficients. The motion control card acts as a processing center, receiving sensor signals, performing algorithmic processing, and outputting motion control commands to a stepper motor driver. The motion control card performs a difference calculation between the physical distance value and the standard focusing distance to obtain a position deviation value. A Kalman filter algorithm is applied to the position deviation value for data smoothing, and a state prediction model is established using the most recent N frames of cached data to generate corrected position compensation data. The position compensation data is converted into pulse control quantities for the stepper motor driver. When the pulse control quantity is greater than a preset threshold, a motor drive command is generated according to a PID control algorithm. The motion control card controls the stepper motor driver to drive the lens assembly to perform position compensation according to the motor drive command, maintaining the lens assembly and the detected target at the standard focusing distance, and continuously acquiring the distance signals for closed-loop control.

[0074] In summary, this invention converts distance signals collected by sensors into precise physical distance values ​​using calibration coefficients, ensuring the accuracy of measurement data; utilizes a motion control card for real-time difference calculations and a Kalman filter algorithm to achieve intelligent smoothing and dynamic prediction of position deviations; employs a stepper motor drive scheme based on PID control to convert position compensation into precise pulse sequences, effectively avoiding mechanical oscillations; continuously performs position compensation through a closed-loop control strategy to achieve precise adjustment of the lens assembly; and uses a motion control card for data reception, processing, and transmission, reducing latency and improving focusing response speed.

[0075] Example 2

[0076] Referring to Table 1, the second embodiment of the present invention provides an automatic focusing control method based on a displacement sensor. To verify the beneficial effects of the present invention, scientific demonstration is carried out through economic benefit calculations and simulation experiments.

[0077] Specifically, the autofocus test platform was constructed in a standard laboratory environment (temperature 23±1℃, relative humidity 45±5%) using Keyence LK-G5000 series displacement sensors, Mitsubishi FX5U programmable controllers, Oriental Motor ARD-K series stepper motor drivers, and an industrial camera (equipped with a 50mm fixed-focus lens).

[0078] Furthermore, the displacement sensor was calibrated using a Renishaw XL-80 laser interferometer as a standard. Within the 0-5mm measurement range, calibration points were taken every 0.5mm to obtain the sensor's linearity curve. Calibration coefficients were obtained through least-squares fitting: zero-point offset was -0.023mm, and the proportionality coefficient was 1.0124. The experiment used a 100kHz sampling frequency, averaging 10 data points each time, and applied a Butterworth low-pass filter with a cutoff frequency of 1kHz for signal processing.

[0079] Furthermore, in the distance measurement experiment, a polished silicon wafer was used as a standard plane, and reciprocating motion tests were conducted at different distance positions, with measurement data recorded. The system was set with a preset standard focusing distance of 200mm and a preset depth-of-field threshold of ±0.1mm. The position compensation control parameters were set as follows: velocity attenuation coefficient... =0.85, location noise figure =0.02, speed noise figure =0.08, time decay factor =0.3, temperature compensation coefficient =0.003, position compensation coefficient =1.05, measurement system error coefficient =0.02, thermal drift coefficient =0.002. The stepper motor driver uses 16 microstepping mode, and the PID parameters are configured as follows: =0.8, =0.1, =0.05.

[0080] Specifically, as shown in Table 1, in terms of distance measurement accuracy, the present invention achieves 0.45 μm, a 75.7% improvement over the traditional method. This is mainly attributed to the adoption of calibration coefficient compensation and digital low-pass filtering processing mechanisms. The system response time is reduced from 420 ms in the traditional method to 180 ms, an improvement of 57.1%, improving the dynamic performance of the system. The position compensation accuracy reaches 0.82 μm, a 66.5% improvement compared to 2.45 μm in the traditional method. This is due to the synergistic effect of the Kalman filtering algorithm and the state prediction model. In terms of system stability, the fluctuation of the present invention is only 0.31 μm, while that of the traditional method is 1.82 μm, an improvement of 83%, fully demonstrating the superiority of the present invention in suppressing system fluctuations. In high-speed target tracking scenarios, the present invention can still maintain an accuracy of 1.35 μm, while the traditional method degrades to 3.68 μm, indicating that the present invention has stronger adaptability in dynamic scenarios.

[0081] Table 1 Comparison between the present invention and traditional methods

[0082] Test parameters Method of the present invention Traditional methods Distance measurement accuracy (μm) 0.45 1.85 System response time (ms) 180 420 Position compensation accuracy (μm) 0.82 2.45 System stability (μm) 0.31 1.82 High-speed target tracking accuracy (μm) 1.35 3.68 Vibration resistance (μm) 0.65 2.15 Temperature drift compensation (μm / ℃) 0.12 0.45 Energy consumption index (W) 12.3 16.8 Control algorithm convergence time (ms) 85 245

[0083] Furthermore, vibration resistance tests show that the method of this invention has 3.3 times the disturbance rejection capability of the traditional method. Regarding temperature drift compensation, the method of this invention reduces the temperature effect to 0.12 μm / ℃, while the traditional method is 0.45 μm / ℃, thanks to the introduction of a temperature compensation coefficient and a thermal drift correction mechanism. In terms of energy consumption, the method of this invention saves 26.8% of power consumption compared to the traditional method, mainly due to a more precise control strategy that reduces unnecessary compensation actions. The convergence time of the control algorithm is also shortened from 245 ms to 85 ms, an improvement of 65.3%, which fully demonstrates the advantages of this invention in control efficiency.

[0084] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.

Claims

1. An automatic focusing control method based on a displacement sensor, characterized in that: include, The motion control card collects distance signals of the detected target through sensors and converts the distance signals into physical distance values ​​through calibration coefficients. The motion control card acts as a processing center, receiving sensor signals, performing algorithm processing, and outputting motion control commands to the stepper motor driver. The motion control card calculates the difference between the physical distance value and the standard focusing distance to obtain the position deviation value; The position deviation value is smoothed by applying the Kalman filter algorithm, and a state prediction model is established using the most recent N frames of cached data to generate corrected position compensation data. The position compensation data is converted into a pulse control quantity for the stepper motor driver. When the pulse control quantity is greater than a preset threshold, a motor drive command is generated according to the PID control algorithm. The motion control card controls the stepper motor driver to drive the lens assembly to perform position compensation according to the motor drive command, so that the lens assembly and the detection target are kept at a standard focusing distance, and the distance signal is continuously collected for closed-loop control; The motor drive command includes a direction signal and a pulse sequence; the method for generating the position compensation data is as follows. A buffer space is set in the motion control card, and N frames of position deviation values ​​are stored by timestamp to construct a system state vector, wherein the system state vector includes position state components and velocity state components. Based on the historical trend of the position deviation value and the system state vector, a state prediction model is established, wherein the state prediction model includes the system state transition equation and the observation equation. The Kalman gain matrix is ​​calculated in real time using a motion control card, and the position deviation value is input into the state prediction model. The optimal estimate is then calculated by combining the output predicted state and the Kalman gain matrix. ; Based on the optimal estimate The above steps are executed iteratively to output the filtered position compensation data.

2. The automatic focusing control method based on a displacement sensor as described in claim 1, characterized in that: The lens assembly includes a camera, a lens, a coupling, and a lead screw drive mechanism; the stepper motor driver controls the lens assembly to perform position compensation according to the motor drive command, including the following steps: The stepper motor driver receives motor drive commands output from the motion control card and converts the motor drive commands into a winding excitation sequence, wherein the winding excitation sequence controls the operation of the stepper motor driver in a phase excitation mode. The coupling drives the lead screw transmission mechanism to rotate, converting the rotational motion into linear motion, so that the lens assembly reciprocates along the optical axis. The distance signal between the lens assembly and the target is acquired by the sensor and fed back to the motion control card to form a closed-loop control. The feedback signal of the closed-loop control is filtered in real time and then used in the next round of position compensation calculation to keep the lens assembly and the target at a standard focusing distance.

3. The automatic focusing control method based on a displacement sensor as described in claim 2, characterized in that: The method for generating the motor drive command is as follows: The position compensation data is converted into pulse control quantities by the data conversion unit of the motion control card according to the subdivision coefficient of the stepper motor driver. The positive or negative sign of the pulse control quantity represents the motion direction of the stepper motor driver. A preset threshold is set for the pulse control quantity. When the absolute value of the pulse control quantity is greater than the preset threshold, the PID control algorithm is triggered; when the absolute value of the pulse control quantity is less than or equal to the preset threshold, the current pulse control quantity is maintained. The motion parameters of the stepper motor driver are calculated using trapezoidal acceleration and deceleration programming, and the PID control algorithm is used to generate motor drive commands from the motion parameters and pulse control quantities. The motion parameters include the starting frequency, the maximum operating frequency, and the acceleration.

4. The automatic focusing control method based on a displacement sensor as described in claim 1, characterized in that: The specific formula for the state prediction model is as follows: ; in, Let k be the position state component at time k. Let k be the velocity state component at time k. The sampling time interval, The velocity attenuation coefficient, The position noise figure, For the standard deviation of position measurement, For the velocity noise figure, For the standard deviation of speed measurement, The measurement noise at time k follows a Gaussian distribution with a mean of 0 and a standard deviation of 0.

1. Let k be the observation equation at time k; The optimal estimate The specific formula is as follows: ; in, Let k be the prior state estimate at time k. Here is the Kalman gain matrix. Let H be the actual observation value at time k, and H be the identity matrix. Let be the estimation error at time k.

5. The automatic focusing control method based on a displacement sensor as described in claim 1 or 4, characterized in that: The method for obtaining the position deviation value is as follows: The motion control card reads the preset standard focus distance value from the internal register and calculates the difference between the physical distance value and the preset standard focus distance using a fixed-point arithmetic method. The preset standard focus distance value is based on the camera lens optical parameters and depth of field range calibration. The difference is compared with a preset depth-of-field threshold to determine the compensation direction; when the absolute value of the difference is greater than the preset depth-of-field threshold, the autofocus compensation mechanism is triggered; when the absolute value of the difference is less than or equal to the preset depth-of-field threshold, the current lens position is maintained. The difference is converted into a positional deviation value in micrometers, and the calculation timestamp of the positional deviation value is recorded.

6. The automatic focusing control method based on a displacement sensor as described in claim 5, characterized in that: The method for obtaining the physical distance value is as follows: A displacement sensor is used to emit a light beam to illuminate the surface of the target and receive the reflected echo signal. The displacement sensor uses the triangulation principle. Based on the reflected echo signal, a distance signal is obtained according to the angle relationship between the incident beam and the reflected beam on the position-sensitive device, wherein the distance signal is output in the form of a voltage analog quantity; The motion control card collects several sampling points of the distance signal to form a sampling data sequence, and uses an analog-to-digital converter to convert the sampling data sequence into a digital signal; The calibration coefficients are extracted based on the pre-calibrated linearity curve of the sensor, and a linear transformation is performed in combination with the calibration coefficients to eliminate the nonlinear error of the sensor and obtain the physical distance value. The calibration coefficients include zero offset and proportional coefficient. The physical distance value is subjected to digital low-pass filtering, and a cutoff frequency is set to filter out high-frequency noise components and improve the signal-to-noise ratio of the measurement signal.

7. An automatic focusing control system based on a displacement sensor, based on the automatic focusing control method based on a displacement sensor according to any one of claims 1 to 6, characterized in that: include, The distance signal acquisition module is used by the motion control card to acquire the distance signal of the detected target through the sensor, and convert the distance signal into a physical distance value through calibration coefficients. The motion control card acts as the processing center, receives the sensor signal, performs algorithm processing, and outputs motion control commands to the stepper motor driver. The position deviation calculation module is used by the motion control card to perform difference calculation between the physical distance value and the standard focusing distance to obtain the position deviation value; The state prediction and compensation data generation module is used to apply the Kalman filter algorithm to the position deviation value for data smoothing, and to establish a state prediction model using the most recent N frames of cached data to generate corrected position compensation data. The pulse control quantity conversion module is used to convert the position compensation data into pulse control quantities for the stepper motor driver. When the pulse control quantity is greater than a preset threshold, a motor drive command is generated according to the PID control algorithm. The stepper motor driver module is used by the motion control card to control the stepper motor driver to drive the lens assembly to perform position compensation according to the motor drive command, so that the lens assembly and the detection target are kept at a standard focusing distance, and the distance signal is continuously collected for closed-loop control.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, it implements the steps of the automatic focusing control method based on a displacement sensor as described in any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by the processor, it implements the steps of the automatic focusing control method based on a displacement sensor as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Image capturing device and image capturing control method

    CN102547332A

  • Methods and apparatus for autofocus

    CN108535833A