This matrix is a economic and gives you a bit of the technical knowledge about how various components work.
Components required:
- NXP 89v51 (with development kit) which has 8051 core.
- 27 led's.
- 7805 voltage controller.
- 20 resistors of 1 ohm.
- 11.052 crystal oscillator
- capacitors-.22ufx2,10uf,.1uf.
- 4007 diodes x 3.
- A switch and a connector.
- Battery 12v/9v.
- pcb,soldering lead, a soldering gun,and lots of wires(preferably single strand).
Construction:
A crystal oscillator must be connected to the microcontroller. These connections can be obtained through the data sheet of 8051.
The voltage regulator circuit is as shown above where pin1 is the input (9v) ,pin2 is GND and pin 3 is the regulated output (5v).
diagramatic representation of the connection |
Above shown is the construction of the matrix. Here A1 shows the first row ,first column and first layer,
B1 is 1st row,2nd column and first layer, and so on.. The hashed region to your left bottom is the micro controller.
Anode and Cathode connections |
Connect the anodes of the led's column wise as shown in the picture (vertical connections). Now that the anode connection of the entire matrix is done lets concentrate on the cathode(negative) terminal.
Connect the cathode of led's in each row.PLEASE DO NOT INTERCONNECT THEM.In the picture the cathode connections is done by the black wires as shown in the background of the matrix.
figure A |
figure B |
After the anodes and the cathodes of the led's are connected/wired then follow the connections as shown in the figure B. Here P1.0 is the 1st pin in port1 of 8051 and CFI1 stands for the leds C,F,and I whose anodes are interconnected and must be connected to pin P1.0. and so on.. Pins P3.1,P3.2 and P3.3 must be connected via diodes (whose cathodes are connected to the micro controller) to the cathodes obtained by each rows.
Figure A gives a total perspective of the connections when the whole circuit is turned upside down,having the micro controller pins towards your left.
Working:
The 7805 regulator regulates the voltage across the micro controller.
ORG 0000H
start: // PATTERN
MOV P3,#01H
MOV P1,#0FFH
CALL DELAY2
MOV P3,#06H
MOV P1,#04H //TO LIGHT G1
CALL DELAY1
MOV P3,#0AH
MOV P1,#10H //TO LIGHT E2
CALL DELAY1
MOV P3,#0CH
MOV P1,#40H //TO LIGHT C3
CALL DELAY1
MOV P3,#0CH
MOV P1,#01H //TO LIGHT C1
CALL DELAY1
MOV P3,#0AH
MOV P1,#10H //TO LIGHT E2
CALL DELAY1
MOV P3,#07H
MOV P1,#00H //TO LIGHT G3
CALL DELAY1
MOV P3,#0BH
MOV P1,#0FFH //TO LIGHT D1,E1,F1,F2,E2,D2,D3,E3,F3
CALL DELAY2
MOV P3,#0DH
MOV P1,#45H //TO LIGHT A1,C1,A3,C3
CALL DELAY1
MOV P3,#0BH
MOV P1,#45H //TO LIGHT D1,F1,D3,F3
CALL DELAY1
MOV P3,#07H
MOV P1,#45H //TO LIGHT G1,I1,G3,I3
CALL DELAY1
MOV P3,#01H
MOV P1,#0FFH
CALL DELAY2
MOV P3,#03H
MOV P1,#0FFH
CALL DELAY2
MOV P3,#07H
MOV P1,#0FFH
CALL DELAY2
MOV P3,#0AH
MOV P1,#10H
CALL DELAY2
SJMP START
DELAY1: // TO GENERATE A DELAY OF APPROX 571ms
MOV R1,#0FFH
MOV R2,#0FFH
MOV R3,#04H
HERE1:
DJNZ R1,HERE1
HERE2:
DJNZ R2,HERE1
HERE3:
DJNZ R3,HERE1
RET
DELAY2: //TO GENERATE A DELAY OF APPROX 1s
MOV R1,#0FFH
MOV R2,#0FFH
MOV R3,#07H
HERE5:
DJNZ R1,HERE5
HERE6:
DJNZ R2,HERE5
HERE7:
DJNZ R3,HERE5
RET
end$
Consider the 0FFh input to P1 and 03H input to p3.
i.e P1-11111111 and p3-00000011
Depending on the pin connections 1 will lit up the led and 0 will GND it
Make sure that u create a '.hex' file which is required to burn the program onto the microcontroller.
For burning the program on to the chip I've used FLASH MAGIC.
Delay calculation:
The 8051 micro controller uses 1/12th oscillation frequency to execute each instruction. i.e
(11.0592 x 10^6) =921.6 khz=1.085x10^-6 sec.
12
Each instructions take a particular time to execute. for Eg: MOV takes 1 machine cycle,DJNZ takes 2 cycles,INT takes 2 cycles and so on..
Consider the below subroutine.
DELAY1: // TO GENERATE A DELAY OF APPROX 571ms No of machine cycles
MOV R1,#0FFH 1
MOV R2,#0FFH 1
MOV R3,#04H 1
HERE1:
DJNZ R1,HERE1 2x256x256x4
HERE2:
DJNZ R2,HERE1 2x256x4
HERE3:
DJNZ R3,HERE1 2x4
RET 2
The 8051 micro controller controls the on and off timings of each led, amalgamation of which gives a beautiful light effect. The light on-off time and choosing an led can be done through programming 8051. I used keil for programming, u can get it through google. I programmed in ALP(Assembly language programming).
Code:
start: // PATTERN
MOV P3,#01H
MOV P1,#0FFH
CALL DELAY2
MOV P3,#06H
MOV P1,#04H //TO LIGHT G1
CALL DELAY1
MOV P3,#0AH
MOV P1,#10H //TO LIGHT E2
CALL DELAY1
MOV P3,#0CH
MOV P1,#40H //TO LIGHT C3
CALL DELAY1
MOV P3,#0CH
MOV P1,#01H //TO LIGHT C1
CALL DELAY1
MOV P3,#0AH
MOV P1,#10H //TO LIGHT E2
CALL DELAY1
MOV P3,#07H
MOV P1,#00H //TO LIGHT G3
CALL DELAY1
MOV P3,#0BH
MOV P1,#0FFH //TO LIGHT D1,E1,F1,F2,E2,D2,D3,E3,F3
CALL DELAY2
MOV P3,#0DH
MOV P1,#45H //TO LIGHT A1,C1,A3,C3
CALL DELAY1
MOV P3,#0BH
MOV P1,#45H //TO LIGHT D1,F1,D3,F3
CALL DELAY1
MOV P3,#07H
MOV P1,#45H //TO LIGHT G1,I1,G3,I3
CALL DELAY1
MOV P3,#01H
MOV P1,#0FFH
CALL DELAY2
MOV P3,#03H
MOV P1,#0FFH
CALL DELAY2
MOV P3,#07H
MOV P1,#0FFH
CALL DELAY2
MOV P3,#0AH
MOV P1,#10H
CALL DELAY2
SJMP START
DELAY1: // TO GENERATE A DELAY OF APPROX 571ms
MOV R1,#0FFH
MOV R2,#0FFH
MOV R3,#04H
HERE1:
DJNZ R1,HERE1
HERE2:
DJNZ R2,HERE1
HERE3:
DJNZ R3,HERE1
RET
DELAY2: //TO GENERATE A DELAY OF APPROX 1s
MOV R1,#0FFH
MOV R2,#0FFH
MOV R3,#07H
HERE5:
DJNZ R1,HERE5
HERE6:
DJNZ R2,HERE5
HERE7:
DJNZ R3,HERE5
RET
end$
Consider the 0FFh input to P1 and 03H input to p3.
i.e P1-11111111 and p3-00000011
Depending on the pin connections 1 will lit up the led and 0 will GND it
Make sure that u create a '.hex' file which is required to burn the program onto the microcontroller.
For burning the program on to the chip I've used FLASH MAGIC.
Delay calculation:
The 8051 micro controller uses 1/12th oscillation frequency to execute each instruction. i.e
(11.0592 x 10^6) =921.6 khz=1.085x10^-6 sec.
12
Each instructions take a particular time to execute. for Eg: MOV takes 1 machine cycle,DJNZ takes 2 cycles,INT takes 2 cycles and so on..
Consider the below subroutine.
DELAY1: // TO GENERATE A DELAY OF APPROX 571ms No of machine cycles
MOV R1,#0FFH 1
MOV R2,#0FFH 1
MOV R3,#04H 1
HERE1:
DJNZ R1,HERE1 2x256x256x4
HERE2:
DJNZ R2,HERE1 2x256x4
HERE3:
DJNZ R3,HERE1 2x4
RET 2
total: 921107
machine-cycles
If the micro controller takes 1.085us to execute each instruction,then
921107x1.085x10^-6= 571ms.
Vary the delay and the code to get different patterns.
Here are some of the other led matrix projects. http://www.youtube.com/results?search_query=3x3x3+led+matrix&oq=3x3x3+led+matrix&gs_l=youtube.3...14246.17186.0.17477.6.6.0.0.0.0.248.1155.0j5j1.6.0...0.0...1ac.1.2oBtiW2TLcA
Awaiting for feed back,
other technical posts irrespective of the branch are welcomed,
thank you.
No comments:
Post a Comment