Last year I bought myself a modest mill/drill for my birthday/christmas/St. Leonard's Day presents for the next several years. I'm still not sure about how good of an idea it was to spend that money, but I have had quite a bit of fun with it.
One thing that I soon found myself missing was a set of digital readouts. While one can keep track of the position of the cutting head using counted revolutions of the feed axes, it is laborious (especially for long travels), doesn't account for feed slack, and is only marked in decimal inches.
Packaged, professional DRO's can be bought off the shelf, but they're too pricey for most hobbyists (certainly for me). I had previously seen reasonably priced digital calipers of unknown quality on eBay, and after stumbling across an article on the communication protocol used in their on-board data port, I decided to see if I could build my own readouts using digital calipers as the indicator axes.
The calipers:
From eBay I purchased 6", 8" and 12" digital calipers for a total cost of about $100 including shipping. After a long and distinctly unsatisfying customer service experience with the vendor, the calipers finally arrived, and I checked them against a calibrated $300 Mitoyu caliper at work. They were off by up to 0.06mm along their length, which is actually better than I expected. For the sort of work I'm doing, that sort of inaccuracy is going to be small compared to machine and hold-down flex, way slack, and lack-of-skill-introduced-error that will happen, so I moved on to getting that signal out of the caliper and into a PC.
The translator board:
Chinese knock-off calipers transmit positional data at a regular rate through two pins on their data port. www.shumatech.com has an excellent article on the nature and voltage levels of that signal, without which I would not have been able to pull this off. My thanks to them.
This signal needs buffering, amplification from 1.5V to something a voltage a computer or controller can use, and translation from a 24 bit relative position stream to a series of bytes which can be read into the PC. For the first two I used a simple NPN inverter with 10k on the base and a 1k pullup to 5V on the collector. Conversion of the data stream is done using a PIC16F628A running at 20Mhz, which reads in the bit stream, parses it into bytes, appends start and stop bytes, and sends them via RS-232 to the PC.
The PC:
An interrupt running on the PC (an old P-133 desktop bought at a garage sale for $20 including monitor and keyboard), stores incoming serial bytes in a buffer. The display program (written in Turbo C++ 2.01 from 1991!) polls the receive buffer, and if there are enough bytes therein to possibly constitute a message (5) decodes it. If new position information was received, the new position value is placed on the screen.
I also included a number of functions in the PC display, such as allowing axis rescaling, arbitrary offsets, multiple origins, and three stored positions. Adding such features in the PC side software is quick and simple (at least as far as my software skills go). I intend to add such things as hole centre finding, and midpoint finding, working off the registers, but there's been no hurry.
This was a very educational project. As well as ending up with a nifty 3 axis readout, I learned:
There's three things that PC's do well:
The things PC's do not do well:
For lab gear/hobby use one can usually simplify things significantly by sharing the load between a controller and a PC
In this design I use the controller, which runs fast in real time, to take care of the high speed I/O with the calipers. This is communicated at a much slower speed to the FIFO in the PC's serial port, and from there at unpredictable intervals is read by the PC. The PC then does the math and displays the result for the human. The RS232 junction is also convenient because it provides some degree of protection for the PC. The line drivers aren't bulletproof, by any means, but they are tougher than a printer port or direct ISA bus hookup would be.
Board layout:
The reader board shown in the photo below has 4 jumpers (the blue wires). By being a bit more flexible on port assignments on the next board I etched (this one being the motor control board for the eventual numeric control of this same mill) required no jumpers, event though it had a higher component count. Many of the components I used can themselves be used as jumpers. By changing, for instance, the footprint of a resistor it can be used to jump multiple traces which would otherwise prevent sucessful routing.
Extra components:
In the past I've always built electronics by laying out a minimal circuit, and then adding to it as neccessary to deal with whatever complications arise. Now that I've learned to etch boards, I'm trying to look at it the other way around. If I think I might need a bypass cap on the power line, for instance, in the old style I would fit it in when/if I needed it. If the board is being etched ahead of time, however, then there's very little marginal effort to putting in pads for that bypass cap right from the beginning. If they turn out to be needed, then the holes are drilled and the component installed. If not, no harm done.
Handy tip:
Placing the power supply capacitor on the controller can be challenging. It has to be near the pins, but spans multiple signals, which makes routing it difficult. Somewhere I read a suggestion that the cap can be soldered to the top of the chip instead of the legs. This turns out to be a very neat solution for the problem. You simply cut the legs on the cap short, bend them over 90 degrees, and lay the cap onto the top of the chip. Small dabs of solder attached the cap legs to the root of the controller power and ground pins. I'm sure this isn't kosher for production, but for prototyping it works quite nicely.
And now, the photos:
The first pics show the calipers and their mounting arrangements. The X caliper is the only one mounted directly to the mill body (the other two are driven by wooden push-rods). Note that each caliper is insulated electrically from the shell of the mill, as they are positive case ground. The wooden push rods are used to a) insulate the caliper electrically, and b) take up misalignment. The long wooden rod will flex easily in all axes except along it's axis, where it is comfortably stiff enough for my use.
The X and Y calipers are provided with aluminum shields to protect them from metal chips and impacts. The shields are supported at both ends.
Packaging of the Z axis went especially well. It fits into the space which was previously occupied by the depth stop, where it is nicely out of harm's way. The cable rubs on the inner wall of the head casting, but it'll be years before that becomes an issue.
These two show the circuit board on which the translator circuit lives.
Note the plywood backing used as a freeform insulating support for the boards. Not according to the rules for a commercial product due to it's combustibility, but very handy for quick hookups and the general layout of electrical or piping systems. I've previously used such a sheet for laying out a compressed air valving system including "instant" tube fittings (see McMasterCarr Pg 135) and semi-rigid polyurethane hose. Check this stuff out if you're still using rigid pipe to carry air. Laying things out on plywood like this is convenient because it provides a base rigid enough to support valves and off-board runs, while allowing rapid attachment (using #6 or #8 robertson drive pan head screws) anywhere on the sheet. But I digress...
Along the bottom of the board are the caliper plugs, and the bypass buttons that allow the caliper's data/clock lines to be used in place of the calipers' front panel buttons (which are rendered inaccessible by the shields). The seventh switch, located at the right, is a reset switch for the whole board.
A red LED is used as a general purpose signaler for troubleshooting. Now that the board works I don't use it any more, but it hasn't been worth my time to take it off yet. It may find future use as I grow the unit's capacity.
The 3 conductor ribbon cable carries the RS232 signals from the PC's motherboard. The yellow/black cable carries +5VSB from the computer's ATX power supply.
The +5/GND/GND/+12 connector is for future growth, as is the second three conductor ribbon cable.
Also shown is a view of the computer and controller casing together, with the access door for the controller open. The keyboard is hinged out of the way to allow access.
These last two show the PC display and the back of the PC.
The three x/y/z triplets at the left are the three stored register locations. The current indicated position can be moved into any one of these registers for later use. "Origin 0" means that the first of the two coordinate systems is being used. They can be independently scaled and offset.
At the bottom right is a field used for user interface. When entering data, there'll be a question like: "NEW X POSITION" in this field.
The back of the computer and controller show the wires I'm using to run the calipers. If you've got good eyes, you'll see that one of them is a keyboard cable, and the other two are from deceased mice (Thank's to the IS folks at work here for donating the cords from dead mice/kbd. One of the more unusual requests they'd had in a while.)
If anyone's interested in the board schematics, layouts, the software, or general hints on how to build this sort of thing, feel free to email me.
Plans for the future include:
The next stage of the game is for the PC to control the motion of the slides as well. That will allow me to cut slants, circles, and finally start carving real moulds for casting. As of 20060129 I've got a motor connected to the Y axis feed, the motor board partially populated and ready for firmware, a simple G-Code program written for testing, and a number thoughts about how to run the control loop.