Teensy

I promise to get back to my woodworking posts soon, but I do want to make a quick note about an electronics platform that I’m eager to try. 

The teensy platform has caught my eye recently.  While I’ve been an Arduino guy for some time, this one looks like it would give me a little more power and flexibility.  The benefits include more digital I/O pins, more analog inputs, and more PWM pins.  It is roughly the same size as an arduino pro mini, but has onboard usb.  Furthermore, the usb is runs natively, unlike the arduino which relies on a usb to serial bridge.  By running natively, the teensy can appear to a host computer as any other regular usb device such as a mouse, keyboard, etc.  If that isn’t enough of a plus, the teensy is also cheaper.  For $16, you get 25 digital IO, 12 analog in, and 7 pwm versus $19 for an arduino pro mini which gives you 16 digital, 6 analog, and 6 pwm with no onboard usb.

Advertisements

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 http://www.cnc4pc.com.  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.

CNC Build – Part 2: The Mechanicals

The idea behind a CNC is that the unit moves the router around on its own.  This being the case, I needed to design a way of incorporating automated movement into my mill.  Turning from woodworking to electronics, I began planning how I would move the various parts of my mill electronically.

Relying on every other CNC mill that I’ve seen, plus all of the robotic theory at hand, the obvious choice for my actuation is stepper motors.  Stepper motors, like regular electric motors, can spin continuously and can turn in either direction.  Unlike a conventional motor, however, a stepper motor moves in precises increments called “steps”.  If you add power to a regular motor, it will spin until power is turned off.  In this fashion, it is difficult to specify how many degrees the shaft has turned.  With a stepper, however, it will only turn one step.  The motors I purchased have step of 1.8 degrees.  This means that I can control the rotation of the shaft by 1/200th of a turn.  Regardless of voltage or amperage supplied to the motor, it will only turn 1.8 degrees at a time.

Using a stepper motor, I can control rotation, but I need to convert that to distance across an x, y, and z axis.  There are several options I could have used to convert rotational movement to linear movement.  The two common ones in the CNC universe are belts and lead screws.  Using a belt, the object that must move linearly is attached to a point on the belt.  As the motor turns the belt, the object moves accordingly.  This works nicely, but I chose the other route: lead screw.  Attached to my stepper motor is a 3/8″ diameter threaded rod.  The rod passes through the object via a t-nut.  As the lead screw turns, the t-nut threads up and down the rod, moving what the nut is attached to accordingly.

In my CNC, I will have three lead screws; one per axis.  Each lead screw has its own stepper motor.  As I had mentioned, the stepper motor turns in 1.8 degree steps which means 200 steps per rotation.  The threaded rod had 16 threads per inch (a nut would have to turn 16 full rotations to move one inch).  This equates to 3200 (200 x 16) steps per inch, meaning that each axis will have a resolution of 1/3200″ (minus any slop).  I feel pretty good about those numbers.

CNC Build – Part 1: Mill Design

I’ve spent a few weeks toiling over possible designs for my CNC mill.  I’ve fought to keep a balance of effectiveness and simplicity.  I want it to be a full-fledged CNC, but I also continue to hear my dad’s voice in the back of my head reminding me of the engineer’s cardinal rule: K.I.S.S. (keep it simple, stupid).  The key element was that it needed to work without requiring hard-to-find or expensive parts.  This project is meant more as a way to prove to myself that I can produce something this complex and less of producing something that will be immensely helpful in my long-term woodworking.  That being the case, I didn’t want to spend a lot of money on this if it turns out to be a massive failure.

With this mindset, I came up with the following criteria:

  1. The unit will be made of wood.  Metal might be stronger and might last longer, but if I find that a part of my design isn’t working, I won’t feel bad about ripping out a 7 inch long chunk of 1×6.  That kind of mistake only costs a few cents to fix.
  2. A CNC that can cut a 4’x8′ sheet of plywood would be really cool, but A) I don’t have space for that in my garage and B) what would I be working on that would need computer-controlled cutting of something in that scale?  If I’m going for the detail that only a computer can give me, it is bound to be something small anyways, so the max size can and should be less than 24″x24″.  This will give me a mill that can sit on the corner of my workbench when not in use.
  3. Pre-engineered electronics.  Yes, I could probably design my own circuit board for a 3-axis stepper driver, but why?  So many already exist.  I don’t need to re-invent the wheel on this one.  Furthermore, interfacing the drivers with the computer via the parallel port is done with a breakout board.  These, again, already exist.  I don’t need to design my own.  It may cost a few dollars more, but it is just that: a few dollars.  In the grand scheme of things, the extra $10 it will cost to buy pre-designed electronics will save me more than that in the value of my electronics R&D time.

So I sat down behind MS Visio (a tool I love for my woodworking projects) and began to mock up mill designs.  Using elements of mills I had seen in other people’s projects, I came up with what I call CNC-V1.

In version 1, a fixed gantry is centered over a 2’x4′ unit.  The table slides back and forth under the arm for the Y axis.  The arm contains a sliding panel to create the X axis.  The sliding panel holds the router carrier, which moves up and down for the Z axis.

Design of the first version of my mill

The Y axis table contained bearings with a grove in the middle, which were designed for sliding patio doors.  These ran across the edge of steel angle iron, which was bolted to the bottom of the unit.  Overall, this worked.  The table top rolled nicely over the angle iron, but the unit was much too big.  This type of design requires twice the footprint of the maximum carving size.  Back to the drawing board.

After a few days, I found a concept that I liked.  Rockler sells a CNC mill that uses a moving arm instead of a moving table.  This allows for a smaller footprint.  Their CNC is a couple thousand dollars, but I figured I could create the mechanicals of mine for under a hundred.

Top of my second cnc design

Here, two under-mount drawer slides are attached to the top of the base.  These  support a cross arm which then rolls across the depth of the unit (Y axis).  A stationary table is then supported above the arm.  The arm is then attached to two uprights to support the X axis as it did in the first version.

The drawer slides worked significantly better than the v-groove bearings on the angle iron.  Tolerances are much tighter and the fear of the bearings lifting off of the angle iron was removed.  The only issue is that when the arm slides back, the upper part of the two drawer slides extend out of the base.  This was not an issue since the table support across the back could be shortened to allow them to pass by.  I found this to work so well that I’ve changed the X axis to be based on the same slides.  For $10 a pair at Menards, this was a fantastic find.

One Friday night and one Saturday morning and the unit took shape.

Photo of the cnc

At this point, the upper slides are attached and a panel connects them.  A stub of a 2×4 comes off the back of the panel and passes between the 1×4 upper arms.  I still need to design the Z axis, but I assume it will act much like the first two.  Stay tuned for updates.