Me and kids are doing a binary clock with nano and LEDs. I never used any circuit design software, couldn't tell difference between npn and pnp until recently! However have been doing a lot of reading and now about to etch my first board. With a 4x6 LED grid in mind I used the Fritzing to design a pcb layout. However I am hoping someone can please look over my design. It will suck if after the etching and all, if I had screwed up!
I could not get fritzing to make my PCB design to look articulate in the schematic view somehow. So I exported it, opened the PDF in gimp and colored the layers differently so that it is easy to see. Also included the actual etching pdfs but made a colored image to see both top and bottom in one. It is the png.
Can someone please check my design and guide me if any faults? All the transistors are CBE left to right something like bc547, resistors are 330ohm to base of transistors. Row 1-4 and Columns 1-6, so 10 digital pins to drive the grid.
I put one series resistor in front of v+ our do I need one ongoing of each led? I am planning to run these one at a time in fast and brief pulses.
Also, what about running these without the transistors ? V+ feeds in and column pin will stay high when not needed and which ever column needs to allow a led to light up will go low allowing grounding. Considering only one led being active at a time, can the nano not take it ?
Go look up the use of the MAX7219 IC for driving LED matrices. It solves virtually all of your circuit and wiring problems for you.
You intend to multiplex this display. You are using buffer transistors to increase the driving current for the multiplexed LEDs. You do need current-limiting resistors - using one for the whole display is only meaningful if you propose never to light more than one LED at a time.
The MAX7218 does all this for you - one current control resistor, two bypass capacitors and three control lines to interface with the Arduino. Up to 64 LEDs, but you can restrict the matrix size to anything less and obtain greater brightness.
As has been said in other threads, you need to decide this before you go and make a PCB. As a matter of fact, you probably do not need a PCB as you can use two pieces of stripboard ("Veroboard") oriented at right angles to mount the LEDs. MAX7219 modules (complete with LED matrix) are cheaply available on eBay, albeit at a delay. There are other suppliers, it may be - indeed quite likely is - more practical to purchase a module (kit), use it to mount the MAX7219 and then simply wire the positions intended to mount the matrix, to your own matrix.
And - with a MAX7219, the multiplexing is performed for you - no need for code to multiplex.
@GrumpyMike- Transistors are BC547. For some reason I couldn't make the schematic look organized in Fritzing, I actually laid out the components in PCB view and when I went to schematic view, even after all the connections were in place - all the components were all over the place, overlapping and a tangle!
@PaulB - Veroboards sound quite interesting for one offs. I was planning to only light one led at a time and flash them faster than the eye can see the on-offs.
As you can tell newbie here. Also the learning process is more valuable than end result. I will go read about the MAX7218.
Those are NPN transistor and so you are driving the LEDs with a common collector or emitter follower configuration, which is the wrong configuration to use.
For some reason I couldn't make the schematic look organized in Fritzing, .......
This is because Fritzing is absolute crap. If I had my way I would completely destroy this stupid application. If you can not draw a schematic you stand no chance of progressing with electronics.
I was planning to only light one led at a time and flash them faster than the eye can see the on-offs.
That is not the way you drive a matrix because the duty cycle ( on / off ratio ) will be so very small that the LEDs will be very dim. You drive it so you have a whole row or column on at a time.
Read this:- http://www.thebox.myzen.co.uk/Workshop/LED_Matrix.html
About Fritzing: It does show the schematic view but all tangled, I did not realize you have to manually place components on schematic after making the board in PCB mode. After looking up their documentation, it seems it does not place schematic to reflect pcb placements. You can tell that it is my first round with electronics! Once I placed all the components on pcb mode and went to check schematic, got spooked. Good lesson I guess- check frequently.
What software do you suggest for a newbie who does it for fun - also need to be usable by a 10yr old.
About transistors- It is common emitter I believe.
About duty cycle - I will look that up. Any links to documentation you suggest - to read up on that. I heard of duty cycles for sine waves - not that I know it but will read about it.
Thanks for the link at the end. Goal is learning, flashing lights being a good motivation
What software do you suggest for a newbie who does it for fun
One system is Eagle, it is free and not too difficult to learn. There is no point in having an easy to learn system if it only works like Fritzing. However:-
it seems it does not place schematic to reflect pcb placements.
No nothing ever does, because it is the wrong way round. Some of the more expensive systems allow placement on a PCB to be reflected in the schematic, this is called "back annotating". But for correct work flow it is the wrong way round. You generate a schematic and only when it is right do you take the step to laying out a PCB.
About transistors- It is common emitter I believe.
No it is not! It is like I said an emitter follower sometimes known as a common collector. Basically your fundamental circuit is wrong so don't waste your time doing a PCB layout until it is correct.
Grumpy_Mike:
Those are NPN transistor and so you are driving the LEDs with a common collector or emitter follower configuration, which is the wrong configuration to use.
This is because Fritzing is absolute crap. If I had my way I would completely destroy this stupid application. If you can not draw a schematic you stand no chance of progressing with electronics.
That is not the way you drive a matrix because the duty cycle ( on / off ratio ) will be so very small that the LEDs will be very dim. You drive it so you have a whole row or column on at a time.
Read this:- http://www.thebox.myzen.co.uk/Workshop/LED_Matrix.html
OK. I hooked up 4 LEDs to breadboard and to 4pins as 2x2, ran through them LOW opening the cathode and High on anode giving me option to control all 4 individually. I see what you mean by duty cycle making it dim. They do indeed run dim and even at 20microseconds delay flash I can still see the flicker!
skodela: @PaulB - Veroboards sound quite interesting for one offs. I was planning to only light one led at a time and flash them faster than the eye can see the on-offs.
(A common discussion & explanation on these forums.)
That is what Multiplexing is all about. It is very useful. What it absolutely cannot do is to compensate in any fashion for lack of current driving capability, in fact it is always less efficient than driving a LED singly. The MAX7219 however does this by design to give the ability to drive up to 64 LEDs - up to eight at a time in each of eight "columns", not one at time - in a matrix and it does this "scanning" or "strobing" for you as well as providing current regulation.
Paul__B:
(A common discussion & explanation on these forums.)
That is what Multiplexing is all about. It is very useful. What it absolutely cannot do is to compensate in any fashion for lack of current driving capability, in fact it is always less efficient than driving a LED singly. The MAX7219 however does this by design to give the ability to drive up to 64 LEDs - up to eight at a time in each of eight "columns", not one at time - in a matrix and it does this "scanning" or "strobing" for you as well as providing current regulation.
Thanks for the suggestion. I just ordered the Max7219 and the 8x8 LED preassembled panel from ebay. While I wait I will probably play with the shift registers just for the sake of learning. Also ordered some ULN2803 after reading the article as Grumpy Mike suggested. This is a lot to learn but in a good way. At least I can understand some of the terms now
Grumpy_Mike:
Square waves have a 50% duty cycle yes.
The frequency should not make things dimmer, so it looks like your code is wrong somewhere.
A quick hack is what I did to test 2x2 LED on a bread board. If I am only lighting one LED then it does not dim too much. I had another version that I brought down to 20milliseconds for a single LED, but above 20ms I can see flicker. It is ofcourse dimmer with the 330ohm series resistor than without but did not leave it too long. Then I will set up the breadboard and try again to see where I went wrong!
int p1=4;
int p2=5;
int n1=6;
int n2=7;
void setup(){
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
}
void clearup(){
digitalWrite(4,LOW);
digitalWrite(5,LOW);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
}
void loop(){
int r1=random(4,6);
int r2=random(6,8);
int iter=random(1,3);
for (int n=0;n<iter;n++){
digitalWrite(r1,HIGH);
digitalWrite(r2,LOW);
delay(20);
// THIS ABOVE LINE IS WHERE I TRIED VARIOUS
//TIMINGS INCLUDING delayMicroseconds() as well.
//If I am only lighting one LED then it does not dim too much
clearup();
}
}
with the 330ohm series resistor than without but did not leave it too long.
Never ever do that. You will have damaged both your Arduino and LED.
did not leave it too long
There is no length of time that is not too long.
What is this supposed to do?
for (int n=0;n<iter;n++){
It seems to loop a random number of times and so call a random number of delays without changing anything else. This is not the way to code multiplexing.
Grumpy_Mike:
Never ever do that. You will have damaged both your Arduino and LED.
There is no length of time that is not too long.
What is this supposed to do?
for (int n=0;n<iter;n++){
It seems to loop a random number of times and so call a random number of delays without changing anything else. This is not the way to code multiplexing.
That was when I was playing with it further. The random iteration was just for fun, to flash one of the 4 LEDs randomly. The one I tested for visible blinking was more straight forward. No random iter, single LED, repeatedly on, delay then off. I will try to find the code. Probably did not even save it.
So LEDs can't tolerate higher current/voltage even for a fraction of a second without the 330ohm in series? I was under the misconception they can tolerate it for a brief period then. I guess not risk it.
But that is not what it does. It flashes the same LED a random number of times.
It is not just the LED it is also the Arduino output. LEDs have a pulse current rating which is higher than the continuous current rating but with no current control there in theory is nothing to limit the current. However the source impedance of the voltage supply will limit the current but there is no way that will be at a safe value for both the LED and the voltage supply (Arduino Pin).
Grumpy_Mike:
But that is not what it does. It flashes the same LED a random number of times.
It is not just the LED it is also the Arduino output. LEDs have a pulse current rating which is higher than the continuous current rating but with no current control there in theory is nothing to limit the current. However the source impedance of the voltage supply will limit the current but there is no way that will be at a safe value for both the LED and the voltage supply (Arduino Pin).
True. I played with this some, previous iteration of same had r1 and r2 but no iter block so going through loop and flashing the LEDs. Then I started goofing off with lights for fun!
About the second point - I understood till source impedance. That I need to read about now.