CNC Router

2016-01-18

(CNC,Arduino)

I bought a CNC router model 3020 from Alibaba, and had an interesting experience setting it up. In the end I set it up with an Arduino running the GRBL G-Code interpreter, which is perfect for my needs.

The router is advertised as an engraving machine, but I thought it looked sturdy enough to route plastic and wood. There are videos out there of people cutting aluminium using the machine, but I have not tried that yet. The machine has a motor control box with a parallel port at the back. Initially I intended to plug it directly into a Linux box running LinuxCNC software, and purchased a parallel card for my main machine to do that. However I had a difficult time getting the parallel port to work (queue rant about manufacturers not giving a crap about Linux support) and gave up in the end. So a nice expensive CNC router with no way to drive it...

I was about to get an old PC for work with an onboard parallel port, but then came across a project called GRBL. It's a G-Code interpreter running on an Arduino, and is designed to interface with the kind of controller my router has.

After some basic tests running GRBL I got a spare case and mounted the Arduino inside. I had a definition if the pinouts for the parallel port from here (which interestingly also has info about hacking in limit switches), so wired the Arduino up to the appropriate pins:

Arduino with GRBL wired up to the parallel port

Here is a closeup of the pin connections on the parallel port. Note: There are only 6 pins connected at this point, three axis direction pins, and three axis step control pins.

Parallel port side pins

To my complete amazement this setup ran out of the box. I used the Arduino development environment to connect to the Arduino over USB serial, and was able to make the machine move by manually typing G-Code commands. I am really impressed with the GRBL developers for being able to squeeze a fully functional G-Code interpreter into an Arduino. I have not had any problems with this software - it works like a charm!

I have since used the machine to cut a bunch of shapes by generating G-Code on my desktop, and loading this by streaming it to GRBL using the reference Python script included in the distribution.

The machine does not have end stops yet, but I have figured out a workflow that I quite like that doesn't use end stops. Essentially I generate each shape I want to cut at origin (X=0,Y=0,Z=0) and then start the spindle and manually manuver the machine to where I want to start cutting. I then manually wind the spindle down until it just touches the plastic and takes barely a scratch off the surface. That is my Z=0 axis position.

In G-Code I make a test cutting path, which raises the spindle by 2mm and traces the path of the shape, returning to origin and placing the spindle back at Z=0. This tells me if I have any obstructions, or if there is a bug in the G-Code. I watch this fairly carefully, so I don't have to worry when it's really cutting. From a Z=0 position the G-Code takes cuts below 0. For 4mm plastic PVC I usually take 2mm cuts, with a final 1mm into a sacrificial wooden layer of board under the plastic to make sure the cut is all the way though. Lately though I think I could be taking the full 5mm cut in one go without too much hassle.

This system works pretty well for me. If I wanted to take it a step further I could model the full sheet of plastic in my G-Code software, and cut all parts of a design in one foul swoop. However with my tank chassis I found I had made a mistake in a dimension in my design, and it was nice to be able to test out the parts one by one as they were cut.

I took a stab at adding end-stops to the machine, but I never got around to wiring them up. To do that I cracked open the motor driver board:

Inside the motor control unit of the 3020

And searched for the unsoldered 6 pin header at the back of the board. I wired this up to three RCA sockets on the back of the driver box, and was going to have plugs that ran to the switches.

The driver board of the 3020

This is how I mounted the Y axis rear end stop. I cut a bit of aluminium L-shaped bar, and then drilled and tapped two M4 threads into the body of the machine. What is not shown there is I also drilled and tapped a hole directly opposite the roller on the switch arm. I then put in another bolt, but with a nut so I could screw the bolt out to the correct clearance for activating the switch, and then tighten the nut against the body of the machine to keep it in place.

Top view of the Y axis rear end stop

Here you can see a bit better how I mounted the L-shaped bit onto the router.

Underneath the Y axis rear end stop

I should really finish that at some point.