Maker Pro
Maker Pro

Simple transistor circuit problem

rasklangus

May 19, 2013
18
Joined
May 19, 2013
Messages
18
That doesn't sound as expensive as I thought Bob, however the double sided boards will add £100/m2 plus extra for the double sided assembly. I would be totally out of my depth with a microcontroller project (as you can see I am struggling with a 2 transistor latch :)

The components are all sourced from Farnell and prices are accurate (I was surprised at the prices too)... 2.3p each for 3000+ of npn darlington sot23 package, 0.7p each for 3000+ of pnp transistor, 10uf ceramic caps for 1p when I buy 1000+, resistors are 0.1p each and the LEDs are from Brightek and are 6p each for 1000+

The switches are a resistive contact triggering a darlington transistor.
 

rasklangus

May 19, 2013
18
Joined
May 19, 2013
Messages
18
So Bob, you obviously really know what your doing if your talking about knocking something together with 64 pin microcontrollers ;) Can I direct you back to my attempt to connect all my capacitors through one potentiometer and have them all able to charge and discharge independently. I thought putting a diode in each line to the pot would work but it appears not. Its probably obviously a stupid thing to do in your eyes but can you explain why it doesn't work or even offer any other simple solution (without adding any, or many, more components)?
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
Hi rasklangus. It seems you're serious about this... I have several comments and questions...

1. Have you worked out how much power all those LEDs are going to consume if they're all ON at maximum current? And how you're going to provide that much power? Power supplies aren't cheap either; you need to include them in your budget.

2. Are you confident that Chris's circuit will do what you want? I've studied it and I don't understand how it's supposed to work. Chris, could you write up a brief circuit description?

3. From the point of view of reliability, practicality, cost, and almost every other consideration, a microcontroller-based solution is the best idea by far for a project of that size. As BobK has suggested, you should build the project from square modules, with one microcontroller per module, and, say, 7x7 LEDs. It might work out that a different number of LEDs, and perhaps even an oblong shape, would be better.

4. Are you planning to use a single-sided PCB?

5. I'm interested in how you are going to do the human-to-electronics interface. Are you planning on using very sensitive pushbuttons? Or touch contacts? Are you aware of electrostatic discharge and the problems it can cause?

6. You're right that the more columns that are multiplexed, the lower the percentage of time that each LED is ON for. This is dealt with by increasing the ON current, but this can only be done up to a certain point without damaging the LEDs. But the flickering that you describe should not be a problem, unless there are bugs in the driving code.

7. The one effect you will notice with multiplexed LEDs, that you won't notice with non-multiplexed LEDs, is that when you turn or move your head near them, you will see multiple images of them. To see what I mean, get a digital alarm clock that uses an LED display, and turn it on in a dark room. Hold it in your hand and shake it around, or put it stationary and shake your head quickly. You should see lots of little images of the digits.

You will get this effect if you multiplex the LEDs. It is especially noticeable in a dark room. It can be minimised by using a high multiplex frequency (digital clocks typically multiplex at mains frequency). You will also see this effect if you use PWM to vary the LED brightness, which is the normal way of varying LED brightness when driving them from a microcontroller. It's possible to convert a PWM signal from a microcontroller into a steady current to drive the LED but this requires components, of course.

8. Re controlling the independent discharge of multiple capacitors from a single input, you can do this with a current sink for each capacitor (look on Wikipedia for current sink) by driving the bases of all the transistors from a common rail. But I'm more concerned about the design of the circuit. If you're planning to make 60,000 of them, I think you need to do a lot of testing and perhaps optimisation first! My first concern is making sure that the circuit does exactly what you want, which is why I would like to see an explanation of how it works as a first step.

9. Another possibility created by the use of microcontrollers would be controlling the maximum power consumption. Most of the time, I imagine, only a small proportion of the LEDs will be ON, and they could be operated at full brightness without exceeding a modest power requirement. For cases where more LEDs are ON simultaneously, you could either use more power supplies (or more powerful ones), or scale down the total brightness to keep the power consumption within the necessary limit. This is probably easier to do with microcontrollers than with discrete circuits.

