# DIY arduino circuit boards optimized for electronic indexing head



## TorontoBuilder (Jan 20, 2015)

I've uploaded eagle Schematic & PC board layout files to the downloads section for my prototype Arduino compatible Microcontroller (using a replaceable ATmega328PU IC installed in a socket) and a lighted 5 button user input carrier board.

This project is optimized to drive a stepper motor using Chuck Fellows' electronic indexing head sketch (some slight software re-writing may be required). 

Benefits of this project include:

  -compact design optimized to fit a small protective enclosure

  -wide input voltage range from 3.5v - 36V, up to 5A current.

  -onboard 3.5V to 36V 12V, 1A linear regulator for 12V cooling fan

  -small form factor accommodates all pin inputs on PCB smaller than an UNO

  -separate lighted 5 button keypad break-out board attachment

  -larger button faces (10mm dia) w/ wider spacing for easy user input

  -female header to attach your choice of either 20x4 or 16x2 LCD display

  -easy front panel attachment of keypad & display w/ your choice of spacing

  -plug & play header for Pololu's A4988 stepper motor driver carrier board!

  -plug & play header for Pololu D24V5F5 5V, 500mA DC regulator

  -header plugs for remote blue LED power on indicator lamp & 12V cooling fan

The smaller form factor means that arduino shields wont fit this board, but then this board doesnt need them anyway. All the required components are there and are much more adaptable to fitting to a compact case.

The power input is intended first to flow thru a panel mounted dc power jack soldered to a main power switch then soldered to the large solder pads on the PCB.

NOTE: try this design now at your own risk since I haven't yet assembled a test circuit. I'm awaiting parts and the printed PCB boards. The final boards will be available thru OSH Park.com. I have no relation to them and dont make any money from their sale of my shared project.

Comments are very welcome.

In addition to these boards the controller will require two pololu parts, 
1. Pololu 5V, 500mA Step-Down Voltage Regulator D24V5F5
2. A4988 Stepper Motor Driver Carrier, Black Edition 

on and you'll need components which I will post a bill of materials to and a list of suppliers. The lighted LED buttons are $0.99 each on ebay, or about $7.00 each from digikey (ouch)

I'll post a notice once I get the schematic verified and tested.


----------



## ShopShoe (Jan 21, 2015)

I'm following this TorontoBuilder.

I used to do electronics a long time ago and all this stuff has been interesting, but I have a limited budget (gotta have more and more tooling first....) and have been wondering how to "jump in" to some projects that will actually help me in the metal shop and be precise, reliable, and repeatable as well. Hopefully this will provide the jumping-off point I have been looking for.

Good luck and keep us posted.

--ShopShoe


----------



## canadianhorsepower (Jan 21, 2015)

Torontobuilder

I think that your 68 ohm for your LED is a bit low
it gives you twicw the current it needs

cheers
Luc


----------



## TorontoBuilder (Jan 21, 2015)

Shoe, 

My goal was to try to create an inexpensive and simple project for people who wish to replicate Chuck's electronic controller for an indexing head project. 

The end result should be a very simple, robust and reliable controller that wont break the bank and is enjoyable project in its own right.

