Wednesday, June 3, 2009

Desktop CNC Router I

I'm excited about my new summer project!! I'm working on a desktop CNC router that I plan to design and build from the ground up. I've been reading about DIY CNC projects, so this idea is nothing new, but in the true spirit of DIY, I plan to design and build everything myself (with the exception of motors and ICs and such). This does however include making my own control software, stepper motor drive circuits, frame, etc....

So here's the basic overview. I'm using the motor from an old dremel tool as the router, 3 stepper motors from Anaheim Automation, an ATX power supply from an old computer (~200W), custom built stepper motor chopper drive, serial connection to a windows computer, and a custom computer program to translate a G-Codes into commands for the motor. I'm leaving the CAD to the professionals.

Step one is to build the stepper motor driver. The circuit is essentially a 3-axis chopper drive for 6 or 8 wire unipolar stepper motors. The micro controller (pic18f452) accepts serial input, conditioned through the max232, as control for the motors. In additions, there is a step and direction pin for each motor, where a pulse train can be used to control the motor. To control the chopper drive I'm using 2 mcp4922, which are 12 bit DACs. The DACs set a reference voltage for the comparators for each motor. When the drive transistor for a coil is turned on, a current begins to flow through the coil, transistor and it's series resistor. As the current reaches the motors rating, the voltage across the resistor reaches the set point from the DAC and the comparator trips, telling the micro controller to turn of the transistor. An internal timer in the micro controller periodically turns the power transistors back on. This way the motors can be driven about their rated voltage, without damaging the coils.

The coils for my motors have a resistance of 1.4 Ohm, so I chose 5W, 0.1 Ohm resistors to minimize the power loss in the resistor. I also picked the power MOSFETs to have a low on resistance, and to operate around logic levels. I had to sacrifice a little bit of voltage and current, but they are still rated higher then I expect to use.

The micro controller communicates to the computer through an rs232 interface, which I will elaborate on more in a post about the firmware. This allows the user to set the limiting current for each motor as well as the chopper frequency through software. This will also be how the computer moves the motors. 
I have the circuit constructed on a breadboard, and am currently working on writing and debugging the code for the PIC. I'm doing the entire microchip code in assembly, so hopefully it will be optimized. With the breadboard, I only had enough room to drive one motor, so last weekend I started building the final board for the motor. It would be easier to get a printed circuit board made, but that costs money (I think I calculated $40 to $60) and I feel like contracting out something that I'm perfectly capable of doing myself is not in the spirit of DIY. Besides, this outer is primarily intended to make circuit boards. So if it works out well, I might have it re-build itself. 

After getting the circuit on the board, I still have a lot of work to do on the firmware. I'm still a little uncertain if I can control all 3 motors in with proper timing. Luckily, after browsing my code, I've realized I still have room to optimize if needed. And I can always ru the PIC at 40MHz.  I also have to work out a way to control the dremel through software. I'm thinking of using the VCO to drive  a V/F converter, in turn driving a triac at the dremel. I've never done this type of circuit before, so I need to look into it some more.