[Answered] MOSFET won't turn OFF as expected

QUICK BACKGROUND:
I’m having an issue with a circuit, and could use some help. It works fine in my home studio, but misbehaves in the location where it will be used. I have limited access to that location, and I’m looking for suggestions to help point me in the right direction.

WHAT SHOULD HAPPEN:
The specific goal here is simple: when a Mac is powered down (by a user), I want an audio interface to also power down. There’s a USB cable from the Mac to an Arduino pin (not the micro USB port), which acts as a sort of sensor, when the Macs turn off, the voltage drops on the USB cable’s +/- wires, the Arduino notices and drops a MOSFET gate’s voltage to LOW (0V) and the audio interfaces turn off. This works as expected in my studio with a Mac and a test device in place of the audio interface (details below), but when I bring the project into the orchestra pit at my show (the ultimate destination), something unexpected happens.

All devices are powered by DC Power Adapters (‘wall wart’ style), except for a MacMini which plugs into a UPS device, which is plugged into A/C.

Most of it is working surprisingly well, except one part of the circuit. The schematic shows the smallest subset of connections which still allow the problem to persist, so I figured it was a good place to start.

WHAT DOES HAPPEN:
The problem is as long as the Mac’s USB cable is plugged in, I seem to be unable to turn off the MOSFET. As mentioned, when the Mac is powered down, the Arduino attempts to set the pin controlling the MOSFET’s Gate to LOW (0V), but current seems to keep flowing from Drain to Source, and the connected audio interface remains powered ON. If I physically remove either end of the USB cable, the connected device immediately powers OFF. Plug the USB cable back in, device turns ON, pull it out, device turns OFF.

Can someone explain to me how a USB cable from a powered down MacMini is able to turn the MOSFET on and off?

Again, if I exchange the audio interface with the test device (equipment details below), the MOSFET behaves just fine - the device turns ON and OFF as expected. But when I re-instate the actual device, the audio interface, the MOSFET behaves as before, turning OFF only if the USB plug is physically removed.

I should note that the audio interface also runs a separate usb cable to the MacMini so maybe power is coming from there somehow? But these particular audio interfaces cannot run on usb power alone (RME Audio Interface Bus Power), plus the Mac is powered DOWN and shouldn’t be sending any power thru USB.

And, the audio interface is connected to a keyboard controller via a MIDI cable. But as far as I know there isn’t enough power running down MIDI cables to run these audio interface.

The problem persists even if I remove the DC power from the Arduino. (I realize I'm risking frying the Arduino - I'm OK with that).

All these devices are ultimately connected to the same A/C circuit (our ‘audio power’ circuit), so they should be sharing the same ground (I hope). The one exception might be the Macs, which are plugged into the UPS, which is plugged into audio power as well. But could the UPS isolate the ground somehow and cause this weirdness? I only started suspecting the UPS at the end of the last session, so I’ll plug everything directly into audio power next time to see if that helps.

Again, I only have access to this equipment for 4 hours a week, and it takes about an hour to setup and another hour to break it down and be sure we’re ready for the evening’s performance. So 2 hours a week is all I get. I want to hit the ground running next week, so any suggestions by y’all would be most gratefully appreciated!

p<

(more equipment details to follow)

EQUIPMENT DETAILS:
‘Actual Device’ (I don’t have extras of these to test in my studio, so testing is limited to weekly work calls):
The actual connected device I wish to power ON and OFF is an RME Audio Interface (RME UC Fireface Audio Interface ) whose power brick is rated at 12V 2A.

‘Test Device’ (I have extras to test as needed):
The test device, which behaves correctly, is an Aviom Headphone Mixer (Aviom A-1611 which runs on a 24V / 500mA DC power adapter).

DIFFERENCES BETWEEN THE ACTUAL AND TEST DEVICES:
The MOSFET won’t turn off when the actual device is connected, the MOSFET will turn off as expected with the test device.
The actual device connects with another usb cable to the MacMini, which sends data during performance, the test device does not (remember the Mac was powered down for this test).
The actual device connects with a keyboard controller via MIDI, while the test device does not.
Their power requirements are different.
The actual device connects to a inline power brick (pictured below) which has which connects to A/C by a cord. The test device connects to a power adapter which is directly plugged into an A/C outlet

