Drive a 12V analog switch from logic level input - Page 1
Forum section: electronics / beginners

author: hermitengineer
author_rank: Regular Contributor
timestamp: November 22, 2019, 06:49:43 am
content: I'm looking for a quick and dirty way to interface with a 4066 analog switch from a MCU. The 4066 is supplied with 12V, and if I read the datasheet right, that means it needs close to 9V to turn it on. So I need a logic to 12V level shifter (I picked 12V because there's a rail for that). One quick and dirty solution is to drive a PNP transistor with an NPN transistor. But I'd like to simplify that even more.Would an optocoupler be a viable way to supply the 12V? I'm thinking, MCU digital pin -> resistor -> LED side of optocoupler -> ground; 12V -> collector -> connector to switch. Possible IC would be VOM617A-3.

author: A Hellene
author_rank: Frequent Contributor
timestamp: November 22, 2019, 07:32:05 am
content: How about just using a low power N-Channel MOSFET (e.g. the 2N7000 or its SMD version 2N7002) in common Gate topology, and a 1..22k pull-up resistor?Input will be the Source pin, the Gate pin will be connected to the low voltage Vdd supply rail, and output will be the Drain pin with a 4k7..12k pull-up resistor to +12V.-George

author: jhpadjustable
author_rank: Frequent Contributor
timestamp: November 22, 2019, 08:26:53 am
content: Invert the control input and use just one transistor?Less dirty is to use complementary PNP/NPN transistors in 6-pin small packages.Quote from: A Hellene on November 22, 2019, 07:32:05 amThat level shifter design depends on the difference between the two rails being smaller than Vgs(th). 7V is way too much.

author: A Hellene
author_rank: Frequent Contributor
timestamp: November 22, 2019, 09:00:21 am
content: Nah! The transistor doesn't care about Vdg being 7V, as long as its Source is tied to the Gate! It is a 60V device with a Vgs_th of 1.0 .. 2.5V, so a Vgs_th of 3.3V will open the channel all right in order to pass the 1..2mA pull-up Drain current.Also, being in common Gate topology, it does not need any inversion at its input:- When its input is logic-high Vgs == (Vdd-Vdd) = 0V, so the channel is closed and no Drain current flows; the output becomes +12V via the output pull-up resistor.- When its input is logic-low Vgs == (Vdd-Vss) = (Vdd)V, so the channel opens and Drain current flows; the output becomes 0V via the logic output transistor of the level-shifter driver and the 5Ω transistor channel.Actually, that circuit above, is a stripped-down version of the bi-direcrional level-shifter Philips proposed at their IIC protocol specification!-GeorgeEDIT: Clarifications and corrections.

author: magic
author_rank: Super Contributor
timestamp: November 22, 2019, 09:02:56 am
content: You should probably use BSS138 instead of 2N7000, though. The latter is rather marginal at 3.3V.Not sure what to use in THT.

author: hermitengineer
author_rank: Regular Contributor
timestamp: November 22, 2019, 09:05:55 am
content: Quote from: jhpadjustable on November 22, 2019, 08:26:53 amOh, duh. You mean something like the upper part of this?

author: Alex Nikitin
author_rank: Super Contributor
timestamp: November 22, 2019, 09:12:56 am
content: Quote from: jhpadjustable on November 22, 2019, 08:26:53 amNo it doesn't.CheersAlex

author: hermitengineer
author_rank: Regular Contributor
timestamp: November 22, 2019, 09:13:33 am
content: Oh yeah, the simple transistor circuit above won't work anyway because the existing circuit has a 10K pull-down to ground connected to its switch control. So you pretty much need to drive it with the transistor instead of trying to let a pull-up handle it.

author: A Hellene
author_rank: Frequent Contributor
timestamp: November 22, 2019, 02:06:40 pm
content: Quote from: hermitengineer on November 22, 2019, 09:13:33 amOh, yes, it will work!Just remove the pull-down '4066 cntrol input resistor, or make the MOSFET Drain pull-up resistor steeper (of a lower resistance that recommended above); e.g. of the one fifth of the bilateral switch pull-down input resistor value, because both the recommended MOSFETs (the 2N... as well as the BSS...) can very easily handle a few decades of milliampers Drain load with a more than 3.0V Gate drive.-George

author: jhpadjustable
author_rank: Frequent Contributor
timestamp: November 22, 2019, 03:17:13 pm
content: Quote from: Alex Nikitin on November 22, 2019, 09:12:56 amOh, I see I got the source and drain backwards while looking into it.Disregard...Quote from: hermitengineer on November 22, 2019, 09:05:55 amYeah, like that. But either of these solutions is troublesome if there's a big pulldown on the higher-voltage side to contend with, unless you can get rid of it. Or move the pulldown to the lower-voltage side and get rid of the pullup on the lower-voltage side.

author: Benta
author_rank: Super Contributor
timestamp: November 22, 2019, 05:33:51 pm
content: Almost all analog switches have separate digital and analog supply pins with internal level shifting. The 4066 is an exception. Check out the DG6xx or the DG4xx series from Vishay, for instance.

author: hermitengineer
author_rank: Regular Contributor
timestamp: November 22, 2019, 06:35:59 pm
content: For more background, this is a vintage game console, the Colecovision. It has an expansion port that I'm connecting to. The pin in question switches video output from its internal chip to the expansion port's video input. Commercial expansion modules just shorted +12V to the video enable, but I'd like to be selective.Anyway, I'd like to treat the CV itself as a black box, though I at least know its internal circuitry. So that means no mods to the 4066 or removal of its 10K pull-down.

author: Zero999
author_rank: Super Contributor
timestamp: November 22, 2019, 11:42:02 pm
content: Why not simply use a logic level translator IC such as the CD4504 or CD40109? It's non-inverting and doesn't require any other components.http://www.ti.com/lit/ds/symlink/cd4504b.pdfhttp://www.ti.com/lit/ds/symlink/cd40109b.pdfOh and if you do want to go discrete, a BJT can be used in non-inverting configuration by connecting the input to the emitter, rather than the base.

author: vk6zgo
author_rank: Super Contributor
timestamp: November 23, 2019, 03:31:00 am
content: Of course, you do realise that +12v is a legitimate logic level in its own right?

author: hermitengineer
author_rank: Regular Contributor
timestamp: November 23, 2019, 07:40:01 am
content: Quote from: Zero999 on November 22, 2019, 11:42:02 pmA 4504 may indeed be the most robust and simple solution. I just turn up my nose at the number of unused gatesWhy don't they make a single-gate version that can take 12V+?As mentioned above, the existing circuit within the "black box" that I'm interfacing to uses a 10K pull-down, so a resistive supply would not be a good match. So unfortunately, that level shifter circuit has the same problem as the MOSFET ones.

author: vk6zgo
author_rank: Super Contributor
timestamp: November 23, 2019, 04:05:14 pm
content: Quote from: hermitengineer on November 22, 2019, 09:05:55 amIf it doesn't have to be very fast, the bottom part would be better.

author: Zero999
author_rank: Super Contributor
timestamp: November 23, 2019, 08:43:38 pm
content: Quote from: hermitengineer on November 23, 2019, 07:40:01 amI don't know why they don't make a single gate version, but they're not expensive, so not using all of the gates shouldn't matter. It will certainly use less power than a discrete solution and probably work out cheaper too.In the discrete solutions, an additional transistor can be added to pull the output hard up to the positive rail or use the opto-coupler, as you posted before, but both options will be more expensive and power hungry than a logic level translation IC.The pull-down resistor is also no problem for a logic level shifter IC.