Author Topic: Use transistors to switch between two signals  (Read 7072 times)

0 Members and 1 Guest are viewing this topic.

Offline gbuilderTopic starter

  • Newbie
  • Posts: 8
  • Country: gb
Use transistors to switch between two signals
« on: April 19, 2018, 10:09:22 am »
Hello,
As a beginner, I have tended to use lots of relays for logic and switching, since the way they operate is very intuitive.
I'm staring to understand that in many cases, using transistors for switching is a better choice (cheaper, smaller, better for high frequency switching, etc)

I've enjoyed learning how to use transistors to switch a signal on or off, invert, buffer and provide gain. Very useful.  :)

I'd now like to understand if it is possible to use transistor circuit to switch between two different signals.
Specifically, I'd like to find a circuit which will perform the same function as my relay switching circuit below.

In this case, the MCU digital output state determines which signal from the inputs is connected to the output.



Update: Thanks hamster_nz for spotting the flaws in my relay circuit. It was just a quick sketch to illustrate my question, but you are quite correct and I have uploaded a corrected version which might be useful for people reading the thread in future:

« Last Edit: April 25, 2018, 10:37:42 am by gbuilder »
 

Offline gbuilderTopic starter

  • Newbie
  • Posts: 8
  • Country: gb
Re: Use transistors to switch between two digital signals
« Reply #1 on: April 19, 2018, 10:57:51 am »
Hmm, or should I be using an "analogue switch"/"multiplexer" IC for this function?
« Last Edit: April 19, 2018, 11:00:09 am by gbuilder »
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19345
  • Country: gb
  • 0999
Re: Use transistors to switch between two digital signals
« Reply #2 on: April 19, 2018, 11:00:23 am »
Hmm, or should I be using an "analogue switch" IC for this function?
Or some logic gates, if there are only two signals.
 

Offline ogden

  • Super Contributor
  • ***
  • Posts: 3731
  • Country: lv
Re: Use transistors to switch between two digital signals
« Reply #3 on: April 19, 2018, 11:08:06 am »
I'd now like to understand if it is possible to use transistor circuit to switch between two different signals.

Indeed it is possible. After all digital chips are made out of transistors :) I suggest you to skip transistor switch build, just learn multiplexers. Better invest your time into something more useful :)

https://en.wikipedia.org/wiki/Multiplexer

What you want is 2:1 SPDT switch (multiplexer), like http://www.ti.com/product/cd4053b that chip have 3 switches inside.
 
The following users thanked this post: gbuilder

Offline boffin

  • Supporter
  • ****
  • Posts: 1027
  • Country: ca
Re: Use transistors to switch between two digital signals
« Reply #4 on: April 19, 2018, 11:29:48 am »
I'd now like to understand if it is possible to use transistor circuit to switch between two different signals.

Indeed it is possible. After all digital chips are made out of transistors :) I suggest you to skip transistor switch build, just learn multiplexers. Better invest your time into something more useful :)

https://en.wikipedia.org/wiki/Multiplexer

What you want is 2:1 SPDT switch (multiplexer), like http://www.ti.com/product/cd4053b that chip have 3 switches inside.
Actually the 4053 is a single 1P8T switch (pick one of 8), fed from a 3-bit number

Where as the 4066 might be more useful (and easier to find).  Four individual SPDT switches
http://www.ti.com/product/CD4066B
 
The following users thanked this post: gbuilder

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19345
  • Country: gb
  • 0999
Re: Use transistors to switch between two digital signals
« Reply #5 on: April 19, 2018, 12:13:17 pm »
I'd now like to understand if it is possible to use transistor circuit to switch between two different signals.

Indeed it is possible. After all digital chips are made out of transistors :) I suggest you to skip transistor switch build, just learn multiplexers. Better invest your time into something more useful :)

https://en.wikipedia.org/wiki/Multiplexer

What you want is 2:1 SPDT switch (multiplexer), like http://www.ti.com/product/cd4053b that chip have 3 switches inside.
Actually the 4053 is a single 1P8T switch (pick one of 8), fed from a 3-bit number

Where as the 4066 might be more useful (and easier to find).  Four individual SPDT switches
http://www.ti.com/product/CD4066B
No, '4053 is three SPDT switches.
https://assets.nexperia.com/documents/data-sheet/HEF4053B.pdf

