Today, Zheng Motion Assistant will share with you the method and implementation instructions for galvanometer correction using the ZMC408SCAN open-type laser galvanometer motion controller.
01. Introduction to ZMC408SCAN Controller
The ZMC408SCAN is a newly launched open-source laser galvanometer motion controller from Zheng Motion Technology, supporting the EtherCAT bus and designed specifically for industrial laser + galvanometer + motion control applications. It enables multi-axis联动 motion control via the EtherCAT bus and pulse axis interface.
The ZMC408SCAN supports communication interfaces such as ETHERNET, EtherCAT, USB, CAN, RS485, and RS232. Various expansion modules can be connected via CAN and EtherCAT buses to expand digital, analog, or motion axes.
(1) The ZMC408SCAN has a built-in high-precision PSO position synchronization output function, which can keep the laser output spacing constant even when deceleration adjustment is made when machining fillets and curves, in high-speed machining situations;
(2) Supports laser galvanometer control and galvanometer feedback, including 2 galvanometer interfaces, supporting 2D galvanometers and 3D galvanometers. With the MOVESCAN motion command without acceleration or deceleration, the galvanometer processing at corners is automatically delayed, achieving precise and efficient laser control and improving the productivity of laser processing equipment;
(3) The laser on/off delay can be flexibly adjusted during movement via commands, with fast response, precise control down to the microsecond level, and simple setup process, greatly reducing the engineer's parameter adjustment time;
(4) It comes with a built-in LASER laser control interface, supporting laser power supplies of IPG, YLR, YLS and other types. It also has an EXIO expansion IO interface, which can flexibly control various mainstream lasers on the market through a customized adapter board;
(5) Supports simultaneous control of 16 ZMC408SCAN controllers by PC to form a laser processing system with a galvanometer array;
(6) Onboard 4-channel high-speed differential pulse output, with 4-channel high-speed differential encoder feedback, supports EtherCAT bus driver control, supports 5-axis XYZAC interpolation, and supports mixed interpolation of galvanometer axis and motion axis;
(7) Supports a variety of motion control functions such as linear interpolation, arbitrary circular interpolation, spatial circular arc, helical interpolation, electronic cam, electronic gear, synchronous following, and virtual axis setting.
02. Galvanometer Control
A laser galvanometer is a special motion device used in the field of laser processing. It relies on two galvanometer mirrors to reflect the laser beam, thus creating motion in the XY plane.
Unlike ordinary motors, laser galvanometers have very small inertia and a very small load during movement, resulting in a very fast system response. Therefore, acceleration and deceleration of the galvanometer do not need to be considered during its movement. Galvanometers are generally divided into analog and digital galvanometers. Analog galvanometers use a driver board that receives analog signals. Commonly used analog galvanometer signals are DC voltage variations from -5V to +5V, corresponding to the motor's swing angle. For example, -5V to +5V corresponds to a motor swing angle of -10 degrees to +10 degrees.
The digital galvanometer is controlled by digital signals, which conform to the XY2-100 protocol. The digital value -32768~32767 corresponds to the maximum swing angle of the motor.
The positive motion provides a dedicated motion command for galvanometer axis control, enabling the galvanometer to respond quickly via ZAux_Direct_MoveScanAbs or ZAux_Direct_MoveScan.
Compared to regular motion command control, Scan motion commands do not include acceleration/deceleration planning, but support time control at the microsecond (µs) level. The runtime is directly calculated from the speed and vector distance set via ZAux_Direct_SetForceSpeed.
The current SCAN controller supports the control of 1-2 XY2-100 digital galvanometer axes.
I. Galvanometer Axis Configuration
The positive motion SCAN controller supports 1-2 galvanometer axes. Different controllers map different axis numbers and support different galvanometer axis functions. The axis numbers corresponding to different galvanometer groups are shown in the figure below.
The corresponding galvanometer axis type is set via the command ZAux_Direct_SetAtype. There are three types of galvanometer axis types:
§ One shaft type value is 20 (galvanometer type, with galvanometer status feedback, supported only by ZMC408SCAN);
§ One axis type value is 21 (galvanometer axis control type);
§One shaft type value is 22 (galvanometer type, with galvanometer position feedback, only supported by ZMC408SCAN).
§* indicates unsupported features.
II. Galvanometer Correction
1. Key points to note
The laser galvanometer scanning system is shown in the figure below. It can be seen that the actual working range of the galvanometer scanning is determined by the maximum deflection angle and working height of the galvanometer. Therefore, when mapping the output of the galvanometer axis deflection angle (-32768~32767) to the actual working range, a proportional mapping based on the test length is required.
The coordinate system established by the galvanometer scanning system is a non-orthogonal coordinate system, and the actual scanning field will cause pincushion distortion. The pincushion distortion caused by the scanning of the galvanometer itself is shown in Figure (left). In addition, the use of the F-Theta plane field lens will cause barrel distortion of the output contour as shown in Figure (middle). The superimposed output graphic has both barrel and pincushion distortion as shown in Figure (right).
To ensure that the software coordinates correspond to the actual operating distance and the output trajectory is not distorted, it is necessary to correct each data point in real time. Typically, a lookup table and piecewise linear interpolation method is used for position correction. The more correction points there are, the more accurate the actual output position will be.
The forward motion SCAN controller provides methods such as BOX calibration and multi-point calibration. Regardless of whether it's coefficient calibration or multi-point calibration, the calibration point parameters are written to the controller's internal system array TABLE register. Therefore, when other functions in the program utilize the TABLE register, careful attention must be paid to the proper allocation of addresses.
(1) Box coefficient correction
Coefficient correction refers to adjusting and correcting the coefficients based on several cases, such as pincushion/barrel distortion, parallelogram distortion, trapezoidal distortion, and scaling, in the output image of the galvanometer.
The coefficients are corrected by calling ZScan_CorrectFactor. First, the galvanometer is controlled to draw a square correction pattern. The corresponding coefficient parameters are adjusted according to the distortion of the correction pattern as shown in the figure below. The scaling factor is adjusted according to the marking length and the measurement length. The correction is considered successful when the actual marking size matches the setting. The correction factor is the amount of change entered, usually with 0 as the reference.
(2) 9-point calibration
Nine-point calibration refers to calibrating the galvanometer based on the theoretical and actual positions of each point in a 3x3 grid marked within the working range.
First, control the galvanometer to pre-draw a 3*3 calibration table. Then, fill in the actual measured X and Y coordinates in the order P1-P9 as shown in the diagram, along with the theoretical coordinates of point P1 and P9. Perform a 9-point calibration by calling ZScan_Correct9. Recalibration and testing are required until the actual calibration and theoretical values reach the expected accuracy range.
(3) 25-point calibration
25-point calibration refers to calibration based on a 5x5 grid marked within the working area. The calibration process is the same as 9-point calibration, performed by calling ZScan_Correct25. The more calibration points, the higher the calibration accuracy.
2. Introduction to Galvanometer Commands
(1) 9-point correction of the galvanometer axis
(2) 25-point correction of the galvanometer axis
(3) Correction of galvanometer axis coefficient
(4) Cancel galvanometer correction
03. Program Demonstration
The nine-point correction process is the same as the 25-point correction process, but the 25-point correction is more accurate. The 25-point correction can be rewritten using the nine-point correction routine.
1. The nine-point correction procedure is as follows:
·
ZMC_HANDLE handle = NULL; // Connection handle int rtn = ZAux_OpenEth("192.168.0.11", &handle); // Connection controller if(CheckError(rtn,"ZAux_OpenEth")) return; // Check function return for(int iAxis = 4;iAxis<6;iAxis++){ rtn = ZAux_Direct_SetAtype(handle,iAxis,21); // Set axis to galvanometer axis if(CheckError(rtn,"ZAux_Direct_SetAtype")) return; rtn = ZAux_Direct_SetUnits(handle,iAxis,500); // Set axis pulse equivalent if(CheckError(rtn,"ZAux_Direct_SetUnits")) return;} rtn = ZScan_CancelCorrect(handle,0,-1,-1,200,1,1000); // Cancel galvanometer calibration if(CheckError(rtn,"ZScan_CancelCorrect")) return; double m_dXMeasurePt[9] = {-51.5,0,49.5,-52.9,0,50.1,-51.8,0,49.0}; double m_dYMeasurePt[9] = {-51.5,-51.0,-53.0,0,0,0,51.9,51.5,53.9}; rtn = ZScan_Correct9(handle,0,m_dXMeasurePt,m_dYMeasurePt,0,21,500,-50,-50,50,50,1,1000); // Galvanometer 0 9-point calibration, calibration data is stored in system array TABLE(1000 - 1004+21*21*2) if(CheckError(rtn,"ZScan_CorrectFactor")) return; rtn = ZAux_Close( handle); // Close the connection and release the handle if(CheckError(rtn,"ZAux_Close")) return; handle = NULL;
2. The coefficient correction routine is as follows:
·
ZMC_HANDLE handle = NULL; // Connection handle int rtn = ZAux_OpenEth("192.168.0.11", &handle); // Connection controller if(CheckError(rtn,"ZAux_OpenEth")) return; // Check function return for(int iAxis = 4;iAxis<6;iAxis++){ rtn = ZAux_Direct_SetAtype(handle,iAxis,21); // Set axis to galvanometer axis if(CheckError(rtn,"ZAux_Direct_SetAtype")) return; rtn = ZAux_Direct_SetUnits(handle,iAxis,500); // Set axis pulse equivalent if(CheckError(rtn,"ZAux_Direct_SetUnits")) return;} rtn = ZScan_CancelCorrect(handle,0,-1,-1,200,1,1000); // Cancel galvanometer correction if(CheckError(rtn,"ZScan_CancelCorrect")) return; double m_dMaxBox[2] = {131,131}; // Maximum correction area double m_dCorrectBox[] = {131,131}; // Actual correction area double m_dOffset[2] = {0,0}; // Offset is generally used for red light offset double m_pdFactor[2][4] = {{1,0,0,0},{1,0,0,0}}; // Correction coefficient scaling coefficient, barrel/pincushion distortion coefficient, parallelogram distortion coefficient, trapezoidal distortion coefficient rtn = ZScan_CorrectFactor(handle,0,m_dMaxBox[0],m_dMaxBox[1],m_dCorrectBox[0],m_dCorrectBox[1],m_dOffset[0],m_dOffset[1],&m_pdFactor[0][0],&m_pdFactor[1][0],0,21,1,1,500,1,1000); // Magnetic mirror 0 coefficient correction, correction data is stored in the system array TABLE(1000 - 1004+21*21*2)if(CheckError(rtn,"ZScan_CorrectFactor")) return;rtn = ZAux_Close( handle); // Close the connection, release the handleif(CheckError(rtn,"ZAux_Close")) return;handle = NULL;
04. Galvanometer Correction Tool
The galvanometer correction tool includes a variety of correction methods, such as 9-point correction, 25-point correction, coefficient correction, multi-point correction, and document correction.
Mechanical parameters in the parameter setting interface:
First, select the corresponding controller by IP address, then set the mechanical parameters, select the laser type, set the galvanometer number, and ensure that the XY direction of the marking pattern matches the software display.
Marking parameters:
Fill in the marking speed, idle speed, shaft type, and pulse equivalent (the basic unit of motion and speed commands; the pulse equivalent needs to be modified to the number of pulses per 1mm movement of the galvanometer; after modification, the marking pattern should be small compared to the predetermined size before measurement and correction can begin; if the pre-calibration marking pattern is incomplete or much larger than the predetermined size, decrease this parameter; otherwise, increase the parameter).
For example:
§ Switch Delay: Multi-point correction of the center point depth, adjusting the switch delay.
§ Off-light delay: Adjust the off-light delay if the outermost ring is not sealed.
§Corner Delay: Adjust the corner delay as the line on the right is deeper.
§Jump Delay: Multi-point correction dots have small tails; adjust jump delay.
§End Delay: Add an end delay after all movements have finished.
Laser energy control:
(1) Analog signal DA (0~4095 corresponds to 0~10V voltage)
(2) PWM (adjusting the duty cycle and setting the frequency)
(3) I/O combination
Note: The control parameters for laser energy need to be modified according to the control type of laser energy power. Please refer to the laser manual.
1.9-point correction and 25-point correction
§ Set the starting position of the table for the correction parameters: This address should not conflict with other table addresses. Approximately 1000 data entries will occupy 1000 table addresses.
§Red light tour: Can be used to correct graphics;
§ Pre-calibration size: Area; this parameter is used for pre-calibration patterns.
§After pre-marking the graphic, take out the marked graphic and measure it: measure the distance between two points and fill in the distance parameter between the two points in the corresponding box;
§ Marking and Pre-calibration: Begin marking and pre-calibrating the graphic according to the parameter settings and pre-marking dimensions;
§Correction Only Button: Performs galvanometer correction only, no markings;
§ Marking Dimension: Area. Use this parameter for marking pre-correction patterns;
§Correcting and Marking: Based on the marked dimensions, begin correcting and marking the graphic;
§Save to File and Save to Controller: Saving to file saves the data to the local computer (saving to a file can be used for file correction and multi-point correction), while saving to controller saves the data to the controller's flash block (ensure that different flash blocks are used for different galvanometer axis numbers to avoid conflicts).
§Emergency Stop: Marked emergency stop.
(1) Pre-correction effect diagram of 9-point correction marks
(2) Correction and marking effect diagram
(3) 25-point correction is the same as 9-point correction, except that there are more points and the correction accuracy is higher.
2. Coefficient Correction
The coefficient correction is similar to the 9-point correction, except that it adds an origin offset and an XY scaling ratio.
3. Multi-point correction
(1) Correction size: Same as above;
(2) Radius of the mark point: The radius of the mark circle (point);
(3) Number of marking points: 9*9, 17*17, 33*33, and 65*65 are available. Currently, 9*9 and 17*17 are under development. For more number of marking points, please contact the Zhengdong Technology Support Engineer.
(4) Spacing between fill points: the difference in radii of concentric circles;
(5) Complete image: Mark the complete image (the scanner can scan the entire image);
(6) Left/Right Shapes: Mark the left/right shapes; (When the shapes are large, the scanner cannot scan all the shapes at once. Please mark the left and right sides separately, scan them separately, and import the two images).
(7) Emergency Stop: Marked Emergency Stop;
(8) Point processing:
§Mode: Single image, Two images: Depending on whether the correction drawing after scanning and marking is scanned twice, or marked separately on the left and right sides.
§ Polarity: White background with black dots, black background with white dots
§Thresholding Method: Automatic, Manual Threshold: (Threshold parameter range 0~255) For black and white photos, white is 255 and black is 0. Pixels between the low and high thresholds are processed as 255, otherwise as 0. This is used for image processing after scanning and marking.
§Low threshold: 0~255
§High threshold: 0~255 should be set to be greater than or equal to the low threshold data.
§Maximum Area/Minimum Area: Filter image noise (speculiarities) by selecting the area around the origin.
§See Zvision Help for details
(9) Import 9-point correction file: Import 9-point correction file (multi-point correction requires the file in "Save correction data to file" in 9-point correction).
4. Document Correction
Functions: Import files saved by "Save Correction Data to File" for 9/25/Multi-point Correction, update parameters to the correction interface, correct only or correct and mark, etc.
That concludes our presentation on the open-source laser galvanometer motion controller for positive motion technology: C++ galvanometer correction method and implementation.
For more exciting content, please follow the "Zheng Motion Assistant" WeChat official account. For related development environment and example code, please contact Zheng Motion's technical sales engineer: 400-089-8936.
This article is original content from Zheng Motion Technology. We welcome everyone to reprint it for mutual learning and to jointly improve China's intelligent manufacturing level. Copyright belongs to Zheng Motion Technology. Please indicate the source if you reprint this article.