using L293D h-bridge with current sensing for stepper chopper circuit

recently i'm thinking about using L293D h-bridge with current sensing for stepper driving
the specs for L293, L293D are here

and the pinouts are as follows

1 1,2EN |  VCC1 16 
2 1A    |    4A 15
3 1Y    |    4Y 14
4 GND   |   GND 13
5 GND   |   GND 12
6 2Y    |    3Y 11
7 2A    |    3A 10
8 VCC2  | 3,4EN 9

the trouble is that i want to do current sensing for micro stepping
i'm initially thinking about measuring current directly off the motor pins with shunt resistors, but the reversing currents makes the design rather difficult
i ran across this innovative solution that uses diodes
http://forum.arduino.cc/index.php?topic=324977.0
but diodes would shutoff when voltages falls to around/below 0.7 volts, this'd create abrupt jumps/drops in the measured currents

of course there is also the l298 h-bridge with built in current sensing pins as well as l293e
http://www.st.com/content/ccc/resource/technical/document/datasheet/82/cc/3f/39/0a/29/4d/f0/CD00000240.pdf/files/CD00000240.pdf/jcr:content/translations/en.CD00000240.pdf

but l293d is considerably cheaper than l298n and l293e on retail sites such as ebay

hence the motivation to stick with l293d

now the questions,

  1. are those ground pins separated for each half bridge on the l293d and could i use those ground pins to measure currents relevant to each 1/4 half bridge units on the l293d?
  2. if it isn't feasible to measure currents directly off the ground pins for current sensing / chopper control, i'd guess we'd need to fall back to measuring currents in series with the motor outputs pins. the trouble is that this current is reversing. how do we go about measuring that? even with an op amp, it would swing in an opposite polarity when the h-bridge reverses

thanks much in advance

Why not use a proper stepper driver like an A4988 or DRV8825. Current control and microstepping built in and much more efficient than the antique L293?

Those ancient chips are extremely inefficient, and totally impractical for use in a microstepping driver.

But, you would probably learn a great deal while attempting to design with them.

well i've indeed considered a4988 and drv8825, just that a4988 and drv8825 runs on the step and dir pin protocols, this requires the mcu to run in a tight control loop to time each (micro) step and when there are multiple steppers the mcu would be pretty busy simply running the steppers and having little timeslice for any thing else.

in addition, the a4988 and drv8825 modules (drv8825 being better) has small chip surfaces which makes them very hard to cool

one other disadvantage is a4988 and drv8825 uses the step and dir pin protocols and these pins can't be shared, this very much limits the use on mcus / boards with few pins.

hence the motivation to use an mcu for the stepper control itself, and one can do all kinds of microstepping since l293d is simply only a h-bridge and all that microstepping 'intelligence' is done in the mcu itself

the more elaborate stepper drivers some of them cost more than common arduino mcus and a h-bridge even for that matter the l298n

I have to wonder why all those 3D printers and CNC machines use the A4988 and DRV8825 drivers given all of their disadvantages.

a_g123:
well i've indeed considered a4988 and drv8825, just that a4988 and drv8825 runs on the step and dir pin protocols, this requires the mcu to run in a tight control loop to time each (micro) step and when there are multiple steppers the mcu would be pretty busy simply running the steppers and having little timeslice for any thing else.

This does not make any sense as an argument for using an L298. An Arduino has even more work to do when driving a stepper motor with an L298 because it must control the timing of signals on all 4 motor coil wires rather than on a single step pin.

And if you are thinking of also burdening the Arduino with current measurement and current limiting ....

...R
Stepper Motor Basics
Simple Stepper Code

Hi,
What are the specs of your stepper motors.

4988 and 8825 are both MOSFET outputs, the 298 is a bipolar transistors.

MOSFETs have a very low ON resistance, so they dissipate very little heat, compared to the 298 that drops up to 2V across it and needs a heatsink.

The MOSFET drivers are way more efficient.

the a4988 has on board microstepping selection.

drv8825 has microstepping ability too.

Tom.... :slight_smile:

in addition, the a4988 and drv8825 modules (drv8825 being better) has small chip surfaces which makes them very hard to cool

Since they can handle twice the current (without any extra cooling) that the L293D can, this argument makes no sense at all.

Robin2:
This does not make any sense as an argument for using an L298. An Arduino has even more work to do when driving a stepper motor with an L298 because it must control the timing of signals on all 4 motor coil wires rather than on a single step pin.

And if you are thinking of also burdening the Arduino with current measurement and current limiting ....

...R
Stepper Motor Basics
Simple Stepper Code

well, you have a point there, A4988 and the better DRV8825 takes care of much of the stepper motor driving.
however, the motivation is slightly different, i think there are some advantages of using the mcu / arduino for that matter as the motor driver. the idea is that L293D and L298 are high current devices that does the motor control, the idea is to separate the 'power driving' stages (i could have use a mosfet h-bridge for that matter) from the control stages. this is so that if a low cost L293D part burns out for some reason, it can be swapped with a new piece at a lower cost.

of course A4988 and DRV8825 aren't that expensive these days, and i think using those stepper drivers makes sense as well. A4988 and DRV8825 goes at a slight premium compared to L293D going for around $1 on ebay. while L293D is around 40c a piece on ebay.

Hi,

think there are some advantages of using the mcu / arduino for that matter as the motor driver. the idea is that L293D and L298 are high current devices that does the motor control,

  • What are the specs of your stepper motors, Please.
  • What voltage are you using to drive them?
  • Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
  • What do you consider high current?

293 and 298 are 2A each side.

Tom... :slight_smile:

a_g123:
i think there are some advantages of using the mcu / arduino for that matter as the motor driver. the idea is that L293D and L298 are high current devices that does the motor control, the idea is to separate the 'power driving' stages (i could have use a mosfet h-bridge for that matter) from the control stages.

Read the Allegro A4988 datasheet to get an idea of how much thought and complex engineering has been built into the a4988 driver.

...R

a_g123:
if a low cost L293D part burns out for some reason, it can be swapped with a new piece at a lower cost.

Or, you could adopt a more state-of-the-art approach to your design, and prevent a failure by doing it right in the first place.

And anyway, the cost of a repair isn't limited to the cost of the failed part. It must include the opportunity cost of the plant being out of action, and possibly even penalties for late delivery. Not to mention the risk of injury if a motor and whatever's attached to it is un-controlled.

thanks much for the replies the steppers i'm trying to control are NEMA17 motors commonly found on the cheaper 3d printers

i'm seeing specs for currents in the order of less than an amp hence i think i may do some experiments with them, the lower current ones are likely pretty drivable using a L293D even if the bipolar device probably isn't a best fit.
the hard part with L293D is that it doesn't have current sensing pins and unless it is somehow possible to use the ground pin for that purpose, i'm left with trying to hack up something to do current sensing on the motor driving output pins.
it is pretty challenging to design given the reversing voltages and currents when the h-bridge reverses

if that's too difficult i may resort to the L298N instead which has the current sense pins provided on chip, and current sensing become as simple as placing a shunt and a low cost op amp at the current sensing pins

but L298N is pricier than L293D. The only benefit is that L298N could take a full 2 amps and hence could drive the bigger motors

may resort to the L298N

But you're still dabbling with decades old tech, which by now the makers should pay us to use.

a_g123:
thanks much for the replies the steppers i'm trying to control are NEMA17 motors commonly found on the cheaper 3d printers

And how many of those 3D printers are using L298 drivers for their stepper motors?

Think about it ... those guys will wish to save every penny in materials cost but they don't use L298 drivers. That must tell you something.

...R

Robin2:
And how many of those 3D printers are using L298 drivers for their stepper motors?

Think about it ... those guys will wish to save every penny in materials cost but they don't use L298 drivers. That must tell you something.

...R

yup you have a point there, if you look at those l298n modules on sale in ebay

you can see the rather large heat sink and discrete diodes (they are no included on chip)
that module alone easily cost more than those a4988 and drv8825 modules

on the other hand given the heat sink it would be more likely the l298n can take a full 2 amps driving a moderately high current stepper, that would obviously make a difference in terms of speed
actually i've not actually worked with a4988 and drv8825 but i think they are fine motor drivers, just that i've actually meddled with some smaller mosfets transistors, i noted that small mosfets do not necessarily offer low resistance and large mosfets are expensive. a smaller mosfet with higher resistance would likely need no less cooling that that l298n with a decently sized heat sink and my guess is h bridges with good mosfets are expensive naturally. even if i choose to do the same - separate the driving h-bridge from its control mcu, the good mosfet h-bridge may well be a pretty costly affair in that design.

a4988 and drv8825 (which i think is better) are pretty nice drivers
but as it goes, i'm happy to play with the l298n and even the l293d for my own experiments with microstepping which means doing current sensing

on the other hand given the heat sink it would be more likely the l298n can take a full 2 amps driving a moderately high current stepper

Nope. But you will learn.

actually an idea is that a 3d printer controller can be made up of 'co-operating' arduinos

some of the boards notably stm32f103 - blue pill - reaches $2 price point on ebay
(the benefit with this soc is that it is an arm cortex-m3 32bit mcu, it does USB natively on chip and runs at a pretty fast 72mhz)

and even more recently stm8s a 8 bit mcu - reaches $1 price point on ebay

could be programmed - 'arduino style'
http://www.stm32duino.com/

that sort of provides some motivation to meddle with them as stepper controllers as now with things like the blue pill, you could literally parse g-codes from a 3d printing file and control 2 motor for instance. hence, the job of running a 3d printer could be split up between 2-3 blue pills controlling separate motors and devices (e.g. a heated bed, monitor temperatures etc)

but this design would detour from the more common monolithic printer controllers design as it would require a co-ordinating host so that the 2-3 arduinos run the printer in sync

i found a mosfet h bridge TB6612FNG

unfortunately it seemed this doesn't have current sense pins as well

a_g123:
actually an idea is that a 3d printer controller can be made up of 'co-operating' arduinos

but this design would detour from the more common monolithic printer controllers design as it would require a co-ordinating host so that the 2-3 arduinos run the printer in sync

This is all just making unnecessary work for yourself

it does USB natively on chip and runs at a pretty fast 72mhz

What is the advantage of 72MHz when the job can be done perfectly with a 16MHz chip?

...R