Logo CNC Lathe Spindle Encoder

encoder-003.jpg

Project Description

This project was dreamed up late one evening when I decided I wanted to be able to use the CNC capabilities of my lathe to cut threads. I use EMC2 software running under a realtime patched Ubuntu kernel. In order for the lathe threading to function under computer control, the computer must know where the chuck spindle is located so that the position of the cutting tool may be phase locked to the rotation of the chuck. This project implements a homemade quadrature encoder with 360 counts/revolution and an index pulse. One of the easiest places to monitor the position of the headstock spindle is at the main drive pulley. The headstock on this lathe has a large diameter cast iron pulley that makes it quite easy to mount an encoder wheel. The first job was to cut an encoder wheel. To do this I used a 0.047" endmill to cut the encoder out of kitchen cabinet laminate (tradename Arborite). The encoder disk was bolted to the cast iron spindle pulley by drilling and taping for 6 6-32 bolts.

encoder-001.jpg encoder-002.jpg

The second part of the project involves making 3 slot encoder detectors that will be used to detect the slots in the encoder wheels and generate 5 volt TTL signals that get fed into the parallel port as phase A,B and Z. The detectors are H21LTB slot detectors made by Fairchild. These are very easy to use... supply 5 volts and they will give you nice clean TTL signals that tell you when the slot is blocked or clear. The main task in using these devices is figuring out a way to mount them so they can be properly positioned to generate the quadrature signals required. I mounted the slot encoders on a small PCB with a couple of resistors, indicator led and a bypass capacitor. The slot in the PCB allows the height of the encoder to be adjusted so the encoder wheel runs freely through the slot encoder. The mounting point of the aluminum angle bracket allows the position of the slot encoder to be adjusted so it looks cleanly through the holes in the encoder disk.

encoder-004.jpg encoder-005.jpg encoder-006.jpg

The slot encoder assemblies have short flying leads that attach to a distribution terminal board. The distribution board has terminal connections for a small A/C wall wort and the A,B,Z and ground connections back to the computer parallel port. The distribution board consists of a fuse, bridge rectifier, filter capacitor, and a 5 volt regulator with a few bypass caps. I found that I had to spray paint the encoder wheel with flat black paint to eliminate some leak thru in the IR slot detectors. You will need an oscilloscope to adjust the position of the slot detectors to get a nice 90 degree difference between the A and B channels. The Z channel should be adjusted to give 1 pulse/revolution. As you can see, the paint was still wet when I fired up the spindle.... leaving a few extra black spots and racing stripes in the cabinet!

encoder-007.jpg

System Requirements

The G code file for cutting the encoder wheel uses named variables and owords for looping and conditional execution. You will need to use EMC2 Version 2.2 or later. At the time this web page was put together, 2.2 had not been released... I used the cvs pre2.2 version. I used eagle 4.13r1 light for the PCB designs. This project is not meant to be a step by step construction project. You must be familiar with machining, electronics, PCB design and layout, surface mount PCB construction and be willing to drill holes in your machine. This web page is meant to provide ideas and inspiration to homebrew CNC fanatics. All the pieces for this project came from my junkbox. Have fun and be safe.

Electrical Drawing(s)

Eagle PCB file - spindle-enc-ps.sch(196.4k)
Eagle PCB file - spindle-enc-ps.brd(10.1k)
Eagle PCB file - spindle-encoder.sch(108.7k)
Eagle PCB file - spindle-encoder.brd(8.2k)

G Code

Encoder Wheel - spindle-encoder.ngc(8.7k)
Sensor PCB bottom drill - spindle-encoderbd.ngc(1.4k)
Sensor PCB bottom mill - spindle-encoderbot.ngc(15.4k)
Sensor PCB bottom cutout- spindle-encodermb.ngc(622b)
Dist. PCB bottom drill - spindle-enc-psbd.ngc(3.8k)
Dist. PCB bottom mill - spindle-enc-psbot.ngc(31.8k)
Dist. PCB bottom cutout - spindle-enc-psmb.ngc(506b)

home.jpg Back to Lawrence's Software Stuff Page