Maybe I chose the wrong MOSFET for this (IRLB8721Pbf: https://cdn-shop.adafruit.com/datasheets/irlb8721pbf.pdf) - I thought it was in spec, but maybe it can’t really handle 2A current of the RMEs. I was previously using another MOSFET (FQP30N06: https://www.onsemi.com/pub/Collateral/FQP30N06-D.pdf), but thought it might not actually be logic level, thus contributing to the problem so I switched to the IRL8721. Both worked fine, but both presented the same issue as I am describing with this thread.

The UPS is an APC Smart-UPS C 1000: APC Smart-UPS C 1000
APC Documentation)

A FEW THINGS OF NOTE:
All devices in question have no on/off switch, they power up as soon as they are plugged into a power source. Except for the Macs of course.
I realized after the most recent work-call that the Macs are plugged into a UPS device (details below), which is plugged into the same A/C circuit as the rest of the devices. Could that UPS device somehow be a source of the problem? Does it somehow isolate its ground so that units plugged into it aren’t ‘sharing’ the same ground as the Arduino?
I’m not a trained electrical engineer, but I’ve been using MOSFETS and building MIDI circuits etc for a few years now. I thought it would be within my grasp to create a switching system such as this to manage the power status of a few devices. I’ve gotten close, but obviously something is just beyond the grasp of my understanding of it all, as seen by this vexing bug.

NEXT TIME I WILL TRY:
Removing the UPS from the circuit by plugging everything directly into the same power strip, to see if the UPS is somehow involved in the trouble.
Removing MIDI cable from Yamaha to see if is getting power from that.
Removing the Mac’s power cable (and keeping the USB cable plugged in) to see if somehow power is coming in through the USB ports even tho’ the Mac is powered down.
Removing the Arduino itself from the pcb (I didn’t solder it in directly, it’s plugged into pin headers which are soldered into the pcb itself)
I’ll try and work up the nerve to test some amperage levels at the next work call. The connected devices are multi thousand dollar boxes, and I’ve already blown fuses on my multimeter checking other circuits, so I’m treading slowly.

This is why its normal to use high-side switching for powering slave devices - your grounds are likely not
isolated in the environment you mention, meaning low-side switching is bypassed.

Use high-side switching and the grounds can be common all the time.

Fascinating, I'll definitely look into it. Many thanks.

For what it's worth, I'm in the process of building and testing high side switches for this circuit. I'll post results when they are in. Thank you!

Hey could you try a digital pin for the mosfet switching? I still want to see the low side switch working. Wish I could see the complete diagram to see what’s really going on.

Is it possible that the UPS continues to provide USB power even when the Mac is off never triggering an off to your system? Quick way to check is to plug a phone in see if there is still power.

I’m sure Mark is right. So the difference in ground potential is causing this. Still perplexed.

@wolframore

Thanks for this - all very good suggestions indeed. I'm perplexed as well and would love to root out the exact cause.

I do believe however, as MarkT suggested, it's a shared ground issue - the circuit is finding a way to complete itself despite my best efforts. So I've currently moved on to implementing a high side switch for the devices. It's taking a bit of time because I have limited access to the system. I have to wait until the next work call to test it, which won't be until next Wednesday.

Maybe if all goes well I'll have a minute to try and figure out exactly how the circuit was completing itself (pulling Mac A/C plug, pulling out the Arduino etc, putting everything on the UPS, putting nothing on the UPS etc). If so, I'll post the results here.

Remember that a mosfet turns on only if there is a gate-source voltage differential, and you can measure that differential with a voltmeter unless it's a leakage thing where the meter might interfere too much. You can also measure the difference in voltage between the various grounds you are dealing with. Ideally there should be no difference, or even no galvanic connection at all, but there can be differences in how the various power supplies are generated, which can make them connected in odd ways.

Also remember as discussed in another thread that optoisolators can be used in situations like this to allow you to determine if a supply is powered up without connecting to it in any way except optically. A 4N25 is pretty cheap.

Will your device print tickets?

Is this how it is hooked up: A1 pin 6 signals the Arduino to kill the voltage to A3 Pin8 is that correct...?

I would change r15 from 100k to 10k and r14 from 10k to 10 ohm. Watch the voltage on the gate.

Is the Arduino ground and the mosfet ground common..?

I think you are going to need a p channel. The body diode is causing problems because it is forward biased so conducting all the time and won't shut off. Let me do some more check an will get back with you.

MarkT:
your grounds are likely not isolated in the environment you mention, meaning low-side switching is bypassed.

Ahhh... this is a possibility... but the real question is why does it work in one situation but not the other.... hmmm,

here are a couple clues: - they are sharing ground through other connections.

The actual device connects with another usb cable to the MacMini, which sends data during performance, the test device does not (remember the Mac was powered down for this test).

The actual device connects with a keyboard controller via MIDI, while the test device does not.
Their power requirements are different.

We were focusing on the MOSFET and not the real issue.

Hello Everyone - I was finally able to find time to wire up a protoboard prototype, based on the discussion on this thread (you are all amazing). I brought it into the pit and actually had success with turning the MOSFET (and the device it was connected to) ON and OFF as expected.

So, the high side switch worked where the low side switch did not. Confidence is growing.

Next step is redesigning the whole circuit and getting a few prototype pcbs printed to see if I can make this work within the greater framework. This may take a couple of weeks, but I'll report back any new developments. If I can get it together, I may try to post the whole circuit on this forum (probably start another thread and put a link here) to see if I've made any other obvious errors.

For now, here's some more info, if anyone is interested.

DETAILS:
As mentioned, there are a few distinct A/C power circuits running into the pit area.

AUDIO POWER (turned ON and OFF each performance day).
LIGHTING POWER (not used for audio devices, dims during performance)
24 HOUR POWER (always on, runs hallway lighting etc)

All my devices and keyboards are plugged into AUDIO Power. One of those devices is a UPS, which powers the Macs and the audio interfaces. The Macs and audio interfaces were the ones I concentrated on for this thread.

The prototype board (high side switching mosfet controlling the audio interface power, and sensing the Mac's on/off status) worked when I plugged its power supply into the UPS, and it worked when plugged directly into AUDIO Power, and it also worked when plugged into regular '24 Hour Power' that run the hallway lights etc. So all those A/C sources share a common 'ground / return' - or somehow can fake it enough for this circuit to work. I was glad to find that out.

This is true despite the AUDIO power having an 'isolated ground' from its source power (main building power). I can't pretend to understand why.

@MarkT

This is why its normal to use high-side switching for powering slave devices - your grounds are likely not
isolated in the environment you mention, meaning low-side switching is bypassed.

Yes, this was the answer. So far so good, thank you!

@wolframore

Hey could you try a digital pin for the mosfet switching? I still want to see the low side switch working. Wish I could see the complete diagram to see what's really going on.

Is it possible that the UPS continues to provide USB power even when the Mac is off never triggering an off to your system? Quick way to check is to plug a phone in see if there is still power.

Unfortunately I had very little time for testing etc, just wanted to get something up and running. Do you think I'd be better off using digital pins? I could rework those assignments when I redesign the pcb. I also did want to try unplugging the Mac power cable from the UPS to see if the old circuit (low side) would still misbehave. That's on the list for the next work call!

@ thedoc8

Is the Arduino ground and the mosfet ground common..?

It seems so, given the way the high side switching circuit works (arduino power) no matter where it is plugged in.

@ShermanP

Remember that a mosfet turns on only if there is a gate-source voltage differential, and you can measure that differential with a voltmeter unless it's a leakage thing where the meter might interfere too much. You can also measure the difference in voltage between the various grounds you are dealing with. Ideally there should be no difference, or even no galvanic connection at all, but there can be differences in how the various power supplies are generated, which can make them connected in odd ways.

Also remember as discussed in another thread that optoisolators can be used in situations like this to allow you to determine if a supply is powered up without connecting to it in any way except optically. A 4N25 is pretty cheap.

As always, great info, thank you. I just ordered a bunch of 4N25's and will thrash about with them when they arrive. And maybe this week I'll be able to get a multimeter into the pit and see if the grounds are really shared, and inspect the voltages at various pins.

@ShermanP

Will your device print tickets?

Ha! Nice try ... but if you are ever in the nyc area, give me a shout.

I started another thread on my way to building the prototype mentioned above (high side switching). It is located here.

Maybe you covered this and I missed it, or forgot, but you aren't running the AC into your circuit, are you? I mean, each of those three AC sources is powering some kind of DC power supply, and that's what you're measuring. Right?

Well congratulations on getting it to work. Too bad about the tickets. Is there a prize if we guess which show it is?