Switching a 9V line in a 3.3V circuit - Page 1
Forum section: electronics / beginners

author: Maxlor
author_rank: Frequent Contributor
timestamp: January 05, 2014, 05:07:50 am
content: I'm experimenting with switches and toggles today, and encountered one problem for which I need a hint. How can I electronically switch connect or disconnect a signal line that occasionally goes much higher than Vdd, i.e. between 9 and 14V?I've come up with a circuit that allows me to connect and disconnect a PICkit3 from the target board using a single momentary switch. Yes, not the most useful thing, and I could use a slide switch, but it's really just an exercise to figure out how to do something like that, and disconnecting the PICkit3 is the first practical example that came to mind.I can disconnect and reconnect the data lines of the PICkit3 easily using a 74HC4066 analog switch. However, the reset line goes into the range 9-14V when entering programming mode, and the 4066 as well as a couple of other types of switches I looked at only handle Vdd+0.5V or something like that. I could use a relay, but I was hoping there was a more elegant, solid state, solution?My first thought was using a transistor, but: the reset line has 3 states, low (0V), high (3.3V) and programming (9V), and I couldn't figure out how to make that work. So, how do you do it?

author: jeremy
author_rank: Super Contributor
timestamp: January 05, 2014, 06:17:17 am
content: How about a good old mechanical relay?http://en.wikipedia.org/wiki/Relayedit: whoops, just read that you thought of relaysHow about using a MOSFET? In a switching configuration, mosfets basically only care about whether the gate is higher than the threshold voltage, you can switch much higher voltages and currents within the rating of the device on the drain and source? See solid state relays (aka MOSFETs + support circuitry inside a big blob of epoxy)edit2: Also, look for level shifting circuits based on MOSFETs a lahttps://www.sparkfun.com/products/8745

author: Maxlor
author_rank: Frequent Contributor
timestamp: January 05, 2014, 07:35:09 am
content: Oh that sounds good. I haven't familiarized myself with the differences between the different types of transistors yet; I guess I should get started on thatThanks!

author: Simon
author_rank: Unknown
timestamp: January 05, 2014, 08:20:26 am
content: your going to need an analogue switch really to pass highs or lows a relay does sound like the best option.

author: jeremy
author_rank: Super Contributor
timestamp: January 05, 2014, 08:33:10 am
content: Ah, if you're just pulling the reset line high to burn the flash in the micro, I can't imagine it would make a huge difference whether you use a FET or a traditional relay.Gotta avoid mechanical parts when you can

author: Rerouter
author_rank: Super Contributor
timestamp: January 05, 2014, 08:37:07 am
content: for $1.50 you can buy an optical analog switch, a large number of them only take 1mA to switch, and can handle a considerable current. (essentially 2 photo-fets back to back to prevent the body diode causing problems)

author: Simon
author_rank: Unknown
timestamp: January 05, 2014, 08:37:28 am
content: well analogue switch of some sort then

author: Maxlor
author_rank: Frequent Contributor
timestamp: January 06, 2014, 12:46:59 am
content: I can't figure out how to do it with just mosfets :/ If it's possible, please show me how. What I'm thinking is, if I have a signal at 9V, I can switch my gate between 0V and 3.3V all I want, it won't matter.Would an optocoupler work? Or will the PICkit3 be able to pull low the !MCLR input on the PIC even if the optocoupler is off?I'm pretty sure an SSR would work... but it's an order of magnitude more expensive, and they seem to be rather slow. I measured the PICkit3's reset pulse with at 0.7ms, that would be skewed significantly by an SSR (but it would probably still work.) In any case it feels like overkill, after all it's just a signal line, not a current carrying one, there has to be a simpler way.

author: jeremy
author_rank: Super Contributor
timestamp: January 06, 2014, 01:29:58 am
content: Hi Maxlor,I did a quick ltspice of one solution. It uses a n channel mosfet to do the switching, and then a BJT to protect the 3.3V line from the high voltages of the 9V line. The gap between V(9v_line) and V(load) will depend on the mosfet you choose.I did it pretty hastily, so sorry for any mistakes. I'm at work! I can give you the .asc file if you like, but the forum won't let me upload it...

author: Dave
author_rank: Super Contributor
timestamp: January 06, 2014, 01:52:46 am
content: A P-channel MOSFET would work better in the circuit above - less voltage drop between drain and source (just I*RDS(on)instead of VGS(threshold)).

author: Maxlor
author_rank: Frequent Contributor
timestamp: January 06, 2014, 02:30:00 am
content: Thanks jeremy, I can duplicate that. I'll try that and play with it. At first glance, the results aren't exactly what I need, because the load in this instance has a weak pullup to Vdd (and shouldn't be pulled low unless the control input allows it,) but maybe the suggested circuit does that. But... it's 03:30 in the morning now, and I have to show up for work for the first time this year in a couple of hours. I'll fire up LTSpice later

author: Maxlor
author_rank: Frequent Contributor
timestamp: January 07, 2014, 06:16:12 am
content: Nope, no dice. Even with CONTROL switched off, the programmer would still be able to pull the reset pin low (see image.) But maybe if I add another mosfet in series...Actually, I think you've provided me with the crucial clue I needed. Combining the NPN and MOSFET like that is clever! The other part I think I know how to do.

author: Maxlor
author_rank: Frequent Contributor
timestamp: January 07, 2014, 08:10:22 am
content: It works nowMade with EveryCircuit on the train to work:

author: jeremy
author_rank: Super Contributor
timestamp: January 07, 2014, 08:20:13 am
content: sorry mate, must have misunderstood what you needed. glad you got it in the end