Friday, 30 October 2015

Continuous Autofocus Laser Cutter Hack


We were inspired by the Glowforge laser cutters ability to continuously autofocus it's z axis. A camera mounted in the head of the laser detects a laser dot being shone onto the surface of the material and from there it can determine how far the lens needs to be adjusted to set the focal height for the correct cutting distance.

The Nintendo Wii Remote has an optical camera in it that is used to detect up to four points of infrared light. The hardware automatically identifies these points and feeds back XY positions through a bluetooth connection. The cutting laser on a laser cutter is an infrared beam, as it cuts through the surface of the material there is a moment where it is reflected off the material and the Wiimote is able to detect the location of the cut. The location data is fed back to a laptop and by comparing this point against the initial 'in focus' point we're able to detect if the Z axis needs to move up or down and by how much. The laptop sends data to an arduino that is connected between the laser cutters onboard Leetro controller and the Z axis stepper motor driver. The Arduino controller is the same as we have used on previous projects to control the Z axis. The result is a laser cutter that has the ability to remain in focus throughout the duration of a cut.



The project was written using C# and Brian Peeks Wiimote Lib, which made it incredibly easy to connect to the Wiimote using just a few lines of code. The source is available here but be warned it is a horrible mess of gaffa taped code written for a project that could never be more than an interesting hack.
The problems:
  1. Our laser cutters move the whole bed up and down to adjust the focal height. There is a lot of mass to move and it gains momentum so it isn't able to adjust the Z axis as fast as required. This is why it's so noisy as it tries to keep up with the requested position.
  2. The camera in the wiimote is capable of detecting light sources 60 times a second, the laser cutter is not able to process this information fast enough so there is some lag between the height change and the actual movement.
  3. The Wiimote is only able to detect the focus height while the laser is actually cutting. If the laser stops cutting and moves to a new area with a different height then the system will take a second to adjust to the new height once it starts cutting again.
  4. The increased mass on the cutting head prevents the laser cutter from reaching it's top speed of 50mm/s, and even if it could the response time from the system would not be fast enough to cope with changes that quickly.
This is a great proof of concept hack for a focusing system like this. In it's current configuration it is impractical as a working solution but it certainly was fun making it happen!