# uln2003a: Switching ground of device works, however, optional USB function of device doesn't work correctly

I use the uln2003a to switch a device (with use of a MCU) that is capable doing several things, like fm-radio, bluetooth, playing MP3's etc. It also provides an USB function when it is connected to a computer, it provides an usb soundcard and a SD-card interface. The function is only enabled/started when selected on the device.

The switch works okay, however, when connected to a computer the device is recognized but the computer is unable to communicate with the devices. In Windows there is an exclamation mark present with the comment "Device doesn't start, code 10".

When I bypass the uln2003a switch with a wire, connect ground directly so the uln2003a has no function, all of the devices operates just fine. I tried the following experiment:

1. Start the device,
2. Connect point A and B with a wire (see schematic below) to bypass switch,
3. Select USB mode and working fine.

As soon as I disconnect this wire (ground still connected via uln2003a), devices starts to malfunction in Windows.

Question:

The uln2003a switch the same ground and I don't understand why USB is not working. Can somebody explain what's going on?

Simple schematic to give some idea what's going on:

The ULN2003 datasheet says Vce(sat) can be as high as 1.6V which is pretty high for a "low" output. When you shorted the connection with the wire you got 0V which is why it worked. The ULN2003 isn't really useful for this application because it can never pull the output low enough.

What you are doing is "low side switching" -- for USB I would recommend high side switching and put a Texas Instruments TPS2051B power switch between +5V from USB and your device's +5V input. Then connect the device to ground like normal.

http://www.ti.com/product/TPS2051B

The TPS2051 has a simple interface; there's an enable pin and a fault status indicator. It's easy to use and can handle up to 500mA for your device you are switching.

• Thanks for the answer. So okay, not suitable for this task. I take a look at it, thanks. – Codebeat Mar 13 '18 at 15:04
• Pretty simple, actually the same drive operation only the positive route. I see there is also a TPS2054 with four channels. One question, what is the ULN2003A suitable for, only to drive motors? – Codebeat Mar 13 '18 at 15:31
• I chose this answer as accepted because it provides a solution. – Codebeat Mar 13 '18 at 15:46
• Good question, I'd say motors, relays, solenoids, and LEDs are the most common application for it. – user171804 Mar 13 '18 at 16:40

Take a look at the graph "6.14 Typical Characteristics" in the ULN2003 datasheet.
Even with only a small amount of current the output is still at least 0.7V above ground.
That means that your device's USB signalling is all going to be (at best) shifted 0.7V higher than it's supposed to be (could be even worse) - making the USB host in your PC very unhappy.

• Thanks for the answer. "making the USB host in your PC very unhappy", haha. That's strange, is there something I can do to pull it down/correct it or do I need to take another route? – Codebeat Mar 13 '18 at 15:00
• @Codebeat cut the power on the high side.. – Trevor_G Mar 13 '18 at 15:02

When you have a Darlington output stage you can expect significant volt drops: -

To turn on Q2 you need about 0.7 volts applied to its base with respect to the emitter. Given that the base voltage is supplied via Q1 and Q1 sources this voltage from Q2's collector you cannot realistically have the output falling below 0.7 volts unless you have a very light load on the output.

• Thanks for the clear answer. One question, what is the ULN2003A suitable for, only to drive motors? Why it is so populair when there are so many possible side effects? – Codebeat Mar 13 '18 at 15:36
• @Codebeat I don't particularly like it because of the natural loss of voltage - you can get a MOSFET output version that drops a much smaller voltage (don't ask what the number is but it's supplied by TI). Popularity doesn't mean it's good! It's like the crappy L293 H bridge or the crappy 741 op-amp - people keep using 'em and it beats me why! – Andy aka Mar 13 '18 at 15:47
• Okay, haha, thanks. I chose this ULN2003A because it is easy to drive without any external components required and safe for the MCU and very cheap. Can you give me some positive alternatives/suggestions? And yeah, the LM386 amp is also very populair, dunno why. I don't understand they use the cheaper and more powerful one like the PAM8304 instead. – Codebeat Mar 13 '18 at 15:53
• TPIC2701 is worth a look. 0.5 ohm on resistance. – Andy aka Mar 13 '18 at 15:57
• I read that the TPIC2701 device suggested is N-type and obsolete and very expensive. \$14 for 2 pieces. – Codebeat Mar 13 '18 at 16:09

We spend a lot of time ensuring the integrity of the grounding system to minimize noise in systems, ensure proper return current management, and to maintain as close to a constant reference voltage across the circuit/system as we can achieve. (The latter being the issue that stopped you!)

Adding a switch in the ground side negates all that and adds all kinds of hard to debug issues. As such, it should be avoided wherever possible.

Furthermore, when you switch the ground side you leave the device hot.

Internally it is still connected to whatever rail it is attached to. That means the output pins will tend to pull or drive whatever they are attached to up to the rail. Even input pins can do some strange and unpredicted things with the ground disconnected.

Having the device not directly connected to a power source is safer.

Of course, having a device in circuit with Vcc disconnected can also be problematic. The device can actually take power from the input pins via the protection devices if whatever is connected to them can supply enough current.

As such, depowering devices takes some careful design and is often not a trivial matter.

• Thanks for the clear answer. One question, what is the ULN2003A suitable for, only to drive motors? Why it is so populair when there are so many possible side effects? – Codebeat Mar 13 '18 at 15:35
• @Codebeat that device is really old. It was good for driving multiple higher current devices like row driving LED matrices and the like. There are better MOSFET drivers available though. – Trevor_G Mar 13 '18 at 15:43
• Okay, thanks. I chose this ULN2003A because it is easy to drive without any external components required and safe for the MCU and very cheap. Can you give me some positive alternatives/suggestions? – Codebeat Mar 13 '18 at 15:49
• @Codebeat If you are only switching one device, a decent P-MOSFET on the high side is sufficient. – Trevor_G Mar 13 '18 at 15:54