|
1066
|
Forum 2005-2010 (read only) / Interfacing / Re: Pulling my hair out trying to drive this led array
|
on: March 05, 2010, 11:00:30 pm
|
Again, I'm lost. Mark says using all NPN's is fine. Rant says I need PNPs to source current. (Isn't the ULN2803 supposed to source current?) Which is correct? And why? And can I use ULN2803s to both source and sink current? (<- This is what I really need to know!) As for the pulsed current rating on the LED's, here's the datasheet for the arrays I'll be using: http://www.kingbright.com/manager/upload/pdf/DC-20-20GWA%28Ver1189408447.8%29It seems to indicate that I can pulse them with a maximum of 140mA of current if I am multiplexing 10 leds and pulsing each one for only 100 microseconds, which is like updating the display at 1000hz. Hm. I wonder if that 0.1ms is a typo. I wish these data sheets had more data. I mean how am I supposed to figure out what other values are safe to pulse at? I mean if I extrapolate linearly, I might assume I can pulse 70mA for only 0.2ms, or 35 for only 0.4ms and that can't be right. And is linear extrapolation even the correct way to go about it? I wish there was a graph! Though 35 for 0.4s would kind of make sense which lends credence to 0.1ms being a typo. Hm... Maybe I should look at some of theoir other bargraph datasheets to see if those state something different... ...well crap. All their datasheets for the bargraphs use the same template, and say the same thing. I'd hoped there might be an older one sitting around.
|
|
|
|
|
1067
|
Forum 2005-2010 (read only) / Interfacing / Re: Pulling my hair out trying to drive this led array
|
on: March 05, 2010, 03:11:40 pm
|
|
What about a decoder? I saw those while researching various chips as well. Is there some kind of 8-bit decoder I could use to sink large amounts of current?
Wait, you said I need different kinds of transistors on the positive side...
Could you explain why I need different kinds of transistors? My understanding is that voltage goes in one side, and comes out the other if you apply voltage to the base pin. In that way the transistor acts like a switch.
So why can't I just connect the rows and colums to one side or the other of that transistor? Ie, conect the output of one group of transistors to the rows, with the input going to Vcc, and the input of another group of identical transitors to the columns, to pull them down, with the output going to ground?
What am I missing here?
|
|
|
|
|
1068
|
Forum 2005-2010 (read only) / Interfacing / Pulling my hair out trying to drive this led array
|
on: March 05, 2010, 01:06:35 pm
|
Hey guys, So, as I mentioned the other day, I'm trying to drive four green 20 segment bar graphs from an Arduino Pro Mini, in a manner not unlike a vu meter. My experiments with a 10 segment LED bar graph have led me to determine that powering the equivalent of eight of them directly from the Arduino's pins isn't going to work. For my first experiment, I wanted to see how bright my LED's would be if I lit them one at a time with 20mA of current. I calculated that with this setup, to update the entire array of 80 leds 60 times a second, I would need to keep each led lit for 208 microseconds. Unfortunately, the results if this experiment were less than stellar, and I ended up with an extremely dim array. My next experiment was to see how the array would look if I split it into eight groups of 10 leds, and lit 10 leds at a time, putting 15mA of current through each for 2083 microseconds, again for a 60hz refresh of the display. This would require a total of 150mA of current, which the Arduino can supply, but not sink on a single pin, so I would have one transistor per group of leds through which I would sink that current safely. That was the plan anyway. But this test was also a bit of a let down. The array ended up being only half as bright as I'd like it to be. At this point, I'm not sure what would be the best direction to go with this. One option, I think, would be to use two sets of tansistors, one for the rows, and one for the columns, to source and sink the current. (Do I need to use two different types of transistor to do this?) But that option is unappealing because it would require way too much soldering. The last time I tried to solder 18 transistors point to point the resulting board was a mess and didn't work and I never figured out where the problem was. The other option I have is to use a few IC's to drive the leds somehow. I'm not sure what the best option for this would be though. Using a 4017 looks like it's right out. If I'm lighting the leds one by one, I'd have to pulse them with 120mA of current just to get them to the point I'm at now where I'm putting 15mA through 10 of them at once. And I'm certain the 4017 can't deliver that kind of current. I'm not even sure it can deliver 10mA. I've also looked at the 74HC595 shift register. I'm not sure if it's best suited to this task though, or if it could handle even the 200mA needed to drive 10 leds at a time at 20mA each, nevermind the 400mA I'd like to put through it to pulse the led's to be brighter since I'd still be multiplexing them and running them 1/8th of the time. Also, since they only have 8 bits, I'd need two if I were to put them on the rows, and three if I have to put them on both the rows and columns. (And I don't even know if they can sink current.) Then there's this that caught my interest just now. I wondered if there might be an IC which just has a bunch of transistors in it to make my life easier when wiring them up, and I came across something called a darlington transistor array. Here's one I found which has eight inputs and outputs: http://www.st.com/stonline/books/pdf/docs/1536.pdfI don't understand why these have two transistors for each pin, unless that just allows them to amplify the voltage more. I also don't know if they can both source and sink current. But if they can both source and sink current, and they're set up to work like a switch that I can just turn on and off by applying voltage to the right pin, then these seem like they'd make wiring up my array really simple. I could just solder them up against each edge of the array and bridge the gap between the pins, (or maybe stick some resistors between if needed) and no crazy mess with 18 individual transistors with pins that have to be bent funny to get them to fit the holes in the perfboard. Anyway, let me know what you think. I'd be really happy to hear that I can simply stick a few of those ULN2803A transistor arrays on there with a few resistors on the rows so I can get away with cylcing through 80 leds 10 at a time, and put 40mA through each of them this way.
|
|
|
|
|
1069
|
Forum 2005-2010 (read only) / Interfacing / Re: How to search for breadboard friendly parts?
|
on: March 08, 2010, 03:01:31 am
|
|
For switches and pots "through hole" is probably one term you should look for.
For IC's you want DIP.
Also, the parts should have a "pitch" or spaceing between the leads of .1" or around 2.5mm.
You might consider looking at the data sheets for the parts as well. Those often contain drawings of the part in question.
|
|
|
|
|
1070
|
Forum 2005-2010 (read only) / Interfacing / Re: Beginner---combining 2 sketches!!??
|
on: March 07, 2010, 02:33:47 pm
|
|
Let me just clarify the abover a bit.
Let's say, after 10 seconds, you want to start fading your display out, and you want the fade to last 2 seconds.
You might, in your main loop do something like this:
fadestart = 10000 fadetime = 2000 fadeend = fadestart + fadetime
if (millis() >= fadestart) && (millis() < fadeend) { fadevalue = constrain(255.0 * (1.0 - (millis()-fadestart)/fadetime), 0, 255) analogWrite(ledpin, fadevalue); }
You can get a lot more complicated than that, having, say a global state which you can put in a switch statement to use to fade in, display 1, display 2, display 3, then fade out, in turn, but that's the basics.
Btw, another way of keeping track of time is to have an accumulator and add the amount of time which has passed since the previous loop to the accumulator each time through. So it 10 nanoseconds has passed, you add that and when 500 nanoseconds has accumulated, you do something, then either never do it again, or reset it and wait till a boolean is set to true to do it again, or just reset it to 0 and let it repeat the action forever.
|
|
|
|
|
1071
|
Forum 2005-2010 (read only) / Interfacing / Re: Beginner---combining 2 sketches!!??
|
on: March 07, 2010, 02:11:22 pm
|
I'm not gonna try to undertsand what your code is supposed to do because it seems to be doing some nonsensical things. As such, there's no simple solution to your problem that I can suggest like running one of the loops every third iteration if the code may be altered to behave differently. So you need some kind of a generic solution. The reason you're having a problem is because you're explicitly specifying all of the steps, and the delays between them. You're saying "do this, pause half a millsecond, then do this this pause half a millisecond, then repeat 500 times." But what you should be doing is putting everything in a big loop, and specifying the time at which each event should occur, and have one or more state variables for special circumstances. In other words, in void loop(), you want to keep track of millis() or micros() which start at 0 and begin counting up when your program starts, and when they pass certain milestones, do certain things. You could for example, trigger an event every 30 milliseconds, like your second code example has. And you could pair that with a state. So, you might have a varable Fade, which is your state, and initially you have it set to true. Then every 30 milliseconds, you eithe increment or decrement another variable FadeValue which tells you what to set the analog pin to, until FadeValue reaches 255 or 0, whichever direction your state variable Fade says you're going at the time. Meanwhile, you can have other events trigger, and since the loop runs constantly, and no delay statements are ever actually used, these things can all run concurrently. Oh and, I can't reccomend any of them because I haven't used them, but there seem to be some libraries already out there to help you with timing and triggering events at certain times. If you find it too difficult to manage your own timing functions maybe these will help: http://www.arduino.cc/playground/Code/EventFusehttp://www.arduino.cc/playground/Code/Metrohttp://www.arduino.cc/playground/Main/MsTimer2Ps: I'm new to the Arduino myself, so there might be better ways of doing things. I come from a background of programming games, and keeping track of the time and various states and how much time has passed between updates is what comes naturally to me. But maybe interrupts are a less power-hungry way of doing things on a microcontroller. I dunno.
|
|
|
|
|
1072
|
Forum 2005-2010 (read only) / Interfacing / Re: Multiplexing - Too dim. Need help!
|
on: March 02, 2010, 02:39:27 am
|
Those are only the base to emitter breakdown voltage, when you use the transistor to switch an LED on this will be at 1.2V tops so it doesn't matter. Perhaps, but it's not like the only thing I'm ever gonna run with a transistor is an LED. Maybe in this case it doesn't matter, but I want to know how to use the things properly. :-) I will probably need to run a motor or a speaker off one at some point in the near future. So, in that case, if it's not gonna cost me a bunch more, I'd like to get the more robust model because I'll be getting spares and then I'll have what I need at hand for whatever the purpouse. Anyway, after pulling my hair out and trying to understand that page on transistors, and figuring out that I could get rid of 2/3rd of the results by just looking at the ones available in a bulk pack, and determining that Fairchild was quite a bit cheaper than On and they're probably just as good as one another, I was able to whittle the list down to the following: http://www.mouser.com/Semiconductors/Transistors/Bipolar-Transistors/_/N-2xpqhZscv7?P=1z0z60lZ1z1414h&Keyword=2222+npn+transistor+fairchild&Ns=Pricing|0&FS=TrueAnd from that list, I selected the PN2222ABU, because the datasheet for it is newer than the PN2222BU, the specs look better, and the PN2222ANLBU appears identical to it in every way, but four cents more for reasons I cannot fathom. Also Mouser's got 60,000 of the PN2222ABU on order, so I know they're not planning to phase it out anytime soon.
|
|
|
|
|
1073
|
Forum 2005-2010 (read only) / Interfacing / Re: Multiplexing - Too dim. Need help!
|
on: March 01, 2010, 05:06:50 am
|
I've spoken with a few folks here about using those pins, and the consensus seems to be that it's only a problem if you've actually got stuff hooked up to them that might draw a current or introduce noise while you're trying to upload. To circumvent that issue, I've mounted my Arduino Pro Minis on machine pins so that I can remove them from the circuit while programming:  Btw, those machine pins kinda suck. I bought em from sparkfun, and they're supposed to be breakaway, but every other time I broke one off, half the plastic sheared away from the body of the pin, exposing it. I didn't have that problem with their breakaway headers, but those are fairly long and while they'll seat in an IC socket, they leave a pretty big gap beneath the arduino, and the sides of the pins are left exposed. Anyway, in regards to interrupts, I don't know anything about those. I'm still learning how to code this thing. Nobody's mentioned any potential issues with those to me though. Oh, and I'm still wondering which of these transistors would do the job for me: http://www.mouser.com/Semiconductors/Transistors/Bipolar-Transistors/_/N-2xpqh?P=1z0z60l&Keyword=2222+npn+transistor&FS=True&Ns=Pricing|0I don't know whether I need a 6v or 5v one, or if that matters, or what makes those different from one another.
|
|
|
|
|
1075
|
Forum 2005-2010 (read only) / Interfacing / Re: Multiplexing - Too dim. Need help!
|
on: February 28, 2010, 01:48:18 pm
|
Basically I don't get why you do it like that in your test, unless it's just a test. If you can use all the pins simultaneously, do that. It was a test. I did it to learn how to do multiplexing, to debug, and to see how bright 10 leds in a bargraph would be when multiplexed. (Also, I had them set up as a common cathode, so there was only a single 82 ohm resistor, and I didn't know what effect turning on multiple pins would have in that circumstance, and didn't want to risk blowing anything up.) 4 20-segment LED bargraph. I reckon you could split that up into 8 10-segments, using the Arduino directly you could in fact get away with using 8 outputs as multiplexing, and 10 outputs for the LED's (eight segments in parallell), thus having 1/8th duty cycle for each segment. But leaving no pins left for buttons and the piezo. If I were to put 10 pins into each of those displays, and have one pin coming out of each, then in theory I could source 40ma to each LED. (Though of course I'd keep this to a more reasonable 20ma) But the return pin can only sink 40ma. So that means in reality, I'm limited to just 4ma per LED in each of those arrays. Right now, I have a 10 segment bargraph. I am putting 40ma into each LED, but only for 1/10th of the time. That is an average of 4ma per LED. However, due to human perception, as outlined here: http://www.piclist.com/techref/io/led/pulse.htmPutting 40ma through for 1/10th of the time will actually appear twice as bright as running 4ma through 100% of the time. So... If I were to do what you suggest, the numbers say that each of those 10 led bargraphs would be half as bright as the one I am now multiplexing, even though the led's will be run at a 100% duty cycle, because I can't run each led in that array at more than 4ma or I'll burn out the pin they're returning current to. In short, it won't work. But if it did work... or if it could be made to work... it might work. :-) What I mean is, if I COULD source 20ma to each of those led's in that array, and multiplex the 8 10 led bargraphs with a 1.8 duty cycle... they'd be plenty bright. I can't do that though because the Arduino can't put out a total of more than 200ma though and I still gotta run that piezo. But 10-15ma per LED... That'd still be brighter than what I was getting in my multiplexing test. That would be bright enough. So what if... I set up each of those bargraphs to be common cathode, and then I stuck a transistor off that common cathode. And then instead of having the cathod return to one of my arduino pins, it went to ground, and I switched the transistor with the return pin instead? Then the output pins could source their 15mA of current, and that would get sunk by ground, which can handle 150mA, instead of another pin, which can't. And I'll have 50mA left over for my piezo, which I assume it plenty to run it, but again I don't really know for sure. That'll require 18 pins for the array, and one for the piezo. I soldered machine pins onto my Ardino Pro Minis so I can detach them from the circuit to program them, which gives me access to all 14 digital pins, plus the 6 analog pins, so I'd have enough pins for LED's and piezo. And only one of the switches needs to be on a pin, so that makes 20. I should have enough... What I need to know now though is if a transistor can source that 150mA for the array. I assume it can, since I've seen them used to light incandecent bulbs. Oh, and I need to figure out how to work the things. I guess just setting the pin high will be enough to put it full on?
|
|
|
|
|
1076
|
Forum 2005-2010 (read only) / Interfacing / Multiplexing - Too dim. Need help!
|
on: February 28, 2010, 06:01:56 am
|
Okay, here's my problem: I'm using a 5v Arduino Pro Mini, and I need to multiplex four 20 segment led bargraphs in a manner which is to resemble a vu-meter. In addition, I need to power a piezo speaker for sound, and two illuminated pushbuttons. The pushbuttons can be powered directly from the battery, so they probably don't need to be considered, but the piezo will need to be, and I have no idea how much current it uses. (Though I can provide spec sheets for it.) I've just got done experimenting for the evening with a 10 segment LED bargraph, and I discovered I had a problem. When multiplexing just those 10 led's, the display far was too dim. So, I did some googling, and found this page: http://www.piclist.com/techref/io/led/pulse.htmReading that, I determined that I could improve the brightness of my display two ways. The first was that since I wasn't using a 100% duty cycle for my LED's, I could pulse them at higher than 20mA. I could in fact, probably pulse them safely at the max output for a single pin on the Arduino: 40mA. The second was that rather than flip each LED on and off as fast as possible and, it might be better to only update the display 60 times a second. So, dividing 1000 by 60, and then dividing that by the number of leds in the array, which is 10, I determined I should keep each led on for around 1.6 milliseconds, or 1600 microseconds. (I later changed this to 1400 so the display would be updated 70 times a second because I can detect a 60hz flicker) And I guess this allowed the LED enough time to illuminate properly because it certainly helped, effectively doubling the percieved brightness of the display. Here's the code for the multiplexing btw:
void setup() {
for (int x = 2; x < 12; x++) { pinMode(x, OUTPUT); } }
void loop() { for (int x = 2; x < 12; x++) { digitalWrite(x, HIGH); delayMicroseconds(1400); digitalWrite(x, LOW); } }
Still, even with these two modifications, the 10 segment display was only just bright enough to be acceptable. It dawned on me that I had to run like eight of these things in order to build the display I needed. How on earth was I going to get those to be bright enough? I thought maybe I could light more than one led at once? But to get the same brightness, I'd have to light eight of them. And if I'm running each one right now at a peak of 40mA, then having eight would require 320mA, and though the Pro Mini 5v specs say it can can source a total of only 200mA. So divide 200 by 8, and that's 25mA. Meaning, I'm almost back where I started. IF I could figure out how to wire those 80 led's so I could light 8 at once, I'd still be left with a display which is fairly dim and unimpressive. Maybe even too dim to see in the daylight. So, I need another way. The easy route doesn't look like it's gonna work. I either need to use some kind of bargraph driver IC, or several 4017 decade counters, or several 4015 dual shift registers, or maybe I might be able to get away with just a handful of transistors. So what would be the easiest route to go here? Keep in mind I'm gonna have to solder all this by hand onto perfboard, I'm gonna have to build several of them, and I'd really rather not have to build something that needs four IC's to work. I'm thinking sticking some transistors onto the rows and columns is gonna be the easiest route to go. Not sure how to wire that up though. It needs to be done in a way that would allow me to light at least 8 leds at once and put 40ma through each of them.
|
|
|
|
|
1078
|
Forum 2005-2010 (read only) / Interfacing / Re: Is there a limit to the mA I should put thru gnd?
|
on: February 27, 2010, 05:47:16 pm
|
|
I found the bit in the Atmega datasheet on the ground pins, but I'm talking about the ground pin on the arduino pro mini board.
I guess though, it doesn't make a difference, does it? If I'm pulling 200mA out of the Arduino, then 200mA needs to go in, and that would go through the ATMega's ground pin.
Thanks for the help! :-)
|
|
|
|
|
1079
|
Forum 2005-2010 (read only) / Interfacing / Re: Is there a limit to the mA I should put thru gnd?
|
on: February 27, 2010, 05:38:55 pm
|
|
Where is this datasheet? Are you referring to one for the atmega chip, or for the pro mini?
Also, am I not supposed to directly connect things between pins and the negative terminal of a battery? Do I always need to connect them to the ground pin on the arduino?
I don't understand why there would be a 200mA limit on the ground pin, when you connect the negative terminal of the battery to one of the ground pins, and presumably it's a direct connection from there to the other ground pins.
|
|
|
|
|
1080
|
Forum 2005-2010 (read only) / Interfacing / Is there a limit to the mA I should put thru gnd?
|
on: February 27, 2010, 04:55:44 pm
|
|
I've soldered some machine pins to my arduino pro mini, and have placed it on my breadboard, and am getting ready to hook up a 10 led bargraph to it.
The plan is to connect 150 ohm resistors to each of the led's cathodes, and put 20mA through them. (The forward voltage is 2.1v)
It occured to me though that this will put 200mA through my ground pin on the Arduino, which I'll be connecting to the bus on the breadboard so I can get the power over the led's on the other side.
Is that safe for the Arduino? I assume it is. But what's the limit? The arduino, for now, is gonna be powered off USB. So that's gonna limit the total current to 500mA. I plan to hook it up to a battery, but since I want to be able to test on USB, I'll be staying below that.
I should note too that I plan to run more than those 10 leds off the arduino. One project will have 11 leds and a piezo, and the one with the bargraph will have that, plus another five or six led's, all of which may be lit at once. That's what I need to know the maximum for.
I'm guessing the gnd pins just go to the gnd pin on the USB, and not through the microprocessor, so there's no problem, but I can't tell by looking at the circuit.
|
|
|
|
|