So what’s it all about?


What is this project all about? The Micro Indexer is a summation of several months of Arduino tinkering. The end product is a controller for a stepper motor, for use as an accessory to milling machine. Often a milling machine is used to cut gears or to put symmetrical flat surfaces on a piece of round stock.

Early on I became interested in working with stepper motors with the hope of learning enough to possibly create a "digital dividing head" and perhaps later control the lead screw on my metal lathe. There are many versions of this concept already done - but naturally I want to do MINE!

The project consists of an Arduino to create the pulses for the stepper motor (by way of a Big Easy Driver), and also to provide an interface for selecting step functions, editing the step values, and to provide a RUN button to execute a single step, as well as providing forward/reverse.  Since the Big Easy Driver has pins to select micro-stepping division, I included a function to control that as well.

 This is a moderately advanced project and covers many basic areas of building a functional Arduino-based project. Parts procurement, software design, stepper motor basics, I2C bus... Lotsa goodies!

In the panels below is a short overview of each of the major parts in the project.

So what’s it all about?
MI-Parts

Arduino Pro Mini


The project started as an early Arduino exercise, and one of the first things attempted was to get a 7-segment display to operate.  I've seen interfaces where button-presses were used, but that struck me as a bit... clunky.  I went for a mechanical rotary encoder.  This way I could increment and decrement the digits by turning the knob. The Arduino Pro Mini was used in the soldered stand alone version to replace the Arduino Uno.

So I purchased a 7-segment display with an I2C "backpack" from Adafruit.  While you can run such a display directly from the Arduino, there would be ton of connections to manage each segment of the display (which could be a big rats-nest of wire!) - I thought the 2-wire bus of the I2C system was simpler.  And a good place to start learning.

The original project was done with the typical Arduino Uno and solderless breadboard.  It took about 2 months to get the whole thing going; interfacing to the Big Easy Driver, getting all the code to work with the rotary encoder, and display...

Once all software and hardware were proved out I wanted to build a standalone system. For this the Pro Mini was perfect. It comes with .10 centered pins, and could be easily installed on a solder-protoboard. I found the perfect boards at Wright Hobbies.

Arduino Pro Mini
MI-Parts

Rotary Encoder


The mechanical rotary encoder (as opposed to the more advanced optical version) provides an output that can be used to detect not only motion but direction. This signal is called a "quadrature" signal is two square waves that are 90 degrees out of phase with each other.

In the sample illustration, you see 3 pins: The center pin is ground, the other two provide the A and B signal. Decoding this in software is a non-trivial exercise! Thankfully, there are many coding samples on the web. The one I based my library on is here.

Part of the problem is the mechanical aspect of the RE: It is a series of wipers moving on and off contacts, and as a result, you have the usual contact bounce issues. MCU's like the Arduino are so fast they can detect the many hi-to-lo transitions that result from a contact opening or closing.

Using Mr. Mazurov's code as a starting point I created my own library for interacting with the encoder. His code handles the debouncing very nicely, and returns a value for a step up or down. With this I can increment or decrement the 7-segment display.

Rotary Encoder
MI-Parts

7 Segment Display


The 7 Segment display: the heart of the interface.  No endless button-presses needed here, either!

These units are readily available, but "out of the box" take a bit of work to control.  The device is multiplexed, and would involve a lot of connections/pins to handle each segment. Not to mention a lot of lines of code.  Technology to the rescue!  

There are a number of seven segment display driver chips available that when used, only need power, ground and the I2C clock and data signals.  Adafruit provides a nifty package with the 7 segment display and a "backpack" which is a little board with just such a chip installed.  Adafruit also supplies a library to begin working wit the display.  I found that code to be a bit more than I needed, so (with total credit to Limor) I created my own version which only handles the 7 segment display.

Of course you now have to learn how to work with the I2C bus - but an exercise well worth the effort. And once you've 'got it', the door is open to controlling any number (well - there IS a limit) of devices with only two wires. 

7 Segment Display
MI-Parts

LED Driver and Breakout Board


Now comes the real fun -using a Surface Mount chip: an LED Driver!  The plan had evolved to where I would use RBG LED's for the menu indicators.  In the default mode ("Select") of the rotary encoder, the pulses are used to increment the menu-index, which currently runs from 0 to 3.  The menu-index is used to access an array which contains the data for the current function.

While Adafruit and Sparkfun (and others) have various versions of such a control chip, I decided to 'roll my own' and dip into the world of Surface Mount soldering.  I found the NXP P9622 driver chip (from Mouser Electronics). It had just the features (and a boat-load more) that I was looking for, and would handle 16 LED's.  Each of my RGB LED's only use 2 colors, so that made a total of 10 (4 functions and fwd/rev) would be needed.

Next I had to find a good breakout board. For that I ended up at Proto Advantage and found a bunch of good boards there. Just be sure to get one with the right pitch-spacing for the chip you are using.

From there, a search of You Tube will provide a goodly number of tutorials on SMD soldering and supplies needed. Not too difficult, but get at least 2 for your first-go: It is pretty easy to get solder bridges.

LED Driver and Breakout Board
MI-Parts

DIN Connectors


Not really much to say about DIN Connectors - they are great way to have motors and power supplies as external units and are fairly compact and inexpensive.  For this level of motor control, I believe they have adequate power handling ability.

I had a little trouble finding 4-conductor wire by the foot, so ended up making my own.  I took 4 strands of #22 wire and pinched one end in a vise. The other end went into drill. Then at low speed, a nice twist was put on.  It does get a bit kinky, but better than 4 loose wires with ty-wraps.

In this version of the Micro Indexer, I'm making a 5V VCC power by way of a 7805 voltage regulator.  Since this is running with a 12-volt supply, I bring this in on a simple 1/8" mono audio jack. BUT - while the regulator does handle the 12 volts it is running a bit hot.  On the next generation I'd get a power supply (nice one here) that gives both 24 and 5 volts, and bring that to the control box by way of a 3-pin DIN.

DIN Connectors
MI-Parts