10. I would be happy to help with microcontroller selection and programming if you decide to go that way. There are probably others here who would also help, and who have more recent experience with PICs.
 
Last edited:

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
Another reason in favor of using microcontrollers is this: You could connect them all together to a master and insert your own patterns onto the display, which might make for some interesting, perhaps even dazzling effects.

Kris's answer for controlling the discharge rate is a good one. Your pot would end up controlling a variable voltage regulator that is then fed to the all current sinks. This is quite doable with 1 more transistor needed in each cell. You would have to be aware of the current drawn by the current sink base, though, this could add up to a lot with 80000 cells.

BTW I have never used a 64-pin micro, only 44 at most.

Edit: The 64-pin micro could not handle 7x7 non multiplexed. It would need 14 pins for the switches (multiplexed), and it only has 55 I/O pins. It could just handle 6x7 with 13 pins for the switches, but that would leave no extra pins for communication. So you would have to go to an 80 pin for 7x7 or you could do 6x6 or 5x7 with a 64-pin.



Bob
 
Last edited:

CDRIVE

Hauling 10' pipe on a Trek Shift3
May 8, 2012
4,960
Joined
May 8, 2012
Messages
4,960
Kris, I had to type this up in Notepad for a quick paste and go because my DSL, actually Tel Line, is having issues.

When I posted that circuit it wasn't clear what rasklangus' project was. He wanted a discrete circuit that can do two things. One was light a single low current LED with a push button switch (S1) and have it decay when S1 is released. The other option that he wanted was a latch function which is accomplished with Q2, LED2, S2 and R3. I used LED2 for the required Q2 (Vbe) compensation (common with high side switching of PNP's) because they're cheaper and far more common than Zeners. He could stack Diodes though.

Chris
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
I don't think he is using that circuit anyway.

Bob
 

rasklangus

May 19, 2013
18
Joined
May 19, 2013
Messages
18
Hey, thanks for all the responses :)

Kris, The LEDs I am using draw 20ma @3.3v. At 20mm grid spacing there are 2500/m2 so that's 50A/m2. I figured on a 250w PSU to be safe. It also appears that powering each m2 with a separate PSU is going to be cheaper than one big PSU for everything (I guess the big PSUs are custom made or at least in small batches where as the smaller ones are mass produced? Anyway, about £30 for each m2 should cover it.

I have modified Chris's circuit slightly and have been tweaking it on my Breadboard so I know it does the job nicely as a single LED circuit (thanks Chris). And don't worry, I would not be committing to any mass production until I had done much tinkering and optimising to my satisfaction :)

The microprocessor method is beginning to appeal (especially as it will create a much more adaptable interface) I am capable of simple C++ etc. but am very daunted by the electronics side. I guess I am going to have to start reading up :)

