This is some documentation for my CNC motion control board and it is currently an work in progress.

CNC Controller Motion Board Design Notes (Rev. D)

With each revision of my board I learn things to make the next version better. The previous revision C worked but was still overly complicated. This is where I keep my design notes as I make design decisions:

Homing
I will distinguish between two kinds of homing here -- accurate and approximate. Accurate homing is when you get the machine to exactly the same position within the positional accuracy of the machine. Approximate homing gets the machine to approximately the same position with some modest amount of positional error. Approximate accuracy can be acheived with a fairly simple homing switch on each axis. Accurate homing probably needs a more accurate homing switch and probably some sort of index mark on the axis motor. As I thought through the issues I came to the following conclusion -- neither accurate or approximate homing is worth the hassle of implementing. Accurate homing can be maintained by simply leaving the machine on and always reposition the machine under CNC control. If the machine is powered down, the CNC controlling software can remember where it was before power down and simply assume that it has not moved since. Hence, for this version of the system, there is no support for homing; just leave the machine powered up.
Limit Switches
There are two purposes for limit switches -- safety and homing. Limit switches can be used for approximate homing. My opinions on homing are discussed above; I do not think the effort of designing a system to use limit switches as an approximate homing system is worth the effort. There are two safety issues associated with limit switches -- human and machine safety. For machine safety, the purpose of tripping a safety switch is to protect the machine from damaging itself. For human safety, while the machine is potentially damaging itself, it might also be generating high speed projectiles that damage a nearby human. Other forms of tool failure can also generate high speed projectiles. The best solution for stopping high speed projecties is an enclosure. Given the relatively small machines being targeted here, I am going for a very simple strategy of removing power from the stepper motors, selenoids, and spindle motor. This can be done by wiring normally closed limit switches in series and detected when the circuit is broken by tripping a limit switch.
Emergency Stop
The purpose of emergency stop is to stop the machine from damaging 1) a person, 2) the machine itself, and 3) the work piece. Just like the limit switch strategy, I intend to have the emergency stop switch be wired in series with the limit switches. This is a simple and effective emergency stop strategy.
H-Bridge Selection
When it comes to choosing H-Bridge IC's, there are some hard choices to make. It is fairly easy to take 8 IRF640 MOSFET's and build a couple of very powerful H-Bridges that work in the 18 amp range. Since IRF64's are avaiable for about ~$.70/each, it is hard to justify spending much more than $6-$7 per axis. There are very few H-Bridge solutions at that price point. All I found were the A3977 and the good old L298. While I like the A3977, they do not have a very good selection of application notes. In particular, I could not really figure out how they wanted to deal with excess heat generation. Conversely, the L298's are quite easy, just slap a heat sink on. Maybe in some future revsion of this controller I will switch over the the A3977, but not for this revision.
Chopper Design
Rather than use two PIC16F268's and a MAX548A to control the chopping of the L298's, I think it is possible to use a single PIC16F676 instead. This is done by using a couple of channels of the A/D to read the sense voltage across the sense resistor. The single PIC16F676 implements a simple step and direction interface that can be directly attached to a parallel port interface. PIC16F676's are really cheap.
Axis Connectors
I originally wanted to use DB-9 connectors for the axis connectors because they can be screwed in, but I am short of PCB edge space. The current thought is to use .8" wide DIN 5 connectors (a good suggestion from somebody on the net with a nom de plume of "ballendo".) Alas, the DIN 5 connectors have a current limit of 2 Amps per pin.
USB
For USB support I intend to use the Microchip PIC16C745 with built in USB hardware support. This chip is basially pin-for-pin compatible with the PIC16F876A except three pins are set asside for USB support. Alas, this chip is OTP (one time programmable) so I will have to purchase the UV window version of the chip and develop with the ever so painful waiting 20 minutes or so for the UV to erase the part. Sigh. The rest of the firmware can be developed using the flash memory of the PIC16F876A.
Spindle Motor
Being able to control a spindle motor seems like a good idea. The problem with spindle motors is that they operate in a significantly different power regime than the stepper motors on this board (i.e. fractional horse power motors.) I suspect that most spindle motor controllers use some sort of 120VAC circuit with no corresponding issolation transformer. For this reason, I decided to push the power electronics for the spindle motor off this board, but left the control electronics on board. The control electronics are a RS-422 signal that can pulse the spindle motor on and an RS-422 tachometer circuit to measure speed.
Parallel Port
The parallel port will connect directly to the PIC16F676's step and direction lines. If no serial control is needed, the PIC that controls the serial lines will simply tri-state the lines attached to the step and direction lines. There is nothing that can be done using the serial interface that can not also be done using the parallel port interface.
Schottky Diodes
The schottky diodes needed by the L298's will be mounted vertically to save board space and improve heat transfer.
Selenoids
One of these days I would like to support an a coolant pump and automatic tool changer -- nothing has sophisticated as Joe Vicar's Automatic Tool Changer but with similar functionality where the tools are stored on the edge of the table. I figure I can drive two selenoids with a single L298, so why not try to add that to the design.
Probe
A single bit of probe input via RS-422 or simple switch is be provided. The parallel port feeds this bit back.
VDC Power Supply
The power supply is assumed to be off-board. I am planning on a single 24-VAC at 12 amps transformer (Jameco: 221410CX), an full wave bridge rectifier (Jameco: 179477CX), and a big 10,000 µF filter capacitor (Jameco: 157373CX), along with a power switch and fuse. A bleeder resistor and LED are on-board to discharge the capacitor after power off. The 24 volt transformer is measured in RMS and actually generates a peak-to-peak voltage of 34 volts minus bridge rectifier losses. While this is well less than the 48 volts system is capable of accepting, the hassle of adding another 10 volts is not really worth it. This may restrict the rapid moves by a little, but not significantly.
Enclosure Considerations
It seems quite important that the controller be designed to be stuffed into an enclosure. Since it is hard to find a premade enclosure that is "exactly" the right size, I am assuming the an over sized enclosure will be used. In this scenario, the controller board will have to live stuffed into a corner of the box with connections along two edges of the PCB that share a common corner. Since the controller board is EuroCard sized (100mm × 160mm) This gives me a total edge budget of 260mm. This not a lot of space to play with. I am currently planning on putting the parallel port connector (2.10"), the RS-232 connector (1.20") and USB connector (.50") along the short edge. Since this adds up to 3.80", this is only .1" of margin to leave between the connectors. This is way tight. Along the other edge, I need to put 4 stepper connectors, the selenoid connector, the motor/tachometer connector, probe connector, and limit switch connector The stepper and selenoids are on a 5-pin DIN connector which is .8" wide and the others are on a 6-pin mini-DIN connector that is .5" wide. Since 5 × .8" + 3 × .5" = 5.5", I should have a little margin left over on this edge.

The PIC16F676 only has 14 pins and they are allocated as follows:

PinsUse
2H-Bridge 1 Control
2H-Bridge 2 Control
2Current Sense for both H-Bridges
120 MHz Clock
3Commands
1VRef
1Reset
1Power
1Ground
14Total

The commands are as follows:

Cmd2 Cmd1 Cmd0 Description
000Do nothing
001Execute command; then clear it
010Step clockwise
011Step counter clockwise
100Do Nothing (Command mode)
101Shift 0 into command register
110Shift 1 into command register
111Do nothing
The Cmd2 pin is shared across all the axes. Thus a single parallel port plus a single additional output bit (one of 4 available) should do the trick.

The commands have yet to be determined, but essentially the will allow the specification of the stepping table -- full stepping, half stepping, quad stepping, etc. In addition, individual values can be down loaded into each table. Each table entry is 8-bits. The PIC16F676 is operating at 5 volts and the A/D is in 10-bit mode. The table assumes that the upper 2-bits are from an A/D conversion are zero. Thus, 0 corresponds to 0 volts and 255 corresponds to 5×255/1024 or approximately 1.25 volts. With a .5 ohm sense resistor this corresponds to 2.5 amps. Since the L298 should not be operated continuously at more than 2 amps, the firmware limits the top table entry value to 204. Additionally, there are commands to set the table position and the minimum delay between turning an H-Bridge off.


Copyright (c) 2001-2005 by Wayne C. Gramlich. All rights reserved.