Ik heb zelf een 8x7 led matrix in elkaar gesoldeerd om te multiplexen.
Hiervoor gebruik ik de bekende atmega16 + hc74595 shiftregister voor.
Dat ziet er dus zo uit


Maar wat ik ook doe, ik krijg het niet aan de gang, dus na 2 weken aankloten hoop ik dat jullie me kunnen helpen.
De leds werken goed, de 74hc595 heb ik al vervangen, ik zie de pinnen hoog en laag gaan en het protocol heb ik volgens mij ook goed door.
1 Zet datapin hoog of laag
2 Clock pin hoog
3 Even wachten
4 Clock pin laag
5 herhaal dit 7 maal
6 latch pin hoog
reset = hoog, output enable = laag
Het lijkt of het shift register totaal niet reageert.
PB1=Latch
PB3=Data
PB4=Clock
En er zijn 2x 74hc595 in serie
Hier is mijn code
Hiervoor gebruik ik de bekende atmega16 + hc74595 shiftregister voor.
Dat ziet er dus zo uit


Maar wat ik ook doe, ik krijg het niet aan de gang, dus na 2 weken aankloten hoop ik dat jullie me kunnen helpen.
De leds werken goed, de 74hc595 heb ik al vervangen, ik zie de pinnen hoog en laag gaan en het protocol heb ik volgens mij ook goed door.
1 Zet datapin hoog of laag
2 Clock pin hoog
3 Even wachten
4 Clock pin laag
5 herhaal dit 7 maal
6 latch pin hoog
reset = hoog, output enable = laag
Het lijkt of het shift register totaal niet reageert.
PB1=Latch
PB3=Data
PB4=Clock
En er zijn 2x 74hc595 in serie
Hier is mijn code
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
| #define DataPin (1 << 3)
#define ClkPin (1 << 4)
#define LatchPin (1 << 1)
#include <avr/io.h>
#include <util/delay.h>
#include <stdlib.h>
void main(void)
{
int i=0;char flip=1;
//simpele test om alle leds aan te zetten
// alles uitzetten wat we niet gebruiken
DDRA=255;
DDRB=0;
DDRC=255;
DDRD=0;
// maar nu met shift registers
/*
Step 1: Set Latch, Data, and Clock low
* Setting the Latch low tells the shift register we are about to write to it.
*/
while(1){
//even met de led knipperen
_delay_loop_2(30000);_delay_loop_2(30000);_delay_loop_2(30000);
_delay_loop_2(30000);_delay_loop_2(30000);_delay_loop_2(30000);
PORTD|=2;
_delay_loop_2(30000);_delay_loop_2(30000);_delay_loop_2(30000);
_delay_loop_2(30000);_delay_loop_2(30000);_delay_loop_2(30000);
PORTD&=~2;
_delay_loop_2(30000);_delay_loop_2(30000);_delay_loop_2(30000);
_delay_loop_2(30000);_delay_loop_2(30000);_delay_loop_2(30000);
PORTD|=2;
_delay_loop_2(30000);_delay_loop_2(30000);_delay_loop_2(30000);
_delay_loop_2(30000);_delay_loop_2(30000);_delay_loop_2(30000);
PORTD&=~2;
flip=1-flip;
PORTB=0b00000000;
for(i=0;i<8;i++)
{
/*
Step 2: Set Data pin to the logic value you want to send to the Shift Register
*/
flip=1-flip;
if(flip)PORTB|=DataPin;
else PORTB&=~DataPin;
/*
Step 3: Set Clock pin high, telling the Shift Register to read in the current Data pin value
*/
PORTB|=ClkPin;
/*
* All other values currently in the Shift Register will move over by 1 place, making room for the current logic value of the Data pin.
Step 4: Set the Clock pin Low and repeat steps 2 and 3 until all data has been sent to the shift register.
*/
PORTD|=2;
_delay_loop_2(50000);
PORTB&= ~ClkPin;
PORTD&=~2;
_delay_loop_2(50000);
//PORTC&= ~DataPin;
PORTB=0b00000000;
}
flip=1-flip;
for(i=0;i<8;i++)
{
/*
Step 2: Set Data pin to the logic value you want to send to the Shift Register
*/
//PORTD|= DataPin;
flip=1-flip;
if(flip)PORTB|=DataPin;
else PORTB&=~DataPin;
/*
Step 3: Set Clock pin high, telling the Shift Register to read in the current Data pin value
*/
PORTB|=ClkPin;
/*
* All other values currently in the Shift Register will move over by 1 place, making room for the current logic value of the Data pin.
Step 4: Set the Clock pin Low and repeat steps 2 and 3 until all data has been sent to the shift register.
*/
PORTD|=2;
_delay_loop_2(50000);
PORTB&= ~ClkPin;
PORTD&=~2;
_delay_loop_2(50000);
//PORTC&= ~DataPin;
PORTB=0b00000000;
}
/*
* The clock pin must be set low before changing to the next Data value. Toggling this pin between high and low is what creates the "clock pulse" the shift register needs to know when to move to the next step in the process.
Step 5: Set Latch high
*/
PORTB|=LatchPin;
PORTB|=ClkPin;
/*
* This tells the shift register to take all of the data that has been shifted in and use it to activate the output pins. This means that you will not see data as it is shifting in; no change in the output pins will occur until the Latch is set high.
}
} |
[ Voor 1% gewijzigd door it0 op 16-08-2008 13:39 . Reden: nu met pics ]