I had not considered static discharge problems, I was reluctant to say previously as the person commissioning me has asked me not to but the application is to use water pistols to trigger the LEDs, not touch. The LEDs and circuits are to be all mounted on one side of a PCB and then encapsulated in epoxy using a mould for each board, leaving the contacts (gold plated so they don't corrode) for triggering the LEDs exposed, We have tested this extensively and have this working very well.

I would be concerned with passing more current through the LEDs for a shorter period to compensate for the time they will be off. Blowing LEDs when you have as many as I am proposing is not something I would want to risk. I would be sticking to manufacturers recommended specs for life expectancy etc. I guess will have to do some testing to see if the drop in brightness would be acceptable (or I could get brighter LEDs, but that's more cost :)

I am going to spend a couple of hours trying to find out about current sinks as you have suggested. Thanks for your detailed response and for your time and attention Kris :)
 

rasklangus

May 19, 2013
18
Joined
May 19, 2013
Messages
18
Yes Bob, you are totally correct about the adaptability of a microcontroller based circuit, the possibilities would be endless and would hugely extend the scope of the project.

I am going to get stuck in to understanding about current sinks as you have explained but I will be trying to get my head around microcontrollers too. If its going to cost about the same I would be stupid not to do it this way for the flexibility it would offer.

Would the microcontroller be able to drive the 20ma LEDs directly or would it have to be via transistors? Also would I need one controller for the LED array and one for the sensors? If so this would double the cost :/
 

rasklangus

May 19, 2013
18
Joined
May 19, 2013
Messages
18
Oh, I see Bob; some pins for inputs, some pins for outputs. The one microcontroller would be handling both.
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
Kris, The LEDs I am using draw 20ma @3.3v. At 20mm grid spacing there are 2500/m2 so that's 50A/m2. I figured on a 250w PSU to be safe. It also appears that powering each m2 with a separate PSU is going to be cheaper than one big PSU for everything (I guess the big PSUs are custom made or at least in small batches where as the smaller ones are mass produced? Anyway, about £30 for each m2 should cover it.
OK, I was just checking that you'd considered that factor. Yes, it's best to power the individual sections from separate power supplies. Have you considered the heat dissipation? Also, what about getting mains power into the power supplies? How many watts total? If it's more than about 2400 watts, you may need a special mains power feed. When you're talking about such a large scale, you may have to consider factors that you normally take for granted as not being an issue.
I have modified Chris's circuit slightly and have been tweaking it on my Breadboard so I know it does the job nicely as a single LED circuit (thanks Chris). And don't worry, I would not be committing to any mass production until I had done much tinkering and optimising to my satisfaction :)
I would like to see a schematic, and a PCB layout, of where you're up to. You have several interested people here; take advantage of the many eyes that are available to look for possible problems. If you're committing to such a large scale, large budget project, every opinion you can get is valuable.
The microprocessor method is beginning to appeal (especially as it will create a much more adaptable interface) I am capable of simple C++ etc. but am very daunted by the electronics side. I guess I am going to have to start reading up :)
Good. I think microcontrollers are your best option.

There are many people here who can advise you: Steve, BobK and CocaCola come to mind immediately. It would help us to help you if you would describe the project in as much detail as possible. We understand the general idea, and it sounds very cool to me, but I would like to know more about the human interface, i.e. how you plan to detect people's fingers.
I had not considered static discharge problems, I was reluctant to say previously as the person commissioning me has asked me not to but the application is to use water pistols to trigger the LEDs, not touch.
Ah! I can see why he didn't want you to say that. It's a clever idea that would add a new dimension to the user experience! It also adds requirements like the contacts needing to be non-corroding, some way to ensure that water drops won't simply drip down and activate all the circuits in a line below them, and a way to ensure that water doesn't stick to the contacts and never drip off.
The LEDs and circuits are to be all mounted on one side of a PCB and then encapsulated in epoxy using a mould for each board, leaving the contacts (gold plated so they don't corrode) for triggering the LEDs exposed, We have tested this extensively and have this working very well.
Excellent!
I would be concerned with passing more current through the LEDs for a shorter period to compensate for the time they will be off. Blowing LEDs when you have as many as I am proposing is not something I would want to risk. I would be sticking to manufacturers recommended specs for life expectancy etc. I guess will have to do some testing to see if the drop in brightness would be acceptable (or I could get brighter LEDs, but that's more cost :)
LEDs have separate specifications for pulsed and continuous current. You would not be exceeding the manufacturer's specifications. In the real world, most LEDs are driven multiplexed.
I am going to spend a couple of hours trying to find out about current sinks as you have suggested. Thanks for your detailed response and for your time and attention Kris :)
You're welcome, and thanks for explaining the water pistol twist!
 

rasklangus

May 19, 2013
18
Joined
May 19, 2013
Messages
18
Chris, I had a look at the Picaxe chips, they do look very orientated towards a novice like me but the 44 pin one is £5! That would be an expensive way to go. How about this instead...

http://uk.farnell.com/freescale-semiconductor/s9s12g96f0cll/mcu-16bit-s12g-100lqfp/dp/2080105

100 pin, 86 i/o £2 each if I buy 100.

Now I have all of 2 hours knowledge on these things but would this not allow me to have 64 outputs for LED driving and 16 inputs for a multiplexed trigger switch array?

In theory could I not run 400 LEDs on a 20x20 multiplexed output array and a 20x20 multiplexed trigger input array? I am guessing this wouldn't work however as the duty cycle for each LED would be so short that they would not be able to run very bright. I will need to check manufacturers specs to figure out the size of multiplexed array I could run. If the number of multiplexed LEDs is restricted to say a 7x7 array, is it possible to run multiple arrays from one chip?

I know nothing about these chips, is the one I have picked suitable? can you suggest what I might look for when choosing? I would guess I should be thinking about how these chips would interface with the higher level control if I decided to go this way (I am guessing this would be a PC).
 

rasklangus

May 19, 2013
18
Joined
May 19, 2013
Messages
18
Kris, I have thought about heat dissipation but it shouldn't be a problem with all the PSUs mounted in a case with a big fan. The power supply I was looking at has a little fan in the case anyway. Also the max power wont be an issue as I intend to wire the whole rig to its own breaker directly from the distribution board/fuse box.

I will post some circuit diagrams tomorrow for you guys to pick to pieces :) and give as much detail as I can regarding the project.

