DIY arduino circuit boards optimized for electronic indexing head

Home Model Engine Machinist Forum

Help Support Home Model Engine Machinist Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.
Joined
Jan 4, 2013
Messages
359
Reaction score
84
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.

divider-head-main-board-schematic.jpg


divider-head-main-board-pcb.jpg


lighted-button-breakout-board-schematic.jpg


lighted-button-breakout-board-pcb.jpg
 
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
 
Torontobuilder

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

cheers
Luc
 
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

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

cheers
Luc

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!

$(KGrHqV,!pEFG-t2E0f+BR)ttoUtnw~~60_57.jpg
 
Last edited:
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
and I assume they were red at 2 volts:wall:

Cheers
 
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
and I assume they were red at 2 volts:wall:

Cheers

Yes, sorry I like blue LEDs, but they sure have a far different forward voltage than simple red LEDS. However, your input is good since it forced me to re-evaluate and resize resistors so that people can safely choose any colour LED they wish and still operate at safe current levels so their LEDS dont let their magic blue smoke escape.
 
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.

Indexing-Stepper-Controller.jpg


keypad-breakout-board.jpg
 
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.
 
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.
 
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
 
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.
 
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 – 12V, or 9V – 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.

Indexing Stepper Controller Final.jpg


keypad breakout board.png
 
Last edited:
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’s also “bonus” info on how to measure the current of a stepper motor under load conditions, Ohm’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’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’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 (Ω). The formula for calculating the current is expressed as:

I = V / R

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

Current rating: 680 mA (0.68A) per coil
Coil Resistance: 17.65 Ω (Ohms) per coil
Voltage rating: 12 Volts


The ratings mean that with the fixed resistance of 17.65 Ω 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’t require any additional cooling.

In theory I don’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’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 Ω (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’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’s that excess current going? It’s being converted to heat within the motor windings. The motor can’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’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’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’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’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 “reference pin” and ground on the A4988 board and then calculate the resulting current limit setting.

The reference pin voltage is accessible on a “via”, 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’s consider our previous stepper motor example with the following rating:

Current rating: 600 mA (0.6) per coil
Coil Resistance: 6.5 Ω (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’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’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’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’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’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’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’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’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” in ¼” wide steel blanks I may have to source a new motor with higher specifications and adjust the current output.

I’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’s all for this post, if you read to the end of this post thanks, that’s great!

2015-01-27_1648.png


2015-01-27_1647.jpg


00395x01.png
 
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 (Ω). 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 Ω

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 Ω 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 Ω (Ohms) per coil
Voltage rating: 12 Volts

The ratings mean that with the fixed resistance of 17.65 Ω 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 Ω = 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 Ω + 1 Ω) = 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 Ω 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 Ω 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 Ω, 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.
 
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.
 

Latest posts

Back
Top