paint-brush
Galvo Scanner - Pillow and Barrel Distortions Correctionby@sinenko
1,823 reads
1,823 reads

Galvo Scanner - Pillow and Barrel Distortions Correction

by Ilya SinenkoAugust 12th, 2022
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Distortions are mainly of two types: "barrel" and "pillow" The farther the beam is from the center, the more distortion will be.

Company Mentioned

Mention Thumbnail
featured image - Galvo Scanner - Pillow and Barrel Distortions Correction
Ilya Sinenko HackerNoon profile picture


Anyone who has used galvo-scanners knows that you can't just take and draw a figure without correcting distortion. Distortions are mainly of two types: "barrel" and "pillow".

For beginners who are just starting to assemble a device based on a two-axis galvo scanner, I will explain:

The galvoscanner consists of two mirrors fixed on the X and Y axes.

Due to the fact that the laser beam does not hit the second mirror at an even angle, distortions occur on the surface. The farther the beam is from the center, the more distortion will be.

It seems to be a simple geometry and these distortions are a common occurrence, but when you first worked with the galvoscanner, it was not obvious. I thought that the manufacturers of the galvoscanner should have solved this problem.

I thought that the manufacturer built a control board inside the galvoscanner that corrects all distortions. I was wrong. And I had to solve this problem.

How it all started:

It started with the fact that we decided to build an SLS 3D printer.

We bought:

  • CO2 laser 50W

  • galvoscanner RC1001

  • F-theta lens SL1-10.6-210-300Z-LP

  • Differential Line Driver DS26LS31

  • Teensy 4.1Controller


We connected all this and loaded the opengalvo / OPAL firmware https://github.com/opengalvo/OPAL

Launched a simple GCODE with a rectangle. But the rectangle didn't work...

Then, we made a test GCODE with rectangles of different sizes in order to figure out what is the cause of the distortion.Here is what the galvoscanner drew:

After experimenting, I came to the conclusion that there are only two types of distortion.

The first type of distortion: “pillow”, is created by a galvoscanner:

The second type of distortion, "barrel", is created by the F-theta lens.The distortion is not large, 1mm/200mm, but this is critical for 3D printing.

Solve the problem

On the topic of distortion, there is a simple and understandable article, the authors of which are Dongyun Wang, Qiwei Yu, Xinpiao Ye

https://www.sciencedirect.com/science/article/abs/pii/S0030399213003587


The authors of the article used the following formula to correct the distortion of the image obtained by scanning with a galvoscanner:

In our case, we need to do the opposite. The image is applied to the surface using a galvoscanner. We know the coordinates of the image, but we do not know the correct angles of rotation of the mirrors. We need to calculate the angle of rotation of the galvoscan mirrors.

More precisely, we need to calculate the angle of rotation of the mirror X.Because on the X axis there is a “pillow” distortion.


Our formula will look like this:

In C++ the code would look like this:

x_angle = atan(x_cord / (sqrt(pow(d,2)+pow(y_cord,2))+e));


Where:

x_angle - is the angle to rotate the X mirror.

e - is the distance from the X-axis of the galvo scanner to the Y-axis

d -  is the distance from the Y-axis of the galvo scanner to the surface on which the image is applied

x_cord - is the coordinate of the drawn image by X axis (relative to the center)

y_cord - is the coordinate of the drawn image by Y axis (relative to the center)


After recalculating the angle of rotation, the “cushion” distortions disappeared:

Now we need to remove the barrel distortion on the top and bottom of the rectangle.

These distortions are due to the F-theta lens.

To correct “barrel” distortion, we can use the same formula:**
**In C++, the code would look like this:

y_angle = atan(y_cord / (sqrt(pow(d,2)-pow(x_cord,2)/5)));


Where:

x_angle - is the angle to rotate the X mirror.

5 - is the coefficient that varies depending on the type of F-theta lens, I picked this coefficient

d -  is the distance from the Y-axis of the galvo scanner to the surface on which the image is applied

x_cord - is the coordinate of the drawn image by X axis (relative to the center)

y_cord - is the coordinate of the drawn image by Y axis (relative to the center)


And here is the final result:

Finally, a video of the laser work:


This code does not claim high performance, but for our task, it is enough.

If you need high speed, then based on this code, you can generate a matrix of coordinate shifts. And when getting coordinates, adjust the values based on the matrix.


You can follow the development of the SLS 3D printer project on the fork in GitHub:

https://github.com/sinenko/SLS_teensy4_1