All your help is very much appreciated.

David.
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
That would probably be a good fit. I assume you would be using an automatic pick-and-place service with your board assembly house, so a 100-pin gull-wing IC shouldn't be a problem. Are you still planning to use a single-sided PCB?

Now I have all of 2 hours knowledge on these things but would this not allow me to have 64 outputs for LED driving and 16 inputs for a multiplexed trigger switch array?
Now that I know water is involved, I'm not sure how best to read/scan the trigger array. Do you have a drawing of the physical arrangement of the water detector contacts? Reading them using multiplexing could possibly cause problems with interference between adjacent water detector contact pairs. Also, multiplexing switches normally requires a diode for each switch, which adds to the cost.

I think some kind of multiplexing will be needed for the water detector contacts, because there are so many of them, but be aware that the characteristics of the contacts may affect how the multiplexing should be implemented.

What kind of water is to be used in the water pistols? Standard tap water, I guess? Have you measured the current flow through wet contacts with a few volts across them?

In theory could I not run 400 LEDs on a 20x20 multiplexed output array and a 20x20 multiplexed trigger input array? I am guessing this wouldn't work however as the duty cycle for each LED would be so short that they would not be able to run very bright. I will need to check manufacturers specs to figure out the size of multiplexed array I could run.
Right, good call.
If the number of multiplexed LEDs is restricted to say a 7x7 array, is it possible to run multiple arrays from one chip?
Kind of. Let's use an example of an 8x8 LED grid. That is, 8 columns, side by side, with each column consisting of 8 LEDs, one above the other. Let's assume that the columns are enabled one at a time. So the multiplexing operation consists of enabling the leftmost column and outputting the control pattern for the leftmost column of LEDs, waiting 1/8th of the total multiplex cycle, disabling the leftmost column and enabling the next column over with the appropriate LED control information for that column, and so on. After the rightmost column has been displayed, the firmware cycles back to the leftmost column.

The width, that is, the number of columns, determines the share of time for each multiplexed object (in this case, a column). So each column will see 1/8th of the total time. This factor determines how much more current you need to hit the LEDs with, to get the required brightness.

But the _height_ of the columns doesn't affect the current needed. It just affects the number of drivers you need for the LED enable pattern. You could increase the column height to, say, 16 LEDs, but still multiplex them as 8 columns, and each column would still get 1/8th of the multiplex cycle time.

This is pretty much what you mean when you suggest that one micro could drive more than one array. You could say that it's driving two arrays, which are both multiplexed together in the same way, at the same time, and probably using the same column-enable drivers, for simplicity.

So you need to work out the number of columns you want to multiplex by, then you can decide on the column height separately without affecting the width.

You don't have to multiplex them from left to right; you could work from top to bottom. Also, you don't have to expand the width of the multiplexed item linearly; you could, for example, use 16 columns side-by-side, and enable columns 1 and 9, then 2 and 10, and so on.

It is also possible for firmware to adjust the multiplexing behaviour to deal with situations where some columns LEDs need to be bright, if not all columns need to be. For example, any colum that has no LEDs illuminated at all doesn't need to be driven at all, so the remaining columns could be allowed a larger share of the multiplex cycle time. But of course it's possible that you'd need all columns lit, in some situations. In that case, firmware would be forced to allocate 1/8th time to each column, and the display would be dimmer than you would like. With the array being part of a larger image, this might look odd, unless there was some kind of global brightness signal or at least some way of communicating with the four or eight modules closely connected; this would rapidly become complicated!

