Automatic focusing control method based on displacement sensor
By adopting a displacement sensor-based control method in the automatic focusing system, combined with the Kalman filtering algorithm and PID control, the problems of insufficient measurement accuracy and slow response speed in the prior art are solved, and the automatic focusing effect with high accuracy, fast response and stability is achieved.
Patent Information
- Application Number
- CN202411919235.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-25
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2044-12-25
AI Technical Summary
In scenarios with high detection accuracy and fast response speed, existing automatic focusing systems have problems such as insufficient measurement accuracy, slow response speed and poor anti-interference ability, making it difficult to ensure the stability and reliability of the focusing system.
The automatic focus control method based on displacement sensor is adopted, and the Kalman filtering algorithm and state prediction model are introduced, combined with the closed-loop PID control strategy, data smoothing processing, position prediction compensation and system stability are improved.
It improves the control accuracy and stability of the automatic focusing system, reduces mechanical oscillation, improves the focus response speed, and enhances the anti-interference ability.
Smart Images

Figure CN119767140A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of motion control, and in particular to an automatic focusing control method based on a displacement sensor. Background Art
[0002] In the field of machine vision, the working distance between the lens and the target needs to match the nominal working distance of the lens, and its variation range cannot exceed the depth of field of the lens to ensure a clear image. In practical applications, the working distance often fluctuates dynamically due to factors such as equipment vibration and product changes, so it is necessary to adjust the working distance in real time through the autofocus system to keep it within the optimal range. Generally, the higher the detection accuracy, the greater the magnification of the lens used, the smaller the depth of field, and the higher the accuracy requirements for the autofocus system; if the detection speed is faster, the response speed requirements for the autofocus system will also increase accordingly. In the visual inspection of lithium battery pole pieces, the shooting target is usually the edge or surface of the pole piece. These targets are often in a state of dynamic fluctuation and high-speed movement, so an autofocus system with high accuracy and fast response capabilities is particularly needed.
[0003] Traditional autofocus technology is mainly divided into two types: passive autofocus and active autofocus. Passive autofocus evaluates the focus state by calculating the image clarity function, but this method is computationally intensive and easily affected by changes in ambient light, especially in low-contrast scenes, where performance is significantly reduced. Although active autofocus can directly obtain the distance information of the target, the existing technology generally has problems such as insufficient measurement accuracy, slow response speed, and poor anti-interference ability. Especially in scenarios of high-speed continuous acquisition, due to factors such as mechanical vibration, ambient temperature changes, and measurement noise, traditional PID control algorithms are difficult to ensure the stability and reliability of the focusing system.
[0004] In view of the above problems, the present invention proposes an automatic focusing control method based on a displacement sensor. This method effectively solves key technical problems such as data smoothing, position prediction compensation, and system stability in the automatic focusing process by introducing a Kalman filter algorithm and a state prediction model, combined with a closed-loop PID control strategy, and receives, processes, and sends data based on a motion control card, thereby reducing delays and improving focusing response speed. Summary of the invention
[0005] In view of the problems of low detection accuracy, delayed response, weak anti-interference ability and unstable control in the existing automatic focusing control system, the present invention is proposed.
[0006] Therefore, the problem to be solved by the present invention is how to achieve accurate measurement, intelligent prediction and smooth compensation of the detection target distance to ensure that the lens assembly always remains in the optimal focusing state, thereby improving the control accuracy and stability of the automatic focusing system.
[0007] In order to solve the above technical problems, the present invention provides the following technical solutions:
[0008] In the first aspect, an embodiment of the present invention provides an automatic focusing control method based on a displacement sensor, which includes: a motion control card collects a distance signal of a detection target through a sensor, and converts the distance signal into a physical distance value through a calibration coefficient, wherein the motion control card serves as a processing center, performs algorithm processing after receiving the sensor signal, and outputs a motion control instruction to a stepper motor driver; the motion control card performs a difference operation on the physical distance value and a 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 a pulse control amount of the stepper motor driver, and when the pulse control amount is greater than a preset threshold, a motor drive instruction 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 instruction, 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.
[0009] As a preferred solution of the automatic focusing control method based on displacement sensor described in the present invention, wherein: the lens assembly includes a camera, a lens, a coupling and a screw transmission mechanism; the control of the stepper motor driver to drive the lens assembly to perform position compensation according to the motor drive instruction includes the following steps: receiving the motor drive instruction output by the motion control card through the stepper motor driver, converting the motor drive instruction into a winding excitation sequence, wherein the winding excitation sequence controls the operation of the stepper motor driver according to the phase excitation method; driving the screw transmission mechanism to rotate through the coupling, converting the rotational motion into linear motion, so that the lens assembly reciprocates along the optical axis direction; collecting the distance signal between the lens assembly and the detection target through the 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 processed by real-time filtering and participates in the next round of position compensation calculation, so that the distance between the lens assembly and the detection target is maintained at a standard focusing distance.
[0010] As a preferred solution of the automatic focusing control method based on displacement sensor described in the present invention, wherein: the method for generating the motor drive instruction is to convert the position compensation data into a pulse control amount according to the subdivision coefficient of the stepper motor driver through the data conversion unit of the motion control card, wherein the positive and negative values of the pulse control amount represent the movement direction of the stepper motor driver; set a preset threshold of the pulse control amount, and when the absolute value of the pulse control amount is greater than the preset threshold, trigger the PID control algorithm; when the absolute value of the pulse control amount is less than or equal to the preset threshold, maintain the current pulse control amount; use trapezoidal acceleration and deceleration planning to calculate the motion parameters of the stepper motor driver, and use the PID control algorithm to generate a motor drive instruction from the motion parameters and the pulse control amount, wherein the motion parameters include the starting frequency, the maximum operating frequency and the acceleration.
[0011] As a preferred solution of the displacement sensor-based automatic focusing control method described in the present invention, the motor drive instruction includes a direction signal and a pulse sequence; the method for generating the position compensation data is to set a buffer space in the motion control card, and store N frames of position deviation values according to timestamps to construct a system state vector, wherein the system state vector includes a position state component and a speed state component; based on the historical change trend of the position deviation value and the system state vector, a state prediction model is established, wherein the state prediction model includes a system state transfer equation and an observation equation; the Kalman gain matrix is calculated in real time by the motion control card, and the position deviation value is input into the state prediction model, and the optimal estimate value is calculated by combining the output prediction state and the Kalman gain matrix Based on the optimal estimate The above steps are iteratively executed to output the position compensation data after filtering.
[0012] As a preferred solution of the automatic focusing control method based on displacement sensor of the present invention, the specific formula of the state prediction model is as follows:
[0013]
[0014] Among them, p k is the position state component at time k, v k is the velocity state component at time k, Δt is the sampling time interval, τ is the velocity attenuation coefficient, is the position noise coefficient, σ p is the position measurement standard deviation, is the velocity noise coefficient, σ v is the speed measurement standard deviation, η k The measurement noise at time k follows a Gaussian distribution with a mean of 0 and a standard deviation of 0.1. k is the observation equation at time k.
[0015] The optimal estimate The specific formula is as follows:
[0016]
[0017] in, is the prior state estimate at time k, A is the Kalman gain matrix, B y is the actual observation value at time k, H is the unit matrix, b k is the estimation error at time k.
[0018] As a preferred solution of the automatic focusing control method based on the displacement sensor described in the present invention, wherein: the method for obtaining the position offset difference is to read the preset standard focusing distance value from the internal register through the motion control card, and use the fixed-point number operation method to calculate the difference between the physical distance value and the preset standard focusing distance, wherein the preset standard focusing distance value is based on the camera lens optical parameters and the depth of field range calibration; compare the difference 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 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 micrometer dimension, and the calculation timestamp of the position deviation value is recorded.
[0019] As a preferred solution of the automatic focusing control method based on the displacement sensor described in the present invention, the method for obtaining the physical distance value is to use the displacement sensor to emit a light beam to irradiate the detection target surface and receive a reflected echo signal, wherein the displacement sensor adopts the triangulation principle; based on the reflected echo signal, according to the angle relationship between the incident light beam and the reflected light beam at the reflection point on the position sensitive device, a distance signal is obtained, wherein the distance signal is output in the form of a voltage analog quantity; the motion control card collects a number of sampling points of the distance signal to form a sampling data sequence, and converts the sampling data sequence into a digital signal using an analog-to-digital converter; the calibration coefficient is extracted according to a pre-calibrated sensor linearity curve, and a linear transformation is performed in combination with the calibration coefficient to eliminate the nonlinear error of the sensor to obtain a physical distance value, wherein the calibration coefficient includes a zero point offset and a proportional coefficient; the physical distance value is digitally low-pass filtered, 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] In a second aspect, an embodiment of the present invention provides an automatic focusing control system based on a displacement sensor, comprising: a distance signal acquisition module, which is used for a motion control card to acquire a distance signal of a detection target through a sensor, and convert the distance signal into a physical distance value through a calibration coefficient, wherein the motion control card serves as a processing center, performs algorithm processing after receiving the sensor signal, and outputs a motion control instruction to a stepper motor driver; a position deviation calculation module, which is used for the motion control card to perform a difference operation between the physical distance value and the standard focusing distance to obtain a position deviation value; a state prediction and compensation data generation module, which is used to apply a Kalman filter algorithm to the position deviation value for data smoothing, and establish a state prediction model using the latest N frames of cache data to generate corrected position compensation data; a pulse control quantity conversion module, which is used to convert the position compensation data into a pulse control quantity of a stepper motor driver, and when the pulse control quantity is greater than a preset threshold, a motor drive instruction is generated according to a PID control algorithm; a stepper motor driver driving module, which is used for the motion control card to control the stepper motor driver to drive the lens assembly to perform position compensation according to the motor drive instruction, 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.
[0021] In a third aspect, an embodiment of the present invention provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, wherein: when the computer program instructions are executed by the processor, the steps of the automatic focusing control method based on the displacement sensor as described in the first aspect of the present invention are implemented.
[0022] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein: when the computer program instructions are executed by a processor, the steps of the automatic focusing control method based on a displacement sensor as described in the first aspect of the present invention are implemented.
[0023] The beneficial effects of the present invention are as follows: the distance signal collected by the sensor is converted into an accurate physical distance value in combination with the calibration coefficient, thereby ensuring the accuracy of the measurement data; a motion control card is used to perform real-time difference calculation and cooperate with the Kalman filter algorithm to realize intelligent smoothing processing and dynamic prediction of position deviation; a stepper motor drive solution based on PID control is adopted to convert position compensation into an accurate pulse sequence to effectively avoid mechanical oscillation; position compensation is continuously performed through a closed-loop control strategy to realize precise adjustment of the lens assembly; data is received, processed and sent based on the motion control card to reduce delays and improve focusing response speed. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. Among them:
[0025] Figure 1 This is a flow chart of the automatic focusing control method based on the displacement sensor of Example 1.
[0026] Figure 2 This is a control logic diagram of the automatic focusing control method based on the displacement sensor in Example 1. DETAILED DESCRIPTION
[0027] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are described in detail below in conjunction with the accompanying drawings.
[0028] In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention may also be implemented in other ways different from those described herein, and those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present 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 term "in one embodiment" that appears in different places in this specification does not necessarily refer to the same embodiment, nor does it refer to a separate or selective embodiment that is mutually exclusive with other embodiments.
[0030] Example 1
[0031] Reference Figure 1-2 , which is the first embodiment of the present invention, provides an automatic focusing control method based on a displacement sensor, comprising:
[0032] S1: The motion control card collects the distance signal of the detection target through the sensor, and converts the distance signal into a physical distance value through a calibration coefficient. The motion control card serves as a processing center, performs algorithm processing after receiving the sensor signal, and outputs motion control instructions to the stepper motor driver.
[0033] Specifically, the method for obtaining the physical distance value is to use a displacement sensor to emit a light beam to illuminate the detection target surface and receive a reflected echo signal; based on the reflected echo signal, a distance signal is obtained according to the angle relationship between the incident light beam and the reflected light beam at the reflection point on the position sensitive device; the motion control card collects a number of 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 principle; the distance signal is output in the form of voltage analog quantity; the quantization accuracy of the digital signal reaches 0.01 micron.
[0035] Furthermore, the calibration coefficient is extracted according to the pre-calibrated sensor linearity curve, and a linear transformation is performed in combination with the calibration coefficient to eliminate the nonlinear error of the sensor and obtain the physical distance value; the physical distance value is digitally low-pass filtered, the cutoff frequency is set, the high-frequency noise component is filtered out, and the signal-to-noise ratio of the measurement signal is improved.
[0036] It should be noted that the calibration coefficient includes the zero point offset and the proportional coefficient; the measurement range of the physical distance value is 0-5mm, and the measurement accuracy is better than 1 micron, which meets the needs of related detection scenarios such as pole piece burr detection and lithium battery pole piece detection.
[0037] S2: The motion control card performs a difference operation on the physical distance value and the standard focusing distance to obtain a position deviation value.
[0038] Specifically, the method for obtaining the position offset difference is to read the preset standard focusing distance value from the internal register through the motion control card, and use fixed-point arithmetic to calculate the difference between the physical distance value and the preset standard focusing distance.
[0039] Furthermore, the specific formula of the difference Δd includes:
[0040]
[0041] Among them, d i is the measured distance value of the i-th sampling, λ is the time attenuation factor, the value range is [0.1, 0.5], t is the current time point, t i is the i-th sampling time point, M is the number of sampling points, generally 5-10, d s is the preset standard focusing distance, α is the temperature compensation coefficient, the value range is [0.001, 0.005], and T is 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 depth of field;
[0043] Furthermore, 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 automatic focus 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 automatic focus compensation mechanism is a closed-loop control system that is triggered by comparing the difference between the physical distance value and the preset standard focusing distance; the preset depth of field threshold is calibrated and set based on the lens optical parameters and depth of field range.
[0045] Specifically, the difference is converted into a position deviation value in micrometer dimension, and the calculation timestamp of the position deviation value is recorded.
[0046] Furthermore, the specific formula of the position deviation value Δp is as follows:
[0047]
[0048] Wherein, β is the position compensation coefficient, with a value range of [0.9, 1.1], Δd is the difference between the physical distance value and the preset standard focusing distance, ∈ is the measurement system error coefficient, with a value range of [0.01, 0.05], γ is the thermal drift coefficient, with a value range of [0.001, 0.003], and δT is the system working time increment.
[0049] S3: Applying the Kalman filter algorithm to perform data smoothing processing on the position deviation value, and using the cache data of the latest N frames to establish a state prediction model to generate corrected position compensation data.
[0050] Specifically, the method for generating position compensation data is to set a buffer space in the motion control card, store N frames of position deviation values according to timestamps, and construct a system state vector, where the system state vector includes a position state component and a speed state component; based on the historical change trend of the position deviation value and the system state vector, a state prediction model is established, and the specific formula is as follows:
[0051]
[0052] Among them, p k is the position state component at time k, v k is the velocity state component at time k, Δt is the sampling time interval, τ is the velocity attenuation coefficient, and its value range is [0.8, 0.95]. is the position noise coefficient, with a value range of [0.01, 0.05], σ p is the position measurement standard deviation, is the velocity noise coefficient, with a value range of [0.05, 0.1], σ vis the speed measurement standard deviation, η k The measurement noise at time k follows a Gaussian distribution with a mean of 0 and a standard deviation of 0.1. k is the observation equation at time k.
[0053] It should be noted that the state prediction model includes the system state transfer equation and the observation equation; the state transfer equation adopts the uniform acceleration motion model; the uniform acceleration motion model includes the position prediction term and the speed prediction term.
[0054] Furthermore, the Kalman gain matrix is calculated in real time by the motion control card, and the position deviation value is input into the state prediction model, and the optimal estimate is calculated by combining the output prediction state and the Kalman gain matrix. The specific formula is as follows:
[0055]
[0056] in, is the prior state estimate at time k, A is the Kalman gain matrix, B y is the actual observation value at time k, H is the unit matrix, b k is the estimation error at time k.
[0057] Furthermore, based on the optimal estimate The above steps are iteratively executed to output the position compensation data after filtering.
[0058] S4: Convert the position compensation data into a pulse control value of the stepper motor driver, and when the pulse control value is greater than a preset threshold, generate a motor drive instruction according to a PID control algorithm.
[0059] Specifically, the position compensation data is converted into a pulse control amount according to the subdivision coefficient of the stepper motor driver through the data conversion unit of the motion control card.
[0060] It should be noted that the positive and negative values of the pulse control amount represent the movement direction of the stepper motor driver; the preset threshold of the pulse control amount is set to correspond to the actual displacement of ±2.5 microns.
[0061] Furthermore, when the absolute value of the pulse control amount is greater than a preset threshold, the PID control algorithm is triggered; when the absolute value of the pulse control amount is less than or equal to the preset threshold, the current pulse control amount is maintained.
[0062] It should be noted that the proportional coefficient, integral time and differential time of the PID control algorithm are obtained through a self-tuning method.
[0063] Furthermore, the motion parameters of the stepper motor driver are calculated by trapezoidal acceleration and deceleration planning, and the motion parameters and pulse control quantities are converted into motor drive instructions using the PID control algorithm;
[0064] It should be noted that the motion parameters include the starting frequency, the maximum operating frequency and the acceleration; the motor drive instructions 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 instruction, 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 the motor drive instruction output by the motion control card and converts the motor drive instruction into a winding excitation sequence;
[0067] It should be noted that the winding excitation sequence controls the operation of the stepper motor driver according to the phase excitation method; the lens assembly includes a camera, a lens, a coupling and a screw transmission mechanism; the screw transmission mechanism has a self-locking function to suppress position drift caused by external vibration.
[0068] Furthermore, the screw transmission mechanism is driven to rotate by the coupling, and the rotational motion is converted into linear motion, so that the lens assembly reciprocates along the optical axis; the distance signal between the lens assembly and the detection target is collected by the sensor and fed back to the motion control card to form a closed-loop control.
[0069] It should be noted that the feedback signal of the closed-loop control is processed by real-time filtering and then participates in the next round of position compensation calculation, so that the lens assembly and the detection target are kept at a standard focusing distance.
[0070] Furthermore, the present embodiment also provides an automatic focusing control system based on a displacement sensor, comprising: a distance signal acquisition module, which is used for a motion control card to acquire a distance signal of a detection target through a sensor, and convert the distance signal into a physical distance value through a calibration coefficient, wherein the motion control card serves as a processing center, performs algorithm processing after receiving the sensor signal, and outputs a motion control instruction to a stepper motor driver; a position deviation calculation module, which is used for the motion control card to perform a difference operation between the physical distance value and the standard focusing distance to obtain a position deviation value; a state prediction and compensation data generation module, which is used to apply a Kalman filter algorithm to the position deviation value for data smoothing, and establish a state prediction model using the most recent N frames of cache data to generate corrected position compensation data; a pulse control quantity conversion module, which is used to convert the position compensation data into a pulse control quantity of a stepper motor driver, and when the pulse control quantity is greater than a preset threshold, a motor drive instruction is generated according to a PID control algorithm; a stepper motor driver driving module, which is used for the motion control card to control the stepper motor driver to drive the lens assembly to perform position compensation according to the motor drive instruction, 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.
[0071] This embodiment also provides a computer device, which is suitable for the automatic focusing control method based on a displacement sensor, and includes 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 implement the automatic focusing control method based on the displacement sensor proposed in the above embodiment.
[0072] The computer device may be a terminal, and the computer device includes a processor, a memory, a communication interface, a display screen and an input device connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be achieved through WIFI, an operator network, NFC (near field communication) or other technologies. The display screen of the computer device may be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device may be a touch layer covering the display screen, or a key, trackball or touchpad provided on the housing of the computer device, or an external keyboard, touchpad or mouse, etc.
[0073] The present embodiment also provides a storage medium on which a computer program is stored, and when the program is executed by a processor, the following steps are implemented: the motion control card collects the distance signal of the detection target through a sensor, and converts the distance signal into a physical distance value through a calibration coefficient, wherein the motion control card serves as a processing center, performs algorithm processing after receiving the sensor signal, and outputs a motion control instruction to the stepper motor driver; the motion control card performs a difference operation on the physical distance value and the standard focusing distance to obtain a position deviation value; the Kalman filter algorithm is applied to the position deviation value for data smoothing, and a state prediction model is established using the cache data of the most recent N frames to generate corrected position compensation data; the position compensation data is converted into a pulse control amount of the stepper motor driver, and when the pulse control amount is greater than a preset threshold, a motor drive instruction 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 instruction, so that the distance between the lens assembly and the detection target is maintained at the standard focusing distance, and the distance signal is continuously collected for closed-loop control.
[0074] In summary, the present invention converts the distance signal collected by the sensor into an accurate physical distance value in combination with the calibration coefficient to ensure the accuracy of the measurement data; uses a motion control card to perform real-time difference calculations and cooperates with the Kalman filter algorithm to achieve intelligent smoothing processing and dynamic prediction of position deviations; adopts a stepper motor drive solution based on PID control to convert position compensation into an accurate pulse sequence to effectively avoid mechanical oscillation; continuously performs position compensation through a closed-loop control strategy to achieve precise adjustment of the lens assembly; receives, processes and sends data based on the motion control card to reduce delays and improve focusing response speed.
[0075] Example 2
[0076] Referring to Table 1, which is a second embodiment of the present invention, this embodiment provides an automatic focusing control method based on a displacement sensor. In order to verify the beneficial effects of the present invention, scientific demonstration is carried out through economic benefit calculation and simulation experiments.
[0077] Specifically, an autofocus test platform was constructed in a standard laboratory environment (temperature 23±1°C, relative humidity 45±5%) using a Keyence LK-G5000 series displacement sensor, a Mitsubishi FX5U programmable controller, an Oriental Motor ARD-K series stepper motor driver, 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 measurement range of 0-5mm, a calibration point was taken every 0.5mm to obtain the linearity curve of the sensor. The calibration coefficient was obtained by least squares fitting: the zero point offset was -0.023mm and the proportional coefficient was 1.0124. The experiment used a sampling frequency of 100kHz, and 10 data points were collected each time for averaging. A Butterworth low-pass filter with a cutoff frequency of 1kHz was used 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 performed at different distances to record the measurement data. The system was set with a preset standard focus 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, position noise coefficient Speed Noise Factor Time attenuation 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 adopts 16 subdivision mode and configures PID parameters: D 1 =0.8, D 2 =0.1, D 3 =0.05.
[0080] Specifically, as shown in Table 1, in terms of distance measurement accuracy, the present invention reaches 0.45μm, which is 75.7% higher than the traditional method, which is mainly due to the use of calibration coefficient compensation and digital low-pass filtering processing mechanism. The system response time is reduced from 420ms of the traditional method to 180ms, an increase of 57.1%, improving the dynamic performance of the system. The position compensation accuracy reaches 0.82μm, which is 66.5% higher than the 2.45μm of the traditional method, thanks to the synergy of the Kalman filter algorithm and the state prediction model. In terms of system stability, the fluctuation of the method of the present invention is only 0.31μm, while the traditional method is 1.82μm, an increase of 83%, which fully proves the superiority of the present invention in suppressing system fluctuations. In the high-speed target tracking scenario, the method of the present invention can still maintain an accuracy of 1.35μm, while the traditional method degenerates to 3.68μm, indicating that the present invention has stronger adaptability in dynamic scenarios.
[0081] Table 1 Comparison between the present invention and the traditional method
[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, the test results of anti-vibration performance show that the anti-disturbance ability of the method of the present invention is 3.3 times that of the traditional method. In terms of temperature drift compensation, the method of the present invention reduces the temperature influence to 0.12μm / ℃, while the traditional method is 0.45μm / ℃, which is attributed to the introduction of temperature compensation coefficient and thermal drift correction mechanism. From the perspective of energy consumption indicators, the method of the present invention saves 26.8% of power consumption compared with the traditional method, which is mainly due to the more precise control strategy to reduce unnecessary compensation actions. The convergence time of the control algorithm is also shortened from 245ms to 85ms, an increase of 65.3%, which fully demonstrates the advantages of the present 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 rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention, which should all be included in 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 the distance signal of the detection target through the sensor, and converts the distance signal into a physical distance value through the calibration coefficient, wherein the motion control card acts as a processing center, performs algorithm processing after receiving the sensor signal, and outputs motion control instructions to the stepper motor driver; The motion control card performs a difference operation on the physical distance value and the standard focusing distance to obtain a position deviation value; Applying a Kalman filter algorithm to the position deviation value for data smoothing, and using the latest N frames of buffered data to establish a state prediction model to generate corrected position compensation data; The position compensation data is converted into a pulse control amount of a stepper motor driver, and when the pulse control amount is greater than a preset threshold, a motor drive instruction 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 instruction, 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.
2. The automatic focusing control method based on displacement sensor according to claim 1, characterized in that: The lens assembly includes a camera, a lens, a coupling and a screw transmission mechanism; the stepper motor driver is controlled to drive the lens assembly to perform position compensation according to the motor drive instruction, including the following steps: Receiving the motor drive instruction output by the motion control card through the stepper motor driver, converting the motor drive instruction into a winding excitation sequence, wherein the winding excitation sequence controls the operation of the stepper motor driver according to the phase excitation mode; The coupling drives the screw transmission mechanism to rotate, converts the rotational motion into linear motion, and causes the lens assembly to reciprocate along the optical axis; The distance signal between the lens assembly and the detection target is collected 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 participates in the next round of position compensation calculation to keep the lens assembly and the detection target at the standard focusing distance.
3. The automatic focusing control method based on displacement sensor according to claim 2, characterized in that: The method for generating the motor drive instruction is: The position compensation data is converted into a pulse control amount according to the subdivision coefficient of the stepper motor driver by a data conversion unit of the motion control card, wherein the positive and negative of the pulse control amount represent the motion direction of the stepper motor driver; A preset threshold value of the pulse control amount is set. When the absolute value of the pulse control amount is greater than the preset threshold value, the PID control algorithm is triggered; when the absolute value of the pulse control amount is less than or equal to the preset threshold value, the current pulse control amount is maintained; The motion parameters of the stepper motor driver are calculated by using trapezoidal acceleration and deceleration planning, and the motion parameters and pulse control quantities are converted into motor drive instructions using a PID control algorithm, wherein the motion parameters include a starting frequency, a maximum operating frequency and an acceleration.
4. The automatic focusing control method based on displacement sensor according to claim 3, characterized in that: The motor drive instruction includes a direction signal and a pulse sequence; the method for generating the position compensation data is: A buffer space is set on 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 a position state component and a velocity state component; Based on the historical change trend of the position deviation value and the system state vector, a state prediction model is established, wherein the state prediction model includes a system state transfer equation and an observation equation; The Kalman gain matrix is calculated in real time by the motion control card, and the position deviation value is input into the state prediction model, and the optimal estimate is calculated by combining the output prediction state and the Kalman gain matrix. Based on the optimal estimate The above steps are iteratively executed to output the position compensation data after filtering.
5. The automatic focusing control method based on displacement sensor according to claim 4, characterized in that: The specific formula of the state prediction model is as follows: Among them, p k is the position state component at time k, v k is the velocity state component at time k, Δt is the sampling time interval, τ is the velocity attenuation coefficient, is the position noise coefficient, σ p is the position measurement standard deviation, is the velocity noise coefficient, σ v is the speed measurement standard deviation, η k The measurement noise at time k follows a Gaussian distribution with a mean of 0 and a standard deviation of 0.
1. k is the observation equation at time k; The optimal estimate The specific formula is as follows: in, is the prior state estimate at time k, A is the Kalman gain matrix, B y is the actual observation value at time k, H is the unit matrix, b k is the estimation error at time k.
6. The automatic focusing control method based on a displacement sensor according to claim 4 or 5, characterized in that: The method for obtaining the position offset difference is: Reading a preset standard focusing distance value from an internal register through a motion control card, and performing a difference calculation between a physical distance value and the preset standard focusing distance using a fixed-point arithmetic method, wherein the preset standard focusing distance value is calibrated based on the optical parameters of a camera lens and a depth of field range; The difference is compared with a preset depth of field threshold to determine a compensation direction; when the absolute value of the difference is greater than the preset depth of field threshold, an automatic focus 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 micrometer dimension, and a calculation timestamp of the position deviation value is recorded.
7. The automatic focusing control method based on displacement sensor according to claim 5, characterized in that: The method for obtaining the physical distance value is: A displacement sensor is used to emit a light beam to illuminate the detection target surface and receive a reflected echo signal, wherein the displacement sensor adopts a triangulation principle; Based on the reflected echo signal, a distance signal is obtained according to the angle relationship between the incident light beam and the reflected light beam at the reflection point on the position sensitive device, wherein the distance signal is output in the form of a voltage analog quantity; The motion control card collects a number of sampling points of the distance signal to form a sampling data sequence, and converts the sampling data sequence into a digital signal using an analog-to-digital converter; Extracting calibration coefficients according to a pre-calibrated sensor linearity curve, and performing linear transformation in combination with the calibration coefficients to eliminate the nonlinear error of the sensor to obtain a physical distance value, wherein the calibration coefficients include a zero point offset and a proportional coefficient; The physical distance value is digitally low-pass filtered, a cutoff frequency is set, high-frequency noise components are filtered out, and the signal-to-noise ratio of the measurement signal is improved.
8. 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 7, characterized in that: include, A distance signal acquisition module is used for the motion control card to collect the distance signal of the detection target through the sensor, and convert the distance signal into a physical distance value through a calibration coefficient, wherein the motion control card serves as a processing center, performs algorithm processing after receiving the sensor signal, and outputs a motion control instruction to the stepper motor driver; A position deviation calculation module is used for the motion control card to perform difference calculation on the physical distance value and the standard focusing distance to obtain a position deviation value; A state prediction and compensation data generation module is used to apply a Kalman filter algorithm to the position deviation value for data smoothing, and to establish a state prediction model using the latest N frames of cache data to generate corrected position compensation data; A pulse control quantity conversion module, used for converting the position compensation data into a pulse control quantity of a stepper motor driver, and generating a motor drive instruction according to a PID control algorithm when the pulse control quantity is greater than a preset threshold; The stepper motor driver driving module is used for the motion control card to control the stepper motor driver to drive the lens assembly to perform position compensation according to the motor driving instruction, so that the lens assembly and the detection target are maintained at a standard focusing distance, and the distance signal is continuously collected for closed-loop control.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the automatic focusing control method based on a displacement sensor according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the displacement sensor-based automatic focusing control method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Image capturing device and image capturing control method
CN102547332A
Methods and apparatus for autofocus
CN108535833A
Camera module and auto-focus method thereof
CN109154711A
Video target tracking method, system and device and storage medium
CN110290351A
Video image stabilization method for visual detection scene of power transmission line
CN115689939A
Cited By
Method and system for suppressing air pulsation of liquid-driven compressor
CN120720194A
Method and system for suppressing flow pulsations in a liquid driven compressor
CN120720194B
Optical focusing system driven by stepping motor
CN120972337A
Steel belt hole pitch detection method and system based on data processing
CN121677589A