If this is running off 5V, then the 74HC4053 should be used, as it has a lower on resistance. If only one switch is required, then all three can be connected in parallel, for a third of the resistance.
https://assets.nexperia.com/documents/data-sheet/74HC_HCT4053.pdf

If it's just one channel, then a quad NAND can be used. It will be slightly slower, than an analogue switch, but it has the advantage of being buffered.
« Last Edit: April 19, 2018, 01:42:23 pm by Hero999 »
 
The following users thanked this post: gbuilder

Offline ogden

  • Super Contributor
  • ***
  • Posts: 3731
  • Country: lv
Re: Use transistors to switch between two digital signals
« Reply #6 on: April 19, 2018, 01:36:30 pm »
Actually the 4053 is a single 1P8T switch (pick one of 8), fed from a 3-bit number

No. Three individual SPDT switches.

Quote
Where as the 4066 might be more useful (and easier to find).  Four individual SPDT switches
http://www.ti.com/product/CD4066B

No. 4066 is quad bilateral switch

:-DD
 

Offline gbuilderTopic starter

  • Newbie
  • Posts: 8
  • Country: gb
Re: Use transistors to switch between two digital signals
« Reply #7 on: April 19, 2018, 09:12:44 pm »
Your comments have been very insightful, thank-you.

----->Picks up Horowitz & Hill to read about digital logic and multiplexers
 

Offline gbuilderTopic starter

  • Newbie
  • Posts: 8
  • Country: gb
Re: Use transistors to switch between two digital signals
« Reply #8 on: April 19, 2018, 09:38:11 pm »

If it's just one channel, then a quad NAND can be used. It will be slightly slower, than an analogue switch, but it has the advantage of being buffered.


Would you mind talking me through the operation of the circuit you showed here? It looks to me like the decision of which input is connected to the output will depend on the state (high/low) of the input signals.
In my relay circuit, the selection of which input signal is connected to the output is completely determined by the control pin.
Forgive my slow comprehension, this is why I'm always tempted to use relays - their operation is so simple :D !
 

Offline ogden

  • Super Contributor
  • ***
  • Posts: 3731
  • Country: lv
Re: Use transistors to switch between two digital signals
« Reply #9 on: April 19, 2018, 09:54:07 pm »
If it's just one channel, then a quad NAND can be used. It will be slightly slower, than an analogue switch, but it has the advantage of being buffered.


One more disadvantage comparing to analog muxes - it's unidirectional.
 

Offline Jwillis

  • Super Contributor
  • ***
  • Posts: 1688
  • Country: ca
Re: Use transistors to switch between two digital signals
« Reply #10 on: April 19, 2018, 11:42:29 pm »
Why couldn't he use a simply inverter circuit? The two out puts could be used to switch two more transistors to pass the two inputs to one depending on whether the input to inverter is high on low.


« Last Edit: April 19, 2018, 11:51:45 pm by Jwillis »
 

Offline tron9000

  • Frequent Contributor
  • **
  • Posts: 423
  • Country: gb
  • Still an Electronics Lab Tech
    • My Hack-a-day project page
Re: Use transistors to switch between two digital signals
« Reply #11 on: April 20, 2018, 08:35:45 am »

If it's just one channel, then a quad NAND can be used. It will be slightly slower, than an analogue switch, but it has the advantage of being buffered.


Would you mind talking me through the operation of the circuit you showed here? It looks to me like the decision of which input is connected to the output will depend on the state (high/low) of the input signals.
In my relay circuit, the selection of which input signal is connected to the output is completely determined by the control pin.
Forgive my slow comprehension, this is why I'm always tempted to use relays - their operation is so simple :D !

First off, truth table for NAND Gate:
0 0 = 1
0 1 = 1
1 0 = 1
1 1 = 0

the switch dictates which signal will be passed to the output.

When the switch is closed, the signal to the gate connected to 2 goes high, Any state change on pin 2 will be passed to that gates output. With the switch still closed, the gate with both pins tied together inverts the signal from the switch, thus there is a low signal to gate for pin1 and any state change on pin 1 will be blanked (output will always be 1).

so at the final output gate, one input is high (from gate 1) and the other input is changing state and so the output changes state according what is present at 2.

open the switch and everything swaps, the output now changes state WRT pin 1.

The reason Hero999 has show using NAND gates are that NAND gates are/were easier to obtain and produce, Cheaper than AND counterpart, and come in Quad DIP packages: 74LS00

