Tuesday, March 23, 2010

Making it move

Once all of the mechanical parts of the CNC machine are together, I'll need to make it move.  Each of the 3 axes is attached to a nut.  This nut is driven up and down the axis by a lead screw which spans the entire movement range of the axis.  a stepper motor turns the lead screw in precise increments allowing the computer to control exactly where the cutting tool moves.

But Rick, what is a stepper motor?  Regular DC motors spin when a current is applied to them, but there is no way to know how far it spins with the motor alone (sure you could attach some sort of rotary encoder, but then you'd have to carefully meter current to the motor which would change depending on the load applied and there is an easier way).  There are two popular types of motors that you can turn precisely, Stepper and Servo.  Servo motors are commonly used in RC vehicles and killer robots as they can take a position signal (usually a PWM signal) and turn to that degree of rotation.  They cannot however, spin indefinitely.  A stepper motor controller on the other hand, takes two binary signals, direction and step, and moves the motor the specified direction a set amount every time the step signal pulses.  This means the stepper motor can turn as much as it wants in either direction, and knows how much it is spinning, but it doesn't have any sense of a zero position so it has no way of knowing where it is in it's rotation.  To overcome this limitation, the CNC machine will need to zero itself when it starts up.  This process is called homing and is accomplished by slowly moving each of the axes toward it's zero position until it hits a limit switch.  At this point the controller software will know the physical position of the machine and has the ability to move each axis a precise amount, so it can keep track of where it is.

Unfortunately you can't just plug a stepper motor into your computer and expect it to work (well, you could probably get a really really small one to work, depending on how much current your parallel port can source).  You must have an intermediary board which takes output from the computer and turns it into driving current for the stepper motors.  There are two reasons for this.  The first reason I just mentioned: current.  The easiest way to communicate with a stepper motor is with the parallel port since it was originally designed to drive printers (which use stepper motors, hey look at that!).  A parallel port can only produce a small amount of current as it's designed for signaling, not driving.  So the driver board takes the signal from the computer and steps it up to be able to drive a big motor.  The  second reason to use a driver board is to have someone else deal with the complexity of driving the stepper motor coils.  Instead of one coil like a normal DC motor, a stepper motor has a series of 2 or more coils.  these are energized in certain orders to produce the incremental rotation.  Check out Wikipedia's article on stepper motors for a more detailed explanation on their inner workings.  The driver board I used is based around a stepper motor driver chip.  You supply the chip with power, a direction signal and a step signal and it will create the correct pulses for the stepper motor.  it also takes care of microstepping.

I bought a driver board kit from hobbycnc.com.  It comes with 3 stepper motors, a PCB, all of the components to be soldered to the PCB, parts for the power supply and a bunch of other odds and ends.  All you need to get is a case and a transformer for your voltage.  Here's a picture of the semi finished product:

I foolishly purchased a steel case to put everything in without thinking of how much of a pain in the ass it will be to cut holes in the front panel for all of the connectors.  Live and learn.  Hopefully the CNC machine will be strong enough to mill the front panel of it's own controller box.  in the mean time, there will be wires all over the place.

The motor controller also connects to the computer that will ultimately control the whole machine.  I was lucky enough to find a computer in a box in our apartment (I think it was the old hardware from my server) a few weeks before embarking on this project.  The hardware is nothing special, plenty powerful enough to run the control software.  I used the Ubuntu 8.04 release of EMC2.  The control software translates a special kind of machine code called G-Code into physical movement instructions for the machine.  I've only begun looking into generating and using G-Code, so expect more details later.

So, to recap, Computer takes special code and turns it into direction and step pulses for each of the 3 axes which it sends to the motor controller box via a parallel port.  the motor controller takes those signals and energizes the appropriate coils of the stepper motors attached to each axis which turns a screw, which moves a nut that is attached to a part of the machine which in turn, moves the cutting tool.  Simple.

1 comment: