CNC Build – Part 3: Electronics

I’m happy to say that the hard part is over.  Building the structure of the mill and adding the mechanicals into it required the majority of the design because there is no standard way of doing it.  The up side is that this part could be done however I wanted, but the downside was that I had to determine my way of doing it.  Electronics, on the other hand, are much more rigid in design.  When it comes to designing the electronics for a CNC, there is really only one way it can be done, so that’s the way you do it.  When I say that there is only one way it can be done, that is somewhat true and somewhat false.  I actually have two avenues that I could have used, so it is worth weighing the pros and cons of each.

The first route is to have the mill connected to the computer directly.  This is done through a parallel port.  The upside to this is that the computer does all of the g-code (described in my earlier post) processing.  No further processor is needed to run the mill.  There are two downsides, however: a parallel port is required and the computer needs to be close to the mill.  Many computers today don’t have parallel ports because that is a dying technology.  Most new computers have replaced the old parallel and serial ports with USB ports, which don’t help at all in the CNC world.  Also, requiring the computer to be plugged into the mill means that it has to be very close to the mill (same room).  In my case, my computer is in my house and my mill is in my garage.  For this to work, I’d need to have another computer in my garage, which also subjects it to vast amounts of sawdust, which is certainly not good for it.

The second route is to make the mill completely stand-alone.  In order to do this, the g-code  that is generated by the computer’s modeling program is stored on something like an SD card (think of the memory card in your digital camera).  That card is then brought to the mill where a micro controller on the unit processes the code.  The upside here is that the computer does not need to be connected to the mill via a parallel port.  No parallel port is required on the computer, but rather the computer needs an SD card reader.  These are much more common in current computers.  Secondly, because it isn’t connected, it doesn’t need to be in the same room as the mill.  I can design my part in my living room, pop the card out, and then drop it into my mill in the shop without ever exposing my computer to my garage.

If I were to go with the second option, I need to add in a micro controller as a processing unit to read the g-code off of the SD card.  One option is an Arduino.  These are small, inexpensive boards with pretty much anything you’d need for micro controller purposes.  The software used to program them is free and the language is easy to use.  I’ve seen plenty of people program Arduino boards to be g-code interpreters for both CNC mills as well as 3d printers and other robotic manufacturing purposes, but I chose not to go this way.  I worry about adding yet another layer to the framework.  Adding one more piece to the puzzle means adding one more point that can fail.

In order to “Keep it simple, stupid” (I was always offended when my dad said that to me), I’m going with the first route: connecting a computer directly to the mill.  Don’t worry, though.  I don’t plan on using my good computer.  More details on the computer part later on.  Bottom line, however, I’ll be building a small, portable computer specifically for the purposes of designing and milling parts.  I’ll bring this computer out to the garage when I need to use the mill and I’ll bring it back inside with me when I’m done.

Now that we know how the computer is used, let’s talk about the electronics on the mill side.  We know that the mill plugs into the parallel port and we know that the mill contains stepper motors to actuate the motion.  What lies between is just as important.

From the parallel port on the computer comes the parallel cable.  If you had a printer back in the 1990’s, you had a parallel cable.  That is what printers connected to.  Instead of running to a printer, however, it runs to a parallel port breakout board.  I could have made one of these, but I chose to purchase one from  This board is lined with screw-down terminals that represent each of the 25 lines of the printer cable.  The milling software uses six of these lines to send the necessary signals for each of the stepper motors (1 line for direction per axis, 1 line as the “go” signal called the “step” per axis).   The board also contains components to keep the computer safe in case of a malfunction on the mill and vice versa.

Using the six control lines from breakout board, each pair (1 direction and 1 step) per axis is sent to its own stepper driver module.  The stepper driver is a board with circuitry that takes the two signals and compares it to what it has already received.  From there, the board generates two different voltages which are sent through four wires to the stepper motor.  The two voltages represent which step of the 200 per revolution the motor should be at.

Once it is all hooked up, here is how the system works:

The computer reads the g-code and decides the next necessary movement is that the x-axis needs to move a half inch to the right.  A setting in the software allows the user to set the number of steps per inch.  In my case, there are 3200 steps per inch so the software knows that a half inch equals 1600 steps.  The x axis uses lines 2 and 3 in the parallel port; 2 being the direction and 3 being the step.  It turns pin 2 on (electricity is flowing through) to illustrate that it is moving to the right instead of the left.  It then turns pin 3 on and then off 1600 times.  The stepper driver board that is connected to the #2 and #3 terminals on the breakout board see the combination of the 1600 steps on pin 3 and the “on” signal of pin 2 and it understands that this means 1600 steps clockwise.  It sends corresponding power through the four leads to the stepper motor to cause it to turn 1600 1.8 degree steps clockwise; a total of 2880 degrees.  This in turn spins the lead screw clockwise 8 revolutions, which in turn moves the t-nut .5 inches closer.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: