• AVR Freaks

transistor of choice for mulitiplexing?

Page: 123 > Showing page 1 of 3
Author
bonedoc
Super Member
  • Total Posts : 1019
  • Reward points : 0
  • Joined: 2009/11/14 21:58:31
  • Location: 0
  • Status: offline
2010/01/02 17:54:32 (permalink)
0

transistor of choice for mulitiplexing?

About all we have here is radioshack. Can someone recommend a good transistor for this? Nobody there knows anything but cell phone plans. I have some multi-segment LEDs that I wanted to use to switch the ground to each digit by supplying 5v to close the ground and allow flow. I tried a 2n3904 npn resistor, but that doesnt seem to work. Should I use PNP or NPN?
#1

41 Replies Related Threads

    P Lameijn
    Super Member
    • Total Posts : 1984
    • Reward points : 0
    • Joined: 2004/01/22 18:30:23
    • Location: The Netherlands
    • Status: offline
    RE: transistor of choice for mulitiplexing? 2010/01/02 18:28:37 (permalink)
    0
    How much current?

    Regards,
    Peter
    #2
    bonedoc
    Super Member
    • Total Posts : 1019
    • Reward points : 0
    • Joined: 2009/11/14 21:58:31
    • Location: 0
    • Status: offline
    RE: transistor of choice for mulitiplexing? 2010/01/02 18:38:49 (permalink)
    0
    Actually 9 basic LEDs will share the ground to the transistor. Sorry don't have the led sheet in front of me.
    #3
    gogo2520
    Senior Member
    • Total Posts : 140
    • Reward points : 0
    • Joined: 2008/11/06 20:29:41
    • Location: 0
    • Status: offline
    RE: transistor of choice for mulitiplexing? 2010/01/02 19:50:59 (permalink)
    0
    Hello

    Radio Shack carries The 2N3904, that is a NPN transistor that can handle 200 ma, you have them and should work with what you are doing. Maybe your going about it the wrong way. can you post a schematic. How are you hooking up the LEDS so they all go to ground at once? Are you using current limiting resisters too?  If 200 ma is not enough another general purpose NPN transistor is a 2N2222A, that can handle 800 ma and Radio Shack should have them too.
                                    gogo


    Here is a site that explains current limiting   http://www.quickar.com/ledbasics.htm

    And here is one that shows you how to use transistors with LEDS http://www.winpicprog.co.uk/pic_tutorial_extras.htm
    post edited by gogo2520 - 2010/01/02 20:11:32
    #4
    bonedoc
    Super Member
    • Total Posts : 1019
    • Reward points : 0
    • Joined: 2009/11/14 21:58:31
    • Location: 0
    • Status: offline
    RE: transistor of choice for mulitiplexing? 2010/01/02 20:15:27 (permalink)
    0
    Cool. I have both of those type. Basically, I have:

    power->resistor->led->left transistor leg (looking at flat side). The right leg goes to ground. The middle leg is sent the 5v signal. Sorry, I don't have it in front of me. I'll be home in a bit.
    #5
    dchisholm
    Super Member
    • Total Posts : 3805
    • Reward points : 0
    • Joined: 2003/12/14 15:30:12
    • Location: St Louis Mo
    • Status: offline
    RE: transistor of choice for mulitiplexing? 2010/01/02 20:21:24 (permalink)
    0
    Well, I tried to answer your question but this Forum software won't let me post it, so here its my response as an attachment.

    Dale

    p.s. - The forum error I keep getting is:
    An error has occured on the page you were visiting. You may have received this error if you are attempting to submit a form and have used potentially harmful characters in your entries. Please check your entries and remove any special characters that you may have used. You may also click here to return to Microchip.com
    #6
    dchisholm
    Super Member
    • Total Posts : 3805
    • Reward points : 0
    • Joined: 2003/12/14 15:30:12
    • Location: St Louis Mo
    • Status: offline
    RE: transistor of choice for mulitiplexing? 2010/01/02 20:47:47 (permalink)
    0
    ORIGINAL: bonedoc
    . . .  Should I use PNP or NPN?
    By their nature, NPN (and N-channel MOSFET's) are most easily used on the ground side of a load - such as a 7-segment display with a "common cathode" configuration.  The base (or gate) is driven HI to turn the switching transistor ON.

    PNP (and P-channel MOSFET's) are generally used on the supply side of a load - such as a 7-segment LED with a "common anode" configuration.  If the load is driven from the same potential (e.g., +5V) as the microcontroller's supply, an I/O pin can be interfaced to the transistor with a few passive components and will go LO to turn the device ON.

    In either case, things like current-limiting resistors and noise filtering capacitors may be required between the I/O pin and the gate or base of the switching device.

    Dale
    #7
    dchisholm
    Super Member
    • Total Posts : 3805
    • Reward points : 0
    • Joined: 2003/12/14 15:30:12
    • Location: St Louis Mo
    • Status: offline
    RE: transistor of choice for mulitiplexing? 2010/01/02 20:56:59 (permalink)
    0
    ORIGINAL: bonedoc

    Cool. I have both of those type. Basically, I have:

    power->resistor->led->left transistor leg . . .
    The terminology for BJT's is "collector", "base" and "emitter".  For an NPN transistor the load (LED plus series resistor) usually connects to the collector, the emitter goes to ground, and the base connects to the PIC I/O pin through a series resistor, typically in the 1K ohm to 10K ohm range.  (Without the resistor in the base circuit you run a risk of damaging the transistor and/or the PIC.)

    Dale
    #8
    dchisholm
    Super Member
    • Total Posts : 3805
    • Reward points : 0
    • Joined: 2003/12/14 15:30:12
    • Location: St Louis Mo
    • Status: offline
    RE: transistor of choice for mulitiplexing? 2010/01/02 21:06:26 (permalink)
    0
    ORIGINAL: bonedoc

    About all we have here is radioshack . . .  Nobody there knows anything but cell phone plans. . . .
    That's a real problem.  Over the last 20 years, sources for electronic parts have all but vanished in many areas - and I don't mean just places like Donut Center, Texas (Motto: "What a hole!").  Where are you located?  A lot of us "pad" our orders to Digikey and Mouser with common parts we expect to use sooner or later.  Here in St louis we still have two surplus/salvage dealers that stock common (and some uncommon) parts.

    Dale
    #9
    bonedoc
    Super Member
    • Total Posts : 1019
    • Reward points : 0
    • Joined: 2009/11/14 21:58:31
    • Location: 0
    • Status: offline
    RE: transistor of choice for mulitiplexing? 2010/01/02 21:28:30 (permalink)
    0
    Thanks for the help Dale. Here is a pic. I thought I had it right, but it is shorting the board out when I apply 5v to the base. I even tried to flip the transistor around but get the same thing. The top green wire goes to the resistor and led and then to the transistor. The brown hooks the transistor to ground. The other green has 5v to apply to the base to turn open it. Anyone see anything wrong?

    http://img218.imageshack.us/i/26688577.jpg/
    #10
    bonedoc
    Super Member
    • Total Posts : 1019
    • Reward points : 0
    • Joined: 2009/11/14 21:58:31
    • Location: 0
    • Status: offline
    RE: transistor of choice for mulitiplexing? 2010/01/02 21:40:40 (permalink)
    0
    Oh...I added a resistor between the base and the 5v signal. That was the problem!
    post edited by bonedoc - 2010/01/02 22:15:04
    #11
    P Lameijn
    Super Member
    • Total Posts : 1984
    • Reward points : 0
    • Joined: 2004/01/22 18:30:23
    • Location: The Netherlands
    • Status: offline
    RE: transistor of choice for mulitiplexing? 2010/01/03 05:49:00 (permalink)
    0
    Some basic knowledge is needed if you want to work with electronics. You should know you cannot put 5v on a transistor base... [8|]

    Regards,
    Peter
    #12
    Ian.M
    Super Member
    • Total Posts : 13274
    • Reward points : 0
    • Joined: 2009/07/23 07:02:40
    • Location: UK
    • Status: offline
    RE: transistor of choice for mulitiplexing? 2010/01/03 07:12:12 (permalink)
    0
    A more subtle issue is the lack of a pull-down resistor on the base.

    The problem is that the PIC output does not actually go 'rail to rail' so even when it  is logic 0 there is a small voltage there.    If  the PIC is sinking significant current on other outputs, it is possible for the voltage on an output at logic 0 to rise high enough to start turning the transitor on causing the LED to start to glow.

    I would typically use a pull-down resistor of a similar value to the base resistor to be certain the transistor will be off when it needs to be.  It is possible to buy so-called 'digital transistors' that have the series base resistor and the shunt base - emitter resistor built-in.

    Calculation of the correct resistor values is not as simple as it initially appears.  The PIC is limited in it's ability to source or sink current while maintaining its output voltage.  Also for slow* switching applications it is desirable to ensure the transistor always saturates.  This involves determining the minimum base current from the maximum collector current divided by the minimum gain. Unfortunately the gain we are interested in is HFE not hfe, and it is dependent on both the collecter current, voltage  and temperature and is likely to be significantly lower that the minimum hfe given by the data sheet.  If you are lucky, there is a large signal Ic vs Ib curve in the data sheet, but this is a typical curve usually at 25 deg C and will need adjusting downwards. The question is, By how much?

    Often the only data you have to go on is the ratio of  the typical and minimum hfe and all you can do is scale it by the same ratio.   Once you have an idea of the minimum Ib, and have decided how much current you can afford from the PIC, it becomes a relatively simple optimisation problem in circuit analysis which can be approximated by treating the transistor base as an ideal diode in series with a 0.7V source and taking the Thévenin equivalent of the PIC output treated as a voltage source and the two resistors.  The objective is to choose preferred values of resistors that deliver more than the minimum Ib under worst case conditions (mimium supply, resistors at the limits of their tolerance band) for logic 1, while minimising the base voltage for logic 0.

    Its all a bit much for a simple LED but once you get into multiplexed multi-digit 7 seg displays and you are trying to get the same brightness for digits displaying '1' as digits displaying '8' and keeping the same brightness with varying numbers of digits illuminated, it becomes really important.

    *Saturation and slow switching:  Slow in this context can be taken as anything under several KHz.  Getting a transistor back out of saturation is not a fast process and if you are interfacing to fast logic or driving a high speed  serial comms line, it is probably not a good idea to drive the transistor into saturation.

    HTH

    Ian
    #13
    bonedoc
    Super Member
    • Total Posts : 1019
    • Reward points : 0
    • Joined: 2009/11/14 21:58:31
    • Location: 0
    • Status: offline
    RE: transistor of choice for mulitiplexing? 2010/01/03 08:40:58 (permalink)
    0
    Would it be bad to have mosfets or transistors to power the leds? If so, do I need one for each power line, or is there a way to share a larger power yet control them independently?
    #14
    gogo2520
    Senior Member
    • Total Posts : 140
    • Reward points : 0
    • Joined: 2008/11/06 20:29:41
    • Location: 0
    • Status: offline
    RE: transistor of choice for mulitiplexing? 2010/01/03 16:26:08 (permalink)
    0
    If your just trying to light a LED you don't need to use a transistor at all just use a current limiting resister between the LED and the Pic. 
    #15
    tunelabguy
    Super Member
    • Total Posts : 1713
    • Reward points : 0
    • Joined: 2005/04/03 08:30:19
    • Location: Hopkins, MN USA
    • Status: offline
    RE: transistor of choice for mulitiplexing? 2010/01/03 19:43:16 (permalink)
    0

    ORIGINAL: Ian.M

    A more subtle issue is the lack of a pull-down resistor on the base.

    The problem is that the PIC output does not actually go 'rail to rail' so even when it  is logic 0 there is a small voltage there.    If  the PIC is sinking significant current on other outputs, it is possible for the voltage on an output at logic 0 to rise high enough to start turning the transitor on causing the LED to start to glow.


    Yes, but how is the PIC going to be sinking significant current in this application, where the PIC is just driving the base of a transistor?

    Robert Scott
    Ypsilanti, Michigan
    #16
    kl27x
    Super Member
    • Total Posts : 254
    • Reward points : 0
    • Joined: 2006/09/20 13:51:48
    • Location: 0
    • Status: offline
    RE: transistor of choice for mulitiplexing? 2010/01/03 20:20:50 (permalink)
    0
    I wanted to use to switch the ground to each digit by supplying 5v to close the ground and allow flow.

    That suggests you want an NPN transistor.

    But most 7-segment LEDs are common ANODE. Thus you better check your components. For a common anode display, you need to switch the power rail, not the ground rail, to switch each digit. 2n3906, perhaps?
    post edited by kl27x - 2010/01/03 20:52:16
    #17
    kl27x
    Super Member
    • Total Posts : 254
    • Reward points : 0
    • Joined: 2006/09/20 13:51:48
    • Location: 0
    • Status: offline
    RE: transistor of choice for mulitiplexing? 2010/01/03 20:33:05 (permalink)
    0
    Would it be bad to have mosfets or transistors to power the leds? If so, do I need one for each power line, or is there a way to share a larger power yet control them independently?


    You probably won't need a transistor to power each individual segment. And, no, you can't really do anything fancy to pare down from 7 output pins, one per segment, that I'm aware of. They are all connected at the other end, so you can't charliplex them. If you're trying to pare down on components, maybe you would like to use a darlington array. It's not that a darlington transistor is necessary at this level of current, but darlington's are the only transistor types commonly found in septal and octal packages.
    post edited by kl27x - 2010/01/03 20:39:31
    #18
    gogo2520
    Senior Member
    • Total Posts : 140
    • Reward points : 0
    • Joined: 2008/11/06 20:29:41
    • Location: 0
    • Status: offline
    RE: transistor of choice for mulitiplexing? 2010/01/03 22:05:53 (permalink)
    0
    I think if you went to Nigels tutorials you would learn more about this . here is his 7 segment board http://www.winpicprog.co.uk/pic_tutorial_7seg_board.htm
       gogo
    #19
    Ian.M
    Super Member
    • Total Posts : 13274
    • Reward points : 0
    • Joined: 2009/07/23 07:02:40
    • Location: UK
    • Status: offline
    RE: transistor of choice for mulitiplexing? 2010/01/03 22:48:45 (permalink)
    0
    @Robert:  Did you miss I said "sinking significant current on other outputs"?
    As its quite likely there are driver transistors on both the abode side and cathode side of the LED matrix, and getting enough base drive to get enough collector current for daylight visibility of a multiplexed display is a real problem, if you able to avoid using Darlingtons, it is virtually certain that you will be sinking significant current on another output.

    Also the approximation I gave for modeling the base current is a drastic over-simplification.  Google 'Ebers Moll model' for a better understanding of the real issue: the output LOW of a PIC isn't low enough to guarentee enough discrimination between ON and OFF for a high gain transistor. For each order of magmitude improvement you need you have to get the base approximately another 60 mV lower.  For simplicity I am talking in terms of NPN transistors. Its equally applicable the 'other way up' with PNP transistors.

    As in a large multiplexed array the ratio between off time and on time can be significantly greater than 10:1, the current during the short ON pulse has to be as high as you can push it and LEDS glow noticably down to really tiny currents, everything is against you if you dont want LEDs that are supposed to be off to noticably flicker as other ones are switched.

    @gogo:  That design is fair enough for a tutorial to get the basics accross quickly. but its rather over-simplified.  In fact, its guarenteed to make the first digit glow dimly when the second is lit as the second transistor has nowhere to get its base current except through the LEDs of the first digit.

    @kl27x: I second your reccomendation of a Darklington array.  ULN2803 is a nice NPN one: easily available, Octal which is more convenent than Septal for many applications, good for better  than 1/3 A per output pin (though thermal considerations limit it to about 1A total for continuous operation) AND it includes all the resistors needed to set its base drive INTERNALLY so can be connected directly to the PIC.  Every PIC hacker should stock a few  . . . 

    PNP arrays are somewhat rarer (and often include level shifters as well) and as one rarely needs to drive more than 4 digits (common anode), it usually is easy enough to use discrete PNP transistors.
    #20
    Page: 123 > Showing page 1 of 3
    Jump to:
    © 2021 APG vNext Commercial Version 4.5