Saturday, 28 February 2015

Project #2: Open Source Laser Cutter, Part 2

Now that I have an easy way to switch controllers into my laser it's time to try out some of the different softwares. I'm quite comfortable with Arduino and I've got a fair few of them kicking round my house so that's a good place to start so GRBL is the first controller that sprang to mind. It's a simple G-Code interpreter and there are a myriad of programs that send G-Code out via a serial port.

The controller:
GRBL is optimised for the AVR328 microcontroller which is typically found in the Arduino Uno so it's very accessible for beginners. The same chip can also be found on the Arduino Nano which can be bought for as little as £2.50 each (which is why I have a box full) so I used one of these instead.
The wiring for the blacknose is very simple, There are only X and Y axis, X and Y limit switches, laser power and laser On/Off. GRBL connections are well documented but it's worth noting that I used the Lasermode variant of GRBL which has the Laser Power on Pin 11 so it can use the hardware PWM.

It took just 3 slow and steady hours making sure the wiring was right and piggy backing the controller onto the break in board. I think I was much more cautious than usual but I was also reconditioning the machine at the same time. The only minor stumble was with the X limit switch, where the switch wires were bundled in with the stepper motor wires there was electrical coupling which prevented the Arduino from accurately detecting the home switch depression. This was solved by separating the two sets of wires along their length (The leetro controllers presumably have some built in filtering to negate the effects).

The firmware:
As already mentioned I used the Lasermode Variant of GRBL, this is freely available and can be easily compiled and flashed to the device using the Arduino IDE. The only minor problem was that I had to use the most recent development branch of the IDE (1.5.8), but that has now gone into stable release (1.6.0).

GRBL is very clever, all of the machine specific settings are stored in EEPROM on the microcontroller. This means if you update the software all the settings remain on the device. All the EEPROM settings are adjustable using text commands over the serial port. Since the software is downloaded using the Arduino IDE it was easy to set up the device using its serial monitor.

The first task is to work out how many steps per mm the laser has. Read the settings to figure out how many steps per mm are currently being used, request the axis to move 10mm and measure how many mm the laser actually moved. When you know how many steps it took and how far it went you can calculate how many steps per mm the machine actually has. The Blacknose has 78 steps/mm on the X axis and 156 steps/mm on the Y axis.

The next task was to set the appropriate direction bits, GRBL has a setting to make sure the direction lines appropriately, the defaults are acceptable. Finally you test the homing cycle to make sure both axis run up to the limit switches and then stop. The image will appear rotated by 180 degrees because GRBL has the origin in the bottom left and the blacknose has it in the top right. It is possible to modify the GRBL settings to correct this but it hardly seemed worthwhile.

The Software:
GRBL accepts G-Code sent to it via the serial port, so you need 2 additional pieces of software, one to create gcode from your drawings and one to send lines of gcode to the machine. There are numerous way to create G-Code but the one that sprung to mind was DXF2GCode. Most vector programs can output dxf so this solution is independent of drawing package.

It's a very simple offering, the file is loaded and displayed in the main window along with the origin point. You are able to turn each of the entities (drawing lines) on and off as required and you can set the feed speed for the drawing. Because it is intended for all CNC machines it includes options for z axis height but we can just set all of those values to zero. The file created contains a series of G-Code instructions that describe the imported image.

To send the G-Code to the arduino I chose to use Grbl Controller, again it's a cross platform solution and it comes with a few useful Jog functions to move the laser head around which makes it good for testing the machine. A handy text box allows you to type commands directly to the controller. You select the required G-Code file and it is sent line for line to the laser cutter. The laser cutter executes each instruction and cuts your required shape.

Results and Conclusions:
GRBL works on the machine, I was able to cut out the test pattern with only minimal editing of the G-Code. I was a bit worried about the response times, There seems to be a noticable delay between turning the laser on and moving the head. With a CNC mill or a low power laser diode this probably isn't noticeable (or may even be necessary to get the mill up to speed), but with a 40W laser this leads to a burn mark on the work piece.

The is no reduction of power as the laser goes round the corner, This is due to the G-Code being fed into the machine but ultimately it means the corners cut better/burn more than the straight lines when the laser head is moving at speed.

It's an extremely functional arrangement that was pretty simple to set up and get running, There was a bit too much manual tweaking to get it running with the big laser so it's probably best suited for small laser diodes. It's all a great learning exercise, next stop is a serious reduction to the amount of metal work on my laser cutter, before moving over to a Laseraur type controller (whatever that entails)