I've just in the process of finishing a DIY large format (~1200mmx700mm) CO2 laser cutter and wanted to share my control system.
It's commonly said you need a DSP (costs ~$500) to be able to both vector cut and engrave in the same file, and is considered nearly essential by many for a usable laser. But thanks to some great work by some people over at buildlog.net, that is far from true.
bjj (Ben Jackson) developed a linuxcnc component + configuration that allows software PPI. His code is available on github
jv4779 (Jeremy Van Grinsven) built on Ben's work adding a 'duty cycle' mode in addition, as well as a simple control panel with useful information (such as power level) and control such as go to origin and set origin. His code is available on github
Their work is built on work by others, whom they credit in their github pages.
In to the details:
40W glass laser + analog power supply taken from a cheap K40 laser, which came with Moshidraw.
TB6560 red 3 axis stepper driver board (~$40 shipped from ebay) Manual
12V 180W PSU
Aluminium extrusion frame - my own design.
Set up LinuxCNC
Easily done via the LiveCD.
Stick it in a computer, boot up and install.
Other guides cover this, so I won't. But it is very simple.
Use Stepconf wizard to get your machine moving.
Set the pins.
Test movement and velocity and acceleration.
For a laser you'll want very high acceleration.
Find the maximum settings before your steppers stall and then scale back ~30%
The bjj and jv4779 configs allow a few methods to fire the laser.
The simplest is 'magic Z' in which the laser is turned on when the Z axis is negative, and turned off when it goes positive.
This has the advantage of working with any CAM program without modification of a post processor.
Simply set a very small Z move (e.g. Z0.01 to Z-0.01) at a very high velocity (this is to avoid any pause as the machine thinks the Z axis is moving).
There is also the option to trigger via a digital out. This would require modification of a post processor for in most CAM software.
Bart of buildlog.net fame has done exactly that for Vectric products and covers it in a guide: Creating A Laser Post Processor at Buildlog.Net Blog
To control the laser with the TB6560 board and other breakout boards that don't actually break out all the parallel outputs you'll need to do a quick bit of soldering.
I soldered a wire on to pin 8 of the parallel port on the TB6560, and a wire on to a ground pin of the port. I connected the wires to J4 (red wires) on my powersupply (which was originally hooked up to a head marked laser and ground on the Moshidraw board). The test button goes on to the other pins of J4.
I also soldered a spare on to pin 9 for any future output needs (as the 3 axis board only uses 6 output pins for motors, and 1 for relay control)
I've hooked up the 240V supply for the laser power supply to the relay on the TB6560, so that the laser cannot fire when I'm not expecting it to, for example if an estop is triggered.
The relay stays open for a number of seconds specified in the .ini - this is great for hooking up air assist or exhaust. I've got air assist (90L/min aquarium air pump) hooked up that turns on at the start of a job and turns off 10 seconds after lasering is done.
Laser power control
This is the real magic part of the bjj and jv4779 configs. They allow software control of power level, even using an analog power supply (non-pwm).
bjj has implemented 'PPI' - it's actually done in pulses per millimeter (ppmm), which means you'll use values ~1/25th quoted for PPI.
This is triggered by M3 Sxx, where M3 is the gcode for spindle on clockwise and Sxx is the pulses per mm. S10 is 10 ppmm, S100 is 100ppmm. Over a certain number of pulses per mm you'll get continuous cutting (depends on the minimum firing time of your laser, which seems to be around 3ms, as well as feedrate).
M3 also turns the relay on, so without M3 code active the laser can't fire. This also means that the laser can't fire if M5 (stop spindle) is called in the gcode, or if M3 S0 is present.
PPMM/PPI differs from conventional laser firing in that cutting power is not determined by 'power / speed' where slower = deeper cut. The laser is pulsed precisely based on distance, so that in fact running faster results in more power delivered to the material in a given time frame. This means adjusting settings is not a simple linear thing.
jv4779 has expanded on bjj's configs by adding duty cycle.
M3 is ppmm (PPI mode) and behaves the exact same.
M4 (gcode for spindle counter-clockwise) is duty cycle mode which he talks about in the buildlog forum
Duty cycle is a bit easier to adjust because it is simpler relationship. To cut deep at the same power, just slow down the feedrate.
Integrating the configs
Once you have a basic linuxcnc config tested, with appropriate pin outs, and axis velocities etc, you'll need to edit those values in to bjj or jv_4779 config.
This requires some editing of the .hal file and the .ini.
In the .hal you'll need to replace the pins and whatever limit / home switches you've set
For the above TB6560 board my pins are:
Note I've commented out zstep and replaced it with 'net laser-final' (the hal pin that fires in the laser).
net xstep => parport.0.pin-02-out
setp parport.0.pin-02-out-reset 1
setp parport.0.pin-03-out-invert 1
net xdir => parport.0.pin-03-out
net ystep => parport.0.pin-04-out
setp parport.0.pin-04-out-reset 1
setp parport.0.pin-05-out-invert 1
net ydir => parport.0.pin-05-out
#net zstep => parport.0.pin-08-out
net laser-final => parport.0.pin-08-out
setp parport.0.pin-08-out-reset 1
net zdir => parport.0.pin-09-out
setp parport.0.pin-14-out-invert 1
#net spindle-on => parport.0.pin-14-out
net laser-exhaust => parport.0.pin-14-out
net min-home-x <= parport.0.pin-10-in
net max-home-y <= parport.0.pin-11-in
Spindle-on is with 'net laser-exhaust' which controls the relay and leaves the relay on for the number of seconds specified in the .ini file. This is handy for air assist, which I keep on for 10 seconds after laser has turned off.
In the .ini file you'll need to put in the appropriate values for your machine in the axis settings, as well as edit the paths to a couple of files.
Both bjj and jv_4779 have implemented raster engraving features.
I haven't tried either yet.
The simple way to do raster engraving, that allows engraving (raster) and cutting vector) in the same file is to do the raster in CAM. Generate a pocket operation using the kerf of the laser as the tool diameter, with appropriate power settings.
Drawing -> CAM -> LinuxCNC
I'm using Vectric Aspire mainly, which has adequate drawing tools. Sometimes I'll use Solidworks (as I love relationship / dimension based drawing - if there is a good cheap 2D drawing program that works like this I'd like to know).
Once I've got the vectors in Aspire I start generating toolpaths.
I've set up a few 'tools' that are the laser with different settings. E.g.:
'Laser Cardstock Cut' with tool diameter 0.3mm, spindle speed 15 (= M3 S15 in gcode = 15ppmm)
'Laser Cardstock Score' with tool diameter 0.3mm, spindle speed 3 (= M3 S2 in gcode = 3ppmm)
I haven't worked out how to choose M3 or M4 (ppm vs duty cycle) in Aspire - there doesn't seem to be a way to choose spindle direction. So at present I quickly hand edit / replace M3 with M4 if desired.
While the above requires a bit of editing some config files, it doesn't require in depth coding (others have kindly done the work!).
I managed to get my laser going with minimal fuss, in a couple of hours.
I've only done this recently, so there is a lot more fiddling to be done. But I'm impressed at being able to take a K40 laser, add a $40 stepper controller and now have a system that blows Moshidraw out of the water and allows software control of laser power.
Much cheaper than a DSP.
Please post any questions / comments. I'll aim to add some pictures at some point.