Click on sections below to view content. Note all content is available in the zip file in the downloads section.
All documents, code, schematics, firmware etc are offered as an aid to the experienced constructor to allow them to build their own division controller.
I offer no warranty either express or implied, i.e. you build and operate this device at your own risk.
In building and operating this device you accept that there may be bugs or other problems both with the hardware, its associated firmware and documentation that may cause it to function in a manner that could possibly cause injury.
None of the documentation, hardware design or software either in whole or part may be used for commercial purposes.
Any re-distribution of this material must contain the original material in its original form; no charge may be made for its distribution.
I've added a 'shop' section to my site for those who can't or would prefer not to make their own PCB's or program their own PIC's. If you're interested please visit to check availability.
There are notionally three parts to the full indexing controller, these are:
1: The controller.
This is the device whose construction is contained in these pages. It's a simple computer that outputs step and direction pulses to drive a stepper motor driver which are calculated based on what you've told it. It's usual but not necessary for it to be in the same case as the stepper driver.
2: The stepper driver.
The choice of this goes hand in hand with the choice of stepper motor. For a typical 4 to 8 inch rotary table a Nema 23 sized motor is easily capable (I can use my rotary table and an expanding adaptor to drive the spindle on a 5" centre height lathe easily). These motors are usually around the 2 to 3A rating and so you'd be looking for a controller with similar capabilities.
The driver you choose should have step and direction inputs. It should also have similar current capabilities (or better) than the motor you're hoping to drive. Check the supply voltage - you'd expect the upper limit to be in excess of 20v, a low voltage controller will have unsatisfactory performance and is often a pointer to a device with no or poor current control. Finally, there are a number of very cheap L298 based designs on eBay, unless you know what you're looking for I'd avoid these. The issue is the 298 should be paired with the L297 chip to provide current limiting and step+direction inputs and the cheap ones rarely are...
3: The Mechanics.
The mechanics consists of the motor and any couplings to the desired device. It's possible to buy a complete motor and table (for example see ArcEuro's range). There are also a number of couplings freely available and designs on the web to allow the motor to be attached to common rotary tables and dividing heads. In general the design of most is the same, a tube or rectangular spacer which holds the motor at one end whilst the other screws to the table in place of the handle. The distance between the two is such that a flexible motor coupling can be introduced to fasten to the handle and motor spindles.
The controller will drive anything of any size that can use step and direction signals. I've seen it used to drive three inch tables up to huge industrial equipment, servo systems and even hydraulic systems.
It doesn't need to be a dividing or rotary table either. For lathes with a bullgear the motor can drive a worm that can be engaged with the bullgear directly.
If you haven't already check out the thread about the controller on CNCZone, there's much on there including pictures of other peoples completed controllers, advice about motors and drivers, alternative PCB layouts, keypads, cases, designs for couplings etc etc.
- C1, C2 - 22pf to 33pf.
- C3, C4, C6 - 100nF.
- C5 - 470uF 35v (or higher).
- VR1 - 10k preset. (Farnell)
- R1, R2, R3, R4, R6, R7, R10, R11 - 10k resistor.
- R5, R8, R9 - 4k7 resistor.
- RBacklight - 69 to 100 ohms.
- IC1 - PIC 18F4520. (Farnell).
- IC2 - 7805. (Farnell)
- Q1, Q2, Q3 - BC337 (NPN, 500mA IC) (eBay) (Farnell)
- D1, D2 - BYV27 / IN914 (or any fast switch diode). (Farnell)
- Xtal - 10mhz. (Farnell)
- Heatsink for 7805.
- 40 pin DIL IC socket (for IC1). (Farnell)
- Keypad - 4x4 matrix. (Can be constructed from 16 buttons). (Farnell)
- LCD - 4 line 20 column HD44780 compatible display. (eBay)
- PCB (or stripboard).
- Power supply - to suit stepper & controller. (Ex laptop 19v is ideal for most folk). (Rapid)
- Case. (I used Farnell 775-319 or Farnell 723-332 is deeper if using my keypad)
- LS1 - Passive sounder. (Rapid Electronics)
- Connectors, screws etc to suit.
Note: Where provided links are for reference only.
A subset of these parts is available in my shop.
Parts are easily available and non-critical. In general if there's room for it it'll be OK.
However make sure the PIC 18F4520 is a 40 pin DIP – they come in various flavours.
The LCD is a 20 character by 4 line (20x4) HD44780 compatible display. These are available most places, eBay being a good source (search HD44780 and look for 20x4 variants).
I've used a stick on keypad from Farnell for my keypad, but in practise any set of 16 buttons wired in a 4x4 array can be used and would probably be more robust.
It's good practice to provide a small heatsink for the 5v regulator (IC2). As a rule the size required gets larger with the voltage to the board. At 20v I find an heatsink around six square inches works fine for continual use. If using a metal case then the device can be bolted to the case and connected to the pcb via flyleads.
Farnell will nearly always have what you need - at a price.
RS Components are similar to Farnell in what they stock and prices.
Maplin Electronics are expensive but you can buy individual items from high street shops.
eBay's 'Components' section has a lot of stuff, although beware P&P. Good deals in quantity though, especially from the far east.
Some parts (noteably PCB & PIC) are available from me directly (see shop link to right).
It should be fairly easy to build the controller on a piece of veroboard (stripboard) around 100mm x 75mm. I’ve found the best type of board for this purpose has the strips grouped into blocks of 3 connections.
Most components can be placed on the stripboard pretty much as per the PCB overlay.
Starting with the LCD hold it against the stripboard in the correct position and make a note of where the connections line up on the stripboard. The remaining components can be placed as per the PCB version.
Once the parts have been placed, make sure none are accidentally connected and then proceed to wire up using fine hookup wire and referring to the schematic.
Making a PCB
The .zip file in downloads contains the PCB as a PDF file I'd recommend using this as it should print out the right size. (Check against the 40 pin IC socket or PIC chip, the pins should line up with the printout).
If you've never made a PCB before there are various methods, google search is your friend here.
The method I use is the lightbox method which requires a transparency to use in the light box. With this method the higher the contrast the more likely it is to be successful. To obtain a high contrast I run a sheet of inkjet printable transparency through my printer, I let this dry and run it through again (I find gently applying pressure to the edge with my fingers both times gives perfect registration). I then leave this to dry for an hour or so and then use some pre-sensitised board (I've never had any success with the spray on stuff) in a standard lightbox followed by all the usual chemical stuff etc.
If you have problems with the thickness of the tracks then look on CNCZone for the layout done by Lucas, start with this post and read on in case there's a more recent version.
PCB's are available ready made in my shop, see link above.
Construction is straightforward and should present no problems.
First decide if you want to build it on a PCB or using strip board. If a pcb then you can use the design in the downloads section or look on the CNCZone thread for alternative designs.
The 18F4520 microcontroller as purchased will be blank and so you will need a programmer to program it. A number of cheap programmers are available from sources such as eBay. The .HEX file containing the latest code is available in the downloads section. Alternatively I can provide ready programmed chips for a small cost.
Order of Construction
- The actual order of construction is unimportant. However as a rough guide.
- Fit socket for IC1.
- Fit IC2, C3, C4, C5 to provide the 5v power supply.
- Apply power and test for 5v at the output of the 7805 (pin 3, ground on pin 2).
- Fit the clock circuitry, Xtal, C1, C2.
- If the display is connected to the PCB using a plug and socket then attach these.
- Fit backlight resistor. (Check display documentation for value - 82 ohms is a 'safe' value)
- Fit contrast control VR1.
- If display is on a plug and socket then build can be tested.
- Attach display and insert pre-programmed PIC into IC1 socket.
- Applying power splash screen should be shown. (May need to adjust VR1)
- Remove display and PIC and continue.
- Fit keypad pull downs R1, R2, R3, R4.
- Fit any sockets used for connectors.
- Fit beeper components.
- Fit sense / acknowledge components.
To program the PIC you'll need a suitable programmer.
(Pre-programmed PIC's are available from my shop).
Programmers are cheaply and easily available via eBay (and other sources). Make sure the programmer has a suitable socket to hold the PIC and supports the 18F4520.
You can also make a simple programmer, for example: DIY Programmer
Once you've got your programmer I find with a lot of software it's important to set the device type in the programmer before loading the .hex file. Often the software resets the configuration bits once the device is set.
My suggested sequence is:-
- Attach programmer to PC.
- Set device type in programmer software.
- Plug in the PIC.
- Erase the PIC.
- Load the .hex file.
- Check the configuration bits (see below)
- If all is correct then program the device.
- Verify the programming.
One of the most common problems is bad configuration settings.
If in doubt check against the following:-
- Oscillator: HS-PLL Enabled.
- Fail-safe CLK Monitor: Disabled
- INT / EXT Switch over: Disabled
- Power up timer: Enabled
- Watchdog timer: Disabled.
- MCLR Enable bit: Disabled.
- Low power Tmr1: Disabled Tmr1 = high power.
- PortB A/D Enable Bit: Disabled, RB<4:0> Digital IO.
- CCP2 Mux Bit: CCP2 on RC1.
- In circuit debugger: Disabled.
- Low Voltage Program: Disabled.
- Extended Instruction Set: Disabled.
- Stack Overflow Reset: Enabled.
Note that the actual text may vary depending on the software.
The controller has the following connections.
Step and Direction Outputs.
These connect to the stepper motors controller. They are 5v TTL level outputs which can drive most typical controllers directly.
The polarity of each is settable in the dividers setup.
Set whenever the motor is moving. Polarity can be switched in setup.
Note that this can create accumulative errors with some controllers especially in micro-step mode.
Since most modern controllers now have built in intelligence to allow them to reduce the holding current without any other handshaking it may be better to ignore this in most installations.
The two inputs provide soft stops, one in a clockwise and one in an anticlockwise direction. These operate by pulling to ground however there is no isolation provided on board so if they are to be used in an electrically dirty environment I'd strongly suggest they are run through some isolation circuitry.
By connecting the two lines to a single 'lock' switch these can be used to lock the keyboard and prevent accidental triggering. In this case the display will show ** LOCKED ** if an attempt to move the table is made.
Sense and Acknowledge
These are provided to facilitate connecting the divider to either another divider or other equipment (PLC etc.).
Acknowledge provides a open collector signal to indicate the table is moving.
In program mode a special command is provided to pull this line low.
Sense provides an input which can be used to instigate an action on the divider, it's activated by pulling low, holding and then releasing. This triggers the equivalent of next [>>] in normal operations.
In program mode a special command is provided which waits upon a sense event.
As designed the divider expects an input to the voltage regulator of 8-30v DC. Due to current pulled a small heatsink is advised, at the higher voltages a heatsink is a must!
This supply can be provided from the same source as that connected to the controller/stepper (within the voltage constraints) or be separately provided with a suitable wall-wart type supply.
A seperate 5v line is also provided, this can either be used to provide a low current 5v line to another device (the stepper driver) taking into account heatsinking and supply voltage OR it can be used to power the divider from an external 5v source (in this case omit the 7805 since it won't be used).
- Improperly programmed PIC.
- See 'programming' PIC section.
- Incorrect PIC. Supported PIC type for latest firmware is 18F4520, double check this.
- Bad wiring between PIC and LCD.
- Test this by removing PIC and LCD (if possible).
- Referring to circuit diagram check with a multimeter that each pin on the PIC is connected to the correct pin on the LCD.
- Common faults are bad solder joints and hairline crack in PCB track.
- Check that none of the pins has a short circuit to any other.
- Common faults are solder bridges or tracks that didn't completely etch through when making the PCB.
- Incorrectly set contrast. (Even I've fallen for this!)
- Value of C1 & C2 is incorrect (usually too large) for the XTAL. Try reducing them to 22pf (or even removing them).
- Bad power.
- Check for 5v on the output of the 7805 (pin 3), is the LCD backlight on??
- Check for 5v on the appropriate pins of IC1 - in particular check for 5v on pin 1 (this would stop the PIC from resetting on power up).
- As a rule if you're getting black blocks on the LCD then suspect programming and wiring.
- Device resets whilst in use.
- Replace the PIC. (PIC's are static sensitive so take reasonable precautions when handling.)
- In my experience this is always down to a dodgy PIC. I've no idea why this happens although the programmer used seems to have some impact on the frequency. Occasionally reprogramming the PIC fixes it, but most often not.
- If all else fails then call for help on the thread on CNCZone...