One-dimensional slide control method based on camera
By introducing a camera into the DC motor control and using pixel offset to predict the motor stop position, the problem of fast deceleration of the slider on the non-horizontal track and environmental changes is solved, and higher positioning accuracy and real-time performance are achieved. Suitable for high-speed slides and reduces equipment costs.
Patent Information
- Application Number
- CN202211277244.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-19
- Publication Date
- 2024-11-15
- Estimated Expiration
- 2042-10-19
AI Technical Summary
The existing DC motor control technology is affected by gravity on non-horizontal tracks, and the slider deceleration is too fast. Environmental changes such as load changes or additional resistance of foreign objects will reduce working efficiency, resulting in inaccurate positioning and poor real-time performance.
The camera is introduced as part of the control algorithm to calculate the target position distance through pixel offset and predict the motor stop motion, and use the system to perform self-test calculations when it is idle, improve the accuracy and real-timeness of the slider to achieve the slide rail position. Calibration and braking prediction.
It improves the accuracy and real-time positioning of the slider to the target position, reduces the impact of deformation and abnormal environment, and is suitable for high-speed slides, reducing equipment costs.
Smart Images

Figure CN115549533B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of direct current motor control, and in particular relates to a one-dimensional slide rail control method based on a camera. Background Art
[0002] In the field of DC motor control, motor current and encoder count (motor speed) are generally used as inputs to perform control calculations on DC motors. However, for non-horizontal tracks, the rise and fall are affected by gravity, and the forces they receive are also different. During the rise, the slider will decelerate too quickly, so it stops before reaching the target position, or it is constantly corrected, which prolongs the working time.
[0003] With existing DC motor control technology, if there are slight changes in the surrounding environment, such as load changes or foreign matter on the slide rail creating additional resistance, the control of the motor will also be affected, thereby reducing work efficiency. Summary of the invention
[0004] The technical problem to be solved by the present invention is to provide a one-dimensional slide rail control method based on a camera in view of the deficiencies of the above-mentioned prior art. In addition to the conventional motor encoder, a camera is introduced as a part of the control algorithm to improve the real-time and accuracy of the motor movement position; the pixel offset of the camera is used to calculate the distance to the target position and predict the motor to stop moving; during the idle period of the system, the motor is allowed to perform self-test calculations to provide a prediction of the movement status of the next motor operation, and the prediction is made more and more accurate, which can improve the accuracy and real-time positioning of the slider to the target position, and realize the slide rail position calibration and brake prediction based on the camera to improve the displacement accuracy of the DC motor on the slide rail.
[0005] In order to achieve the above technical objectives, the technical solution adopted by the present invention is:
[0006] The camera-based one-dimensional slide rail control method is applied to a one-dimensional slide rail of a slider driven by a motor. The camera is installed on the slider and cooperates with the upper image recognition application to identify the target object to determine the stop time and distance of the slider. The self-test calibration is performed during idle time, and the motor stop test at different positions is performed to calculate the braking prediction at different positions and different load conditions. The method includes the following steps:
[0007] Step 1: The camera is working, the motor is preheated, the input delay, braking time and displacement are measured, the camera offset and motor count are recorded throughout the process, and the linear relationship between the camera offset and the motor rotation is fitted before entering the ready state;
[0008] Step 2: In the ready state, determine whether it is idle:
[0009] If it is not idle, the operation is performed, the slider position is tracked in real time, the target position is predicted, and the final stop position is judged to be accurate. If it is not accurate, the position offset is compensated and the braking time and distance are fed back. If it is accurate, the operation is completed and the machine re-enters the ready state.
[0010] If it is idle, then determine whether it is idle for a long time. If so, proceed to step 4, otherwise proceed to step 3;
[0011] Step 3: Measure the input delay at different positions and calculate the minimum value, measure the braking time and distance, and enter the ready state after fitting the linear relationship between position and braking distance;
[0012] Step 4: Record the camera pixel offset and motor count throughout the process, fit the linear equation of the camera pixel offset and motor rotation, and then enter the ready state;
[0013] To optimize the above technical solutions, the specific measures taken also include:
[0014] In the above step 1, the camera is working and the camera pixel offset is obtained in real time, specifically:
[0015] Convert the image into a grayscale image, then use the Canny edge detection algorithm to calculate the edge lines of the image features, i.e. the contour lines, and save the pixel points of the contour lines;
[0016] Continuously record the pixel points of the contour line of each frame of the camera, compare the pixel points of the current frame with the pixel points of the previous frame, calculate the displacement of each pixel point, and find the median of the displacement of all pixel points, and finally calculate the pixel offset of each frame; this step is performed in parallel with other steps.
[0017] In the above step 1, the motor is preheated and the slider is driven to move along the edge of the slide rail, specifically:
[0018] Assuming that the travel of the slide rail is the X axis, the motor drives the slider to move to the boundary of x=0, and continues to move in the negative direction of the X axis (X-), so that the motor is blocked for a period of time, so that the motor can be quickly preheated, and then moves from x=0 to the positive direction of the X axis (X+). When the motor reaches the other end boundary, the motor is blocked, the motor current increases, and the encoder count does not increase, so it is judged to have reached the boundary x=x max Then the motor drives the slider to return to x=0 immediately, so that the motor can be quickly cooled by air during movement, thus reaching a relatively stable state.
[0019] In step 1 above, the input delay, braking time and displacement are measured as follows:
[0020] When the slider is stationary, send a command to make the motor rotate. This moment is recorded as t1, and the motor drives the slider to start moving in the positive direction of the X axis (X+).
[0021] When the encoder counts from 0 to 1, the moment is recorded as t2;
[0022] When the camera image just changes from a static state to a moving state, the time is set to t3;
[0023] Thus we can calculate:
[0024] The delay from sending the command to the motor encoder count change is d mot =min(d mot ,t2-t1), the first calculation time d mot =t2-t1, i.e. motor delay time;
[0025] The delay from sending command to camera change is d cam =min(d cam ,t3-t1), the first calculation time d cam =t3-t1, i.e. camera delay time;
[0026] When the slider moves at a constant speed, the output to the motor stops. This moment is recorded as t4. At this time, the motor encoder counts from m=0.
[0027] The slider gradually stops moving due to inertia;
[0028] When the camera image changes from a moving state to a stationary state, the time is recorded as t5, at which time m = m stop ;
[0029] It is calculated that it takes Δt from sending the stop command to actually stopping. stop =t5-t4, sliding distance is m=m stop -0;
[0030] Similarly, the motor drives the slider to start moving in the negative direction (X-) of the X-axis, and the input delay is measured twice;
[0031] After entering the uniform speed state, stop the output to the motor and record the braking time and displacement of the negative movement;
[0032] Except for the first execution, each subsequent execution will establish m stop Two sets of linear relationships with Loc in the X+ direction and X- direction: m stop =m stop1 (Loc)X+movement direction, m stop =m stop2 (Loc)X-direction of movement.
[0033] In step 1 above, the camera offset and motor count are recorded throughout the process, specifically:
[0034] Move the slider from the x=0 boundary to the other end x=x max boundary, at this time n=0, m=0, when the motor enters the uniform speed state, it is recorded as time t6; from t6+d cam Starting from time n=n1, record the pixel offset ΔS of each frame n ; When the motor drives the slider to the boundary x = x max At t7+d cam At this moment, n = n end ;
[0035] At the same time, at t6+d mot At the moment, starting from m=m1, the encoder count m and the recording time t of each count are recorded in real time m ; until the slider moves to the other edge x = x max At time t7; at t7+d mot At this time, m=m end ; Finally, the average speed of the uniform state is obtained: v = (m end -m1) / (t7-t6);
[0036] Similarly, from x=x max Move to the boundary of x=0, record the camera offset and motor count throughout the process; when the forward and reverse travel m end When they are inconsistent, take the maximum value m end =max(m end1 ,m end2 );
[0037] Establish pixel offset ΔS i With encoder count C j relation;
[0038] Pixel shift ΔS i The corresponding time (t i =t6+d cam +(n-n1) / fps) is related to the camera frame rate, while the encoder count C j The corresponding time (t j =t6+d mot +(m-m1) / v) is associated with the recording time of the count. After conversion and interpolation of unified time units, a relationship diagram between the pixel offset ΔS and the encoder count C is established, and the two back-and-forth strokes are combined to establish a linear relationship ΔS(C).
[0039] In the above-mentioned ready state, if there are jobs to be executed, it means that it is not idle; if the idle time is within the short-term time threshold and there is no job scheduled, it means short-term idle; if the idle time reaches the long-term idle time threshold and there is no job scheduled, it means long-term idle.
[0040] The above step 2 specifically includes:
[0041] Step B1: Perform the operation and execute the operation instruction;
[0042] Step B2: Estimating and tracking the slider position:
[0043] The position of the slider is Loc = m / m end ×100%
[0044] Among them, m end is the total length of the slide rail, m is the current motor encoder count;
[0045] Step B3: Predict the target position and make the motor drive the slider to stop in front of the designated target;
[0046] Step B4: Identify the camera content through the upper layer application to determine whether the stop position of the slider is accurate. If it is accurate, execute step B5; otherwise, execute step B6;
[0047] Step B5: Execute the operation of the upper layer application. After all instructions are executed, enter the ready state;
[0048] Step B6: Correction of the offset:
[0049] According to the upper-layer application, the camera content is identified, the target position reference is identified, and the motor is used to drive the slider to move to the target reference again; the pixel offset ΔS between the initial stop position and the reference is calculated err , and record the motor encoder count m during the correction process err ;
[0050] Step B7: Feedback on the braking time and distance:
[0051] The braking starting point Loc and ΔS(Loc)+ΔS err Substitute the ΔS(C) function back into the function and perform linear regression calculation on the function again;
[0052] Set the braking starting point Loc and m stop (Loc)+m err Re-introduce m stop (Loc) function and recalculate the linear regression function.
[0053] The above step B3 includes:
[0054] Step B3.1: Obtain the target position through the upper layer application and calculate the pixel offset ΔS between the current position and the target position aim ; Based on the previous estimate of braking distance m stop (Loc) function to calculate the distance required for braking; then m stop Substitute (Loc) into ΔS(C) to get the estimated braking pixel offset
[0055] Step B3.2:
[0056] When ΔS aim >ΔS stop When the system does not process it, it repeats step B3.1;
[0057] when , the system stops outputting to the motor and waits for the slider to stop;
[0058] When ΔS aim <ΔS stop When the system predicts the braking distance, it calculates the pixel deviation ΔS sa =ΔS stop -ΔS aim , through the linear relationship of ΔS(C), it is converted into ΔC=ΔS -1 (ΔS sa ), according to the size of ΔC, a reverse action is applied to the motor to decelerate it.
[0059] The above step 3 fits the linear relationship between the position and the braking time distance, specifically including:
[0060] Establish the position Loc and pixel offset S of the X+ direction movement respectively stop The relationship between the X-direction movement position Loc and the pixel offset S stop The relationship between the position Loc and the pixel offset S of different position points in the same direction stop Perform linear regression fitting and obtain S stop (Loc) function.
[0061] The present invention has the following beneficial effects:
[0062] In addition to conventional motor encoders, the present invention introduces a camera as part of the control algorithm to improve the real-time and accuracy of the motor's motion position; uses the pixel offset of the camera to calculate the distance to the target position and predict the motor's stop motion; uses the system's idle period to allow the motor to perform self-test calculations, and provides a prediction of the motion status of the next motor operation, and makes the prediction more and more accurate, which can improve the accuracy and real-time positioning of the slider to the target position; while ensuring smooth motion, the response rate of the motion is improved; for linear slides, the influence caused by deformation and bending can be reduced; it can be applicable to slides with any direction and bending; the higher the speed of the slide, the higher the motion requirements for the algorithm, and the present invention can be applicable to high-speed slides; reduces the influence of slight deformation of the slide on the motion system; reduces the influence of abnormal environment (such as belt slippage, foreign matter on the slide) on the motion system; reduces the influence of load changes on the motion system; while ensuring smooth motion, the response rate of the motion is improved; the accuracy and real-time positioning of the slider to the target position is improved; in addition, the camera is used to improve the movement of the slider, which reduces the equipment cost. BRIEF DESCRIPTION OF THE DRAWINGS
[0063] Figure 1 This is a flow chart of the one-dimensional slide rail control method based on a camera of the present invention. DETAILED DESCRIPTION
[0064] The embodiments of the present invention are further described in detail below in conjunction with the accompanying drawings.
[0065] like Figure 1 As shown, the one-dimensional slide rail control method based on the camera of the present invention is applied to the one-dimensional slide rail of the slider driven by the motor. The camera is installed on the slider and cooperates with the upper image recognition application to identify the target object to determine the stopping time and distance of the slider; by using the self-test calibration during idle time and the motor stop test at different positions, the braking prediction at different positions and different load conditions is calculated to improve the movement efficiency of the entire motor system and enable the slider to move more smoothly; at the same time, it is also suitable for the working conditions of the motor for non-linear and non-horizontal slide rails; the method comprises the following steps:
[0066] Step 1: The camera is working, the motor is preheated, the input delay, braking time and displacement are measured, the camera offset and motor count are recorded throughout the process, and the linear relationship between the camera offset and the motor rotation is fitted before entering the ready state;
[0067] Step 2: In the ready state, determine whether it is idle:
[0068] If it is not idle, the operation is performed, the slider position is tracked in real time, the target position is predicted, and the final stop position is judged to be accurate. If it is not accurate, the position offset is compensated and the braking time and distance are fed back. If it is accurate, the operation is completed and the machine re-enters the ready state.
[0069] If it is idle, then determine whether it is idle for a long time. If so, proceed to step 4, otherwise proceed to step 3;
[0070] Step 3: Measure the input delay at different positions and calculate the minimum value, measure the braking time and distance, and enter the ready state after fitting the linear relationship between position and braking distance;
[0071] Step 4: Record the camera pixel offset and motor count throughout the process, fit the linear equation of the camera pixel offset and motor rotation, and then enter the ready state;
[0072] In the embodiment, the step 1 comprises:
[0073] Step A1: The camera is working, and the camera pixel offset is obtained in real time:
[0074] Convert the image into a grayscale image, then use the Canny edge detection algorithm to calculate the edge lines of the image features, i.e. the contour lines, and save the pixel points of the contour lines;
[0075] Continuously record the pixel points of the contour line of each frame of the camera, compare the pixel points of the current frame with the pixel points of the previous frame, calculate the displacement of each pixel point, and find the median of the displacement of all pixel points, and finally calculate the pixel offset of each frame; this step is performed in parallel with other steps;
[0076] Step A2: Preheat the motor and drive the slider to move along the edge of the slide rail:
[0077] Assuming that the travel of the slide rail is the X axis, the motor drives the slider to move to the boundary of x=0, and continues to move in the negative direction of the X axis (X-), causing the motor to stall for a period of time, so that the motor can be quickly preheated, and then moves from x=0 to the positive direction of the X axis (X+). When the motor reaches the other end boundary, the motor stalls, the motor current increases, and the encoder count does not increase, so it is judged to have reached the boundary x=x max Then the motor drives the slider to return to x=0 immediately, so that the motor can be quickly cooled by air during the movement, thus reaching a relatively constant state;
[0078] Step A3: Measure input delay and braking time and displacement:
[0079] When the slider is stationary, send a command to make the motor rotate. This moment is recorded as t1, and the motor drives the slider to start moving in the positive direction of the X axis (X+).
[0080] When the encoder counts from 0 to 1, the moment is recorded as t2;
[0081] When the camera image just changes from a static state to a moving state, the time is set to t3;
[0082] Thus we can calculate:
[0083] The delay from sending the command to the motor encoder count change is d mot =min(d mot ,t2-t1)(d at the first calculation mot =t2-t1), i.e. motor delay time;
[0084] The delay from sending command to camera change is d cam =min(d cam ,t3-t1)(d at the first calculation cam =t3-t1), i.e., camera delay time;
[0085] When the slider moves at a constant speed, the motor output is stopped (the output PWM duty cycle is 0), and this moment is recorded as t4. At this time, the motor encoder counts from m=0.
[0086] The slider gradually stops moving due to inertia;
[0087] When the camera image changes from a moving state to a stationary state, the time is recorded as t5, at which time m = m stop ;
[0088] It is calculated that it takes Δt from sending the stop command to actually stopping. stop =t5-t4, sliding distance is m=m stop -0;
[0089] Similarly, the motor drives the slider to start moving in the negative direction (X-) of the X-axis, and the input delay is measured twice;
[0090] After entering the uniform speed state, stop the output to the motor and record the braking time and displacement of the negative movement;
[0091] Except for the first execution, each subsequent execution will establish m stop Two sets of linear relationships with Loc in the X+ direction and X- direction: m stop =m stop1 (Loc)X+movement direction, m stop =m stop2 (Loc)X-direction of movement;
[0092] Step A4: Record the camera offset and motor counts throughout the process:
[0093] Move the slider from the x=0 boundary to the other end x=x max boundary, at this time n=0, m=0, when the motor enters the uniform speed state, it is recorded as time t6; from t6+d cam Starting from time n=n1, record the pixel offset ΔS of each frame n ; When the motor drives the slider to the boundary x = x max At t7+d cam At this moment, n = n end ;
[0094] At the same time, at t6+d mot At the moment, starting from m=m1, the encoder count m and the recording time t of each count are recorded in real time m ; until the slider moves to the other edge x = x max At (t7); at t7+d mot At this time, m=m end ; Finally, the average speed of the uniform state is obtained: v = (m end -m1) / (t7-t6);
[0095] Similarly, from x=x max Move to the boundary of x=0, record the camera offset and motor count throughout the process; when the forward and reverse travel m end When they are inconsistent, take the maximum value m end =max(m end1 ,m end2 );
[0096] Under uniform speed, due to the angle of the camera or the curved track, the "pixel offset ΔS" of each frame i " is not a fixed value. In order to better predict the braking distance and time, it is necessary to establish a "pixel offset ΔS i " and " encoder count C j "relation;
[0097] "Pixel shift ΔS i The time corresponding to "(t i =t6+d cam +(n-n1) / fps) is related to the frame rate of the camera, and the encoder count C j The time corresponding to "(t j =t6+d mot+(m-m1) / v) is associated with the recording time of the count, so the relationship diagram of "pixel offset ΔS" and "encoder count C" can be established through conversion and interpolation of unified time units (that is, the displacement detected by the camera corresponds to the displacement detected by the motor), and the two back and forth strokes are spliced to establish a linear relationship ΔS(C);
[0098] Step A5: Ready state:
[0099] If there is a job to be executed, it means that it is not idle, and step B1 (perform the job) is executed;
[0100] If it is idle for a period of time (such as 3 minutes) and there is no job scheduled, it means short-term idleness, and step C1 is executed;
[0101] If it is idle for a long time (such as 30 minutes) and there is no job arrangement, it means it is idle for a long time, and step D1 is executed.
[0102] In the embodiment, step 2 specifically includes:
[0103] Step B1: Perform homework
[0104] Execute work instructions;
[0105] Step B2: Estimating and tracking the slider position:
[0106] The position of the slider is estimated based on the counts of the motor encoder. The encoder counts increase and decrease as the motor rotates forward and backward. According to the measurement in step A4, the total length of the slide rail is known to be m. end ; Therefore, through the current motor encoder count m, we can get the approximate position of the slider as Loc = m / m end ×100%
[0107] Step B3: Predict the motion of the target position;
[0108] When the camera is in operation and detects a target object, it will brake and predict its position, so that the motor-driven slider can stop accurately in front of the designated target object; reducing and avoiding unnecessary secondary calibration;
[0109] First, locate the target position through the upper-layer application and obtain the target position in the camera;
[0110] Step B3.1: Calculate the pixel offset ΔS between the current position and the target position aim ; Based on the previous estimate of braking distance m stop (Loc) function to calculate the distance required for braking; then m stop Substitute (Loc) into ΔS(C) to get the estimated braking pixel offset
[0111]
[0112] Step B3.2:
[0113] When ΔS aim >ΔS stop When the system does not process it, it repeats step B3.1;
[0114] when , the system stops outputting the motor (the output PWM duty cycle is 0) and waits for the slider to stop;
[0115] When ΔS aim <ΔS stop When the system predicts the braking distance, it calculates the pixel deviation ΔS sa =ΔS stop -ΔS aim , through the linear relationship of ΔS(C), it is converted into ΔC=ΔS -1 (ΔS sa ), according to the size of ΔC, a reverse action is applied to the motor to decelerate;
[0116] Step B4: Determine whether the final stop position is accurate?
[0117] The upper layer application identifies the camera content and determines whether the stop position of the slider is accurate. If it is accurate, execute step B5; otherwise, execute step B6;
[0118] Step B5: Homework Completed
[0119] Execute the operation of the upper layer application. After all instructions are executed, return to step A5 (ready state);
[0120] Step B6: Correction of offset
[0121] According to the upper-layer application, the camera content is identified, the target position reference is identified, and the motor is used to drive the slider to move to the target reference again; the pixel offset ΔS between the initial stop position and the reference is calculated err , and record the motor encoder count m during the correction process err ;
[0122] Step B7: Feedback on braking time and distance
[0123] The braking starting point Loc and ΔS(Loc)+ΔS err Substitute the ΔS(C) function back into the function and perform linear regression calculation on the function again;
[0124] Set the braking starting point Loc and m stop (Loc)+m err Re-introduce mstop (Loc) function and recalculate the linear regression function.
[0125] In the embodiment, step three specifically includes:
[0126] Step C1: Short-term Idleness
[0127] At different positions, perform step A3 (measure input delay, measure braking time and displacement), and then perform C2;
[0128] Step C2: Fitting the linear relationship between position and braking time distance
[0129] Because the slide rail may be non-linear and non-horizontal, the braking time and distance in the X+ and X- directions, as well as in different positions, are slightly different. In order to more accurately estimate the braking time and distance at different positions, the "position Loc" and "pixel offset S" of the X+ direction movement are established respectively. stop "; the relationship between the "position Loc" of X-direction movement and the "pixel offset S stop "; for different positions in the same direction, the "position Loc" and "pixel offset S stop "Perform linear regression fitting and get S stop (Loc) function;
[0130] In the embodiment, step four includes:
[0131] Step D1: Long-term idle: Execute step A4 (record the camera offset and motor count throughout the process)
[0132] The above are only preferred embodiments of the present invention, and the protection scope of the present invention is not limited to the above embodiments. All technical solutions under the concept of the present invention belong to the protection scope of the present invention. It should be pointed out that for ordinary technicians in this technical field, some improvements and modifications without departing from the principle of the present invention should be regarded as the protection scope of the present invention.
Claims
1. A one-dimensional slide rail control method based on a camera is applied to a one-dimensional slide rail of a slider driven by a motor. The camera is installed on the slider and cooperates with an upper-layer image recognition application to identify the target object to determine the stopping time and distance of the slider. The method uses self-test calibration during idle time and motor stop tests at different positions to calculate the braking prediction at different positions and under different load conditions. The method is characterized in that: The method comprises the following steps: Step 1: The camera is working, the motor is preheated, the input delay, braking time and displacement are measured, the camera offset and motor count are recorded throughout the process, and the linear relationship between the camera offset and the motor rotation is fitted before entering the ready state; Step 2: In the ready state, determine whether it is idle: If it is not idle, the operation is performed, the slider position is tracked in real time, the target position is predicted, and the final stop position is judged to be accurate. If it is not accurate, the position offset is compensated and the braking time and distance are fed back. If it is accurate, the operation is completed and the machine re-enters the ready state. If it is idle, then determine whether it is idle for a long time. If it is idle for a long time, proceed to step 4; if it is idle for a short time, proceed to step 3; Step 3: Measure input delay, braking time and distance at different positions, and enter the ready state after fitting the linear relationship between position and braking distance; Step 4: Record the camera pixel offset and motor count throughout the process, fit the linear equation of the camera pixel offset and motor rotation, and then enter the ready state; In step 1, the input delay and the braking time and displacement are measured, specifically: When the slider is stationary, send a command to make the motor rotate. This moment is recorded as t1, and the motor drives the slider to start moving in the positive direction of the X axis (X+). When the encoder counts from 0 to 1, the moment is recorded as t2; When the camera image just changes from a static state to a moving state, the time is set to t3; Thus we can calculate: The delay from sending the command to the motor encoder count change is d mot =min(d mot ,t2-t1), the first calculation time d mot =t2-t1, i.e. motor delay time; The delay from sending command to camera change is d cam =min(d cam ,t3-t1), the first calculation time d cam =t3-t1, i.e. camera delay time; When the slider moves at a constant speed, the output to the motor stops. This moment is recorded as t4. At this time, the motor encoder counts from m=0. The slider gradually stops moving due to inertia; When the camera image changes from a moving state to a stationary state, the time is recorded as t5, at which time m = m stop ; It is calculated that it takes Δt from sending the stop command to actually stopping. stop =t5-t4, sliding distance is m=m stop -0; Similarly, the motor drives the slider to start moving in the negative direction (X-) of the X-axis, and the input delay is measured twice; After entering the uniform speed state, stop the output to the motor and record the braking time and displacement of the negative movement; Except for the first execution, each subsequent execution will establish m stop Two sets of linear relationships with Loc in the X+ direction and X- direction: m stop =m stop1 (Loc)X+movement direction, m stop =m stop2 (Loc)X-direction of movement; In step 1, the camera offset and motor count are recorded throughout the process, specifically: Move the slider from the x=0 boundary to the other end x=x max boundary, at this time n=0, m=0, when the motor enters the uniform speed state, it is recorded as time t6; from t6+d cam Starting from time n=n1, record the pixel offset ΔS of each frame n ; When the motor drives the slider to the boundary x = x max At t7+d cam At this moment, n=n end ; At the same time, at t6+d mot At the moment, starting from m=m1, the encoder count m and the recording time t of each count are recorded in real time m ; until the slider moves to the other edge x = x max At time t7; at t7+d mot At this time, m=m end ; Finally, the average speed of the uniform state is obtained: v = (m end -m1) / (t7-t6); Similarly, from x=x max Move to the boundary of x=0, record the camera offset and motor count throughout the process; when the forward and reverse travel m end When they are inconsistent, take the maximum value m end =max(m end1 ,m end2 ); Establish pixel offset ΔS i With encoder count C j relation; Pixel shift ΔS i The corresponding time (t i =t6+d cam +(n-n1) / fps) is related to the camera frame rate, while the encoder count C j The corresponding time (t j =t6+d mot +(m-m1) / v) is associated with the recording time of the count. After conversion and interpolation of unified time units, a relationship diagram between the pixel offset ΔS and the encoder count C is established, and the two back-and-forth strokes are combined to establish a linear relationship ΔS(C).
2. The camera-based one-dimensional slide control method according to claim 1, characterized in that: In step 1, the camera is working and the camera pixel offset is obtained in real time, specifically: Convert the image into a grayscale image, then use the Canny edge detection algorithm to calculate the edge lines of the image features, i.e. the contour lines, and save the pixel points of the contour lines; Continuously record the pixel points of the contour line of each frame of the camera, compare the pixel points of the current frame with the pixel points of the previous frame, calculate the displacement of each pixel point, and find the median of the displacement of all pixel points, and finally calculate the pixel offset of each frame.
3. The camera-based one-dimensional slide control method according to claim 1, characterized in that: In the step 1, the motor is preheated and the slider is driven to move along the edge of the slide rail, specifically: Assuming that the travel of the slide rail is the X axis, the motor drives the slider to move to the boundary of x=0, and continues to move in the negative direction of the X axis (X-), so that the motor is blocked for a period of time, so that the motor can be quickly preheated, and then moves from x=0 to the positive direction of the X axis (X+). When the motor reaches the other end boundary, the motor is blocked, the motor current increases, and the encoder count does not increase, so it is judged to have reached the boundary x=x max Then the motor drives the slider to return to x=0 immediately, so that the motor can be quickly cooled by air during movement, thus reaching a relatively stable state.
4. The camera-based one-dimensional slide control method according to claim 1, characterized in that: In the ready state, if there are jobs to be executed, it means that it is not idle; if the idle time is within the short-term time threshold and there is no job scheduled, it means short-term idle; if the idle time reaches the long-term idle time threshold and there is no job scheduled, it means long-term idle.
5. The camera-based one-dimensional slide control method according to claim 1, characterized in that: The step 2 specifically includes: Step B1: Perform the operation and execute the operation instruction; Step B2: Estimating and tracking the slider position: The position of the slider is Loc = m / m end ×100% Among them, m end is the total length of the slide rail, m is the current motor encoder count; Step B3: Predict the target position and make the motor drive the slider to stop in front of the designated target; Step B4: Identify the camera content through the upper layer application to determine whether the stop position of the slider is accurate. If it is accurate, execute step B5; otherwise, execute step B6; Step B5: Execute the operation of the upper layer application. After all instructions are executed, enter the ready state; Step B6: Correction of the offset: According to the upper-layer application, the camera content is identified, the target position reference is identified, and the motor is used to drive the slider to move to the target reference again; the pixel offset ΔS between the initial stop position and the reference is calculated err , and record the motor encoder count m during the correction process err ; Step B7: Feedback on the braking time and distance: The braking starting point Loc and ΔS(Loc)+ΔS err Substitute the ΔS(C) function back into the function and perform linear regression calculation on the function again; Set the braking starting point Loc and m stop (Loc)+m err Re-introduce m stop (Loc) function and recalculate the linear regression function.
6. The camera-based one-dimensional slide control method according to claim 5, characterized in that: The step B3 comprises: Step B3.1: Obtain the target position through the upper layer application and calculate the pixel offset ΔS between the current position and the target position aim ; Based on the previous estimate of braking distance m stop (Loc) function to calculate the distance required for braking; then m stop Substitute (Loc) into ΔS(C) to get the estimated braking pixel offset Step B3.2: When ΔS aim >ΔS stop When the system does not process it, it repeats step B3.1; when , the system stops outputting to the motor and waits for the slider to stop; When ΔS aim <ΔS stop When the system predicts the braking distance, it calculates the pixel deviation ΔS sa =ΔS stop -ΔS aim , through the linear relationship of ΔS(C), it is converted into ΔC=ΔS -1 (ΔS sa ), according to the size of ΔC, a reverse action is applied to the motor to decelerate it.
7. The camera-based one-dimensional slide control method according to claim 1, characterized in that: The step 3 of fitting the linear relationship between the position and the braking time distance specifically includes: Establish the position Loc and pixel offset S of the X+ direction movement respectively stop The relationship between the X-direction movement position Loc and the pixel offset S stop The relationship between the position Loc and the pixel offset S of different position points in the same direction stop Perform linear regression fitting and obtain S stop (Loc) function.
