Author Topic: Control 3 transistor switches from two µCU pins  (Read 6126 times)

0 Members and 1 Guest are viewing this topic.

Offline alexanderbrevigTopic starter

  • Frequent Contributor
  • **
  • Posts: 700
  • Country: no
  • Musician, developer and EE hobbyist
    • alexanderbrevig.com
Control 3 transistor switches from two µCU pins
« on: September 01, 2015, 11:10:15 am »
Hi again everyone.

I'm doing a project (one of those word clocks) and I am one pin short from not having to use a shift register.

So I sat down, and made it a challenge to try and design something without looking at google. The next part of the challenge is to ask you guys and take the criticism and errors like a newbie should; with a smile!  :)

Here it is:


Given correct transistor and resistor matching, will this work?
A and B is controlled from a micro controller and it can handle about 25mA at 3v3 on it's GPIO.
« Last Edit: September 01, 2015, 11:39:18 am by alexanderbrevig »
 

Offline PA0PBZ

  • Super Contributor
  • ***
  • Posts: 5127
  • Country: nl
Re: Control 3 logic lines from two µCU pins
« Reply #1 on: September 01, 2015, 11:18:12 am »
So what are you going to connect to the XYZ outputs? Can you see a problem when there are inputs to another circuit that need to be pulled up? Or when they need to be pulled down?
Keyboard error: Press F1 to continue.
 

Offline alexanderbrevigTopic starter

  • Frequent Contributor
  • **
  • Posts: 700
  • Country: no
  • Musician, developer and EE hobbyist
    • alexanderbrevig.com
Re: Control 3 transistor switches from two µCU pins
« Reply #2 on: September 01, 2015, 11:38:26 am »
X Y Z will be a resistive load with LEDs in parallel. This is something I should've said of course  :palm:

EDIT: changed original title somewhat
 

Offline filssavi

  • Frequent Contributor
  • **
  • Posts: 433
Re: Control 3 logic lines from two µCU pins
« Reply #3 on: September 01, 2015, 11:46:35 am »
I can suggest 74HC4051, it's a 8 bit mux (you can use it as a 2 input by putting to gnd/vcc the most significant selection bit

if wou really want to do it the really old way (discrete transistors) I suggest using MOS instead of BJT's they massively simplify the biasing (well if you don't care about floating pins at MCU startup with the transistors potentially on due to leakage to the high impedance floating gate node, you can just skip biasing), they also won't load the MCU outputs as the gate is isolated (ok you may have some pA/fA leakage but that's not the point) 
 

Offline alexanderbrevigTopic starter

  • Frequent Contributor
  • **
  • Posts: 700
  • Country: no
  • Musician, developer and EE hobbyist
    • alexanderbrevig.com
Re: Control 3 transistor switches from two µCU pins
« Reply #4 on: September 01, 2015, 12:16:16 pm »
I want to try to use passives, as shift registers are something I've used before and decided that I wanted to avoid for this project.

I don't care about bias as long as I am able to shut them on/of hard. They will PWM the attached load (current limiting resistor + LEDs in parallel).

I guess I could simulate this in SPICE? *Downloading LT Spice*
 

Offline PSR B1257

  • Frequent Contributor
  • **
  • Posts: 330
  • Country: de
Re: Control 3 transistor switches from two µCU pins
« Reply #5 on: September 01, 2015, 03:02:37 pm »
Quote
be a resistive load with LEDs in parallel.
LEDs are not resistive. And they should not be connected in parallel.

You know, that your Vcc to the LEDs has to be the same as the µC Vcc, don't you?

Apart from that I don't get the point of trying to solve this problem with discrete transistors.

And no, your circuit doesn't work.
« Last Edit: September 01, 2015, 03:14:10 pm by PSR B1257 »
In theory, there is no difference between theory and practice. But, in practice, there is.
 

Offline alexanderbrevigTopic starter

  • Frequent Contributor
  • **
  • Posts: 700
  • Country: no
  • Musician, developer and EE hobbyist
    • alexanderbrevig.com
Re: Control 3 transistor switches from two µCU pins
« Reply #6 on: September 01, 2015, 04:16:27 pm »
Thanks for your answers guys :)

