Laser Diode Driver and Testing

Lasers have always interested me but I finally had a chance to dive a little deeper into how they work and play around with one for myself.
What you see on the left is a picture of the finished product, but there is a lot that had to happen before I got here.

I began with reading up on different lasers and the basic operation of lasers, and decided the easiest to get started on was a diode laser. I purchased a 2W 450nm diode laser from amazon to start experimenting.

I then learned about how to control and drive the laser. Diode lasers like these need a constant current source, so the basic voltage regulator circuit wasn’t going to work. This is because lasers like this one heat up while they operate and tend to allow more current through. If you maintain a constant voltage as the diode heats up the current will increase, and thus it’s power intake and the diode will burn out.

The solution is a current driver. I could easily have bought the driver too but where’s the fun in that. Also there were a few additional features I wanted that I couldn’t seem to find with the available selection of driver  boards. So I decided to build one.

Laser driver based on the LT3518 LED driver.

I started by designing my driver board around the LT3518 LED driver. It had the required current capacity as well as a built in PWM control.

For the first go I started with the schematic from the datasheet, but on my first board revision I didn’t have much luck.

Next I did what I should have done in the first place. I created my design in LTSpice and simulated it. Since this was a switching regulator it was attractive because they are much more efficient and don’t generate so much heat, however they are also quite a bit more complicated. When they don’t work there are more things to go wrong. I found during simulation that there was a spike in current when the PWM turned on, that went through the laser. This would quickly burn out the diode if it wasn’t taken care of. After some tweaking of the circuit and a few added components I was able to reproduce the spike.

During the redesign of the second board I also decided to lay the components out on the board differently with a larger focus on reducing the distance for the sensing components and giving the current carrying leads a more streamlined path on the board. The result can be seen on the right. As a side note OSH park is where I have my boards manufactured. They make very high quality boards as a great price. Check them out here!

Finally working!

Once that board was ordered, put together and after messing up a laser diode or two… I finally had a working laser.

Here you can see one of the first test runs of the laser. I focused it on an old 3D print. The black color really absorbs the laser energy and immediately starts billowing smoke as the laser burns through it.

Of course I spent a lot of time burning random things because of how cool it was to be able to burn holes in things from a distance, however I had bigger plans for the laser.

Making Pictures

When I designed the PWM capability into the laser driver I had a plan. I thought if I were to vary the intensity precisely while the laser was moving I could change the darkness of the burn on whatever the laser was pointed at. Combine that with the precision of movement on my 3D printer or CNC router and I would be able to make pictures.

First i had to develop a mount to hold the laser and driver as well as how I would get power to the laser and signal from the printer control board.

I first created the mount, the result was a 3D printed enclosure that would focus air flow from a fan over the driver board and onto the heat sink around the diode.

Testing the mount and cnc control ability for cutting with the laser. I hadn’t quite finished the PWM control from the 3D printer but I was chomping at the bit to play with my laser in the new mount. So I zip-tied it my CNC router  and fired it up. It left a little bit to be desired on the first go but the ability to cut extremely precisely became apparent immediately. It also happened to be Father’s day when I tested it.

 

First test cutting paper with CNC router and Laser

Finally PWM control

getting the 3D printer to control the pwm going to the laser was a bigger challenge than I had expected it to be. I had planned on using the port the 3D printer used for one of the cooling fans that is already controlled by PWM from the RAMBO controller. It turns out that the PWM was actually just controlling a MOSFET that controlled the fan, meaning that I wasn’t going to be able to get the voltage level I needed for the laser driver.

I ended up diving into the firmware of the RAMBO board, called Merlin, and trying to find an alternative. I also dug up the schematics of the control board to see if it broke any pins out for use that had PWM capability. After digging through pages of code and staring at the schematics for a little while I found that they had built in a generic gcode command into the firmware to control unused pins manually. I found a pin that I could get the signal for the laser, hooked up to it and ran a quick test. By sending this gcode command I was able to turn the laser on and off and vary the intensity. Now I was all set.

First Image with Laser

Now I could control the laser manually from the printer but I needed it to be better than that to engrave images. I threw some code together pretty quickly in Python that took in an image, resized it, turned it to gray-scale and them decomposed it pixel-by-pixel. I was then able to come up with the movement required to have the laser hit every pixel and set the intensity based on the darkness or lightness of each pixel in the image. With this I was able to use the Python code to generate Gcode that I could send to the printer. With the laser attached where the extruder should be and receiving all the normal commands, the printer has no idea its not running like it normally would be. After a few test runs and tweaking of the code I finally got it to trace make the first image! The accuracy was incredible!