Peripheral signal control method, terminal and storage medium based on STM32 vision detection system
By implementing closed-loop control of frame rate and rotation speed and anomaly recognition, the problem of frame loss in the vision inspection system is solved, achieving high-precision and high-efficiency vision inspection, which is suitable for the field of industrial automation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHENGDU SANSHI SCI & TECH CO LTD
- Filing Date
- 2026-01-15
- Publication Date
- 2026-04-21
AI Technical Summary
In existing vision inspection systems, the vision processing module and motion control peripherals share the same clock bus. This can lead to frame loss during high-speed movement of the three-axis stepper motor due to insufficient clock frequency division, resulting in a synchronization error of up to ±5%, which affects the detection accuracy.
By establishing a dynamic mapping relationship between frame rate and speed difference through closed-loop control of frame rate and speed, the regular changes in speed are analyzed, and the correlation between frame rate and speed difference is used for anomaly identification and compensation, ensuring real-time matching between frame rate and speed, and reducing mechanical shock and sudden changes in frame rate.
It improves the robustness and efficiency of the vision inspection system, reduces inspection errors, extends equipment life, reduces unnecessary motor power consumption, and improves system reliability and real-time performance.
Smart Images

Figure CN121523197B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of visual inspection and control technology, and in particular to a peripheral signal control method, terminal and storage medium based on an STM32 visual inspection system. Background Technology
[0002] In the field of intelligent manufacturing, machine vision inspection technology has become a key link in product quality control.
[0003] Regarding this research, application CN202211147805.X provides a machine vision-based detection system and method. The technical solution includes: a first color mark sensor for detecting whether a first surface of the object to be tested is covered with copper foil and emitting a first control signal; a second color mark sensor for detecting whether a second surface of the object to be tested is covered with copper foil and emitting a second control signal; and a light source system, comprising a first light source module and a second light source module, wherein the first light source module is electrically connected to the first color mark sensor, and the second light source module is electrically connected to the second color mark sensor, and the first light source module switches light sources based on the first control signal.
[0004] Another application, CN201711065428.4, provides a visual inspection control method and system. This technical solution includes: a signal receiving module, an image acquisition module, a data processing module, and a post-processing module. The signal receiving module is connected to the image acquisition module via a line; the image acquisition module is connected to the data processing module via a line; and the data processing module is connected to the post-processing module via a line. This technical solution reduces the risk of data packet loss through the caching mechanism of the image acquisition module, improves overall efficiency, and is adaptable to high-speed, complex inspection environments.
[0005] However, the above-mentioned technical solutions still have shortcomings. Their vision processing modules (such as camera interfaces) and motion control peripherals (such as stepper motor drives) often share the same clock bus, leading to resource contention. For example, when a three-axis stepper motor moves at high speed, the visual data acquisition may experience frame loss due to insufficient clock division. In actual measurements, the synchronization error can reach ±5%, directly affecting the detection accuracy. Summary of the Invention
[0006] In view of the problems existing in the field of visual inspection and control technology, the present invention is proposed.
[0007] Therefore, one of the objectives of this invention is to provide a peripheral signal control method, terminal, and storage medium based on an STM32 vision inspection system. Through innovative frame rate-speed closed-loop control, vibration impact quantification compensation, and data-driven anomaly recognition, it improves the robustness and efficiency of the vision inspection system, providing a low-cost and highly reliable solution for the field of industrial automation.
[0008] To solve the above-mentioned technical problems, the present invention provides the following technical solution:
[0009] This invention provides a peripheral signal control method based on an STM32 vision inspection system, comprising the following steps:
[0010] S10: Obtain relevant information on the visual detection of the target object, including the frame rate of the visual detection corresponding to the correct detection accuracy, and mark the frame rate as the reference frame rate;
[0011] S20: Acquire motion control peripheral signals corresponding to the reference frame rate, the motion control peripheral signals including the speed of the stepper motor, and analyze the regular changes in the speed;
[0012] S30: Perform correlation processing on the reference frame rate based on the analyzed pattern of change. The correlation processing includes distinguishing frame rates before the reference frame rate as... , ,..., , Indicates the distinction of the first Each frame rate is used to obtain the change in rotation speed based on the distinguished frame rates;
[0013] S40: Select at least 4 frame rates that are closest to the reference frame rate from the distinguished frame rates, and mark the frame rates as a frame rate group; obtain the rotational speed of the stepper motor corresponding to each frame rate in the frame rate group, and calculate the speed difference between adjacent frame rates in the frame rate group, and mark the speed difference as the reference speed difference;
[0014] S50: When visual detection of an object is performed in the future, if the generated frame rate is the same as any frame rate in the frame rate group during the visual detection process, the rotation speed corresponding to the generated frame rate is obtained. If the rotation speed is less than the rotation speed of the corresponding frame rate in the frame rate group, a control signal to increase the rotation speed of the stepper motor is issued; otherwise, this signal is not issued.
[0015] In a preferred embodiment of the present invention: if the rotational speed is less than the rotational speed of the corresponding frame rate in the frame rate group, the rotational speed is marked as an erroneous rotational speed. The difference between the erroneous rotational speed and the rotational speed of the corresponding frame rate in the frame rate group is obtained. The rotational speed difference is equally divided, including the division based on increasing the rotational speed by one rotational speed per second. When visual detection of an object is performed in the future, if the generated frame rate is the same as the frame rate corresponding to the frame rate in the frame rate group, but the rotational speed increases by one rotational speed for every second of time, the frame rate in the visual detection process is determined to be normal; otherwise, no determination is made, and a control signal to increase the rotational speed of the stepper motor is issued.
[0016] In a preferred embodiment of the present invention, in step S20, the regular changes in the rotational speed are analyzed, and the analysis steps are as follows:
[0017] When performing visual detection on the target object, the time taken to reach the reference frame rate is obtained;
[0018] The time is divided into an initial time period, an intermediate time period, and a final time period, and the change in rotational speed is obtained in the initial time period, the intermediate time period, and the final time period.
[0019] Before the end of the period, based on the change amount, the period corresponding to the largest increase in the change amount is obtained, and the period is marked as the judgment period;
[0020] When visual detection of an object is performed at a future time, if the increase in rotational speed is less than the change corresponding to the judgment period before the end of the time period, the rotational speed is determined to be abnormal; otherwise, no judgment is made.
[0021] In a preferred embodiment of the present invention, the step of analyzing the regular changes in the rotational speed further includes the following:
[0022] Obtain the rotational speed corresponding to the reference frame rate, and set a monitoring period based on the rotational speed. The monitoring period starts at 20% below the rotational speed, and the rotational speed corresponding to the monitoring start point is marked as the monitoring rotational speed.
[0023] The regular changes of the monitored rotational speed toward the rotational speed corresponding to the reference frame rate are analyzed, and the regular changes include the time required for the monitored rotational speed to increase by 1%, and the time is marked as the reference time;
[0024] When visual inspection of an object is performed in the future, if the rotation speed reaches the monitored rotation speed during the visual inspection process, and the time required for the rotation speed to increase by 1% is the same as the reference time, then the rotation speed is determined to be normal; otherwise, if the time required for the rotation speed to increase by 1% is lower or higher than the reference time, then the rotation speed is determined to be abnormal.
[0025] In a preferred embodiment of the present invention, in step S40, the rotation speed difference between adjacent frame rates is calculated in the frame rate group, and the correlation between rotation speed fluctuation and frame rate is calculated based on the rotation speed difference, obtained according to the following formula:
[0026] ;
[0027] In the formula, Indicates the first The rotation speed difference between adjacent frame rate pairs is obtained by subtracting the rotation speed corresponding to the adjacent frame rate in the frame rate group;
[0028] Indicates the first The frame rate difference between adjacent frame rate pairs, where the frame rate difference is the difference between adjacent frame rates in a frame rate group.
[0029] The linear regression coefficient represents the fluctuation range of the rotation speed caused by a unit change in frame rate;
[0030] The intercept term represents the baseline rotational speed fluctuation when the frame rate difference is 0.
[0031] The random error term includes mechanical vibration and electromagnetic interference.
[0032] In a preferred embodiment of the present invention, the following formula is also included:
[0033] ;
[0034] In the formula, The standard deviation of the speed difference is used to measure the dispersion of speed fluctuations.
[0035] This indicates the number of adjacent frame rate pairs in a frame rate group;
[0036] This represents the average value of the speed difference;
[0037] Indicates the first The rotation speed difference between adjacent frame rate pairs is obtained by subtracting the rotation speed corresponding to the adjacent frame rate in the frame rate group.
[0038] In a preferred embodiment of the present invention, the influence of the rotational speed fluctuation caused by mechanical vibration on the frame rate change is calculated based on the calculated results, using the mechanical vibration in the random error term as a basis, and is obtained according to the following formula:
[0039] ;
[0040] In the formula, Indicates frame rate fluctuations. The amplitude portion represents the maximum amplitude of frame rate fluctuations;
[0041] The time-varying part represents the pattern of frame rate fluctuations over time;
[0042] The amplitude represents the maximum displacement or angular displacement caused by mechanical vibration.
[0043] The vibration frequency is determined by the natural frequency of the mechanical structure or by external excitation.
[0044] This indicates the encoder pulse count, which is the number of pulses output by the encoder per revolution of the stepper motor.
[0045] Indicates the transmission radius. This indicates the number of imaging pulses, which is the number of encoder pulses required to acquire one frame of an image.
[0046] The time represents the time used to describe the time-varying characteristics of frame rate fluctuations;
[0047] The initial phase is the initial phase of the vibration waveform, which is determined by the initial state of the vibration source.
[0048] In a preferred embodiment of the present invention, a dataset is generated based on the calculation results. The dataset includes at least 10 to 20 frame rates that fluctuate with rotational speed. When visual detection of an object is performed at a future time, if a frame rate with the same frame rate as that in the dataset appears after the monitored rotational speed is reached, the frame rate is determined to be abnormal; otherwise, no abnormal frame rate is determined.
[0049] A computer terminal includes a processor, an input interface, an output interface, and a memory, wherein the processor, input interface, output interface, and memory are interconnected, wherein the memory is used to store a computer program, the computer program including program instructions, and the processor is configured to invoke the program instructions to execute the method described above.
[0050] A computer-readable storage medium storing a computer program, the computer program including program instructions that, when executed by a processor, cause the processor to perform the method as described above.
[0051] Beneficial effects:
[0052] 1. This invention analyzes the correlation between the reference frame rate of visual detection and the speed of the stepper motor, establishes a dynamic mapping relationship between the frame rate group and the speed difference, and adjusts the motor speed when the actual frame rate deviates from the reference value to ensure real-time matching between the frame rate and the speed.
[0053] 2. The speed change is divided into initial, middle and final use periods. By comparing the speed increase in each period, abnormal periods are marked. This can trigger correction at the beginning of the speed abnormality (such as before the final use period), avoiding frame rate drops or image loss due to insufficient speed. Furthermore, by comparing data from multiple time periods and setting thresholds, false alarms caused by fluctuations in a single data point are reduced, thus improving the reliability of the system.
[0054] 3. A dataset containing 10 to 20 abnormal frame rates was generated. When the actual frame rate matches the value in the dataset, it is immediately determined to be abnormal. In this case, no real-time calculation is required. The abnormality can be identified by directly comparing the dataset, which shortens the control delay. The system can also accumulate historical abnormal data and dynamically update the dataset to adapt to frame rate fluctuation patterns under different working conditions.
[0055] 4. When an incorrect speed is detected, the speed difference is divided equally and gradually corrected by increasing the speed by 1 speed per second. This avoids mechanical shocks or sudden changes in frame rate caused by sudden speed changes, extends the life of the equipment, and only makes fine adjustments when necessary, reducing unnecessary motor power consumption. Attached Figure Description
[0056] 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:
[0057] Figure 1 This is a schematic diagram of the method flow according to an embodiment of the present invention;
[0058] Figure 2 This is a schematic diagram of the process structure of an embodiment of the present invention. Detailed Implementation
[0059] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the described embodiments of the present invention are within the scope of protection of the present invention.
[0060] Because existing technologies may experience frame loss during high-speed movement of the three-axis stepper motor, visual data acquisition may be affected by insufficient clock frequency division. In actual measurements, the synchronization error can reach ±5%, which directly affects the detection accuracy.
[0061] Based on this, the present invention proposes a peripheral signal control method, terminal and storage medium based on an STM32 vision inspection system. Through innovative frame rate-speed closed-loop control, vibration impact quantization compensation and data-driven anomaly recognition, it improves the robustness and efficiency of the vision inspection system and provides a low-cost and highly reliable solution for the field of industrial automation.
[0062] The present solution will be further described in detail below through embodiments and in conjunction with the accompanying drawings.
[0063] Reference Figures 1 to 2 This is one embodiment of the present invention, which provides a peripheral signal control method based on an STM32 vision inspection system, including the following steps:
[0064] S10: Obtain relevant information about the visual detection of the target object, including the frame rate of the visual detection corresponding to the correct detection accuracy, and mark the frame rate as the reference frame rate;
[0065] In this embodiment, the reference frame rate provides a benchmark for subsequent motion control, ensuring the accuracy and real-time performance of visual detection. For example, in high-speed motion scenarios, if the reference frame rate is set to 30Hz, image blurring or missed detection due to insufficient frame rate can be avoided. Furthermore, by acquiring the frame rate in real time, the system can adapt to the needs of different detection scenarios.
[0066] S20: Acquire the motion control peripheral signal corresponding to the reference frame rate. The motion control peripheral signal includes the stepper motor speed, and analyze the regular changes in the speed. The analysis steps are as follows:
[0067] When performing visual detection on a target object, obtain the time taken to reach the reference frame rate;
[0068] The time is divided into an initial time period, a middle time period, and a final time period, and the change in rotational speed is obtained in the initial time period, the middle time period, and the final time period.
[0069] Before the end of the period, the period corresponding to the period with the largest increase in change is marked as the judgment period.
[0070] When visually detecting an object at a future time, if the increase in rotation speed is less than the change corresponding to the judgment period before the end of the time period, the rotation speed is judged to be abnormal; otherwise, it is not judged.
[0071] The analysis steps also include:
[0072] Obtain the rotational speed corresponding to the reference frame rate, and set the monitoring period based on the rotational speed. The monitoring period starts at 20% below the rotational speed, and the rotational speed corresponding to the monitoring start point is marked as the monitoring rotational speed.
[0073] The analysis focuses on the regular changes in the monitored rotational speed towards the rotational speed corresponding to the reference frame rate. The regular changes include the time required for each 1% increase in the monitored rotational speed, and the time is marked as the reference time.
[0074] When visual inspection of an object is performed in the future, if the rotation speed reaches the monitored rotation speed and the time required for each 1% increase in rotation speed is the same as the reference time, the rotation speed is determined to be normal; otherwise, if the time required for each 1% increase in rotation speed is less than or more than the reference time, the rotation speed is determined to be abnormal.
[0075] It should be noted that when an industrial camera detects a target object, in real life, a camera or industrial camera uses a stepper motor to drive the lens assembly to achieve automatic zoom or focus. For example, when a surveillance camera detects a change in the distance to a target, it may briefly start the stepper motor to adjust the focus, but the motor usually stops after the adjustment is completed to reduce noise and power consumption.
[0076] Furthermore, when cameras or industrial cameras need to dynamically adjust their focus (such as switching from a distant view to a close-up), the stepper motor needs to operate in variable speed mode. For example, it rotates rapidly in the initial stage to shorten the adjustment time, and decelerates as it approaches the target focus to improve accuracy and avoid overshoot. In actual testing, during the zooming process of a certain industrial camera, the motor speed decreased from 200 rpm (coarse adjustment stage) to 50 rpm (fine adjustment stage).
[0077] Therefore, acquiring the motion control peripheral signal corresponding to the reference frame is of practical significance;
[0078] S30: Based on the analyzed patterns of change, perform correlation processing on the reference frame rate. This correlation processing includes distinguishing frame rates preceding the reference frame rate. , ,..., , Indicates the distinction of the first Each frame rate is used to obtain the change in rotation speed based on the distinguished frame rates;
[0079] S40: Select at least four frame rates closest to the reference frame rate from the distinguished frame rates, and mark these frame rates as a frame rate group; obtain the speed of the stepper motor corresponding to each frame rate in the frame rate group, and calculate the speed difference between adjacent frame rates in the frame rate group, mark the speed difference as the reference speed difference, and calculate the correlation between speed fluctuation and frame rate based on the speed difference, using the following formula:
[0080] ;
[0081] In the formula, Indicates the first The rotation speed difference between adjacent frame rate pairs is obtained by subtracting the rotation speed corresponding to the adjacent frame rate in the frame rate group;
[0082] Indicates the first The frame rate difference between adjacent frame rate pairs is the difference between adjacent frame rates in a frame rate group.
[0083] The linear regression coefficient represents the fluctuation range of the rotation speed caused by a unit change in frame rate;
[0084] The intercept term represents the baseline rotational speed fluctuation when the frame rate difference is 0.
[0085] This is a random error term, which includes mechanical vibration and electromagnetic interference;
[0086] It also includes calculations based on the following formula:
[0087] ;
[0088] In the formula, The standard deviation of the speed difference is used to measure the dispersion of speed fluctuations.
[0089] This indicates the number of adjacent frame rate pairs in a frame rate group; where, ≥3, because at least 4 frame rates are required to generate 3 differences;
[0090] This represents the average value of the speed difference;
[0091] Indicates the first The rotation speed difference between adjacent frame rate pairs is obtained by subtracting the rotation speed corresponding to the adjacent frame rate in the frame rate group;
[0092] In this embodiment, the rotation speed difference (reference rotation speed difference) between adjacent frame rates within the frame rate group is calculated, and a correlation model (linear regression) between rotation speed fluctuation and frame rate is established.
[0093] By grouping frames by rate (e.g., selecting 4 key frames from 100 historical frames), the computational load is reduced by 95%, improving real-time performance.
[0094] Linear regression models can quantify the impact of unit frame rate changes on rotational speed, providing a precise basis for control signals;
[0095] S50: When visual detection of an object is performed in the future, if the generated frame rate is the same as any frame rate in the frame rate group during the visual detection process, the rotation speed corresponding to the generated frame rate is obtained. If the rotation speed is less than the rotation speed of the corresponding frame rate in the frame rate group, a control signal to increase the speed of the stepper motor is issued; otherwise, this signal is not issued.
[0096] It should be noted that gradient correction (such as increasing by 10 rpm per second) reduces mechanical shock, extends motor life by 30%, and corrects the speed only when needed, reducing motor power consumption by 25% during the correction phase.
[0097] Based on the above, if the rotational speed is less than the rotational speed of the corresponding frame rate in the frame rate group, the rotational speed is marked as an error. The difference between the error rotational speed and the rotational speed of the corresponding frame rate in the frame rate group is obtained, and the rotational speed difference is divided equally, including the rotational speed difference based on an increase of one rotational speed per second. When visual detection of an object is performed in the future, if the generated frame rate is the same as the frame rate corresponding to the frame rate in the frame rate group, but the rotational speed increases by one for every second, the frame rate in the visual detection process is determined to be normal; otherwise, no determination is made, and a control signal to increase the rotational speed of the stepper motor is issued.
[0098] Based on the calculation results, the impact of mechanical vibration-induced rotation speed fluctuations on frame rate changes is calculated using the mechanical vibration in the random error term as a basis. The calculation is performed according to the following formula:
[0099] ;
[0100] In the formula, Indicates frame rate fluctuations. The amplitude portion represents the maximum amplitude of frame rate fluctuations;
[0101] The time-varying part represents the variation of frame rate fluctuations over time; a sine wave.
[0102] The amplitude represents the maximum displacement or angular displacement caused by mechanical vibration.
[0103] This indicates the vibration frequency, which is determined by the natural frequency of the mechanical structure or external excitation (such as unbalanced mass).
[0104] This indicates the encoder pulse count, which is the number of pulses output by the encoder per revolution of the stepper motor.
[0105] Indicates the transmission radius. This indicates the number of imaging pulses, which is the number of encoder pulses required to acquire one frame of an image.
[0106] It represents time, which is used to describe the time-varying characteristics of frame rate fluctuations;
[0107] This indicates the initial phase, which is the initial phase of the vibration waveform and is determined by the initial state of the vibration source.
[0108] Mechanical vibration can introduce speed fluctuations through transmission mechanisms (such as gears and couplings) or motor body vibration, which in turn affects the frame rate stability of visual inspection.
[0109] Therefore, calculating the impact of mechanical vibration-induced rotational speed fluctuations on frame rate changes based on mechanical vibration in the random error term is of practical significance.
[0110] A dataset is generated based on the calculation results. The dataset includes at least 10 to 20 frame rates that fluctuate with the rotation speed. When visual detection of an object is performed in the future, if a frame rate that is the same as the frame rate in the dataset appears after the monitored rotation speed is reached, the frame rate is judged to be abnormal; otherwise, it is not judged.
[0111] In this embodiment, no real-time calculation is required; anomalies can be identified by directly comparing the dataset, with a response time of <100ms. Furthermore, historical anomaly data can be accumulated, and the dataset can be dynamically updated to adapt to frame rate fluctuation patterns under different working conditions (such as switching from static detection to high-speed motion detection).
[0112] A computer terminal includes a processor, an input interface, an output interface, and a memory, wherein the processor, input interface, output interface, and memory are interconnected, wherein the memory is used to store a computer program, the computer program including program instructions, and the processor is configured to invoke the program instructions to execute the method described above.
[0113] A computer-readable storage medium storing a computer program, the computer program including program instructions that, when executed by a processor, cause the processor to perform the method as described above.
[0114] In summary, this application improves the robustness and efficiency of vision inspection systems through innovations such as precise frame rate-rotation speed matching, quantitative compensation for vibration effects, and data-driven anomaly recognition. It provides a low-cost, highly reliable solution for the industrial automation field and has broad application prospects and commercial value.
[0115] 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. A peripheral signal control method based on an STM32 vision inspection system, characterized in that, Includes the following steps: S10: Obtain relevant information on the visual detection of the target object, including the frame rate of the visual detection corresponding to the correct detection accuracy, and mark the frame rate as the reference frame rate; S20: Acquire the motion control peripheral signal corresponding to the reference frame rate, the motion control peripheral signal including the stepper motor speed, and analyze the regular changes in the speed. The analysis steps include the following: Obtain the rotational speed corresponding to the reference frame rate, and set a monitoring period based on the rotational speed. The monitoring period starts at 20% below the rotational speed, and the rotational speed corresponding to the monitoring start point is marked as the monitoring rotational speed. The regular changes of the monitored rotational speed toward the rotational speed corresponding to the reference frame rate are analyzed, and the regular changes include the time required for the monitored rotational speed to increase by 1%, and the time is marked as the reference time; When visual inspection of an object is performed in the future, if the rotation speed reaches the monitored rotation speed during the visual inspection process, and the time required for the rotation speed to increase by 1% is the same as the reference time, then the rotation speed is determined to be normal; otherwise, if the time required for the rotation speed to increase by 1% is lower or higher than the reference time, then the rotation speed is determined to be abnormal. S30: Perform correlation processing on the reference frame rate based on the analyzed pattern of change. The correlation processing includes distinguishing frame rates before the reference frame rate as... , ,..., , Indicates the distinction of the first Each frame rate is used to obtain the change in rotation speed based on the distinguished frame rates; S40: Select at least 4 frame rates that are closest to the reference frame rate from the distinguished frame rates, and mark the frame rates as a frame rate group; obtain the rotational speed of the stepper motor corresponding to each frame rate in the frame rate group, and calculate the speed difference between adjacent frame rates in the frame rate group, and mark the speed difference as the reference speed difference; S50: When visual detection of an object is performed in the future, if the generated frame rate is the same as any frame rate in the frame rate group during the visual detection process, the rotation speed corresponding to the generated frame rate is obtained; if the rotation speed is less than the rotation speed of the corresponding frame rate in the frame rate group, a control signal to increase the rotation speed of the stepper motor is issued. Conversely, this signal will not be emitted if the condition is not met.
2. The peripheral signal control method based on an STM32 vision inspection system as described in claim 1, characterized in that, If the rotational speed is less than the rotational speed of the corresponding frame rate in the frame rate group, the rotational speed is marked as an error. The difference between the error rotational speed and the rotational speed of the corresponding frame rate in the frame rate group is obtained. The rotational speed difference is divided equally, including the difference based on an increase of one unit rotational speed per second. When visual detection of an object is performed in the future, if the generated frame rate is the same as the frame rate corresponding to the frame rate in the frame rate group, but the rotational speed increases by one unit for every second, the frame rate in the visual detection process is determined to be normal; otherwise, it is determined to be abnormal, and a control signal to increase the rotational speed of the stepper motor is issued.
3. The peripheral signal control method based on an STM32 vision inspection system as described in claim 1, characterized in that, In step S20, the regular changes in the rotational speed are analyzed. The analysis steps are as follows: When performing visual detection on the target object, the time taken to reach the reference frame rate is obtained; The time is divided into an initial time period, an intermediate time period, and a final time period, and the change in rotational speed is obtained in the initial time period, the intermediate time period, and the final time period. Before the end of the period, based on the change amount, the period corresponding to the largest increase in the change amount is obtained, and the period is marked as the judgment period; When visual inspection of an object is performed at a future time, if the increase in rotational speed is less than the change corresponding to the judgment period before the end of the time period, the rotational speed is determined to be abnormal; otherwise, it is determined to be normal.
4. The peripheral signal control method based on an STM32 vision inspection system as described in claim 1, characterized in that, In step S40, the rotation speed difference between adjacent frame rates is calculated within the frame rate group. Based on this rotation speed difference, the correlation between rotation speed fluctuation and frame rate is calculated using the following formula: ; In the formula, Indicates the first The rotation speed difference between adjacent frame rate pairs; Indicates the first The frame rate difference between adjacent frame rate pairs, where the frame rate difference is the difference between adjacent frame rates in a frame rate group. The linear regression coefficient represents the fluctuation range of the rotation speed caused by a unit change in frame rate; The intercept term represents the baseline rotational speed fluctuation when the frame rate difference is 0. The random error term includes mechanical vibration and electromagnetic interference.
5. The peripheral signal control method based on an STM32 vision inspection system as described in claim 4, characterized in that, It also includes calculations based on the following formula: ; In the formula, The standard deviation of the speed difference is used to measure the dispersion of speed fluctuations. This indicates the number of adjacent frame rate pairs in a frame rate group; This represents the average value of the speed difference.
6. The peripheral signal control method based on an STM32 vision inspection system as described in claim 4, characterized in that, Based on the calculated results, the impact of rotational speed fluctuations caused by mechanical vibration on frame rate changes is calculated using the mechanical vibration in the random error term as a basis, and is obtained according to the following formula: ; In the formula, Indicates frame rate fluctuations. The amplitude portion represents the maximum amplitude of frame rate fluctuations; The time-varying part represents the pattern of frame rate fluctuations over time; The amplitude represents the maximum displacement or angular displacement caused by mechanical vibration. The vibration frequency is determined by the natural frequency of the mechanical structure or by external excitation. This indicates the encoder pulse count, which is the number of pulses output by the encoder per revolution of the stepper motor. Indicates the transmission radius. This indicates the number of imaging pulses, which is the number of encoder pulses required to acquire one frame of an image. The time represents the time used to describe the time-varying characteristics of frame rate fluctuations; The initial phase is the initial phase of the vibration waveform, which is determined by the initial state of the vibration source.
7. The peripheral signal control method based on an STM32 vision inspection system as described in claim 6, characterized in that, A dataset is generated based on the calculation results. The dataset includes at least 10 to 20 frame rates that fluctuate with the rotation speed. When visual detection of an object is performed in the future, if a frame rate with the same frame rate as the frame rate in the dataset appears after the monitored rotation speed is reached, the frame rate is determined to be abnormal. Conversely, if the frame rate is abnormal, it will not be considered abnormal.
8. A computer terminal, characterized in that, The device includes a processor, an input interface, an output interface, and a memory, which are interconnected. The memory is used to store a computer program, which includes program instructions. The processor is configured to call the program instructions to perform the method as described in any one of claims 1 to 7.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, the computer program including program instructions that, when executed by a processor, cause the processor to perform the method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Vision inspection control method and vision inspection control system
CN107948458A
Detection system and detection method based on machine vision
CN115452856A
Retraction control method, device, equipment and system for intravascular ultrasonic transducer
CN116849706A
Peripheral signal control method of visual inspection system
CN121300203A