Pages: [1] 2   Go Down
Author Topic: Problem with simple transistor circuit  (Read 3408 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 82
Uno momento
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Please see the attached diagram, which shows the circuit twice but the second time a switch has been toggled.

This is a much simplified version of part of my LED multiplexing circuit.  In the real world circuit, I cannot seem to have just one LED (on it's own) lit up, I get a bunch of adjacent ones all glowing together.  Some bright, some dim.  I checked all my connections which seem to look sensible so I have discounted short curcuits in the system.

I went back to my circuit simulator to try to reproduce this problem and it does seem that certain high/low combinations of the top 3 switches can cause current to pass through to the LED.

I've clearly got a flaw in my design here, but I'm not sure about how to go about fixing it.  Am I overloading the transistor somehow?

The real world circuit uses 5 arduino pins to source and sink 5v.  To be totally accurate... the real world circuit has 192 such LEDs, driven by 3 separate multiplexing curcuits.
This system needs 15 IO pins from the arduino, all pins are set to outputs at the start of the program and I want to use various combinations (5 nCr 15) of these pins to select an LED to light up.

My multiplexing boards use common bases and common collectors in order to address the particular LED I want.  It seems that current is leaking through by finding phantom circuits that I never expected could exist.




Is this making any sense?  I'm not sure I've explained properly, but anyway please let me know your opinions, I'd appreciate a bit of a helping hand on this smiley



Adam.


* TransistorProblem.png (41.98 KB, 1399x754 - viewed 87 times.)
Logged

0
Offline Offline
Faraday Member
**
Karma: 16
Posts: 2855
ruggedcircuits.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You have current flowing from base-to-emitter in the second transistor from the top. Remember that the base-to-emitter junction of an NPN transistor is essentially a diode. Try redrawing the circuit with the top transistor removed (since it's off) and the second transistor from the top replaced with a diode (from base-to-emitter). That will show you why current is flowing through the LED.

--
The Aussie Shield: breakout all 28 pins to quick-connect terminals
Logged

0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 82
Uno momento
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So if the collector is tied to GND, then the base voltage always flows out of the emitter?

Now I'm confused about how multiplexing is supposed to work.  I was under the impression that you could use common bases horizontally and common collectors vertically on a grid of transistors and thus use an x,y coordinate to cause the emitter on the relevant transistor to supply the collector current to one of many LEDs.

Do you think there is any way I can get around this without tearing up and starting again?

Logged

0
Offline Offline
Faraday Member
**
Karma: 16
Posts: 2855
ruggedcircuits.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
So if the collector is tied to GND, then the base voltage always flows out of the emitter?

Errr...not sure how to answer that. Voltage doesn't flow, current flows. Current will flow from base to emitter if the base voltage is 0.7V (or so) higher than the emitter voltage.

Quote
Now I'm confused about how multiplexing is supposed to work.  I was under the impression that you could use common bases horizontally and common collectors vertically on a grid of transistors and thus use an x,y coordinate to cause the emitter on the relevant transistor to supply the collector current to one of many LEDs.

I doubt that's possible. Do you have a link to where you saw this idea proposed?

Quote
Do you think there is any way I can get around this without tearing up and starting again?

Personally, no...but I'd like to be proven wrong!

--
The Rugged Motor Driver: two H-bridges, more power than an L298, fully protected
Logged

0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 82
Uno momento
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I saw this concept explained in a video...
http://www.youtube.com/user/kdarrah1234#p/search/8/-1UPPHjR0vk

This guy seemed (to me, at the time) to know what he's talking about but he never actually demonstrates this physically in action, but he does use multiplexing in some of his other videos.  The principle seemed plausible to my novice ears.  I even had the same components that he described, 1k resistors and 2n3904 transistors.

How about if I use much higher ohm value resistors on the transistor bases, to ensure the base voltage never goes reaches 0.7v?  Would that still allow the transistor to act as a switch?

I feel so stupid  smiley-red
Logged

0
Offline Offline
Faraday Member
**
Karma: 16
Posts: 2855
ruggedcircuits.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Ah, OK, I see his trick. He is sourcing/sinking current directly with the Arduino and multiplexing the anode sources and cathode sinks in a 2x4 array (for 8 drivers and 8 sinks).

But that's not the circuit you're using smiley  I'm guessing you're trying to "uber-multiplex" the whole thing by putting his 8x8 array of LED's into greater arrays and just generalizing his solution with top-side NPN transistors but that's not going to work (as you noticed smiley

You will have more luck adding additional NPN transistors at the bottom and switching them between the 8x8 grids.

--
The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, light sensor, potentiometers, pushbuttons
Logged

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 548
Posts: 27393
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Why do you have 2 transistors controlling the anode pin? What is your thinking there?
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Norway
Offline Offline
Sr. Member
****
Karma: 4
Posts: 423
microscopic quantum convulsions of space-time
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I agree with RuggedCirctuits above. Plus I would think even the partial circuit diagrams are partial themselves? Is it supposed to be LED's between the transistors as well? (Which would answer CrossRoads question above, but it wouldn't work like that either).

Quote
Now I'm confused about how multiplexing is supposed to work.  I was under the impression that you could use common bases horizontally and common collectors vertically on a grid of transistors and thus use an x,y coordinate to cause the emitter on the relevant transistor to supply the collector current to one of many LEDs.

Actually I think this is possible. Just don't connect all LED's in series down the columns, as I suspect you have done.

I made a quick-ish schematics for a 4 by 4 transistor LED matrix in the attached file. Its like in the very beginning of the video you linked. Not separated in another transistor grid, which was a trick he used to save on output pins.

NOTE: Not actually tested this. Seeing as you already have a few NPN transistors though, you might use something similar for driving your LEDs. As for the resistors the base resistors are not that critical (1k would do, I think), but the top (column) resistors are. Also, the left-most transistors should handle all the current for a hole row in case all LEDs are lit. 4 LEDs in this case. But if using 8 by 8, 8 LEDs times whatever current, say 20 mA each, equal 160 mA. As peak current is 200mA for 2N3904, this should work, seeing as each row is also on for 1/8th of a time also (do not use peak current continuously!)

For the top resistors, in series with the LED (only one at a time, because only one row is active at a time), the value depends on your LEDs. If they have a forward voltage drop of 2 volts, subtract this from Vcc (5V, if using that), and also subtrackt the 2N3904 saturation voltage (stated as 0.2- 0.3 V). Lets say 2.7 volts are left over the resistor.

Ohms law: R = volts / current, 2.7V / 20mA = 135 ohms. the next higher resistor is 150 ohms I think, which you could use.

As for transistors and how they work, at least bipolar transistors (not FET), here is a nice page about that: http://www.kpsec.freeuk.com/trancirc.htm


Also I would like to say that the method used in the video you linked to seems like an unusual way to multiplex an 8 by 8 array. And only one LED can be lit at a time. Kind of like charlieplexing, but more wasteful on pins. Plus, the Arduino is the source and sink despite using transistors in that case, but as long as just one LED is lit at a time it should be OK. The transistors in this case is just used as a sort of a triple AND gate, to select column transistor, row transistor and these again select the row/column intersection as usual. And as he explains in the video, the transistors themselves are in another two independent 4 by 2 grids. It works (as far as I can see, if wired correctly that is smiley-wink ) but cumbersome imho.


Quote
The real world circuit uses 5 arduino pins to source and sink 5v.

Unless I'm missing something here, the video you linked to uses 6 Arduino pins for each set of transistors (the row or column transistors), then 6 more pins for the other set of transistors (IE two sets of 4 by 2 transistor grids). Even charlieplexing can only select one of 20 LED's with 5 pins.

(5 nCr 15 gives me Ma error. But I don't think that is applicable here, nor 15 nCr 5. For three sets of a 64 LED matrix, one LED at a time in each, there would be simply 64^3 possibilites?)

Another similar approach also only lighting one LED at a time could be (as an example) using two 3-to-8 line decoder/multiplexers, like 74HC138 / 74HC238. Then only 6 pins from the Arduino is needed for an 8 by 8 grid of LED's. For three of these you would need 18 pins.


But the more conventional LED grid multiplexing way is to select one row at a time, and setting all LEDs on one row (or vice versa), thus lighting up one row (or column) at a time. There are many ways to do this, one way is to use the same 3-to-8 multiplexer mentioned for the rows, and then another 8 outputs for the columns. This requires 11 pins for a 8 by 8 grid.

Or, control all grid/columns directly, requiring 16 pins. The one example I found in the Arduino playground was not really good (lacking resistors and also driving everything from the Arduino, destroying the outputs if wired like this!), but the principle was there.

Here is another similar one (basically first hit on google), except using a counter for the rows thus saving even more pins for the rows: http://www.best-microcontroller-projects.com/led-dot-matrix-display.html


Btw, which circuit simulation program do you use?


* transistor LED matrix.png (37.11 KB, 711x600 - viewed 73 times.)
Logged

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 548
Posts: 27393
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Nice work raron, that looks great.

Another option is to get a MAX6953,  can control four 5x7 matrices. They have similar parts for 8x8 matrices.

The shift registers for the rows & columns should also work nicely.

Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 82
Uno momento
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The long explanation that I was hoping to avoid...


Ok here's the complete and unabridged circuit in all it's broken glory.  It's a big image, be warned smiley http://farm6.static.flickr.com/5043/5270847449_cfd2ff298e_o.png

The display is a 24x8 grid made of individual discrete LEDs.  Each LED is ranked horizontally with common cathodes and vertically with common anodes.

The 8 cathodes are sinked (sunk?) by 8 transistors in a 2x4 multiplex arrangement, driven by 6 arduino pins.

The 24 anodes are driven by 2 stages of multiplexing circuits... closest to the LEDs is a 6x4 transistor multiplex, 4 pins direct to arduino and 6 pins from the third multiplex board which is a 2x3 affair.

Overall I'm using 15 pins (5 at any given time) to power a single LED for a few microseconds before selecting a diifferent LED by changing the arduino pin states.

I certainly understand that using fancy ICs to do this would be more sensible but that's not the goal I'm aiming for.  I just wanted to do it all using simple discrete components.

So, to recap, when I turn on the arduino and run it's test program which *should theoretically* illuminate the top-left LED on the grid for about 100 microseconds or so, I actually get 6 LEDs flash at various intensities.  Looks like the current is barging through some of the bases in the anode multiplexing and bleeding into the wrong columns.  On the bright side the top left LED does indeed light up brightly as it should do.

Does anyone have an opinion on my idea of using higher rated resistors on the transistor bases, would that fix the problem?  My aim was to use these transistors as switches (indeed as AND gates as mentioned above).  If 1000 ohms isn't enough to stop current passing through the transistors when the collector is grounded, then what resistor should I use?  I've had a good read of the 2n3904 datasheet but I'm not sure what I'm looking for.

I get the distinct impression (better late than never) that I've bitten off more than I can chew.

Photos of the potentially doomed project so far...
http://www.flickr.com/photos/adamneilward/sets/72157625665416670/detail/

I

Logged

0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 82
Uno momento
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Raron said: "Btw, which circuit simulation program do you use?"

It's a cheap 'n' cheerful thing called "Livewire" which is nice for a beginner like me, I guess I didn't interpret the simulation properly because now I rerun the simulation looking for this very problem I can see it clear as day.  It shows only 1 LED lit up which I what I wanted BUT it also shows that a smaller amount of current is flowing through the exact same set of LEDs that I'm having trouble with.  Here's to learning the hard way eh?

Livewire is now obsolete, you can get it free on their website, but it's a nice package, if simple.  It links up with it's sister application which converts your curcuit simulation into a PCB layout ready for etching.  This is how I made all 3 of my mux boards.

http://www.new-wave-concepts.com/pr/livewire.html
Logged

Norway
Offline Offline
Sr. Member
****
Karma: 4
Posts: 423
microscopic quantum convulsions of space-time
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

CrossRoads: Thanks for the feedback!

wossname:
Thanks for the tip about livewire. I usually use Ubuntu, but I think I will give it a try.

Quote
The long explanation that I was hoping to avoid...
But it made things much clearer smiley Also, nicely drawn schematics there!

Quote
Does anyone have an opinion on my idea of using higher rated resistors on the transistor bases, would that fix the problem?
I think it would help somewhat, but then the question is if it helps enough before the transistor stops functioning as a switch?

I -think- I see the problem. Possible solution (no guarantees though, maybe run it through your circuit simulator beforehand):

Simply connect ordinary diodes in anti-parallell to the anode transistors collector-emitter (IE arrow from emitter to collector). This requires that the common collectors are at GND (or close enough) level when the transistors are off, and since you also use another level of transistor grid, you would need to do this for the "primary"  (first) level of transistors also. Or, since these only saves one arduino pin, maybe omit these altogether, unless you really need that pin.

Then hoping two diodes in series will stop all LEDs now effectively in parallell to these, from dimly lighting up. It requires that the LED forward voltage is higher than two diodes forward voltage combined (in series). Use small signal diodes like 1N4148 or similar. If your LEDs have a very low forward voltage drop (under two times 0.7V, 1.4V, but I think that is unlikely), maybe use germanium diodes (which have about 0.3V drop each).

In fact when I think about it, maybe you can get away with just having diodes in anti-parallel with the primary transistor-grid's transistors, thus getting away with 6 additional diodes.

Reason being there is also a diode connection from base to collector, which would come in effect for the transistors that are off, if the collector is at a more negative potential than the base. Except that since you use two levels of transistor multiplexing, the "collector lines" from this primary transistor grid, is shut off when it is off, forcing a base current to go via the LEDs and light them dimly. At least thats what I think is happening.

Also I'm assuming here that the transistors get a high or low voltage as indicated by your switches (no floating inputs).

Hope this made any sense.
« Last Edit: February 06, 2011, 06:33:40 am by raron » Logged

0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 82
Uno momento
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you do have a look at livewire then you may be interested in seeing my flawed design in action...

* LEDMux.lvw (131.96 KB - downloaded 14 times.)
Logged

0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 82
Uno momento
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Progress... of a kind...

I've re-run my computer simulation but this time with the 2x3 mux unit removed and replaced by 6 high/low switches (eg I need 1 more pin than before).  The problem seems to have vanished.  Only one LED shows any kind of current flow and that is the one is lit up brightly!

Encouraging, certainly but it does mean I need a total of 16 DIO pins to drive this lot.  I'll try it in hardware shortly to see what happens.

In any case I'm not too worried about using 16 pins because the plan is to build an arduino-->display interface board, which will use a pair if 8-bit SIPO shift registers to drive the display and thus using only 3 arduino pins!  I'm assuming that a SR can sink and source current on all it's output pins... I'll have to look into that before I shoot myself in the foot AGAIN! smiley-wink

I used to think programming was hard, but electronics is like doing 200 simultaneous equations in your head!  I need more brain cells. smiley-grin  It's fun to learn this stuff though.
« Last Edit: February 06, 2011, 09:30:07 am by wossname » Logged

0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 82
Uno momento
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

IT LIVES!!!!

[start unhealthy denial/rationalisation]
Ok so I took out the high level 2x3 transistor mux unit and rewired everything else and reworked the firmware and now it lets me select exactly one LED anywhere on the panel!  I'm overjoyed!  This is the culmination of about 2 months of casual headscratching to get this far.

I still don't understand the reason why the 2x3 unit was causing this problem.  Could it be that the 2x3 unit was splitting the current between too few bases, thus each base geting more current than the transistor could take before breaking down?  I'm not even sure that's a technically sensible thought or not but anyway.  I can live with using 16 pins smiley
[end unhealthy denial/rationalisation]

I'm happy to leave that 2x3board out of my design, but I'd still be interested if anyone could diagnose the problem, maybe there's a way I could re-introduce it into the system without the problem recurring.
« Last Edit: February 06, 2011, 12:00:43 pm by wossname » Logged

Pages: [1] 2   Go Up
Jump to: