Driving three stepper motors using single ULN2003 driver - Page 1
Forum section: electronics / projects

author: HWarrior
author_rank: Newbie
timestamp: July 12, 2023, 01:02:32 pm
content: Hi there,I’ve designed a simple circuit that drives me crazy for the last couple of days… The circuit should drive three 28BYJ-48 stepper motors using only 4 GPIO pins from a uC. I decided to extend the available uC pins using 74HC595. 74HC595 has 8 output pins that I can simply control using 4 signals from my uC. 4 out of 8 signals from 74HC595 are connected to the input pins of a single ULN2003 driving all 3 stepper motors. Another 3 out of 8 signals from 74HC595 are used to selectively drive 3 P-channel MOSFETs that supply power to each of the stepper motors. Only one MOSFET is enabled at a time, while the other 2 are disable. As a result, only one stepper motor should be powered at a time. You can find the schematic and the PCB design below.I etched the PCB and soldered all the components, and I can verify that both 74HC595 and ULN2003 work fine if there are not stepper motors connected to the board (all LEDs light up as expected). If steppers are connected, all three of them appear to be driven at the same time regardless of the MOSFET control signals. If only one stepper is connected to the board, it seems to be driven correctly, but as soon as the MOSFET powering the stepper is disabled and another MOSFET enabled, all 4 control LEDs at the ULN2003 outputs O1-O4 light up, again regardless of the control signals at the input of the ULN2003.First, I thought that the problem is in the free-wheeling diodes of the ULN2003 connected to +5V, but it seems that this is not an issue. Higher saturation voltage of the Darlington transistor pair is also not an issue since AO3401 MOSFETs have quite a low threshold voltage.Any ideas? Thanks!

author: CosteC
author_rank: Regular Contributor
timestamp: July 12, 2023, 01:28:13 pm
content: HelloPrimary issue is fact, that if you have one motor "powered" other motors get parasitic power from unpowered windings in "powered" motor.It is visible after you will draw schematic with two motor windings. Not sure if there is good solution to this...Another serious drawback of this circuit is that unpowered motors have very weak holding torque.Using ULN2003 to drive P-MOSFETS is not great idea... Please measure gate-GND voltages. Those are probably floating around 2.5 V.Proposal would be one ULN per motor and maybe shift register to control them all. I know, much more chips, yet it will work correctly.Actually modern SOT-23 MOSFETS can be driven from 74HC shift register/latch and will work better than ULN (with its horribly high voltage drop). Freewheeling diodes are needed too.

author: Ian.M
author_rank: Super Contributor
timestamp: July 12, 2023, 02:06:13 pm
content: You could try bodging in a Schottky diode in series with each motor coil (not the commons) so that idle motors cant be back-driven by the active one, but IMHO you'd do better to look at T.I's TPIC6x595 series of power shift registers. The logic side looks just like a 74HC595 but its parallel outputs are open drain high voltage NMOS capable of directly driving lamps, small motors, solenoids etc. TPIC6C595 has 33V 100mA MOSFETs, TPIC6B595 has 50V 150mA MOSFETs, and TPIC6A595 has 50V 350mA MOSFETs. Two TPIC6B595 chips could drive all three motors fully independently with four high current outputs spare.

author: HWarrior
author_rank: Newbie
timestamp: July 12, 2023, 02:08:44 pm
content: Hi CosteC, thnx for you reply!Gate-GND voltages are fine if steppers are not connected (5V for low input, ~1V for high input, which sets -4V between source and gate and is sufficient to open the MOSFETs). Once the motors are connected, all hell breaks loose. I just fail to see why that happens. Can't find the current paths that cause the issues.You say that it is visible after the schematic with two motor windings is drawn. Can you elaborate on that?Btw, I tried to connect the gates of the MOSFETs to the 74HC595 directly and got the same results. So I don't think the issue lies in driving MOSFETs using Darlington pairs within ULN...Of course, the problem can be solved by using two 74HCs and two ULNs, but I would still like to understand what is going on here...

author: HWarrior
author_rank: Newbie
timestamp: July 12, 2023, 02:19:37 pm
content: Quote from: Ian.M on July 12, 2023, 02:06:13 pmThanks Ian.M! I agree, TPICs are better solution. They are my backup from the moment I faced the issue. But I would still like to understand what's going on here. Looks like a ghost hunt. Really frustrating...