Quote
be a resistive load with LEDs in parallel.
LEDs are not resistive. And they should not be connected in parallel.
LEDs are not ohmic, but surely they are resistive?
They will be wired in parallel with a separate current limiting resistor per diode.


I have never heard that this is a no-no before...

You know, that your Vcc to the LEDs has to be the same as the µC Vcc, don't you?

The point is to not draw/sink the current. The voltage will be the same.

Apart from that I don't get the point of trying to solve this problem with discrete transistors.

And no, your circuit doesn't work.

It was a challenge and as such it does not really matter if you get why ;) Though if it does not work then that is something I do care about. My results in LT Spice seems promising (though may be my lack of experience with the program, just tried it today). Why does it not work?
 

Offline alexanderbrevigTopic starter

  • Frequent Contributor
  • **
  • Posts: 700
  • Country: no
  • Musician, developer and EE hobbyist
    • alexanderbrevig.com
Re: Control 3 transistor switches from two µCU pins
« Reply #7 on: September 01, 2015, 05:39:31 pm »
I'll use some chips in my design and experiment with this at some point. Will update then :) Thanks for pushing me in the right direction : ]
 

Offline PSR B1257

  • Frequent Contributor
  • **
  • Posts: 330
  • Country: de
Re: Control 3 transistor switches from two µCU pins
« Reply #8 on: September 01, 2015, 06:38:03 pm »
Quote
I have never heard that this is a no-no before...
If each LED has its own resistor, they are not longer "in parallel" as an electrician defines parallel  ;)

Quote
Why does it not work?
With !A&!B you turn on both Q_Y and Q_Z. Well, you could mask this condition by software, but if you have silicon diodes in the circuit, Q_X is possibly slightly forward biased and therefore not blocking appropriate.
With Schottky diodes you don't get this issue.
« Last Edit: September 01, 2015, 06:43:47 pm by PSR B1257 »
In theory, there is no difference between theory and practice. But, in practice, there is.
 

Offline LukeW

  • Frequent Contributor
  • **
  • Posts: 686
Re: Control 3 transistor switches from two µCU pins
« Reply #9 on: September 01, 2015, 07:47:21 pm »
You could muck around with a big pile of discrete-transistor logic and in theory do what you want, but maybe something like a http://www.ti.com/lit/ds/symlink/sn74lvc1g139.pdf would be simpler and neater.

It's late and I'm tired and this might be rubbish, but this sort of thing is possibly what you're sort of thinking of in terms of discrete transistor logic.
There probably does need to be a couple of diodes in there somewhere to keep everything in the right state when it's supposed to be.
A proper decoder IC would be much neater.
« Last Edit: September 01, 2015, 07:52:35 pm by LukeW »
 

Offline Redcat

  • Regular Contributor
  • *
  • Posts: 74
  • Country: de
  • Ask why not, not why.
    • redcatimaging
Re: Control 3 transistor switches from two µCU pins
« Reply #10 on: September 01, 2015, 10:18:27 pm »
I don't know if it helps, i'm not experienced with circuit design, but i have done some work in the simulator for you.
I'm not sure, if it works in real world, but you could try it.
You can have following states (A=top switch,B=bottom switch,LED 2=top LED, 3=bottom LED):
!A&!B -> LED 1(most right one)
A&!B  -> LED 2
!A&B  -> LED 3
When you have A&B -> LED 2+3 are on both.


I hope it helps you at least a little to get a basic idea. Current is pulled away from the transistor base to switch off the LED you have no switch for left when the other transistors are on...



I have also tried this 4th state were you have no LED lighting.
This one i'm pretty sure is not a good solution, but at least in the simulator it works.
With A&B all LEDs are off.

No, i've deleted that...it looked  :palm:.

You can download the simulator (google) and try yourself.

Have fun, Tom
« Last Edit: September 01, 2015, 11:15:14 pm by Redcat »
Voltcraft 630-2,Tek 2215A,Tek 475,really handy DIY microcontroller component tester (R/C/D/Q...), ZD-915, ZD-931,Voltcraft 1062D - of course hacked :)
 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11631
  • Country: my
  • reassessing directives...