I know nothing about these chips, is the one I have picked suitable? can you suggest what I might look for when choosing? I would guess I should be thinking about how these chips would interface with the higher level control if I decided to go this way (I am guessing this would be a PC).
Right. The device has an SCI, or serial communication interface. This can be used to transfer data in both directions from a serial port. You would need either multi-drop communication to all panels, or some kind of inter-panel communication, to allow individual panels to be addressed. It also has a CAN interface, which is multi-drop (but probably not as many devices as you would need). I think you can get CAN interfaces for PCs.

This project is rapidly becoming pretty complex for someone with no microcontroller experience. Can you hire an experienced technical person to work with? I have the feeling that only a hands-on person will be able to do a proper job of this project...

Kris, I have thought about heat dissipation but it shouldn't be a problem with all the PSUs mounted in a case with a big fan. The power supply I was looking at has a little fan in the case anyway. Also the max power wont be an issue as I intend to wire the whole rig to its own breaker directly from the distribution board/fuse box.
OK, sounds good. Have you calculated the total power consumption? Assume 75% efficiency for the power supplies, and significant power loss in each panel (75% maximum efficiency, and more likely around 50%, I would suggest).
I will post some circuit diagrams tomorrow for you guys to pick to pieces :) and give as much detail as I can regarding the project.
I'm looking forward to it.
All your help is very much appreciated.
David.
Thanks :) And thanks for giving us an interesting project to think about :)
 
Last edited:

CDRIVE

Hauling 10' pipe on a Trek Shift3
May 8, 2012
4,960
Joined
May 8, 2012
Messages
4,960
Yes, Picaxe chips are more expensive than their counterparts but this is because there's no additional cost for software or hardware. For one offs or small runs they're worth the higher cost for novices.

Chris
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
Just as a point of interest, I'm currently building a device that has a 12x12 array of LEDs and another similar one with a 6x6 array of LEDs.

Both are using a couple of 74HC595's as both the row and column drivers (along with a number of mosfets). A string of 74HC595's can be controlled with just 3 wires, although you can use up to 5. I'm not going to be short on pins, so I'll wire up all 5 (output enable and master clear are not strictly required, but make writing the software easier).

This will make the control of LEDs a little slower, but if it means you can use a 14 pin device instead of a 100 pin device...

The 74HC595's even make it possible to drive each LED individually. This can make wiring easier if they're not naturally laid out in a grid. If you go this way (no multiplexing) then your code doesn't have to be concerned with being able to regularly service the display. All you need do is update it whenever something changes. Since you're switching lower currents at lower speeds, RFI is also significantly reduced.

If you're driving LEDs directly, there are devices like the 74HC595 which incorporate constant current outputs and often which drive more LEDs. (A TB62725FN is one example that I have a couple of).

The other option -- and one that is simple if you have 10 or fewer columns -- is to use a 4017 to control the columns. The 4017 allows only 1 output to be turned on (correct for the columns of a multiplexed display), and an input pulse moves from one to the next. To let you synchronise things, you will need to also provide connection to the clear pin, so 2 pins can replace 10 pins for column driving.
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
Another thing to consider. I know you want smooth brightness control. This becomes more difficult when combined with multiplexing and also becomes an issue when you try to drive too many LEDs from one micro, no matter how it is done. \

The micro needs be able to turn on the LEDs 100 times per second, then leave it on for 0 to 100% of that time. So, in 1/10000 th of a second, you need to be able to determine the state of all the LEDs the micro is controlling. That is 100uSec.

A fast low end PIC microcontroller these days can run about 800 instructions in that time. If you had a 7x7 array, that would give it 16 instructions to make the decision and output the info necessary for each LED, which would be sufficient. Multiplexing or doing more LEDs than this per micro starts getting more difficult. There are some software tricks to do this more efficiently, but they are getting very complex. Plus you have to scan the switches as well.

So, basically, I am putting in a vote for keeping it simple.

Bob
 
Top