Normally on electronic switch - Page 1
Forum section: electronics / projects

author: gaminn
author_rank: Frequent Contributor
timestamp: August 14, 2019, 08:20:02 am
content: Hi,I have an USB device that will be connected to a smartphone. The device can be powered by a smartphone (OTG) and there is also jack connector to supply external power to the device.The ID pin of USB cable will be controlled by the USB device to tell the smartphone whether it should supply USB power or not.Normally, when the device is without power, the ID pin must be shorted to ground. So, when the device is connected to the smartphone it gets 5V.Also, there can be external power connected to the device. In this situation, the device will short the ID pin to ground with e.g. 10 kOhm resistor. This will tell the smartphone, when the device is connected to it, that it should not supply 5V to the USB, instead, it can charge from 5 V supplied by the device.So, I'm looking for a switch that is normally (without any power) shorted to ground, but when there is a power, it can be controlled (to connect some resistor to ground).I don't want to use mechanical relay.

author: Mr. Scram
author_rank: Super Contributor
timestamp: August 14, 2019, 08:29:50 am
content: I'm still not sure what you want to use the switch for. Switch the inputs? Maybe you'd want to look at how something like an Arduino switches between USB and external power.

author: Berni
author_rank: Super Contributor
timestamp: August 14, 2019, 08:34:15 am
content: Things like a JFET or depletion mode MOSFET are conducting when there is no voltage on the gate but stop conducting once voltage is applied. Tho you might need negative voltages to make it work.

author: gaminn
author_rank: Frequent Contributor
timestamp: August 14, 2019, 08:39:13 am
content: Quote from: Mr. Scram on August 14, 2019, 08:29:50 amI want to switch ID pin (it is one pin of USB connector) to:1) when there is no power, it is connected to ground.2) when there is power, there is a resistor connected between ID pin and ground.There is MCU in my device, so the switch will be controlled by MCU.

author: gaminn
author_rank: Frequent Contributor
timestamp: August 14, 2019, 08:41:40 am
content: Quote from: Berni on August 14, 2019, 08:34:15 amI found JFETs that have like 30 ohms rdson, which is more than what I expect from "connected to ground". And also the negative voltage means I have to solder another IC on the board. But yes, it is the best solution I have at the moment.

author: ledtester
author_rank: Super Contributor
timestamp: August 14, 2019, 09:01:22 am
content: Use a 3-pin DC jack such as this:Pin 1 is the center pin which will be connected to the positive supply; pin 2 is connected to GND. With nothing plugged in pins 2 and 3 are connected, but with a plug inserted they are disconnected.Connect pin 3 to the USB ID pin; also connect a 10K resistor in parallel (from the USB ID to GND).When the external plug is not inserted the USB ID pin and GND will be shorted.When the external plug is inserted the resistance between the USB ID pin and GND will be 10K.

author: Berni
author_rank: Super Contributor
timestamp: August 14, 2019, 10:08:01 am
content: Quote from: gaminn on August 14, 2019, 08:41:40 amYou can get power switching depletion MOSFETs that have a on resistance of under 1 Ohm, but since this is just a signal pretty sure 30 Ohm would be just fine too. The phone is likely not measuring the resistance on the ID pin with much current behind it, so it would make sense to have the threshold quite a bit higher than a few ohms since you wouldn't want a handful of milivoltes of voltage to trip it.As for negative voltage you can build a charge pump with your existing MCU, so no extra IC is needed.

author: gaminn
author_rank: Frequent Contributor
timestamp: August 14, 2019, 11:14:48 am
content: Quote from: ledtester on August 14, 2019, 09:01:22 amGreat idea. The only drawback I can see - when there is power outage or user leaves jack connected to the device without connecting adapter to AC power socket, the device will not work.

author: Benta
author_rank: Super Contributor
timestamp: August 14, 2019, 07:45:05 pm
content: Use a SPDT reed relay.

author: David Hess
author_rank: Super Contributor
timestamp: August 14, 2019, 08:46:03 pm
content: A JFET or depletion mode MOSFET would be my first choice.