though it'd be easier to explain this with AND gates. Hey, life gives you lemons...
« Last Edit: April 20, 2018, 08:41:03 am by tron9000 »
Partsbox.io - orangise your parts!
"If you're green you can only ripen. If you're ripe you can only rot!"
 

Offline boffin

  • Supporter
  • ****
  • Posts: 1027
  • Country: ca
Re: Use transistors to switch between two digital signals
« Reply #12 on: April 20, 2018, 05:18:23 pm »
I'd now like to understand if it is possible to use transistor circuit to switch between two different signals.

Indeed it is possible. After all digital chips are made out of transistors :) I suggest you to skip transistor switch build, just learn multiplexers. Better invest your time into something more useful :)

https://en.wikipedia.org/wiki/Multiplexer

What you want is 2:1 SPDT switch (multiplexer), like http://www.ti.com/product/cd4053b that chip have 3 switches inside.
Actually the 4053 is a single 1P8T switch (pick one of 8), fed from a 3-bit number

Where as the 4066 might be more useful (and easier to find).  Four individual SPDT switches
http://www.ti.com/product/CD4066B
No, '4053 is three SPDT switches.

Of course you're right. My bad is I looked at the datasheet for the 4051 (which was the original PDF referenced)  which is a 3 to 8  1P8T switch and to make matters worse, I had a complete brain-fart thinking the 4066 was double throw.  I'll stick to typing only when I'm awake.  4053 will work nicely, but I typically keep 4066s on hand, so I'd probably just glue a couple of channels together to make what the OP was talking about.

 

Offline hamster_nz

  • Super Contributor
  • ***
  • Posts: 2803
  • Country: nz
Re: Use transistors to switch between two digital signals
« Reply #13 on: April 20, 2018, 08:11:10 pm »
Hello,
I'd now like to understand if it is possible to use transistor circuit to switch between two different signals.
Specifically, I'd like to find a circuit which will perform the same function as my relay switching circuit below.

In this case, the MCU digital output state determines which signal from the inputs is connected to the output.





I don't think that that circuit actually will work as you expect. It seems impossible to turn the relay on. A wire from IN1 to OUT is all you need to perform the same function.

Typical internet - even when you supply a circuit schematic, nobody looks at it!  :-//

But being serious now, you might have been meaning this circuit, as rendered in DaveCAD on scrap paper (please ignore that in and out are transposed):

« Last Edit: April 20, 2018, 08:15:41 pm by hamster_nz »
Gaze not into the abyss, lest you become recognized as an abyss domain expert, and they expect you keep gazing into the damn thing.
 

Offline gbuilderTopic starter

  • Newbie
  • Posts: 8
  • Country: gb
Re: Use transistors to switch between two digital signals
« Reply #14 on: April 20, 2018, 10:07:43 pm »
tron9000 thank-you for the clear explanation. My confusion was that I was thinking of the signals as analogue. CLearly this is a solution suitable for digital logic signals.

hamster_nz yes sorry, I must admit I haven't checked the circuit in SPICE or on the breadboard. Another rookie mistake. With NPN transistor switch, for predictable behaviour the load should be between the positive supply and the collector, not between the emitter and ground.
« Last Edit: April 20, 2018, 10:43:19 pm by gbuilder »
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19345
  • Country: gb
  • 0999
Re: Use transistors to switch between two digital signals
« Reply #15 on: April 21, 2018, 12:35:09 pm »
I'm amazed most people, including myself, missed that. Yes, it won't work. R2 will limit the current too much for the relay to turn on.

It might still work with an emitter follower, just with R2 and R1 removed. The relay will get about 4.4V, which may still be high enough to activate it.
 

Offline ogden

  • Super Contributor
  • ***
  • Posts: 3731
  • Country: lv
Re: Use transistors to switch between two digital signals
« Reply #16 on: April 21, 2018, 07:21:23 pm »
I'm amazed most people, including myself, missed that.

That's because question was not about particular circuit. - I missed (to be honest - ignored) to look into that circuit as well :)
 

Offline glarsson

  • Frequent Contributor
  • **
  • Posts: 814
  • Country: se
Re: Use transistors to switch between two digital signals
« Reply #17 on: April 21, 2018, 08:37:02 pm »
I'm amazed most people, including myself, missed that. Yes, it won't work. R2 will limit the current too much for the relay to turn on.
Didn't miss it. The circuit is weird, but it will work with a sensitive 2V relay. However, it wasn't relevant to the question.
 

