Author Topic: Replacing a SPDT/DPDT switch with a circuit  (Read 5391 times)

0 Members and 1 Guest are viewing this topic.

Offline darkphotonsTopic starter

  • Newbie
  • Posts: 4
  • Country: au
Replacing a SPDT/DPDT switch with a circuit
« on: May 16, 2018, 06:15:16 am »
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 this  :scared: I 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?
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 22467
  • Country: gb
  • 0999
Re: Replacing a SPDT/DPDT switch with a circuit
« Reply #1 on: May 16, 2018, 07:52:53 am »
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.
 

Offline netdudeuk

  • Frequent Contributor
  • **
  • Posts: 470
  • Country: gb
 

Online ledtester

  • Super Contributor
  • ***
  • Posts: 4222
  • Country: us
Re: Replacing a SPDT/DPDT switch with a circuit
« Reply #3 on: May 17, 2018, 04:36:51 pm »
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.
 

Offline darkphotonsTopic starter

  • Newbie
  • Posts: 4
  • Country: au
Re: Replacing a SPDT/DPDT switch with a circuit
« Reply #4 on: May 19, 2018, 05:17:06 am »
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.
« Last Edit: May 19, 2018, 05:21:19 am by darkphotons »
 

Online ledtester

  • Super Contributor
  • ***
  • Posts: 4222
  • Country: us
Re: Replacing a SPDT/DPDT switch with a circuit
« Reply #5 on: May 19, 2018, 02:01:08 pm »
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=1yrof9dZ1z0y2tg

Since 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.




 

Online ledtester

  • Super Contributor
  • ***
  • Posts: 4222
  • Country: us
Re: Replacing a SPDT/DPDT switch with a circuit
« Reply #6 on: May 20, 2018, 05:11:38 am »
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 programmer

The 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: [Select]
    HVP0       RESET0   
      HI         X         Q1 pulls RESET1 to +12
      LO         HI        RESET1 pulled to +5 by R1
      LO         LO        RESET1 pulled to GND by Q3

Q1 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.
« Last Edit: May 20, 2018, 05:27:24 am by ledtester »
 

Offline darkphotonsTopic starter

  • Newbie
  • Posts: 4
  • Country: au
Re: Replacing a SPDT/DPDT switch with a circuit
« Reply #7 on: May 20, 2018, 05:27:22 am »
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.
 

Offline darkphotonsTopic starter

  • Newbie
  • Posts: 4
  • Country: au
Re: Replacing a SPDT/DPDT switch with a circuit
« Reply #8 on: May 20, 2018, 05:38:04 am »
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.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

-->