Replacing a SPDT/DPDT switch with a circuit - Page 1
Forum section: electronics / projects

author: darkphotons
author_rank: Newbie
timestamp: May 16, 2018, 06:15:16 am
content: I’ve designed a simple Atmega328 HVPP PCB (12V to target pin 1/reset),the board also supports a little Arduino ISP board to program it.Here’s my problem.Pin 1 on the target chip must either be connected to the 12V for HVPP or to the RST pin of the ISP PCB,obviously not to both at the same time!So I’ve placed a DPDT switch on the PCB where the common1 is connected to the target pin 1 end either switches the 12V or the ISP RST signal to the target chip,the second (integrated) switch is simply used to tell the software which position the switch is in.Now I want to replace the physical switch with a simple circuit to allow the software to switch between to two modes, in such a way that the 12V and the ISP RST pin are always separated. (GNDs can be connected)Only one of them, at any given time, should be connected to the target chip pin1.I have tried many MOSFETs designs but wasn’t able to achieve thisI looked at using analog switch IC’s such as the ADG1419 and the ADG436,but they are not truly SPDT or DPDT switches, and only switch externally connected power supplies.Surely there is a simple solution to mimic a SPDT or DPDT switch electronically?

author: Zero999
author_rank: Super Contributor
timestamp: May 16, 2018, 07:52:53 am
content: Yes, the device you're looking for is a relay. Don't forget to add a reverse diode across the coil, to protect the driver circuit from the high voltage pulse generated, when the coil is turned off.

author: netdudeuk
author_rank: Frequent Contributor
timestamp: May 16, 2018, 09:37:41 am
content: If you search forarduino relayon eBay there are modules for next to nothing.Here's an examplehttps://www.ebay.co.uk/itm/5V-1-2-4-8-Channel-Relay-Board-Module-for-Arduino-Raspberry-Pi-ARM-AVR-DSP-PIC/252051910091?epid=1042400706&hash=item3aaf76edcb:m:mdbiogK3bG3MfWb_sjDpLvw

author: ledtester
author_rank: Super Contributor
timestamp: May 17, 2018, 04:36:51 pm
content: You might get some ideas from this project:https://mightyohm.com/blog/2008/09/arduino-based-avr-high-voltage-programmer/They are just using an NPN transistor to connect +12 to pin 1. To have one control signal activate one transistor when it's on and another when it's off just use a NOT gate (or equivalent) to invert the signal to the other transistor. A NOT gate can be made with a another single transistor.

author: darkphotons
author_rank: Newbie
timestamp: May 19, 2018, 05:17:06 am
content: Thanks for the answers thus far guys,yes ledtester, my HVPP design is based around an MUN5311DW1T1G or a Dual Bias Resistor Transistor,however this only takes care of switching the 12V on/off.I am also aware that I could use a relais but that feels like an over-kill solution for switching two low power signal pins.I don’t really want a mechanical solution either.The free space available on my PCB is about 10x10mm so I need a tiny SMD solution,If none can be found I’ll probably resort to using a mini relais, i found a 5V one with a footprint of 6x10mm, who knew? (IM03TS DPDT)and switch it with a 2N2222/1K and a small fly back diode.

author: ledtester
author_rank: Super Contributor
timestamp: May 19, 2018, 02:01:08 pm
content: The CMOS logic gate family is available in SMD packages and you can also get just one or two logic gates in SOT-23/SSOP-8 foot prints. Look up "single function cmos logic gates" on Mouser, eg:https://www.mouser.com/Semiconductors/Logic-ICs/Logic-Gates/_/N-581zn?P=1yrof9dZ1z0y2tgSince RESET on the Arduino is active low, maybe a single OR gate will work - RESET = HVPP or R, where HVPP is your high voltage programming control signal (active high) and R is the reset signal from the programmer.

author: ledtester
author_rank: Super Contributor
timestamp: May 20, 2018, 05:11:38 am
content: I've given your problem some thought, and here's what I've come up with.Note that the Atmel processors have a weak internal pull-up resistor on RESET.In the attached schematic:- Vcc is +5- RESET1 is the RESET line of the device being programmed- R1 is the internal pull-up on RESET- HVP0 is the digital control signal to activate the high-voltage programming- RESET0 is the RESET signal from your programmerThe logic gate is a NOR gate. Essentially we are computing HVP0 OR RESET0, but doing it with a NOR gate followed by an open drain MOSFET inverter.The operation of the circuit is as follows:Code:HVP0 RESET0HI X Q1 pulls RESET1 to +12LO HI RESET1 pulled to +5 by R1LO LO RESET1 pulled to GND by Q3Q1 and Q3 shouldn't be on at the same time, but if they are there will be a short from +12 to GND. You can mitigate against that by placing a 1K resistor between +12 and the emitter of Q1. This is what the mightyohm circuit does, so it should still activate high-voltage mode when Q1 is on.Any and all critiques are welcome.

author: darkphotons
author_rank: Newbie
timestamp: May 20, 2018, 05:27:22 am
content: Hi ledtester, this is awesome, I was not aware of single gate components. Very handy to know!When I was working on this problem, I started with just two P-MOSFETS and a breadboard, thus I had full control over the Gates.My test options were, no gate active (thus MOSFETs off), gate1 only active or gate2 only active, seems simple right?Yet try as I might I could not get the 12V and RST signals separated, no matter if I used the Drain as input and connected up the Sources or the other way around,the build-in intrinsic diodes always caused issues. Try it yourself on a bread board.I even played around with combinations of N / P Channel MOSFETS.Even when the HVPP 12V circuit is off, as soon as I electrically connect anything to that (ie the RST pin of programmer) both outputs (12V and RST 5V) would be screwed up,because both circuits (the 12V Dual Bias Transistor setup and the ISP programmer) would interfere with one and another.If I could get this setup to work I probably would only need to connect one of the gates to an inverter and Bob’s your uncle.

author: darkphotons
author_rank: Newbie
timestamp: May 20, 2018, 05:38:04 am
content: Thanks for your reply ledtester,my previous reply was to your second to last post. (guess we posted at the same time)I will go over your solution.Here is a schematic of part of my previous setup.