# Current sensing for stepper chopper circuit

Hi, I'm trying to build a bipolar stepper motor driver using L293D. I'm trying to add chopper functionality as well using cheap and easily found parts while keeping board simple. The problem I'm facing is sensing the current.

In other boards, I see ferrite hall effect sensor(like ACS712) being used which I can't use due to cost constraint.

Next method I see is using an extremely small shunt resistor(0.1 ohm) of high wattage in series with the motor coil and using a differential amplifier to sense the voltage across the shunt which is then read by the analog pin. Can the inductive kick on cutting off the supply creep in through the analog pin and kill the arduino or the amplifier?

I didn't want to include amps if I can help it(not terribly fond of em), so I came up with this:

The diode bridge maintains the polarity when the voltage flips. The diodes are fast switching signal diodes. The resistor bridge provides 1/7th voltage to Arduino, so max voltage is 35V and max current is 0.6A(L293D limit). The resistors will be high values to allow as little current through them as possible. Does this look workable and inductive kickback proof?

Why not just buy a "proper" stepper motor driver such as a Pololu A4988 or a Sparkfun Easydriver if your motor does not need more than 750mA.

I don't think an Arduino could sample the voltage fast enough to be an effective current control while at the same time managing the logic for the step pulses. The voltage (for current control) would need to be sampled many times per step.

I do actually have "proper" driver and they are great. Just a bit costly when I just need full or half stepping. It's easy controlling a bipolar with L293D but I was thinking of finding a cheap way to add current sensing for chopping so I could squeeze out more power and speed.

I've done the speed math and I think Arduino can handle it. Not with the default settings but will require a little register tweaking. Running ADC at 1MHz means I get 1MHz/13 = ~77KHz conversions in back to back free running mode but with only using the LSB. Using a NEMA17 rated 12V, 0.33A, 32.6 ohm and 48mH, calculating LR time for 32V, the coil will reach 0.6A in 1.35ms. At 77 KHz, we can get a reading in 1/77000 seconds = 0.013 ms. So we will have 1.35/0.013 = 103 readings by the time current approaches 0.6A.

So I guess arduino is fast enough to detect just as the current reaches above 0.6A and then turn off the current. The problem is will the reverse voltage formed by the inductor to oppose increasing current also cause a voltage change across the resistor divider in my design?

Antzy: Using a NEMA17 rated 12V, 0.33A, 32.6 ohm and 48mH, calculating LR time for 32V, the coil will reach 0.6A in 1.35ms. At 77 KHz, we can get a reading in 1/77000 seconds = 0.013 ms. So we will have 1.35/0.013 = 103 readings by the time current approaches 0.6A.

Assuming your maths is correct (I don't think I am competent to check it) I wonder if the Arduino will have time to do anything else ?

...R

The beauty of hardware ADC is that once started, it will keep running without taking any of Arduino's main program execution time. So it will be running in parallel with my code. So I am free to do whatever I want and read the ADC value when needed.

I see the folly of my design. The voltage formed by inductor to prevent current change can never affect the voltage across the resistors...

Guess it's back to shunt resistors. Sigh! They are so costly and difficult to obtain. Is there no other way?

Antzy: The beauty of hardware ADC is that once started, it will keep running without taking any of Arduino's main program execution time. So it will be running in parallel with my code. So I am free to do whatever I want and read the ADC value when needed.

I know the ADC does not itself consume resources, but your Arduino code has to take the values and make decisions using them. There is not much point using the ADC and then ignoring its results.

...R

Yep. But I'm not waiting in the meanwhile for the result. I can just check if a new value is available. If yes, compare it to max value and if it is higher, set a pin to LOW to turn off the current. If the value isn't available yet, do other stuff and return on next loop execution.

I've decided to skip the chopper part and keep the board simple half/full step driver. I was hoping I could implement microstepping as well after chopper but implementing a chopper is either costly or requires difficult to source parts...