Trybotics Logo

DIY STEP/DIR LASER GALVO CONTROLLER

DESCRIPTION

Hi,

in this Instructable, I want to show you how you can build your own step / dir interface for ILDA standard galvo laser scanners.


As you might know I am also the inventor of the "DIY-SLS-3D-Printer" and the "JRLS 1000 DIY SLS-3D-PRINTER" and while I was building these machines I have start tinkering about how these printers will perform, if I will use a Galvo Scanners instead of a cartesian movement system. However in these days I don't had the knowledge to program a controller for a galvo scanner. So I have used an existing firmware with cartesian motion.

But today and after some research I found an instructable where the author uses an arduino to create a DIY Laser Galvo show. I thought this is exactly what I am searching for, so I have ordered the parts like in his instructable and made some experiments. After some research I found out, that the Arduino will not perform that well as step / direction interface, so I remixed it for the STM32 microcontroller.

Please remember this controller is just a prototype, but usable for a lot of projects. For example in a DIY SLS 3D printer or a laser engraver.

The features of the Galvo controller are:

  • conversion from 5V step/dir signals to ILDA standart
  • 120kHz input frequency of (Step / Direction signals)
  • 12bit Output resolution (0,006° per angle)
  • conversion from polar to linear coordinates
  • compatible with any motion controller which will create a step and direction signal
  • center alignment pin (homing routine)

video of laser galvo controller: (coming soon)


If you like my Instructable, please vote for me in the Remix Contest

Description:

Electronic Parts for the galvo controller:

QuantityDescriptionLinkPrice
1xILDA 20Kpps galvo galvanometer set
Aliexpress56,51€
1x6mm 650nm Laserdiode
Aliexpress1,16€
some
wires
-
-
1x
ST-Link V2
Aliexpress1,92


Electronic Parts for the circuit:

Here are all required parts for the galvo controller. I tried to source all parts as cheap as possible.

QuantityDescriptionName on circuit
LinkPrice
1xSTM32 "Blue-Pill" microcontroller
"BLUE-PILL"
Aliexpress1,88€
1xMCP4822 12 bit dual channel DAC
MCP4822
Aliexpress3,00€
2xTL082 dual OpAmp
IC1, IC2
Aliexpress0,97€
6x1k Resistor
R1-R6
Aliexpress0,57€
4x10k trim-potentiometer
R7-R10
Aliexpress1,03€
some
pin header
-
Aliexpress0,46€

Description:

Here I will you explain, how the controller works in general. I will also show some details for example the calculation of the right angle.


1. MOTION-CONTROLLER

The motion controller is the part where you will create the step and direction signals. The step/direction controll is often used in stepper motor applications like 3D-Printers, Lasers or CNC-Mills.

In addition to the step and direction signals there is a need for a center allignment pin to make the STM32 and the Motioncontroller consitent. That is because the galvos are absolute controlled and there is no need for any limit switches.


2.STM32-Microcontroller

The STM32 microcontroller is the heart of this controller. This microcontroller has several task to do. These task are:

Task 1: Measure signals

The first task is to measure the input signals. In this case it will be step and direction signals. Because I don't want that the motion-controller will be limited by input frequency, I designed the circuit for 120kHz (tested) . To achieve this input frequency without loosing data, I am using two hardware timers TIM2 and TIM3 on the STM32 to manage the step / direction interface. In addition to the step and direction signals there is the llignment signal. This alignment is controlled by an external interrupt on the STM32.

Task 2: Compute the signals

Now the controller needs to compute the signals to the right value for the DAC. Because the galvo will create a non linear polar coordinate system, a small calculation is needed to create a linear dependence between step and actual moved laser. Here I will show you a sketch of the calculation:

Now we need to find the formula for the calculation. Because I use a 12bit DAC, I can give out a voltage from -5 - +5V in 0 - 4096 steps. The galvo I have order has a total scan angle of 25° at -5 - +5V. So my angle phi is in a range from -12,5° - +12,5° . Finally I need to thought about the distance d . I personally want a scan field of 100x100mm, so my d will be 50mm. The high h will be the result of phi and d. h is 225,5mm. To bring the distance d in relation to the angle phi I used a little formula, which will use the tangents and convert the angle from radians into "DAC-values"

Finally I only need to add a bias of 2048, because my scanfield is center alignment and all of the calculations are done.

Task 3: Send values to the DAC:

Because the STM32 i have used has no build in DAC, I have used an external DAC. The communication between the DAC and the STM32 is realized over SPI.


3. DAC

For the circuit I am using the same 12bit DAC "MCP4822" as deltaflo. Because the DAC is unipolar 0-4,2V and you need -+5V bipolar for the ILDA standard, you need to build a small circuit with some OpAmps. I am using TL082 OpAmps. You have to build this amplifier-circuit twice, because you need to controll two galvos. The two OpAmps are connected to -15 and +15V as their supply voltage.


4.GALVO

The last part is rather simple. The Output voltage of the two OPAmps will be connected to the ILDA Galvo drivers. And that's it, now you should be able to control the galvos with step and direction signals

Description:

For the circuit I have used a prototype PCB.

You can connect the step and direction signals directly to the STM32, because I have activated internal pull down resistors. Also I have used 5V tolerant pins for the step, direction and center pins.

You can download the full schematic of the circuit below:

Attachments

Description:

The STM32 is programmed with Attolic TrueStudio and CubeMX . TrueStudio is free to use and you can download it here

Because TrueStudio is not that simple like for example the Arduino IDE, I have generated a .hex file, which you simply need to upload to the STM32 microcontroller.

In the following I will explain, how you uplaod the file to the STM32 "BluePill":

1. Download "STM32 ST-LINK Utility":
You can download the Software here

2.Install and open "STM32 ST-LINK Utility":

3. Now open the Galvo.hex file in the ST-Link Utility: After that you need to connect the STM32 "BluePill" to the ST-Link-V2. Once connected click on the "Connect to traget Button":

Finally click on "Download". Now your STM32 should be flashed correctly.


In addition, I have attached all the source files for the Galvo_Controller in TrueStudio

Attachments

Description:

I have placed all the electronic parts on a 4mm aluminum plate for a better look :-)

Now I will show you how you need to adjust the potentiometers on the circuit probably:

At first some background information about the ILDA standard. The ILDA standard is usually used for Laser shows, and consists of a 5V and a -5v signal. The both signals have the same amplitude, but with changed polarity. So what we have to to is to trim the output signal from the DAC to 5V and -5V.


Adjust the potentiometer:

What you can see here is the output voltage of this circuit at an input step frequency of 100kHz and with a constant direction signal. In this picture everything is fine. The amplitude goes from 0 to 5V and from 0 to -5 . Also the voltages are aligned probably.

Now I will show you what could get wrong while adjusting the potentiometer:

As you can see now both voltages are not aligned probably. The solution is to adjust the offset voltage from the OpAmp. You do that by adjusting the potentiometers "R8" and "R10".

An other example:

As you can see now the voltages are aligned probably, but the amplitude is not 5V but 2V. The solution is to adjust the gain resistor from the OpAmp. You do that by adjusting the potentiometers "R7" and "R9".


YOU MIGHT ALSO LIKE