Featured image of post Raspberry Pi Laser Engraver and Drilling CNCs

Raspberry Pi Laser Engraver and Drilling CNCs

Exploring the creation of CNC machines using Raspberry Pi for laser engraving and drilling.

Raspberry Pi Laser Engraver and Drilling CNCs

Whilst working as a software developer on my gap year, throughout late 2016 and into the Summer of 2017, I had fun with a couple of electronics projects. I thought it’d be interesting to build a CNC machine of some description, and saw some people had done so online with scrap. After a trip to my local recycling centre, I salvaged some old e-waste PCs to get some disc drives and a floppy disc reader. I then resoldered, and reprogrammed the stepper-motor controlled linear drives to allow programmatically controlled precise movement. By mounting two of these linear drives perpendicular to each other, I was able to accurately control the position of each of the X and Y axes. By attaching a pen to one linear drive, I was able to start using this simple ‘plotter’ to draw some basic shapes.

In the early days of this plotter, I programmed shapes by typing numbers into the code by hand, sometimes drawing out the shapes manually and using a ruler to measure the dimensions I was trying to replicate. The quality of this plotter was very poor, but given it had been built entirely from either parts found at a local tip, or lego, with many hacks to get things working I was pleased to get any sort of result at all.

Technical Info: The four-phase stepper motor is a common sight in consumer disc-drives, to date I’ve probably disassembled a dozen and all but one have used a stepper motor combined with a worm gear to slide the carriage back and forth. To control them myself I resoldered new wires onto the motor and used an L293D dual H-bridge driver to control the sequence of pulses for each axis.

By writing some very basic drawing software in java, that exports a file similar to G-code readable by a control script for the Raspberry Pi, I was able to turn these linear drives into a simple, but reasonably accurate, CNC drawing machine.

One of the first plots I tested was a basic sinusoid, to test the capabilities of the CNC when plotting both curves and straight lines. I later made a standalone python script that could process and plot monochromatic bitmap images directly, which allowed the printing of more complex images, and I tested this by printing off several crests and emblems.

Although my first plotter worked very well, I had basically rebuilt the printer except with a far more convoluted and less effective design, and whilst being a fun gimmick it had limited practical use. I felt the ink pen was limiting the possibilities of my design, so I decided to upgrade the pen to a laser. I purchased for around £25 a 200mW 650nm laser module - the diode was housed in a heatsink and had focusable optics - which I powered with an ATX power supply, salvaged from the same discarded PCs as I got the disc drives. I managed to get some great results burning away into some old cardboard, although the laser had no problem scorching wood either.

The final step of this small scale CNC was to modulate the laser using PWM, and to alter the speed of the lower tray to achieve a different intensity of burn as desired. This allowed the processing of greyscale bitmaps, culminating in a very nice laser-engraved cardboard Mona Lisa.

Mona Lisa

For the time-lapse of the laser CNC printing out Mona Lisa, and some footage of how the CNC works, please see the videos below.

After the success of the small scale CNCs, I decided to set to work on building a full scale version capable of wielding a rotary tool to engrave and/or cut a wider range of materials. This next iteration was also built from scrap, this time mostly using discarded printers instead of disc drives. This whole CNC was extremely economical using almost entirely recycled parts, with my only purchases being the rotary tool itself (a cheap Dremel knockoff from Amazon for £11) along with three stepper motors (£1.75 each), 20 ball bearings (£3-4), some threaded rods (£2), and miscellaneous nuts and bolts. I also built a much more sophisticated control script, that runs in python and is able to interpret G-code files to control the CNC accordingly.

The (outdated, see below) code for the G-code interpreter can be found here.

As can be seen from the video above the scrap-based full-scale CNC was functional, but had several systemic problems due to its bare-bones design. As such I decided to up the ante a little bit, and after buying some rectangular metal bars to use as rails, wooden planks for the frame of the CNC, and a few other miscellaneous bits and bobs I was able to put together a more sophisticated CNC that was not limited by my working with scrap materials. Many, many, failed designs, ball bearings, and trips to B&Q later I eventually came up with a working design which I replicated on each axis of the CNC, to build a functional large scale milling machine.

The much updated and far more sophisticated python program to control the full-scale CNC can be found here.

My first full scale tests of the new CNC are now on Youtube and they worked fantastically! More to follow in the next couple of weeks…