author: Ian.M
author_rank: Super Contributor
timestamp: July 12, 2023, 02:29:55 pm
content: Not really a ghost hunt. Stepper motors can act as generators so all the inactive coils in the active motor are feeding the corresponding coils of the desected motors, so the motors are effectively in parallel with bipolar drive to the deselected motors, so step together no matter what you do with the center taps. The center tap common wire isn't nessercery - you could just as well drive these five wire steppers with bipolar drive from a dual H-bridge like any four wire stepper.

author: HWarrior
author_rank: Newbie
timestamp: July 12, 2023, 03:16:28 pm
content: Quote from: Ian.M on July 12, 2023, 02:29:55 pmThanks Ian.M, I think I can see it now. Basically, there is an intended current path through the intended coil, but there are also other unintended current paths that close through other coils of the same and other motors. I quickly draw a schematic to illustrate the problem. Ignore the fact that I used BJTs instead of Darlington pairs. Also ignore the fact that there are no resistors in the bases of BJTs.If I am correct, the diodes in series with the motor coils could indeed solve the problem. But it seems more reasonable to use two TPIC6B595 instead. That is of course if TPIC6B595 does not require external freewheeling diodes. Which I am not so sure about...

author: Ian.M
author_rank: Super Contributor
timestamp: July 12, 2023, 03:25:29 pm
content: It doesn't. Its output MOSFETs are designed to avalanche clamp inductive loads - seedatasheetfig.4.You only need external free-wheeling diodes if you need to limit the clamping voltage <50V because of other components, or want/need to do energy recovery, or if the stored energy in the load exceeds the TPIC6B595 avalanche energy rating.

author: HWarrior
author_rank: Newbie
timestamp: July 12, 2023, 03:35:59 pm
content: Great! Thanks a lot!

author: CosteC
author_rank: Regular Contributor
timestamp: July 12, 2023, 03:40:56 pm
content: Quote from: HWarrior on July 12, 2023, 03:16:28 pmI do not like series diodes as they will eat even more voltage from already not great 5 V. ULN eats more. Maybe you however do not need much torque?Regarding torque, series diodes does not help with holding torque, while driving all motors at all times solves all issues.Avalanching MOSFETs can be done, yet it dissipates power - in this case basically all inductance of winding x squared current x 0.5.. It might be a bit.Good pictures by the way.Regards

author: ArdWar
author_rank: Frequent Contributor
timestamp: July 12, 2023, 04:21:20 pm
content: If you're going to use somewhat uncommon IC, might as well use something more fit for purpose like DRV8860. Better protection and programmability although now you can't just simply do simple on-off bit shift. PWP package one also got much better thermal management.

author: HWarrior
author_rank: Newbie
timestamp: July 13, 2023, 05:58:40 am
content: Quote from: CosteC on July 12, 2023, 03:40:56 pmCouldn't agree more. More components, more dissipation, less performance. The board should be as small as possible. Low torque and speed of the steppers is something I can live with though.Quote from: CosteC on July 12, 2023, 03:40:56 pmI wouldn't warry about it. It seems that the TPIC6B595 can withstand it. See Figure 11. on page 10 of theTPIC6B595 datasheet, as Ian.M pointed out. The test voltage, current, and inductance are much higher than 5 V, 150 mA, and 3 mH that will be present in my application (worst case scenario). In terms of energy, according to the datasheet TPIC6B595 can withstand 3 mJ, while I don't expect more than 50 uJ.Quote from: CosteC on July 12, 2023, 03:40:56 pmThanks! Means a lot!

author: HWarrior
author_rank: Newbie
timestamp: July 13, 2023, 06:04:22 am
content: Quote from: ArdWar on July 12, 2023, 04:21:20 pmThanks ArdWar! I am aware of DRV series. Unfortunately, I am limited to what I can quickly find in the local stores. Unfortunately DRV is not available...

author: CosteC
author_rank: Regular Contributor
timestamp: July 13, 2023, 06:15:07 am
content: Quote from: HWarrior on July 13, 2023, 06:04:22 am74HC595 + ULN2003 (or N-MOSFETs) ? It would be very generic project:) And easy to solder/etch.

author: HWarrior
author_rank: Newbie
timestamp: July 13, 2023, 08:02:57 am
content: Quote from: CosteC on July 13, 2023, 06:15:07 amThat's right! 74HC595, ULN2003, and TPIC6B595 you can find pretty much everywhere.These are quite versatile and easy to use ICs.