Offline boffin

  • Supporter
  • ****
  • Posts: 1027
  • Country: ca
Re: Use transistors to switch between two digital signals
« Reply #18 on: April 22, 2018, 12:54:30 am »
Just take HamsterNZ's circuit, replace the transistor with a FET (2N7000), remove the resistors and you're in business (you could keep the Rs if you really wanted, but if the source is guaranteed Hi/Lo you're fine).  Almost no voltage drop across the FET, the relay will turn on/off just fine, rather than being a bit iffy at 4.4V
 

Offline tron9000

  • Frequent Contributor
  • **
  • Posts: 423
  • Country: gb
  • Still an Electronics Lab Tech
    • My Hack-a-day project page
Re: Use transistors to switch between two digital signals
« Reply #19 on: April 23, 2018, 08:40:29 am »
tron9000 thank-you for the clear explanation. My confusion was that I was thinking of the signals as analogue. CLearly this is a solution suitable for digital logic signals.

Ahh, well then, your best bet is an analogue mulitplexer: DG409

glad you thought my explanation was "clear" - usually I'm not very good at explaining things!
« Last Edit: April 23, 2018, 08:43:14 am by tron9000 »
Partsbox.io - orangise your parts!
"If you're green you can only ripen. If you're ripe you can only rot!"
 

Offline hirada

  • Regular Contributor
  • *
  • Posts: 85
  • Country: de
Re: Use transistors to switch between two digital signals
« Reply #20 on: April 24, 2018, 11:58:43 am »
A reply from a beginner: My (simplified) version of yours to turn on the relay would look like this. The need of a base resistor could propbably be argued and you only have ~4.3V for the relay as opposed to 5V.

Edit: Assuming of course, the MCU output delivers enough current and is 5V as well, so you have 5Vb.

« Last Edit: April 24, 2018, 12:14:16 pm by hirada »
 

Offline tron9000

  • Frequent Contributor
  • **
  • Posts: 423
  • Country: gb
  • Still an Electronics Lab Tech
    • My Hack-a-day project page
Re: Use transistors to switch between two digital signals
« Reply #21 on: April 24, 2018, 02:22:33 pm »
A reply from a beginner: My (simplified) version of yours to turn on the relay would look like this. The need of a base resistor could propbably be argued and you only have ~4.3V for the relay as opposed to 5V.

Edit: Assuming of course, the MCU output delivers enough current and is 5V as well, so you have 5Vb.

The beauty about relays is that even if you switch it low side, leaving one end "flapping in the breeze" its not going to float and/or accidentally turn on.
Partsbox.io - orangise your parts!
"If you're green you can only ripen. If you're ripe you can only rot!"
 

Offline Lt_Flash

  • Regular Contributor
  • *
  • Posts: 78
  • Country: au
Re: Use transistors to switch between two digital signals
« Reply #22 on: April 25, 2018, 07:23:32 am »
You can use LTC4412 to switch between two power sources and also can control it from MCU

http://www.analog.com/media/en/technical-documentation/data-sheets/4412fb.pdf

If that's not a power signals - then why just not use a multiplexer? There's a lot of 2-channel ones available.
 

Offline gbuilderTopic starter

  • Newbie
  • Posts: 8
  • Country: gb
Re: Use transistors to switch between two digital signals
« Reply #23 on: April 25, 2018, 10:36:54 am »
Thank-you all for the input, some very interesting comments and I have learned a lot!
I've enjoyed following the different approaches to solve this very simple problem, I guess that's what makes electronics design interesting.
Sorry for the error in my initial schematic, I've uploaded a correction to the OP.

I've decided to order a bunch of 4053 multiplexer ICs. Of all the 405x series, this seems particularly versatile and might come in handy in many other situations. Also I could get 10 for £2  ;D


 

Offline IanMacdonald

  • Frequent Contributor
  • **
  • Posts: 943
  • Country: gb
    • IWR Consultancy
Re: Use transistors to switch between two signals
« Reply #24 on: April 25, 2018, 12:44:51 pm »
A CD4016 is similar to the 4053 but gives you four single switches.  Another arrangement that works well where small signal handling with low noise and distortion is needed, is a pair of JFETs such as 2N3819's.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf