Let's convert an inexpensive Chinese CNC machine from Parallel Port to Arduino and GRBL.
Alright guys, this is a culmination of weeks of reading, researching and determination. It's my first instructable so hope this helps get you where you need to go.
A little bit of background, before we start:
The 3020, 3040 and 6040 (and the more obscure 2015, 2016 and 2020) CNC router milling machines that come out of China are hugely popular in the hobbyist and professional circles. If you are a DIY type, these machine offer a great way to repeat processes and basically do some things that no hand tool will allow you to do. For the professionals, these machines with their relatively accurate leadscrew/ballscrew assemblies allow for another machine to be pumping away making parts if the machine machine is occupied with a job. All in all, these inexpensive machines (ranging from $600-2500 shipped DHL) are a great way to get into CNC. They can be found all over eBay and Aliexpress, in my experience, you can find marginally cheaper options on Aliexpress and their buyer protection is much better than eBay's.
The model numbers denote the size of the workable area, ie. the 3040 is 30cm x 40cm, the 6040 is 60cm x 40cm etc etc. The range of these models makes for choosing the right one for your shop pretty easy, the more expensive and larger ones (typically 3040 and 6040) will have the more accurate ball screw type linear movements instead of a typically trapezoidal lead screw. the 2015, 2016 and 3020 machines (some 3020 will have ballscrews) will have a nylon or Delrin type nut for linear travel.
You can tell which model has the leadscrew or ballscrews by the letter after the model. 3040T will have "trapezoidal leadscrews" and a 3040Z will have ballscrews (ballscrewz?) :D
I have experience with both the ball screw and lead screw type movements, for the money you are paying, it's better to get a machine with ball screws as they wear better and very little, if no backlash (side to side play) is present. These machines will come setup with stepper motors and typically have cable tracks already built in, also they will come with a controller box.
The controller box on almost all of these machines will come with a very old Mach 3 style Parallel Port interface. Signal pulses will be sent from the Mach 3 software to the port and that drives the motors and makes the CNC machine come alive. This type of system is old, dated and is Windows only. I have been a Mac person since 2003 so I won't switching back to PC's anytime soon, so when I heard you could convert this to Arduino powered, I went from "that CNC is a neat tool" to "that CNC will be mine".
Step 1: Gather Your Bits and Bobs
So, after that long winded introduction, here's how I changed over a 3020 machine with the following bits and bobs:
1) 3020 CNC machine http://www.aliexpress.com/wholesale?catId=0&initi...
2) Arduino Uno (a clone will also work)
3) Protoneer CNC Shield V3.XXX (new boards are due any time now, clones are also available)
4) 3 x A4899 Stepper Motor Drivers (these attach to the CNC Shield, make sure they attach in the right direction!)
5) 3 x 4 Pin Dupont Female Connectors (one for each axis, the board will show you where to attach them)
6) Shielded USB cable (for Arduino, this should be long enough to go from the controller box to your laptop/PC)
7) GRBL firmware http://www.ebay.com/itm/Arduino-CNC-Shield-V3-10-G...
8) G-code generator of choice (inkscape plugin, makercam, JSCUT)
9) G-code sender of choice (Universal G-Code Sender, GRBL Controller, Chilipeppr, etc etc)
Step 2: Crack Open the Controller Box.
You'll see in the video that the conversion is complete, but when you crack open the box, you'll basically see three main components.
1. The power source, this will either be a coil or in my case, a perforated metal box. It will have the main power leads coming from the inside. One set of DC wires will be connected to the driver board...
2. The driver board, you'll recognize this because the leads from the connection cables to the XYZ ports will be attached to this. If you had a board like my 3020, they will be super easy to undo since they are screw terminals. Just undo them and you can pull them out. The power leads from the power source should also be present, this also needs to be undone)
3. The spindle VFD (Variable Frequency Driver), this maybe a closed box or an open circuit board. You'll recognize this since it will have a control board and dial to control the spindle speed.
If you forget the label the XYZ cables, don't worry, just follow them to the ports on the back and you can see which is which.
Step 3: Prep the Arduino and CNC Shield.
The Arduino needs to be flashed with the most current version of GRBL. What does GRBL stand for? No idea, jury's still out.
GRBL is an open source G-Code interpreter, it is to CNC machines as Marlin firmware is to 3D printers. You can find it here: https://github.com/grbl/grbl
Once you have GRBL on your Arduino, you can mount it into the case. BUT before you do that, you need to remove the old parallel port driver board. Don't throw it out, there are likely some awesome electronics components you can salvage from it. You've already undid the wires so this shouldn't be too hard.
I had to mount my Arduino board first with a couple of screws (into the screw bosses from the old board) before attaching the CNC Shield.
Step 4: CNC Shield Physical Settings
The CNC Shield has spots for 4 driver chips. It accepts the A4988 or the DRV8825, the later being more powerful and able to accept up to 36volts and 1/32 microstepping.
I only had A4988 available, so I went with those.
Before installing the driver chips, you have to decide how many micro steps you want to have your machine run at. Rule of thumb is, the more micro steps, the smoother the motions, but lower the torque. Vice versa, the less micro steps, the more torque the stepper motors have.
You have to use jumpers to set how many micro steps, I wanted 1/8 microsteps, which I believe is a good compromise between smooth motion and torque.
To find out how to set this up:
CNC Shield NOTE: I have a clone of the CNC Shield V3, so my jumper settings differed from those advertised on the Protoneer blog. This could be an anomaly, or it could be a wide spread board mistake.
NOTE: when installing the driver chips, make sure they are installed in the correct orientation. You can see on the board where the pins for the stepper motors and on the drivers chips you will see which set of pins need to be going towards the pins. Alternative, you can just look at the many many pictures of the CNC Shield online.
Step 5: Solder Stepper Motor Leads
Ok...so you've removed the XYZ cables from the old driver board, the Arduino and stuff is mounted...now you need to interface the old with the new.
The XYZ cables will need Dupont female connectors to connect to the CNC Shield. You can do this a few ways, the easiest way was to make up a female connector with leads that you can solder the old cables to. The cables will already be colour coded into pairs so try and keep them in the same orientation. It will be RED/RED and BLACK/BLACK, not Black/Red, Black/Red. Conventional electronics wisdom says so but this time its not.
Stepper motors work 2 pairs of leads, this dictates the direction they push when a current is put through, if you find that the direction is reversed when you fire up the machine and jog around, its a simple matter of taking that axis lead on the board and turn it 180 degrees.
Step 6: Connect Power, USB, Arduino and PC
For my conversion, I have a dedicated USB cable that I put into the Arduino and it just simple comes out of the control box, I didn't bother positioning board so I can unplug it. This USB plug not only connects your computer to the Arduino, but it also powers it.
The CNC Shield also needs power, this is to power the stepper motors. The power does not feed into the Arduino, so don't worry about frying it. There should be a screw terminal to attach the lead from the power supply to the CNC Shield, do this.
Once you've attached it, you can fire up your favourite GRBL controller software.
Step 7: CUT! ENGRAVE! DO STUFF!
That's it...this may seem like a long process but honestly, if you've read this entire thing, it will have taken longer to read this than it would be to convert it. This whole process took me about 45 mins.
So...if you didn't watch the video. Here it is again.
Step 8: BONUS! Math!
Here's a quick mini tutorial on finding out the value to put into your GRBL settings for the correct amount steps for translating designs into the real world accurately.
A typical stepper motor has 200 steps PER revolution. These are known as FULL steps or 1.8° per step. This setting has the most torque and is the fastest, however not the smoothest.
Most of these machines will list the kind and size of lead/ballscrew it has. On my 3020, the lead screw is 1404.
14: 14mm diameter of the screw thread (OD)
04: 4mm pitch (or the distance between threads)
We are mostly concerned with the 04 number since it describes the amount of linear travel something connected to the lead screw will travel with ONE revolution. So a 1205 thread is 12mm diameter and 5mm thread size, so on and so forth. This also applies to ball screws, 1603 is 16mm diameter and 3mm thread size.
Now we can connect the two numbers together.
The settings in GRBL call for a PER mm number so its a simple math really.
200/4 = 50 steps to make something travel 1mm
(if we have a 3mm thread, it would be 200/3 etc etc)
50 is the number I put in GRBL
Heres where we get fancy, micro stepping.
I have my CNC machine set up to be 1/8 micro stepping, which means each step is divided into 8 microsteps.
200 steps x 8 micro steps = 1600 total steps/rev
The same math applies
1600/4 = 400 steps to make something move 1mm (again, if your thread is different, than the divider number will be different)
400 is the number I put into GRBL
The more steps the smoother the motions, but slower it will be and less power on the torque.
THANKFULLY, the Chinese CNC machines are all metric, which makes this math very simple. If these were ACME threads, there would be some metric/imperial conversions which would result in some very odd numbers.
Ok now go cut yourself something fun!