For me this project makes sense since the total cost should be around $60 (i'll be postinga bill of materials soon) bucks not including the stepper motor and machines parts. I'll likely be able to complete this faster than it will take for my two sainsmart arduino controllers and lcd keypads to arrive from China too! 

Of course, I need to make a lot of gears for the drive trains for printing presses so this project is very beneficial to me. I don't have a traditional dividing head, and don't know how to use one in any case.


----------



## TorontoBuilder (Jan 21, 2015)

canadianhorsepower said:


> Torontobuilder
> 
> I think that your 68 ohm for your LED is a bit low
> it gives you twicw the current it needs
> ...



A 68 Ohm resistor was selected based on +5V power, the LED's forward voltage rating of +3.6V for the blue LED in the switches, and a recommended operating current of 20mA (.02A). The max current is .30mA. These figures are from the manufacturer's specs.

As per Ohms law, R = V / I

R = (V-Vf) / I

R = 1.4 / .02A 

R = 70 ohms

The nearest standard value resistor is 68 Ohms. 

using that figure I calculated for the actual mA current

I = V/R

I = 1.4 / 68

I = 0.0258A or 20.58mA 

so its fine as far as the specs go, but yes it may be far too bright for a power indicator located on the enclosure. Perhaps a 270 ohm resister will prove a better choice? I'll see once I get my parts from digikey and breadboard some circuits. I've specified a 510 ohm resistor for the onboard blue LED which wont normally be viewable except while programming and testing. 

The LED switches have the same specs, and have the LEDs located under painted 10mm caps with laser etched images on them which cut down the brightness significantly so I wanted max brightness to start with for those. I just used the same resistor calc for the indicator LED. Certainly people can select a much higher resistance value and still have a viewable LED indicator. Thanks for the feedback!


----------



## canadianhorsepower (Jan 21, 2015)

TorontoBuilder said:


> A 68 Ohm resistor was selected based on +5V power, the LED's forward voltage rating of +3.6V for the blue LED in the switches, and a recommended operating current of 20mA (.02A). QUOTE]
> 
> 
> Hahaaaaaaa  it's not written anywhere about the blue LED
> ...


----------



## TorontoBuilder (Jan 21, 2015)

canadianhorsepower said:


> TorontoBuilder said:
> 
> 
> > A 68 Ohm resistor was selected based on +5V power, the LED's forward voltage rating of +3.6V for the blue LED in the switches, and a recommended operating current of 20mA (.02A). QUOTE]
> ...


----------



## TorontoBuilder (Jan 22, 2015)

I thought people may be interested in viewing a mock-ups of the prototype boards. The first is the main controller pcb and the second is the keypad pcb, they attach via jumper wires or a 3 conductor ribbon cable from BUTT_CN on the main board to JP1 on the keypad.

I have to do a bit of redesign of my parts library labelling to assure that the silk screen printed on the board is legible everywhere it needs it to be so people know which parts go where.


----------



## RonGinger (Jan 22, 2015)

Remember the arduino is  limited to 40ma per pin and 200  ma total for all pins. Best to use as little as possible for each indicator.


----------



## TorontoBuilder (Jan 23, 2015)

RonGinger said:


> Remember the arduino is  limited to 40ma per pin and 200  ma total for all pins. Best to use as little as possible for each indicator.



Ron, thanks for the feedback!. You're absolutely correct about the Arduino chip current limitations however only one of the two indicator LED passes thru the controller chip (@ digital pin 13). This is the internal on board LED that displays the blinky code and lets the user know when the aduino chip is on and drawing input power. It also blinks when reset button is pressed.

That LED has a 510 Ohm resister limiting the current draw to less than 7mA, but based on your feedback I'll change that to a 1K resistor to limit current to about 3mA.

All other power draws, such as the cooling fan, the five lighted buttons, the LCD back light and the main power in indicator LED draw power from either +5V or +12V power buses separate from the microcontroller pin outputs and limitations. 

I wanted to preserve the controller pins and limit the current passing through the chip since in future I want to add functionality to the box such as a hall sensor tachometer and surface speed calculator to make this a multi-function device.


----------



## chucketn (Jan 23, 2015)

Toronto Builder, one thing you may want to consider is adding support for a 12c serial LCD to free up more I/o pins on the Arduino.

Chuck


----------



## TorontoBuilder (Jan 23, 2015)

chucketn said:


> Toronto Builder, one thing you may want to consider is adding support for a 12c serial LCD to free up more I/o pins on the Arduino.
> 
> Chuck



Thanks Chuck, that's a good suggestion. I was going to use a 10 pin connector and a split ribbon cable to attach the usual minimum required LCD connections plus leave open the option to either plug the LCD backlight into either +5V & GND or to a digital pin to control the backlight using PWM. 

I wonder if I should just go with 12c as the only option? I'll have to look up the cost impact of that.


----------



## chucketn (Jan 24, 2015)

I ordered a 1602 LCD and the module to make it serial for $4 all in today.

Chuck


----------



## canadianhorsepower (Jan 24, 2015)

chucketn said:


> I ordered a 1602 LCD and the module to make it serial for $4 all in today.
> 
> Chuck


  If your planning to get into this stuff 
There is a book call
Beginning C for Ardruino

pretty good stuff


----------



## chucketn (Jan 25, 2015)

Thanks, Luc. Have downloaded and am studying...

Chuck


----------



## TorontoBuilder (Jan 25, 2015)

canadianhorsepower said:


> If your planning to get into this stuff
> There is a book call
> Beginning C for Ardruino
> 
> pretty good stuff



No link Luke?


----------



## TorontoBuilder (Jan 25, 2015)

I made some significant changes to the controller and keypad PCBs. The changes significantly reduce the space requirements, increase the potential simplicity, and increase the potential modularity to permit greater flexibility for stepper motor selection. 

Oh yeah, the redesign shaved about $3.00 off the price of the PCB boards. The cost of both PCBs together is less than $9.00. Osh park provides free shipping but have a minimum order of 3 boards per set. If mine works I'll have a couple to sell at cost. And no, I do not have any relationship to any of these companies. 

While smaller, the main PCB retains all the analog & digital pins. A user's set up decisions will determine how many pins remain available for uses other than simply controlling an indexing head.

I've replaced the large standard LCD connector with four pin IC2 LCD display connector as the preferred display connection. This allowed the 10K potentiometer to be stripped from the main PCB since IC2 serial boards have their own contrast adjust potentiometer.

NOTE: A standard LCD display can still be used, but will need to be connected from each individual pin to both the main PCB & the keypad PCB, since the standard LCD contrast adjustment potentiometer location has been moved from the main PCB to the keypad PCB. 

If using I2C serial connector the 10K pot connection and headers should be left unpopulated (empty).


POWER REQUIREMENTS

To simplify the project to suit the majority of users the main power input shall be restricted to +12VDC and 5A or less. A high efficiency switching DC to DC regulator provides +5V/500mA for the logic circuits. 

I've sourced a Soyo*SY57ST76-0686A*Unipolar stepper motor rated @ 12V and .68A/phase for my project, however almost any stepper motor rated for 2A per phase or less may be used. 

Almost any stepper motor of less than 2A per phase and 12V may be used with this basic set-up since the A4988 Stepper Driver Carrier board has an adjustable maximum current limiting circuit. You can read more about this feature on Pololu's product blog page here:

https://www.pololu.com/product/2981/faqs 

IF the stepper motor requires more than 12V or if you're not comfortable adjusting the current limiter, I've also modified the power circuit so that the stepper motor power supply is now directed to the A4988 carrier board through connector pins rather than via printed PCB traces.

So, as an option the +12V power supply can be routed through a separate voltage regulator module that would then feed the A4988 carrier board. Pololu has two adjustable regulators rated @ up to 5A each, that cover two broad output ranges; 4V &#8211; 12V, or 9V &#8211; 30V. As switch mode regulators they are not cheap, but they don't heat sinks for cooling. Still you're better to select your stepper motor to suit the basic controller set-up if at all possible. 

A big thank you to those people who have provided their feedback so far. Every one of those posts led to direct changes to make this controller better!

I think I'll just order 3 of each board and head directly to testing rather than waiting to breadboard the circuits first. 


The prototype boards may be viewed here:

Main PCB is 2.3" x 1.3", nice and small! The A4988 carrier projects beyond the rear of the board about .5".

https://oshpark.com/shared_projects/kKuJqIA7

Keypad PCB is approximately 1.5" by 1.5"

https://oshpark.com/shared_projects/hcnykUxw

I'll be revising the uploads files shortly with the revised files so everything is current.


----------



## TorontoBuilder (Jan 27, 2015)

As promised in my previous post here is information on how to adjust the A4988 current limit setting for use with stepper motors rated for a  maximum current less than 2A per phase. 

There&#8217;s also &#8220;bonus&#8221; info on how to measure the current of a stepper motor under load conditions, Ohm&#8217;s law, adding current monitoring capability to the Arduino and finally a really simple process to address power dissipation requirements without any calculations.


*The A4988 Driver Chip Ratings*
The A4988 stepper driver chip is designed to operate any bipolar stepper motor with a drive capacity of up to 35V and ±2A per phase. The stepper motor supply voltage provided to the A4988 break out board however must be between 8-35V and ±4A.

In selecting a stepper motor for your indexing head, your primary concern should be selecting a motor with sufficient holding torque @ a rated amperage of ±2A/ph or less. 

You may use a motor with a voltage rating of less than 8volts and/or less than 2A per coil but you should be aware of how your choice of motor may impact the power dissipation requirements of the A4988 driver chip and may require adjustment to the current limiter.

Failure to provide sufficient power dissipation can result in under specification torque output due to current drop off due to chip over heating, while failure to adjust the current limit may result in catastrophic motor failure.

*Ohm&#8217;s Law*
If your motor is rated less than 2A per phase then you may need to adjust the A4988 current limiter, but then again you may not. Here&#8217;s how to determine if you will need to limit the current of the driver output. 

Ohm's Law states that the current (I) flowing through a conductor (our stepper motor coil winding) between two points (the ends of motor leads) is proportional to the voltage difference across those points. The 'constant of proportionality' is known as the resistance and is measured in Ohms (&#937. The formula for calculating the current is expressed as:

I = V / R

For example, the Soyo model SY57ST76-0686A stepper motor that I&#8217;ve selected for my project is rated at:

Current rating:	680 mA (0.68A) per coil	
Coil Resistance: 	17.65 &#937; (Ohms) per coil 
Voltage rating:	12 Volts


The ratings mean that with the fixed resistance of 17.65 &#937; across the stepper motor windings and a supply voltage of 12 volts across it, the current flowing through the motor shall be 0.68 amps. 

I = V / R, 	or 	12 ÷ 17.65 = 0.68 amps

This motor is well suited for the controller design. The current rating well below the maximum the current output capability of the A4988 driver means my controller shouldn&#8217;t require any additional cooling. 

In theory I don&#8217;t need to adjust the current limiter on the A4988 driver since the voltage input to the motor matches that of the motor rating. This means that the 12V supply voltage is acting as the current limiter.

However, there is nothing physically preventing someone from plugging in a power supply greater than my 12V design input, which would result in higher than rated current being supplied to the stepper motor. Cheap unregulated DC power supplies can also deliver voltages higher than their rated output so it may be advisable to set the current limiter to match the motor rating just to be safe.

*Here&#8217;s a not so ideal example:*

A common stepper motor is rated as follows:

Current rating:	600 mA (0.6A) per coil	
Coil Resistance: 	6.5 &#937; (Ohms) per coil 
Voltage rating:	3.9 Volts

The motor has a known, fixed resistance of 6.5 Ohms when we apply the 12 volt supply across it rather than the 3.9 volts it&#8217;s rated for, the current flowing through the motor will be 1.846 amps (I = V / R). This exceeds the rated input by a factor of 3!

Where&#8217;s that excess current going? It&#8217;s being converted to heat within the motor windings. The motor can&#8217;t handle that excess heat. If this is your stepper motor prepare to see magic blue smoke wafting out of the motor housing in short order if you don&#8217;t shut down driver or limit the current flow! 

*Adjusting the Stepper Motor Current Limit setting of the A4988 Driver*
We can still use that stepper motor rated for 0.6A @ 3.9 volts but the current must actively be limited to under 0.6A to prevent damage to the motor. The trimmer potentiometer on the A4988 board allows the user to adjust the current limit to suit their stepper motor requirements. 

There are two main methods of determining the current output and current limit setting of the driver. 

The first method measures the voltage at a reference pin on the driver board and employs a simple math equation. 

The second involves more complicated measurement the current flow across the stepper motor coil. 

Both methods apply a correction factor, since the A4988 driver only outputs 70% of current limit setting when running in full-step mode. We&#8217;ll be operating our steppers in full-step mode so we need to be aware of correction factors to determine to actual current limit setting. 

I&#8217;m including the more complex measurement technique since my next post will illustrate how to modify this method of measurement to permit the Arduino controller to display the A4988 output current. Adding output current to the display outputs will make it easy to adjust the A4988 current limit and to monitor the chip output during normal operating conditions. At the end of this post I&#8217;ll explain more why it can be beneficial to do so. 

*Method 1:*
To set the current limit with this method you measure the voltage between a &#8220;reference pin&#8221; and ground on the A4988 board and then calculate the resulting current limit setting.

The reference pin voltage is accessible on a &#8220;via&#8221;, a copper lined thru hole that makes an electrical connection between the layers of the printed circuit board. The pin is circled on the bottom silkscreen of the circuit board, but is accessible on both sides of the board.  See the attached photo from the Pololu website.

The current limit relates to the reference voltage as follows:

Current Limit Setting = VREF × 2.5

For example, if the reference voltage is 0.8 V, the current limit setting is 2.0 A. 

Remember, as mentioned previously, in full step mode, the current through the coils is limited to 70% of the current limit setting so we need to correct for that to assure we get sufficient current to our motor so it can provide maximum torque.

Now let&#8217;s consider our previous stepper motor example with the following rating:

Current rating:		600 mA (0.6) per coil	
Coil Resistance: 	6.5 &#937; (Ohms) per coil 
Voltage rating:	3.9 Volts

We wish to limit the current to the 0.60A of the stepper motor we first need to correct for the 70% power rating to find the correct current limit setting to be applied, 0.60A ÷ 0.7 = 0.857A. 

The current limit setting of 0.857A corresponds to a VREF of 0.857A ÷ 2.5 = 0.343V. Simply turn the adjustment screw on the trim potentiometer until you get a reference voltage reading of 0.343V 

Behind that simple looking equation are voltage comparator circuits, current sensing resistors (shunts), and Ohms law. I&#8217;ll have more about current sensing resistors in my next post.

*Method 2:*
To adjust the current limit setting with this method you put the driver into full-step mode and use an ammeter to directly measure the current flow through a motor coil and adjust the trim potentiometer to obtain the desired current setting.

However there are a few caveats, the first of which is that we need to be driving the motor in full-step mode without clocking the STEP input.

Secondly, recall that to we first need to correct for the 70% power rating in full-step mode to find the correct current limit setting to be applied. Therefore to limit the full-step mode current to the 0.60A for our example stepper motor we first calculate the full power setting to be applied:

0.60A ÷ 0.7 = 0.857A 

If you forget to apply the correction factor our motor would happily run all day long, but it will perform below its rated holding torque, perhaps too low to use for your purposes.

Finally due to the A4988 driver circuit design you must measure the current only across the motor coil. Measuring a motor&#8217;s current at the power supply inlet while not normally an incorrect method in this case will result in an inaccurate reading since the A4988 driver circuit and motor coil together can act like a switching step-down power supply where different loops in the circuit have different voltages and currents across the loops.  

Also, you must ensure to measure the current with an ammeter that&#8217;s wired in series with the motor coil you are measuring. People often try to incorrectly measure current by connecting the ammeter in parallel to the circuit, since that&#8217;s how we connect a voltage meter but by doing so all the current will bypass the much higher resistance of the motor coil in favour of the short circuit created by the zero resistance path thru the ammeter. 

Knowing how to properly connect your ammeter in series with the motor coil is helpful since we can build upon that knowledge and later wire a shunt (a special type of current sensing resistor) into the circuit in the same manner as an ammeter and use that shunt to add a current meter function to our controller. 

*Why it&#8217;s beneficial to add current metering to your controller.*
Firstly, the most practical benefit of adding a current meter to your controller is that it acts as a surrogate power dissipation monitor. If the A4988 driver does not have sufficient cooling the current output of the driver will diminish as the chip heats up. Eventually the output may shut down due to the IC chip&#8217;s thermal overload protection.

The conditions you normally operate your indexing head will likely vary greatly from the bench conditions where you tested the driver current output and set the current limit. Measuring the current output with ammeter only during the short time period it takes to adjust the current limiter will not tell you how the driver will perform during your normal operation. Building in current meter functionality to your controller can help assure you that the driver will continue to deliver the set output during normal operations so your stepper motor will deliver the maximum holding torque.

Secondly building the ability to display the A4988 current output into your controller will allow you to easily swap out stepper motors if you need to replace your motor with one of a different specification (such as if your first motor lacked sufficient torque).

NOTE: the current limiting potentiometer is not designed for repeated adjustment but rather as a set it and forget feature. You should not expect the pot to deliver more than a handful of current adjustments over the course of its lifespan. It should however be sufficient to allow a few motor changes over the life of the A4988 carrier board. 

p.s. don&#8217;t solder the driver carrier to the PCB but rather solder female headers into the circuit board and plug the carrier board into the header instead to facilitate easy replacement of the driver if necessary. 

In my case I intend to design my controller to fit into a pretty small enclosure. I intend to purchase and install the minimal number of parts required to suit my space and budget. 

Since the motor I selected is rated for 125 oz-in of holding torque at a modest 0.68A I shouldn&#8217;t require any additional cooling and therefore I plan to omit both a heat sink and a cooling fan from my initial build. My sole source of cooling will be air circulation vents on the bottom and rear of the enclosure.

If the rated torque is too low to provide sufficient holding power to allow me to cut 60 tooth gears 3&#8221; in ¼&#8221; wide steel blanks I may have to source a new motor with higher specifications and adjust the current output. 

I&#8217;ll be cutting gears over work sessions lasting hours at a time, which is ample time for heat to build up inside the enclosure. If my enclosure is too small or if the air vents lack sufficient free area to allow adequate air circulation the chip may over heat resulting in the current output dropping over time. 

By monitoring the current during normal operation I can ascertain if there is any current drop off and implement the following incremental steps one at a time, stopping after each implementation to determine if current drop off has been mitigated:

Increase the free area or number of air vents in the enclosure; 
Add heat sink to the top of the A4988 chip; 
Add a very small cooling fan;
Add larger cooling fan;
Make larger enclosure;
Increase the free area or number of air vents in the larger enclosure; 
Add larger cooling fan;
Add largest cooling fan possible. 

That&#8217;s all for this post, if you read to the end of this post thanks, that&#8217;s great!


----------



## TorontoBuilder (Jan 28, 2015)

In my previous post I wrote about adding current measuring capability to our Arduino controller and alluded to a method of inserting a special type of device called a shunt into the circuit for which we wanted to monitor the current. 

*Dont be Intrusive*
A primary goal of making scientific observations is to do so without influencing the system being observed. However direct current measurement is an inherently intrusive process as a sensor is inserted into our motor circuit. The insertion of a sensor runs the risk of negatively influencing the circuit being measured.

Thats were a shunt comes in. A shunt is a device which allows electric current to pass around another point in the circuit by creating a low resistance path. This is beneficial since added resistance causes a reduction in available current and power.

*HEY WAIT, doesnt the Arduino measure voltage rather than current?*
An Arduino cant actually directly measure current, it measures voltage. Even then typically only voltages under the 5 volt limit of the input pins. So just how are we going to measure current? 

Good question. The type of shunt we are going to use is called a current sensing resistor. Basically, a current sensing resistor could be considered a current-to-voltage converter, since the voltage we will measure across the resistor is proportional to the current flowing through it. 

Hmm that sounds familiar, well it should

Ohm's Law states that the current (I) flowing through a conductor (our shunt) between two points (each end of the shunt) is proportional to the voltage difference across those points. The 'constant of proportionality' is known as the resistance and is measured in Ohms (&#937. The formula for calculating the current is expressed as:

I = V / R

Our arduino is going to measure the voltage across our shunt and well use Ohms law to calculate the current from the measured voltage. 

*Preliminary Shunt Selection Parameters*
Let's evaluate some preliminary shunt selection parameters. Lets assume that we want to measure current values of up to 5 amps maximum.

As previously mentioned were going to use an analog input pin on our arduino to measure the shunt voltage, therefore we must select a resistance value that provides no more than 5 volts across the shunt @ 5A, since the arduino's maximum analog input voltage is 5 volts.

We can use Ohms law to determine the maximum resistor value:

R = V / I, 	or 	5  ÷ 5 = 1 &#937;

1 Ohm is the smallest standard resistor value; they are readily available for pennies, so they seem like a logical choice to use for our shunt. Before we rush out and buy one though we need to evaluate whether or not 1 &#937; resistance will influence our circuit parameters or not. 

*Manufacturers Motor Design Specifications*
So first lets recall the original circuit parameters from my previous post. My selected stepper motor has the following ratings:

Current rating:		680 mA (0.68) per coil	
Coil Resistance: 	17.65 &#937; (Ohms) per coil 
Voltage rating:	12 Volts

The ratings mean that with the fixed resistance of 17.65 &#937; across the stepper motor windings and a supply voltage of 12 volts, the current flowing through the motor shall be 0.68 amps. 

I = V / R, 	or 	12V ÷ 17.65 &#937; = 0.679 amps

Now lets look at the power equation for the motor:

P  = V x I, 	or 	12V x 0.68A= 8.16 Watts of power 

These values MUST NOT change when we insert our shunt into the circuit, so lets see if they do.

*Evaluation of the Shunt in the Circuit* 
Our power supply is 12 volts / 5A therefore our circuit will have 12 volts. 

If our shunt uses 5 volts that would only leave 7 volts (12 - 5 = 7) for the motor. Its pretty intuitive to see thats unacceptable and we could stop the evaluation right here, but lets continue anyway.

The 7 volts remaining for the motor is only the potential minimum, in reality my circuit will have much higher voltage for the motors use since the circuit wont be subject to the full 5 amps. The A4988 the driver chip will limit the current 0.68A. Therefore from Ohms law our theoretical maximum resistor voltage shall be:

V = I x R, 	or 	0.68 x 1 = 0.68 volts, which will leave the motor with 11.32 volts.

Lets examine the impact to the current and power to the motor when we subtract 0.68 volts from the available motor voltage and add 1 Ohm resistance to the overall circuit:

I = V / R, 	or 	(12V  0.68V)  ÷ (17.65 &#937; + 1 &#937 = 11.32  ÷ 18.65  = 0.60 amps

Now lets look at the new power equation for the motor:

P  = V x I, 	or 	11.32V x 0.60A = 6.97 Watts of power 

We can see that there are several problems with this simple approach. Our proposed sensor would create a major impact on our circuit. The 1.19 watt power reduction to our motor (8.16  6.97 = 1.19), represents a reduction in power of 14.58%, now thats pretty damn intrusive.

*Desired Shunt Characteristics*
Knowing that just 1 &#937; of added resistance to the motors circuit reduced the available power by 14.6% we learn that our shunt needs to have some special characteristics to ensure we obtain accurate readings. Most obviously we learn the shunt must have a very low resistance value! 

As the resistance of the shunt must be very small, this also means that the voltage will be proportionally very small making it difficult to measure accurately. Lets use Ohms law to determine the voltage through a 0.01 Ohm resistor @ 1 amp of current:

V = I x R, 	or 	1A x 0.01 = 0.01Volts which = 10mV. Thats pretty small.

Across our 5 amp sensing range there will only be 50mV of voltage potential, and only 10mV potential per amp. Given such a small voltage error in the resistance value can have a profound impact on the voltage output and the current flow being calculated. 

This brings us to our next criteria. The resistance level of current sensing resistor must be known to a high degree of accuracy. The typical 5% accuracy resistor wont cut it. 

Before we examine how the arduino will handle the voltage readings from the shunt, lets ensure that a 0.01 Ohm shunt wont influence our circuit. 

We subtract the maximum possible 0.05 volts from the available motor voltage and add 0.01 Ohm resistance to the overall circuit:

I = V / R, 	or 	(12  0.05) ÷ (17.65 + 0.01) = 11.95  ÷ 17.66 = 0.676 amps

Thats power a reduction in our circuit of only 0.44%, so we see that shunt with a 0.01 &#937; resistor value with an accuracy of 1% is an acceptable option for current sensing in our circuit.

*Reading Analog Inputs with the Arduino*
The arduino controller has a circuit inside called an analog-to-digital converter. The converter reads analog pin input voltage between 0 and 5 volts and converts the voltage to an integer (a whole number) between 0 and 1023. This results in a scale with 1024 steps.

*Voltage and Amperage Resolution*
We can calculate the voltage resolution of each integer (step) as follows: 

Res. = Input Volts / Integer, 	or 	5V / 1024 = 0.0049 volts (4.9 mV) per step. 

Lets round 4.9mV up to 5mV to make things easier. 5mV per step.

Recall that our shunt voltage output (resolution) is 10mV per amp, lets relate that to the digital converters integer step resolution.

Res. = mV per step / mV per amp, 	or 	5mV / 10mV per amp = 0.5A step

This means that the lowest amperage resolution that the arduino can resolve and output using a 0.01 &#937;, or 10mV per amp shunt is 0.5A. 

Given a step resolution of 0.5A and the parameters of my circuit especially the driver current limit setting of 0.68A the arduino based ammeter would only ever display 0.5A when measuring the current flow in my circuit. 

Well that sucks! But why, and what can we do about it?

*Increasing the Scale Resolution*
We cant really change the analog-to-digital converter of the arduino nor should we need to. The 1024 integer scale of the converter output should provide an ample number of steps to provide adequate resolution for our needs. So why are we not getting better resolution?

The answer lies in the input voltage we are providing to the converter. The converter provides an entire 0 to 5V range to work with yet our shunts maximum output voltage of 50mV means were only using 1 percent (0 to 50mV) of the available input range and resolution:

Percentage = (Voltage Range Utilized / Total Voltage Range) x100

0.05V / 5V x 100 = 0.01 x 100 = 1%

It should now be very apparent to us that we need to use a larger percentage of the converters available range which will provide more steps between amps and therefore provide a finer resolution for our ammeter. It should also be very apparent that we need to increase the maximum output voltage of our shunt to do so. However we need to do so without increasing the shunts resistance!

Before we consider how we can increase the voltage output from our shunt lets first consider a voltage multiplier that will yield an amperage resolution suitable to our needs.

To make things easy lets try a multiplier of 10 since engineers seem to like such things. Lets calculate how increasing the voltage by a factor of 10 will impact the analog-to-digital converter output.

*Verifying the Final Scale Resolution Suitability*
Res. = Input Volts / Integer steps, 	or 	5V / 1024 = 0.0049 volts (4.9 mV) per step. 

Lets once again round 4.9mV up to 5mV per step to make calculations simple.

Our new our shunt voltage output will be 100mV per amp:

V = Shunt Vout 10mV x 10 = 100mV 

100mV now relates to the digital converters integer unit resolution as follows:

Res. = mV per step ÷ shunt mV per amp, 	or 	5mV / 100mV per amp = 0.05A

A resolution of 0.05A (50mA) should be suitable for our needs. 

In the case of my motor the arduino should display my motors current as 0.70A or 700mA since it should round 680mA to the nearest 50mA. 

*The Operational Amplifier*
But how do we increase the voltage without changing the resistor value? Enter the operational amplifier. An operational amplifier (op-amp) is a high-gain electronic voltage amplifier integrated circuit. 

Gain is the ratio of an electronic circuits ability to increase the power of a signal from input to output. High gain means that the amplifier can take a signal and increase it exponentially. We only need to increase the voltage signal by a factor of 10, so an operation amplifier IC will suit our needs well. 

*Wrap up*
Thats all for this post in my next post Ill examine an op-amp circuit to amplify the shunt output to the arduino. Then Ill tie it together with an common ammeter sketch for the arduino.


----------



## TorontoBuilder (Jan 29, 2015)

Hmm I guess my posts are too heavy on the boring technical side of things.

Well hopefully i'll get my first shipment of electronic parts from China so I can start an actual physical build of an arduino indexing controller. 

FYI Sainsmart sent me a tracking number for my order its many weeks later and no product and the tracking number they gave me UPS doesnt even recognize.... 

Oh well... I'll likely have built my own controller from parts from Digikey before my sainsmart order arrives.


----------



## chucketn (Jan 29, 2015)

TB, you just keep on keepin' on. I am learning/re-learning much from your posts. 
I, too, am waiting on that slow boat. I've ordered drivers, another LCD, a serial module for the LCD, and a motor/servo/stepper shield that are still outstanding.
I have received the stepper Chuck F recommended, but no way to make it move. I have received the flex couplers to connect the stepper to the RT worm and formulated a plan for an adaptor.
I had already started to make a NEMA23 mount for my RT, but still have some features to add and probably some mods to that. I have Chuck F's program working on my Arduino, but am dead in the water until the other parts arrive.
It's still too cold to be comfortable working in my unheated garage/shop, so I try to use my time to learn...
You are helping the learning part. Thanks for that!

Chuck


----------



## TorontoBuilder (Jan 29, 2015)

Hey Chuck... cold? Huh, we've had a spell of really cold weather, around -10C, its even prevented me from going about 1 block to the library to renew my library card so I can borrow ebooks again... I live in the wrong climate for my tastes.

Im glad you're learning something... writing these posts is helping me to refresh my memory of electronics and to learn new things. There have been a million developments since I learned simple electronic circuits decades ago.

My hope is that by having a firm understanding of the exact electronic processes it will help when I go to program arduino sketches, or rather more accurately when I go to modify existing sketches for my needs.

Its not like I really intend to create a shunt/op-amp circuit for my arduino to measure current.... but it helped me understand how the 185mV output of ACS714 based current sensor relates to the arduino analog-to-digital converter.

For those not familiar with it, the ACS714 is a hall sensor based current sensor, its based on a copper plate placed perpendicular to the current flow. the magnetic flux created by that current flowing thru our sensed circuit creates a proportional voltage across the sensor plate. They two circuits are electrically isolated which is nice... and just like our set-up they have a voltage amplifier circuit, with proprietary filtering to clean up the sensed voltage signal. 

The one difference between the hall sensor and a circuit we could build with a an op-amp is that we could alter or mV output multiplier by our choice of resistor in our amplifier circuit....

Still, the hall sensor will give me a resolution of 26mA which is very close to the 25mA I could get by using a 20x multiplier in my amplifier circuit...  but... I'm getting ahead of myself and my next post.


----------



## xpylonracer (Jan 29, 2015)

Hi TorontoBuilder
I am following your posts with interest but yes I do find all the electronics a bit heavy,  but interesting.
I guess like a lot of forum members I will be more interested in the working item when completed and tested,
and all components listed and available. 
Emgee


----------



## TorontoBuilder (Jan 29, 2015)

xpylonracer said:


> Hi TorontoBuilder
> I am following your posts with interest but yes I do find all the electronics a bit heavy,  but interesting.
> I guess like a lot of forum members I will be more interested in the working item when completed and tested,
> and all components listed and available.
> Emgee



I'm glad that you're following along with interest. I'm sure looking forward to the completed indexing head too! I'm trying to expedite this project now since I dying to begin using it. 

I'm close to having a good finalized bill of materials with links to suppliers, and alternatives if people wish to use a purchased arduino compatible rather than building one from bare PCBs and components.


----------



## Swifty (Jan 29, 2015)

I'm also keen to see that finished product, my knowledge of electronics is virtually zero, but I want to make an electronic divider. The mechanics are no problem, just the electronics. Still, I will have a go at making one once everything is sorted.

Paul.


----------



## Scott_M (Jan 29, 2015)

Hi TB
I am also following along. I have no need for this particular project as I have a 4th axis for my cnc mill. However I do have a need for a small microcontroller for an upcoming project, and recently purchased an Uno and I'm trying to wrap my head around "Arduino C". I am reading "Beginning C for Arduino" listed earlier in this thread or maybe it was Chucks ? But I am reading anything I can find regarding these little marvels. 
So many thanks for taking the time to share !

Scott


----------



## TorontoBuilder (Jan 29, 2015)

Scott_M said:


> Hi TB
> I am also following along. I have no need for this particular project as I have a 4th axis for my cnc mill. However I do have a need for a small microcontroller for an upcoming project, and recently purchased an Uno and I'm trying to wrap my head around "Arduino C". I am reading "Beginning C for Arduino" listed earlier in this thread or maybe it was Chucks ? But I am reading anything I can find regarding these little marvels.
> So many thanks for taking the time to share !
> 
> Scott



I'll try to post links to specific projects if you tell me what you wish to do with your controller. It's amazing ho many fantastic tutorials there are out there. Especially youtube videos. I've been soaking up the knowledge from them.


----------



## Scott_M (Jan 29, 2015)

Hi TB
Thanks for your help on this, however I feel that I may be on my own with a lot of this. I know there are a bunch of sketches out there but trying to meld them all together may prove to be more work than just starting fresh. Anyway here is what I would like to do, and at the risk of hijacking or going off topic feel free to respond via PM or just ignore my sorry butt 

I would like to automate a job I do a lot. It involves cutting a piece round plastic to a specific length and burning one end.
I would like to use 3 motors, I think I need 1 stepper but could use simple DC gear motors for the others.
Process
Step motor turns rubber feed wheel an exact amount feeding stock a specific distance.
first DC motor brings down a hot wire past the end of the plastic rod and retracts, this polishes the end
2nd DC motor brings down a razor blade and cuts the plastic rod to length and retracts.
repeat a specified number of times.

The acrylic plastic rod is 1.5mm diameter so none of the motors need to be very big. I was looking at Nema 11 size for the stepper.
The hot wire motor will have no resistance so a small motor will work there too and distance is not critical so time or a micro switch could control its retract trigger.
The razor blade will require some force, maybe 4-5 pounds based on me pushing a razor blade through the material on a scale. So I was thinking gear motor driving a rack and pinion.

I would really appreciate any insight or links you could provide.

And I really don't mean to wander off-topic too much or hijack

Thanks again

Scott


----------



## TorontoBuilder (Jan 29, 2015)

Scott_M said:


> Hi TB
> Thanks for your help on this, however I feel that I may be on my own with a lot of this. I know there are a bunch of sketches out there but trying to meld them all together may prove to be more work than just starting fresh. Anyway here is what I would like to do, and at the risk of hijacking or going off topic feel free to respond via PM or just ignore my sorry butt
> 
> I would like to automate a job I do a lot. It involves cutting a piece round plastic to a specific length and burning one end.
> ...



Hey Scott, I dont mind a little off topic stuff on this thread... if it grew to be a lot of info we could start a new thread.

It sounds like linear actuators may be the way to go for the razor cutter and hot wire motions. How much travel do you need for the cutters? 

You could make your own from cheap low torque steppers motors and achieve precise motion control at a low cost. You would build upon the hardware already being discussed.

Have a look at this:

http://www.ebay.ca/itm/NMB-Linear-A...907?pt=LH_DefaultDomain_0&hash=item541921711b

Just curious, couldn't your hot wire act as both your cutter and polisher?

I edited out the question you had already answered in your post... I read read more closely. silly me


----------



## Scott_M (Jan 29, 2015)

I like that actuator !!!
It will work fine for the hot wire.

The "cutter" has to be a blade or scissor, to give a clean edge. The hot wire will leave a rounded bulbous end. Which is what it is doing on the "polishing" end.
The cut is about an inch behind the polished end.
I am going to order a couple of those actuators and see how much power they have. The actual cut is only 1.5mm plus over travel and clearance so 10mm may be enough to get a little mechanical advantage on a scissor mechanism.
Thanks a lot !! that is a big help

Scott


----------



## TorontoBuilder (Jan 29, 2015)

Scott_M said:


> I like that actuator !!!
> It will work fine for the hot wire.
> 
> The "cutter" has to be a blade or scissor, to give a clean edge. The hot wire will leave a rounded bulbous end. Which is what it is doing on the "polishing" end.
> ...



The throw on that actuator may not be long enough to use alone but you may be able to use a linkage. You'll likely find a nice 2" stroke actuator suitable...  on ebay they range from $10 bucks from china, or $35 to $50 each from US. 

http://www.ebay.ca/itm/Heavy-Duty-5...t-Motor-/201275680079?&_trksid=p2056016.l4276

http://www.ebay.ca/itm/TWO-Heavy-Du...332?pt=LH_DefaultDomain_0&hash=item20e65f0104


----------



## canadianhorsepower (Jan 30, 2015)

Scott_M said:


> Hi TB
> my head around "Arduino C". I am reading "Beginning C for Arduino" listed
> Scott


 
Hi Scott
I did post that link but there is anoither one in the download section called build a robot but it's all interfacing with the arduino board
have a look

cheers
Luc


----------



## chucketn (Jan 30, 2015)

Searching the downloads area doesn't return anything on build a robot...

Chuck


----------



## canadianhorsepower (Jan 30, 2015)

chucketn said:


> Searching the downloads area doesn't return anything on build a robot...
> 
> Chuck


 here is the link

http://www.homemodelenginemachinist.com/downloads/files/how-to-build-a-robot.pdf

enjoy

Luc


----------



## chucketn (Jan 30, 2015)

Got it, thanks LUC.

Chuck


----------



## Scott_M (Jan 30, 2015)

Thanks Luc !

I suggest we get back on topic.

Sorry for the side step.

Scott


----------



## TorontoBuilder (Jan 30, 2015)

So to follow Scott's advice I'll post something back on topic, and that is rather brief too since it has changed my plans a little....

I wanted to see if I could design a custom arduino clone from scratch and build one especially suited for my project. I've achieved a design and went about sourcing components from digikey canada and elsewhere, and put together my bill of materials.

While this doesn't come as a surprise it is never-the-less surprising... just the cost of my board for an arduino clone will cost me about $30 Canadian, without tax. That's without any volume discounts of course but comparable to what an arduino Uno clone will cost me here in Canada. The two Uno R3s I ordered from sainsmart are costing me under $10 bucks each, plus whatever customs charges me, I doubt it will be much. 

Another downside is that some of the nano clones dont have polyfuses to protect computer you will use to program the arduino.

Similarly, and more to my size considerations and needs I can buy a MINI USB Nano V3.0 ATmega328P clone from ebay for less than $5 or $4.25 in quantity. The one downside of the nano is that it uses a surface mount chip that cannot be easily replaced if you fry your control controller, BUT the upside is the entire board costs less than the cost of a new atmega328P-PU chip with bootloader. 

So, I think I will design a different variant of the main control board into which I plug the nano as if it were a large chip using a couple of header strips. I'll then have headers to easily plug in the other components. Ease of use and cost effectiveness will be the main considerations 

.
For those curious people I'll be uploading the bill of materials spreadsheet to the downloads section later today


----------



## Holt (Jan 31, 2015)

I haven't posted for quite a while, but recently I got a mill, and have been looking for a dividing head for it, then I came across Chuck Fellows Arduino powered head, and fell in love immediately.
I really appreciate that someone take the time to make a "how to" for this project, but I wondered if some of you genius people could make an improvement that would make the head perfect. In C F's tread there was a link for a mill with synchronized index head for use when hobbing gears.
[ame]https://www.youtube.com/watch?v=ZhICrb0Tbn4&x-yt-cl=85114404&x-yt-ts=1422579428[/ame]
I have a rotary encoder with 1000 pulses per revolution, if I mount that on the mill spindle, I would imagine it would be possible to write a program that would rotate the dividing head in the desired synchronized speed.
The perfect solution would be a switch where I could choose between the two programs.
What do you think? would it be possible?


Holt

PS: I have no idea how to program the Arduino, so I can't do it myself, but I just ordered a education set, so hopefully I will be able to do some simple programming in the future.


----------



## TorontoBuilder (Jan 31, 2015)

Holt said:


> I haven't posted for quite a while, but recently I got a mill, and have been looking for a dividing head for it, then I came across Chuck Fellows Arduino powered head, and fell in love immediately.
> I really appreciate that someone take the time to make a "how to" for this project, but I wondered if some of you genius people could make an improvement that would make the head perfect. In C F's tread there was a link for a mill with synchronized index head for use when hobbing gears.
> https://www.youtube.com/watch?v=ZhICrb0Tbn4&x-yt-cl=85114404&x-yt-ts=1422579428
> I have a rotary encoder with 1000 pulses per revolution, if I mount that on the mill spindle, I would imagine it would be possible to write a program that would rotate the dividing head in the desired synchronized speed.
> ...




Hi Holt,

I saw the same video and wanted to perform the exact same task. I don't have a CNC mill or the software in that video, but am pretty sure that it is possible to have the arduino perform the same tasks. 

First we need to add a rotary encoder to the mill, and program an arduino interrupt to trigger our program whenever the mill motor rotates... then we'd have the arduino read the speed based on the steps per rotation. Finally we'd have the arduino output the step command to the stepper driver at a rate proportional to rotation of the mill shaft. I think it shouldn't be that difficult to figure out, especially since we only need to encode for rotation in forward if we want to make things dead simple.

One key is working out a suitable number of slots per revolution to assure fast accurate shaft speed rotational measurement. large plotters often had 200 holes per rotation... which actually matches the steps of common stepper motors. 

The dividing head will be my first arduino project, but not my last. I also know how optical encorders work to some extent so I can undertake that for my mill. The problem is that each mill owner will have to make modifications to suit their own machine. Otherwise we can develop standard hardware for that project


----------



## rodw (Feb 1, 2015)

John, there is a much easier way to measure rotation. Just grab one of these https://www.sparkfun.com/products/11102

You'd have to check the maximum RPM of the mill spindle vs the speed at which the Arduino can sample the rotary encoder pulses when selecting the steps per revolution of the encoder you use. The other limiting factor will be the maximum stepper resolution. From Memory, the NEMA 17 and 23 I played with maxed out at about 400 RPM with both the Polou and Gecko microdrive. Its been a while since I looked at these encoders with the same idea in mind. Pretty sure they also sense direction.

Glad you know about interrupts. You'll need them.


----------



## Holt (Feb 1, 2015)

rodw said:


> John, there is a much easier way to measure rotation. Just grab one of these https://www.sparkfun.com/products/11102


 
The link doesn't seem to work.
The stepper motor speed at 400 rpm is more than adequate, I wouldn't imagine a spindle speed over 250 rpm with a gear hopper, if you cut a 10 tooth gear, the indexer should rotate at 25 rpm, if the indexer is geared to the stepper at 5/1, the stepper speed would be 125 rpm.
I would not imagine the need for smaller gears as 10 tooth, and the larger gear, the slower speed.


Holt


----------



## TorontoBuilder (Feb 1, 2015)

Thanks Rod,

I'd seen the rotary encoder from sparkfun, but hadn't looked at it closely since it didn't look like there was an easy way to interface it with the mill spindle.

Yes such encoders output a square waveform that allows the controller to easily sense direction of rotation. Depending on the direction of rotation, the leading edge of the wave is either high and falls off, or is low and rises. 

I recall reading that stepper motors have a limited maximum rpm rate so yes the hobbing set-up would have to be lower overall rpm within the maximum speed specification of the stepper.


----------



## TorontoBuilder (Feb 1, 2015)

Holt said:


> The link doesn't seem to work.
> 
> Holt



Copy and paste the link in your browser... as viewed it works.


----------



## canadianhorsepower (Feb 1, 2015)

TorontoBuilder said:


> Thanks Rod,
> 
> I'd seen the rotary encoder from sparkfun, but hadn't looked at it closely since it didn't look like there was an easy way to interface it with the mill spindle.
> 
> ...


 
Here is a good encoder tutorial with the interface programming.
simply attache directtly to the mill spindle
http://www.pjrc.com/teensy/td_libs_Encoder.html


cheers


----------



## rodw (Feb 1, 2015)

TorontoBuilder said:


> Thanks Rod,
> 
> I'd seen the rotary encoder from sparkfun, but hadn't looked at it closely since it didn't look like there was an easy way to interface it with the mill spindle.
> .



Just tap a thread on the inside of the spindle and screw in an appropriate adapter that attaches to the encoder.

EDIT: That might get in the way of the draw bar so on my SX3 you could attach it to the drive pulley in much the same way as the belt ratio can be accounted for in the software. I'd have to pull the top cover off again to see what the end of the drive shaft looks like.


----------



## rodw (Feb 1, 2015)

canadianhorsepower said:


> Here is a good encoder tutorial with the interface programming.
> simply attach directly to the mill spindle
> http://www.pjrc.com/teensy/td_libs_Encoder.html
> 
> ...



So this tutorial says the maximum speed the Arduino can handle is about 127,000 pulses per second. The encoder fires 4 pulses per step. I think the 200 step encoder from Sparkfun would be a better choice (and lines up with the resolution of most steppers). 
https://www.sparkfun.com/products/10932

There will be 200x4 = 800 steps per revolution. So 127,000 / (200 *800) = 158.75 RPM maximum spindle speed. Lets say 150 rpm design maximum.

With a 90:1 rotary table, and assuming maximum design RPM of the stepper was 360 rpm, the fastest as standard RT can rotate is 4 rpm (360/90) unless you add some sort of geared drive. (I've seen some RT's driven by a timing belt ). I think this says you'd need to build a dedicated spindexer type fixture. I think my minimum spindle speed is about 90 RPM so a 10:1 ratio needs 9RPM on the RT.

If you assumed that the inertia of the spindle slowed the RPM enough so the software always caught up when the direction changed (pretty safe assumption I think), The interrupts just need to  be modified to maintain the Direction of the stepper (DIR).  

For simplicity, lets assume a direct drive and you want a 10:1 ratio, all the Arduino needs to do in the main loop is to check the encoder accumulator, you'd need something like this.

```
if(EncoderCount >= 10){
   DriveStepper(dir,  1);  // Output 1 step in current direction set by interrupt.
   EncoderCount -= 10;
}
```

This is way simpler than a dividing application. I think it would be best to be a dedicated Arduino for the task. Remember to use the timer interrupt to drive the stepper motor.....


----------



## canadianhorsepower (Feb 1, 2015)

rodw said:


> So this tutorial says the maximum speed the Arduino can handle is about 127,000 pulses per second. The encoder fires 4 pulses per step. I think the 200 step encoder from Sparkfun would be a better choice (and lines up with the resolution of most steppers).
> https://www.sparkfun.com/products/10932
> 
> There will be 200x4 = 800 steps per revolution. So 127,000 / (200 *800) = 158.75 RPM maximum spindle speed. Lets say 150 rpm design maximum.
> ...


 
Instead of frying your brains with math formula:fan: that I didn't wright maybe you should read what I sugjest 





> simply attache directtly to the mill spindle


 
This is only to help people. Maybe instead of puking on "my sugestion link" you should take your personal time and put an article on it
this would allow people to complaint about it


----------



## rodw (Feb 1, 2015)

canadianhorsepower said:


> Instead of frying your brains with math formula:fan: that I didn't wright maybe you should read what I sugjest
> 
> This is only to help people. Maybe instead of puking on "my sugestion link" you should take your personal time and put an article on it
> this would allow people to complaint about it



Luc, I made two posts. Clearly  you missed my first post where I suggested how to attach the encoder. If ya gunna play with electronics, you have to know the limits before you start. Otherwise you could dive on the tools, do a lot of work and then find it won't work and end up with....:fan:


----------



## TorontoBuilder (Feb 1, 2015)

canadianhorsepower said:


> Instead of frying your brains with math formula:fan: that I didn't wright maybe you should read what I sugjest
> 
> This is only to help people. Maybe instead of puking on "my sugestion link" you should take your personal time and put an article on it
> this would allow people to complaint about it



except cant be attached to my mill spndle since the drawbar is in the way.... and I have about 3 drawbars I need to use for different collets and boring head etc...


----------



## Holt (Feb 2, 2015)

rodw said:


> There will be 200x4 = 800 steps per revolution. So 127,000 / (200 *800) = 158.75 RPM maximum spindle speed. Lets say 150 rpm design maximum.


 
You got your math wrong, the 158.75 revolutions is per *second,* so 158.75 times 60 = 9525 rpm


Holt


----------



## TorontoBuilder (Feb 2, 2015)

FINAL Indexer Control Board Design - REVISED to be utilize a low cost Arduino Nano V3 rather than a arduino clone circuit.

The Nano plugs into a motherboard via 15pin female headers.

The motherboard name is "Arduino Nano Based Electronic Indexer v2.1" 

This will be my final board design.

Input power between 6.5-12 VDC up to 5A. 

5VDC Fixed Voltage Regulator board up to 800mA to power Arduino and accessories.

Optional Motor Supply Adjustable Voltage regulator board 1.25-36VDC, 0-5A output iin case the 12V regulated power supply is not suitable for your selected stepper motor. 

Uses a Nano V3.0 with mini-USB connector connected to the main PCB via two 15 pin headers.

Features:
Main board +5V power input soldering pad or pin input options.
Motor Voltage input soldering pads, 
Connector headers for lighted Keypad break-out board, IC2 LCD Display, and +5V & GND terminals for optional cooling fan and current sensor power.

Bill of Materials:
http://www.homemodelenginemachinist...o-based-electronic-dividing-head-v10-306.html

Link to Boards:

 https://oshpark.com/shared_projects/NNEXkE31  

https://oshpark.com/shared_projects/hcnykUxw

This final revision added the current sensor connector to the board, relocated and widened the 5V and GND traces on the board and added more room for the 100 uF motor capacitor. As soon as my boards arrive I'll follow with a detailed build log.


----------



## rodw (Feb 2, 2015)

Holt said:


> You got your math wrong, the 158.75 revolutions is per *second,* so 158.75 times 60 = 9525 rpm
> 
> 
> Holt



Thanks Holt. It was early in the morning and I was half asleep. Thats why its good to share. 

The  other side of the problem (being the maximum speed a stepper can run a 90:1 rotary table at) still stands at 4 rpm because I measured this speed with a digital tacho. 



TorontoBuilder said:


> except cant be attached to my mill spndle since the drawbar is in the way.... and I have about 3 drawbars I need to use for different collets and boring head etc...



That may not be as hard as you think. Here's a pic of the drawbar on my SX3 mill. this is one I made.






It would not be too hard to come up with a way to connect the encoder to the drawbar via some sort of disconnect.

I know each mill is different, but I think it could be done quite easilly even if it required a dedicated drawbar with the encoder attached.


----------



## canadianhorsepower (Feb 2, 2015)

TorontoBuilder said:


> New Board Design
> 
> Input power between 6.5-12 VDC up to 5A.
> 
> ...


 
I make my own board do you have the original file "eagle are what ever program you use"

Now am I missing something:wall::wall: why would you want to hook the encoder to your mill spindle :hDe: can't see the advantage 

cheers


----------



## Holt (Feb 2, 2015)

canadianhorsepower said:


> Now am I missing something:wall::wall: why would you want to hook the encoder to your mill spindle :hDe: can't see the advantage
> cheers


 
It is to synchronise the speed at the mill spindle with the speed of the index spindle for gear hobbing, see the Youtube video in answer #38
It would be a very nice extra feature


Holt


----------



## canadianhorsepower (Feb 2, 2015)

Holt said:


> It is to synchronise the speed at the mill spindle with the speed of the index spindle for gear hobbing, see the Youtube video in answer #38
> It would be a very nice extra feature
> 
> 
> Holt


 
Holt

I went back to the video these are not encoders but opto coupler allowing him to read GREY code with two of them to know if it goes forward or reverse and the third one to read the frequency or RPM.
 you would send this signal to a steppermotor controler like this one
http://2.bp.blogspot.com/-DUMUZllDl...StepperMotorController+555+timer+circuits.gif
 and you could control what you want at the rate you want in relation to your spindle speed and direction


----------



## TorontoBuilder (Feb 2, 2015)

rodw said:


> That may not be as hard as you think. Here's a pic of the drawbar on my SX3 mill. this is one I made.
> 
> 
> 
> ...



Thanks Rod...

Your pic got me thinking... 

I think I can to come up with something for the drawbar I use with my collet holders at least. Assuming there is sufficient length protruding above the retainer nut. 

I assume I can make a coupler for each drawbar, some one is a hex head the other two are square head. But I've never made a square or hex hole in anything before let alone one that was concentric with another piece. I guess I'll have to get my brother to mill the holes.

Whatever I do I'll have to do away with the spndle cap and make a larger on that also acts as an encoder mount


----------



## TorontoBuilder (Feb 2, 2015)

rodw said:


> That may not be as hard as you think. Here's a pic of the drawbar on my SX3 mill. this is one I made.



p.s. I like the pic of the kookaburra on your photobucket page.. reminded me of a song I learned when I was young... laugh kookaburra laugh...


----------



## canadianhorsepower (Feb 2, 2015)

TorontoBuilder said:


> p.s. I like the pic of the kookaburra on your photobucket page.. reminded me of a song I learned when I was young... laugh kookaburra laugh...


 

Hi do you have the original PCB drawing for your board
 did you read the post I put here about the EMC 2 the guy is using in post 38


----------



## Holt (Feb 2, 2015)

canadianhorsepower said:


> Holt
> 
> I went back to the video these are not encoders but opto coupler allowing him to read GREY code with two of them to know if it goes forward or reverse and the third one to read the frequency or RPM.
> you would send this signal to a steppermotor controler like this one
> ...


 
How would you control the stepper speed 100% with that?
If it takes lets say 10 minutes to cut a 50 tooth gear, if the stepper is off by half a revolution by the end of that time, you end up with a helical gear in stead of a straight cut, that kind of precision can't be achieved with a potmeter.


Holt


----------



## canadianhorsepower (Feb 2, 2015)

Holt said:


> How would you control the stepper speed 100% with that?
> If it takes lets say 10 minutes to cut a 50 tooth gear, if the stepper is off by half a revolution by the end of that time, you end up with a helical gear in stead of a straight cut, that kind of precision can't be achieved with a potmeter.
> 
> 
> Holt


 Holt

check this video you will understand more This is how weve been controlling robots and close loop CNC for years

check the speed also



http://www.pjrc.com/teensy/td_libs_Encoder.html


----------



## TorontoBuilder (Feb 2, 2015)

canadianhorsepower said:


> Hi do you have the original PCB drawing for your board
> did you read the post I put here about the EMC 2 the guy is using in post 38



Hi Luc,

Sorry I had uploaded the pcb to the downloads section but just recently deleted it since I came up with a board to supercede the original... since I no longer intended to test and build the original.

I saw post 38 and the comments related to that, but wasnt sure how people meant to attach the rotary encoder to the mill. I think I have a good grasp on it now. I was too fixated on attaching a perforated disk encoder by trapping it between the spindle and the drawbar retainer nut


----------



## rodw (Feb 3, 2015)

I know we went off topic with the encoders But I'm glad to see it made people think. The simplest method of attaching an encoder to a drawbar would be to chuck the drawbar in your lathe, drill a hole into the end of the drawbar, insert the encoder shaft and add a grub screw to secure it. Maybe you could modify a socket spanner if your drawbar has a hex head for a disconnect.  I have turned a socket down before so they are machinable. Just machine an adapter that fits over the socket to attach the socket to the encoder.

John, could you attach an encoder to the motor shaft At the top of the mill? You can account for the belt ratio in software.

Luc,  the encoders also include grey code and can sense direction and RPM (With the right software). We don't need to calculate RPM, just ensure that the RT rotates proportionally to the spindle by counting pulses, doing some maths and sending a scaled output pulse on another port to the RT. Its very simple code.


----------



## TorontoBuilder (Feb 3, 2015)

I'm not sure about attaching to the motor shaft since I havent had the cover off the motor since I got the mill in November. I suppose I could, I'll check. I have gear driven model so I should look up the gear ratio somewhere.

I do want to figure this out fairly soon since I'll be working a hobbing program into my controller....


----------



## rodw (Feb 4, 2015)

I'll be following Your project. I did a fair bit of work on a software library for the menus and data entry for an Arduino RT controller. But I kept getting interrupted and running out of time and could never pick it up again. I have all the hardware and was going to include an SD card Which I have on a shield. I was going to use a freetronics lcd and keyboard.


----------



## TorontoBuilder (Feb 4, 2015)

rodw said:


> I'll be following Your project. I did a fair bit of work on a software library for the menus and data entry for an Arduino RT controller. But I kept getting interrupted and running out of time and could never pick it up again. I have all the hardware and was going to include an SD card Which I have on a shield. I was going to use a freetronics lcd and keyboard.




Nice I think the Freetronics LCD/keypad shield is the best one out there. Its one of the few that has a button height sufficient to allow them to be accessible when in an enclosure. Looks to be excellent build quality. 

I used the resistor values of the freetronic for my own keypad buttons so the sketches will be compatible without any modification.

Yesterday I ordered 3 arduino Nanos, 3 LCD displays and IC2 serial backpacks, 3 current sensors and etc. nothing left but the waiting again.


----------



## rodw (Feb 5, 2015)

TorontoBuilder said:


> Nice I think the Freetronics LCD/keypad shield is the best one out there. Its one of the few that has a button height sufficient to allow them to be accessible when in an enclosure. Looks to be excellent build quality.
> 
> I used the resistor values of the freetronic for my own keypad buttons so the sketches will be compatible without any modification.
> 
> Yesterday I ordered 3 arduino Nanos, 3 LCD displays and IC2 serial backpacks, 3 current sensors and etc. nothing left but the waiting again.



The only problem with the freetronics is that you do get a bit of keyboard bounce. I'll have to go digging for some of the code and libraries I have which fixed it and might save you some time. One of them had a screen saver feature which is handy as I have burnt out a screen in 24 hours when left running constantly.


----------



## Scott_M (Feb 5, 2015)

Hi Guys
This may be a silly question, but I am new to these things.
I was looking at the Freetronics mentioned above, with these shields that don't have pins on the top, how are you supposed to add your driver shield ?
Or access any of the other unused pins ?

Scott


----------



## TorontoBuilder (Feb 5, 2015)

Scott_M said:


> Hi Guys
> This may be a silly question, but I am new to these things.
> I was looking at the Freetronics mentioned above, with these shields that don't have pins on the top, how are you supposed to add your driver shield ?
> Or access any of the other unused pins ?
> ...



Hi Scott, there are no silly questions.

The LCD shield is meant to be a terminal shield... i.e. the last in the chain since its the user interface you need to keep accessible.  The only pins typically on LCD shields point down for this reason.

Locate your motor shield underneath your lcd shield.

I've always thought that protoshields are not so good because they become less accessible when you stack other shields on top of them, thats why I designed my own motherboard. Its all a trade off...


----------



## Scott_M (Feb 5, 2015)

Thanks TB

I made the mistake of telling one of my machinist buddies about this, and now it seem I may have an electronic dividing head in my future to do list.
This however would need to be a higher power setup. He wants to motorize his 8" rotary table. So I am thinking of using a gecko with an external power supply and a nema 34 motor. Looking at that freetronics LCD with the nice buttons , it doesn't seem to have the extra holes to solder pins to. How would one get at the pins needed for step and direction signals ?

Scott


----------



## TorontoBuilder (Feb 5, 2015)

Scott_M said:


> Thanks TB
> 
> I made the mistake of telling one of my machinist buddies about this, and now it seem I may have an electronic dividing head in my future to do list.
> This however would need to be a higher power setup. He wants to motorize his 8" rotary table. So I am thinking of using a gecko with an external power supply and a nema 34 motor. Looking at that freetronics LCD with the nice buttons , it doesn't seem to have the extra holes to solder pins to. How would one get at the pins needed for step and direction signals ?
> ...




you have several options...

First you could solder the leads to the pin stubs on the topside of the lcd shield. Not the best option.

Or you could solder the step dir leads to the pins on the underside of the LCD shield close to the header so that it doesnt interfer when you plug in the lcd shield the your UNO. 

Or install a protoshield between your uno and the lcd shield.

Or wait till I make a new motherboard for working with heavy duty steppers


----------



## Scott_M (Feb 5, 2015)

Ahhhh Protosheild

http://www.amazon.com/dp/B00HBVVKPA/?tag=skimlinks_replacement-20  with screw terminals !

I will keep an eye on your development, and see if you are ready by the time I have to start that project.

Thanks again, I do appreciate the help !

Scott


----------



## rodw (Feb 6, 2015)

Scott_M said:


> Ahhhh Protosheild
> 
> http://www.amazon.com/dp/B00HBVVKPA/?tag=skimlinks_replacement-20  with screw terminals !
> 
> ...


Beat me to it, Freetronics also have one Like this.
http://www.freetronics.com.au/colle...ucts/terminal-shield-for-arduino#.VNSpVeh47MI

The other 2  tricks I've used is 

1. to solder on some ribbon cable to a protoboard and add an IDC  connector to the ribbon and solder an IDC socket onto some perforated board.

2. For the Aussies, solder these guys onto the prototype board.
http://www.jaycar.com.au/productView.asp?ID=HM3130&form=CAT2&SUBCATID=991#1
Jaycar also have a 3 terminal one the same and these have dovetails at each end so they clip together like Leggo to make longer  terminal strips. Just get the ones with the same pin pitch as what arduino use. They  fit to every second hole.


----------



## rodw (Feb 6, 2015)

Here, found some pics

IDC connector and ribbon cable soldered to prototype board.







Freetronics attached to Prototype board with arduino uno on the bottom.






We best not go off topic about what this is meant to be.... Solar PV output controller for hot water system.


----------



## rodw (Feb 6, 2015)

I finally fired up my old PC and found all my Arduino code. I've actually done a lot of development of bits and pieces of the user interface code for a rotary table controller based on the Freetronics board which should be able to be slotted straight into this project of Johns if he keeps the pin assignments the same. Stuff I did was complete menu system and form data entry module as well as playing around with stepper drivers. I'll try and go through it and post some of it up on another thread dedicated to software for this project. I started on this because I could see the limitations of Chucks controller and wanted to get a robust system in place. I just ran out of time. So if there is some interest, maybe one of you guys could take my work and build on it to make the software as kickass as Torontobuilders hardware.

As always, the User Interface code is 90% of the project. Getting data into the system with only 4 keys is quite challenging. The actual controller code is pretty trivial. Too late now. 

Maybe over the weekend.


----------



## chucketn (Feb 6, 2015)

Rod, I'm working on adding a serial LCD and 4x4 Keypad to Chuck F's build. I have the prototype of Chucks working but not installed on the RT yet. I have 2 more Arduino Uno's, a stepper shield, LCD, Serial adapter, and 2 screw type proto boards on order. Looks like another week to 10 days before I get all the parts.

Chuck(chucketn)


----------



## TorontoBuilder (Feb 6, 2015)

rodw said:


> I finally fired up my old PC and found all my Arduino code. I've actually done a lot of development of bits and pieces of the user interface code for a rotary table controller based on the Freetronics board which should be able to be slotted straight into this project of Johns if he keeps the pin assignments the same. Stuff I did was complete menu system and form data entry module as well as playing around with stepper drivers. I'll try and go through it and post some of it up on another thread dedicated to software for this project. I started on this because I could see the limitations of Chucks controller and wanted to get a robust system in place. I just ran out of time. So if there is some interest, maybe one of you guys could take my work and build on it to make the software as kickass as Torontobuilders hardware.
> 
> As always, the User Interface code is 90% of the project. Getting data into the system with only 4 keys is quite challenging. The actual controller code is pretty trivial. Too late now.
> 
> Maybe over the weekend.



hey rod, I'm happy to help on the software too... I need to learn more. I'd like to see HMM guys develop the best controller out there if we can.

I'll look for the new thread under software


----------



## TorontoBuilder (Feb 6, 2015)

I got my delivery from Sainsmart today but then my laptop display died... talk about bad timing.

I had to dig out one of my old desktops and am now trying to restore all my programs. Tomorrow though I'll begin working on my arduino sketches.


----------



## rodw (Feb 6, 2015)

I've been having some trouble getting a compiled and working stuff off my old PC. I gt very confused where the Arduino IDE puts libraries and stuff so I need to do a bit ore work on this but the bits I had are:
1. a complete menu system that I had cleaned up and got working specifically for a Rotary table and the Freetronics display
2. a comprehensive field data entry library I'd added a field type to add angles in degrees minutes and seconds. The data entry was based on pressing up and down arrows to increase a number under the cursor by a specified amount. I wanted to add another integer field data entry routine that let you do the same thing to an integer (eg Number of Divisions) as the current data entry routine was based on incrementing or decrementing by specific amount which could become tedious.
3. Some trivial code to drive a stepper driver using the timer interrupt. It is not desirable to use delay()
4. I had also experimented with using an SD card and was able to read and write files


----------



## rodw (Feb 8, 2015)

Well, I made some progress on software and created a thread here http://www.homemodelenginemachinist.com/showthread.php?p=261280#post261280


----------



## TorontoBuilder (Feb 24, 2015)

Ah I love ebay... at least the one vendor since my package arrived in about 1/3 the time it took my sainsmart shipment to arrive.

I now have everything but my circuit boards and stepper motor.

3 Nanos
3 20x4 lcd displays w/ serial adaptors
3 current sensors
5 stepper drivers... and more

so soon the build photos will start coming. everything is much smaller than I thought... I hope I can keep hands steady enough to solder well.


----------



## TorontoBuilder (Mar 12, 2015)

I got all my PCB boards delivered... 
.
I'm thrilled with the results with the minor exception that I forgot to re-size the stepper driver headers when I selected cheaper chinese driver instead of the pololu one.

Not a big problem, I'll just use the more expensive pololu driver on those boards.

I've made 5volt switching power supply boards, current sensing boards, op amp boards to expand the current sensing scale, keypad board boards and the main arduino boards.

I also had foam cutter circuit board made up too, so I can make foam patterns for lost foam casting.

Tomorrow I'll start soldering everything together.


----------



## rodw (Mar 13, 2015)

Looking great! I wanna see it dividing ...


----------



## rodw (Mar 14, 2015)

TorontoBuilder

Just an idea for you seeing you have to adjust your board layout design. What about including a header that presented the signals for 2 more Stepper drivers?

Then design a daughterboard for the additional stepper drivers to mount to. 

The reason I suggest this is that the way my software has turned out, it supports multiple devices (both rotary and linear) and defines separate step and direction pins for each device.  There are opportunties to control different devices from the same controller.

This idea would preserve your compact footprint yet allow people to wire in a power feed linear drive or other device if they wanted to.

Or use it as the basis for a GRBL CNC controller...... maybe.


----------



## TorontoBuilder (Mar 14, 2015)

rodw said:


> TorontoBuilder
> 
> Just an idea for you seeing you have to adjust your board layout design. What about including a header that presented the signals for 2 more Stepper drivers?
> 
> ...



They will be done...


----------



## Scott_M (Mar 16, 2015)

Wow TB

They look great !

Keep us posted.

Scott


----------



## TorontoBuilder (Mar 16, 2015)

rodw said:


> TorontoBuilder
> 
> Just an idea for you seeing you have to adjust your board layout design. What about including a header that presented the signals for 2 more Stepper drivers?
> 
> ...



Hi Rod,

I'm working on re-configuring the main board to accept more stepper boards (each via its own header and larger carrier board)

I've laid out a stepper carrier board with screw terminals for the motor VIN & GND as well as a screw terminal for the 2B, 2A and 1B, 1A output. I've also added an onboard 100uF capacitor. 

Now its decision time, since we need to overcome some design issues, pin limitations etc, as well as consider whats already available on the market. 

There are several cnc shields that allow use of 3 or 4 stepper drivers and GRBL  language. They range from cheap 3 motor versions with plugin Nano and a single motor capacitor to 4 motor versions with individual caps for each stepper driver and fully optimized for cnc use.

I can arrange the board to be low profile & compact with 2 stepper drivers, Or I can layout the main board to accept stepper daughter boards oriented vertically, with the compromise of adding 1.25" to the height, but can accommodate 3 or maybe even 4 stepper boards.

The additional steppers will each require 2 more digital pins... will we have enough if using standard LDC connections?

Reviewing the pin utilization this is what I think your sketch uses, please correct me if I am wrong:

LCD using digital pins 4, 5, 6, 7,8, 9, 

I cant recall what you did with DIR & STEP since I recall that you had conflicts with Freetronics using D3 for PWM control of the backlight on the lcd shield. You're using D2 and ??

A0 for keypad 

I think we can at least easily add another stepper motor using pins D11, D12... IIRC one of the two pins needs to be PWM and D11 meets that requirement.

By my reckoning we're out of pins unless use serial LCD display... 

or I may have read somewhere about serial configuration of stepper drivers or the ability to share a common STEP pin. Does that sound familiar? 

If you wanted more than two steppers we need to free up digital pins and I think that serial LCD display is easiest method to achieve that.

Please people let me know what you think...


----------



## TorontoBuilder (Mar 16, 2015)

Just an FYI in case you were not aware... 

On the Freetronics LCD shield the LCD backlight with current limiting, brightness and on/off controllable by D3, can be moved to D2, D10 for easy project pin compatibility with Chuck's original sketch.

http://www.freetronics.com.au/pages/lcd-keypad-shield-backlight-control#.VQdPqo54pcQ


----------



## rodw (Mar 17, 2015)

John, you got the pins right and yes, I recently noticed the Freetronics backlight pin can be moved. The reason why they use pin 3 is that it supports PWM so the backlight can be dimmed. On another  pin, you loose the dimming capability but my sketch is  not dimming the display anyway so it won't matter.

I'm using pins 1&2 for the stepper which is not ideal as the hardware interrupt pins conflict. These might be needed  if you wanted to add a rotary encoder.

Don't forget you can use the remaining 5  analog pins for digital I/O so you have heaps of pins. It would be good to keep the Freetronics analog display pins free.

It would be good if the code base had a single #define that selected between a digital or analog display. 

Personally I don't think we need to worry too much about CNC compatibility with other shields. If thats what people want, they'll probably buy a dedicated grbl shield or a TinyG 4 axis. These both replace the Arduino bootloader and you need the Atmel AVRRISP (Which I have) or equivalent to program and you won't need a display. Just keep a PWM pin free for spindle speed and bring all spare pins (including the analog LCD PINS) out to a header for custom displayless applications. 

I got my linear controller version out into the shed  last night, some bugs but I'll report on the other thread.


----------



## TorontoBuilder (Mar 17, 2015)

So how about a board w/ support for three stepper drivers? 

I'd find it useful to have one rotary controller and two linear controllers that could drive steppers attached to my milling machine table x & Y axis's.

I wasn't aware that analog pins could be used as digital I/O pins.

I dont see a digital pin 1 on the nano... I'm attaching a pic with the nano pin outs and a much more detailed pdf

Since I'm redesigning the board now is the time for changes. For ease of compatibility with your sketch would you tell me what pins two to connect to the traces going to the stepper DIR and STEP connectors for each of 3 stepper drivers? But remember I dont think I have a D1 

View attachment nanopdf.pdf


----------



## rodw (Mar 17, 2015)

TorontoBuilder said:


> So how about a board w/ support for three stepper drivers?
> 
> I'd find it useful to have one rotary controller and two linear controllers that could drive steppers attached to my milling machine table x & Y axis's.
> 
> ...


Confusing isn't it?

Pins 0 and 1 are RXD and TXD as shown in the PDF. These can be used a a serial port but are still able to be used as digital pins.

Pins 2&3 are wired to the hardware interrupts so maybe they should not be used for a stepper as they probably should be reserved for a rotary encoder if you want to try ykur hand at hobbing.

The good news is that it does not matter which pins you choose to use for steppers as my software sketch is configurable at the device level. Eg.when adding a new device you specify which pins to use for step and direction and the data is stored in EEPROM. The code could be modified so if it sees an empty EEPROM, it creates 3 devices and set them to your chosen defaults. Currently, it is only creating 1 device When it sees an empty EEPROM.

Also make sure you present the step and direction pins for each stepper somewhere so you can use external steppers. But I think you will allow for that anyway. Im out of time But will see what grbl uses.


----------



## TorontoBuilder (Mar 17, 2015)

THX! Rod

Much clearer... 

Yep I also intended to have male header pins to access every pin if desired. I didnt realize how you were using eeprom very cool.

Hobbing is on my list of wants so yes I'll keep pins open

So let me see whats what...


----------



## rodw (Mar 18, 2015)

John, what pins are you using for your  SPI LCD display? I'm wondering if you just don't put a Spi driver chip on your board and then people can add the LCD display to the chip like this?
http://playground.arduino.cc/Main/LiquidCrystal This hardwires in the backlight.

That would standardise the display to 10, 11, and 13. Keep 0&1 free for serial port, 2&3 free for  an encoder, keep port 9 free for spindle PWM output. and your 3 steppers could be on 4&5,  6&7, and 8&12. Port A0 for keyboard,. The remaining analog ports free for user features. Check that would work first though!


----------



## TorontoBuilder (Mar 18, 2015)

rodw said:


> John, what pins are you using for your  SPI LCD display? I'm wondering if you just don't put a Spi driver chip on your board and then people can add the LCD display to the chip like this?
> http://playground.arduino.cc/Main/LiquidCrystal This hardwires in the backlight.
> 
> That would standardise the display to 10, 11, and 13. Keep 0&1 free for serial port, 2&3 free for  an encoder, keep port 9 free for spindle PWM output. and your 3 steppers could be on 4&5,  6&7, and 8&12. Port A0 for keyboard,. The remaining analog ports free for user features. Check that would work first though!



I have a bunch of 12C serial adapters that use pins SCL, and SDA leaving all my digital pins avaiulable. These adapters are $1.50 CAD on ebay so I think it's best option since its cheap, fairly well supported and only uses 2 pins. 

!REVISED BELOW!

I'll now be using the following pairs for the steppers: 6&7, 8&10, 11&12


----------



## rodw (Mar 18, 2015)

TorontoBuilder said:


> I'll use the following pairs for the steppers: 7&8, 10&11, 12&13



and the display is on Analog pins A4  & A5?


----------



## TorontoBuilder (Mar 18, 2015)

rodw said:


> and the display is on Analog pins A4  & A5?



Correct. On the Nano A4 & A5 are serial pin SDA & SCL


----------



## rodw (Mar 19, 2015)

TorontoBuilder said:


> Correct. On the Nano A4 & A5 are serial pin SDA & SCL



Ordered a couple of SPI interfaces and LCD displays ex Hong Kong. They'll take 2-3 weeks.

I thought I'd just clarify that my sketch only supports one device at a time. You have to swap devices (eg. Load another device out of the EEPROM via the menu) to drive a different stepper. That won't really be to much of a drama with a single linear interface as its unlikely you'd want a linear drive and a rotary drive at the one time. Driving X&Y might get a bit annoying.


----------



## TorontoBuilder (Mar 19, 2015)

rodw said:


> Ordered a couple of SPI interfaces and LCD displays ex Hong Kong. They'll take 2-3 weeks.
> 
> I thought I'd just clarify that my sketch only supports one device at a time. You have to swap devices (eg. Load another device out of the EEPROM via the menu) to drive a different stepper. That won't really be to much of a drama with a single linear interface as its unlikely you'd want a linear drive and a rotary drive at the one time. Driving X&Y might get a bit annoying.



thx for the clarification... one at a time is fine... there remain many uses for such a controller.


----------



## rodw (Mar 19, 2015)

TorontoBuilder said:


> thx for the clarification... one at a time is fine... there remain many uses for such a controller.



And of course, you could write your own multi stepper code.....


----------



## TorontoBuilder (Mar 19, 2015)

rodw said:


> And of course, you could write your own multi stepper code.....



haha touche...

Once I have one good controller up and running I'll try to do just that. But first I need to get rotary controller into production to make gears for an etching press I have been planning to make for almost a decade...


----------



## rodw (Mar 20, 2015)

TorontoBuilder said:


> haha touche...
> 
> Once I have one good controller up and running I'll try to do just that. But first I need to get rotary controller into production to make gears for an etching press I have been planning to make for almost a decade...



At least you didn't rebuff with a comment about me making my own board! The earlier sketches will be a good framework for other projects.


----------



## TorontoBuilder (Mar 20, 2015)

The revised single stepper rotary control board in available for anyone who wants 3 from Oshpark.

This has been revised to correct the stepper driver carrier width. You may use any Pololu a4988 board. It makes use of external 5 button analog keypad via pin A0 and will accept 1C2 LCD or any sainsmart or freetronics compatible lcd  

Main board:
https://oshpark.com/shared_projects/eqntBWjI

Keyboard:
https://oshpark.com/shared_projects/hcnykUxw

As soon as my revised boards arrive I'll start a build thread to put it all together...


----------



## TorontoBuilder (Mar 20, 2015)

As per Rod's suggestion I've made a simple compact main board & plug in modules for the a4988 stepper drivers.

This will allow people to take advantage of Rod's multi-function software design to use a single control box for multiple uses.

The main board is available here:
https://oshpark.com/shared_projects/WQivbqSm


It also uses the same separate keypad which is here:
https://oshpark.com/shared_projects/hcnykUxw


Finally here is the link to the daughter boards:
https://oshpark.com/shared_projects/3KdDlilG

The daughter boards uses a 6 pin 3.5mm screw terminal block for all motor connections and the motor power & ground. 

This board has a surface mount 100uF capacitor. iAlmost all 25v caps will fit under the stepper driver (ie less than 0.25" height), or a panasonic EEE-FT1V101AP 35V capacitor if you need higher capacity cap. 

The daughter board plugs into main board using 4 male 90 deg header pins and is oriented vertically.


----------



## rodw (Mar 20, 2015)

Looks great. What is the maximum stepper voltage for the driver?

I'll get around to ordering a set as I've got a mate very keen as well (and he's better at soldering than me).


----------



## TorontoBuilder (Mar 20, 2015)

rodw said:


> Looks great. What is the maximum stepper voltage for the driver?
> 
> I'll get around to ordering a set as I've got a mate very keen as well (and he's better at soldering than me).



a4988 driver max current is 35v


----------



## Scott_M (Mar 20, 2015)

TorontoBuilder said:


> a4988 driver max current is 35v


 

Amps ?

Scott


----------



## TorontoBuilder (Mar 21, 2015)

Scott_M said:


> Amps ?
> 
> Scott



2A per phase although the pcb traces can handle higher the driver chip cant


----------



## rodw (Mar 21, 2015)

John so if you wanted to run a bigger stepper and say a 3.5 amp or even 7 amp Gecko controller, you'd just get the 3 stepper board and wire everything up to the main board? Or would you add unpopulated daughter boards so you could use the terminal strips?

And also what is the purpose of the capacitor? Is that something the polou driver needs?


----------



## TorontoBuilder (Mar 21, 2015)

rodw said:


> John so if you wanted to run a bigger stepper and say a 3.5 amp or even 7 amp Gecko controller, you'd just get the 3 stepper board and wire everything up to the main board? Or would you add unpopulated daughter boards so you could use the terminal strips?
> 
> And also what is the purpose of the capacitor? Is that something the polou driver needs?



That board is designed specifically for the a4988 driver. If you want to use gecko you can connect the board via jumper wires to the DIR, STEP 5V and GND pins. The gecko has its own terminal strip for the motors connections if i recall correctly.

The 100uF capacitor acts as a start capacitor when motor first comes on and to minimize current ripple as motor operates. Its recommended by the chip manufacturer. Gecko likely has such capacitor built into their stepper drivers.


----------



## AFCarbon15 (Apr 16, 2015)

Subscribed !   Thanks for all the info.


----------



## TorontoBuilder (Apr 16, 2015)

AFCarbon15 said:


> Subscribed !   Thanks for all the info.



Ah great your post reminds me I have been deficient in keeping this thread updated.

I've yet to order new boards from Oshpark since I got bus on another project. I'll be back on track soon.


----------



## keithh (Apr 16, 2015)

Thanks for your work,  looking forward to picking this up in the near future.

Thanks again

Keith


----------



## rodw (Apr 17, 2015)

John, if you have not sent these out, there is a standard for stepper pinouts called PMinMO and you'll see it in the circuit diagram here .
http://www.piclist.com/techref/io/stepper/THB6064/index.htm

I nearly bought a DIY stepper kit like this one so it would be good to support this standard for those who wanted to use bigger external stepper drivers


----------



## Carbuilder (Apr 22, 2015)

One more person is reading and learning from this thread (that would be me!). 
I'm new to the forum but have used my 3-in-1 machine for years to make all sorts of parts for car modifications (real ones, not models). I recently added DRO's to it and it is fantastic to use.

I've just started playing with an arduino experimenters kit and am trying to learn all I can about it. I am really enjoying this thread; not understanding all of it the first time though, but that's OK. You are explaining things very well, so don't skimp on the details! I know it takes a lot more time to add posts, but they are being read.

thank you,

Rick
Bolton, Ontario
Just "above" Toronto as they say


----------



## canadianhorsepower (Apr 22, 2015)

rodw said:


> John, if you have not sent these out, there is a standard for stepper pinouts called PMinMO and you'll see it in the circuit diagram here .
> http://www.piclist.com/techref/io/stepper/THB6064/index.htm
> 
> I nearly bought a DIY stepper kit like this one so it would be good to support this standard for those who wanted to use bigger external stepper drivers


This is what I'm using here are some the pics
they work great

Luc


----------



## TorontoBuilder (Apr 23, 2015)

canadianhorsepower said:


> This is what I'm using here are some the pics
> they work great
> 
> Luc



thx.. that will take up more real estate, but I'll mod the design when I get a minute. 

So much going on right now since I'm learning to drive 1:1 scale electric streetcars


----------



## fiddle561 (Apr 16, 2016)

Hello i liked your build, i ordered your boards (4.1 version). i started to build and ran into interference between nano and other board. also what type of connector were u planning on using for motor connector. The pin spacing is too wide and too narrow for the different connectors. pictures attached. THANKS FOR ALL THE WORK U PUT IN TO THIS. I really appreciate the work


----------