Re: Control 3 transistor switches from two µCU pins
« Reply #11 on: September 02, 2015, 02:49:17 am »
output at collectors?
X = (!A | !B)
Y = !A
Z = !B

Code: [Select]
A  0  0  1  1
B  0  1  0  1
X  1  1  1  0
Y  1  1  0  0
Z  1  0  1  0
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Offline PSR B1257

  • Frequent Contributor
  • **
  • Posts: 330
  • Country: de
Re: Control 3 transistor switches from two µCU pins
« Reply #12 on: September 02, 2015, 04:24:28 am »
Quote
Well, you could mask this condition by software
:palm:

Quote
They will PWM the attached
Than you can't mask this condition in software, since you are inevitable toggling between different states if you are applying a PWM signal to the inputs.
In theory, there is no difference between theory and practice. But, in practice, there is.
 

Offline alexanderbrevigTopic starter

  • Frequent Contributor
  • **
  • Posts: 700
  • Country: no
  • Musician, developer and EE hobbyist
    • alexanderbrevig.com
Re: Control 3 transistor switches from two µCU pins
« Reply #13 on: September 02, 2015, 06:46:11 am »
Thanks all.

You can download the simulator (google) and try yourself.

Have fun, Tom

Thanks! I will definitely do that. In addition to try it on the breadboard :)

However I have changed my thinking and will try to go a more tried and true path.


That is 74HC164 serial-in/parallel-out shift register into a 74HC07 buffer which drives an IRF511 N-channel PFET to turn on and off LED loads.
With my 12V supply I'll drive strings of max three (Vf = 3v, Iled = 60mA) in 'parallel' and calculate the resistor for n LEDs with R = (12 - (n * Vf)) / (n * 60mA). Then figure out worst case current draw and design the power supply with headroom.

When the project is a bit further along I'll post it in projects section.

Thanks again, I will do some  :-/O

I was mistaken when I said I would PWM it. I won't. It will change states at most ever five minutes  :-[
 

Offline PSR B1257

  • Frequent Contributor
  • **
  • Posts: 330
  • Country: de
Re: Control 3 transistor switches from two µCU pins
« Reply #14 on: September 02, 2015, 02:45:27 pm »
Quote
drives an IRF511 N-channel
This MOSFET is a heap of crap, even for this (presumably, since 'n' remains unknown) low currents. Why are you biasing it to stay on?
A way better choice is a logic-level MOSFET, like IRF3708. Do not bias this one from the 12V rail, but add a 1k gate resistor.

Quote
in 'parallel' and calculate the resistor for n LEDs with R = (12 - (n * Vf)) / (n * 60mA)
No, each string requires a resistor.

Quote
It will change states at most ever five minutes
O.k. Then you need no additional gate driver, just the gate resistor mentioned above.
In theory, there is no difference between theory and practice. But, in practice, there is.
 

Offline alexanderbrevigTopic starter

  • Frequent Contributor
  • **
  • Posts: 700
  • Country: no
  • Musician, developer and EE hobbyist
    • alexanderbrevig.com
Re: Control 3 transistor switches from two µCU pins
« Reply #15 on: September 02, 2015, 03:15:24 pm »
After some time to think I've scrapped the DIY approach. I'll use a constant current LED driver IC with PWM.

Thanks for the input (as for the each string needs a resistor then I completely agree, it's what I implied). Lesson learned: Use ICs where applicable for projects and keep 'experiments' to the breadboard ;)
 

Offline alexanderbrevigTopic starter

  • Frequent Contributor
  • **
  • Posts: 700
  • Country: no
  • Musician, developer and EE hobbyist
    • alexanderbrevig.com
Re: Control 3 transistor switches from two µCU pins
« Reply #16 on: September 03, 2015, 10:51:14 am »
I'll let this thread die now but I just wanted to link to this http://alexanderbrevig.github.io/projects/2015/09/03/Norwegian-word-clock-project/ which is a log of the steps I went through to get from the discrete transistor hackery to a string of APA102C RGB LEDs  :scared:

Still on a custom PCB with a custom aluminum front plate though : )
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf