PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : LED Matrix am RP6



M1C
13.01.2010, 15:57
hi,
ich will auf meiner RP6-Erweiterrungs-Platine eine 3x3 LED-Matrix aufbauen.
Also hab ich mir aus ein paar Beispielen die angehängte Schaltung "zusammengeklaut" und mit TinyCad neu gezeichnet.

Y1-6 beziehen sich auf Pins beim uC (also 5V).

Kann das so funktionieren?

Transistor: TRANSISROR BD 139-10 STM (bei Conrad)
LED: http://www.conrad.de/goto.php?artikel=182427

mfG

radbruch
13.01.2010, 17:00
Hallo

Neun Leds würde ich Charlieplexen, außer den LEDs benötigst du dazu nur vier Widerstände und vier Portpins:
http://www.josepino.com/?how_control_leds

Leider habe ich im Moment keinen besseren Link. Ein Beispiel mit dem RP6-Base:
http://www.youtube.com/watch?v=ZPYhrQl-d4M
http://www.youtube.com/watch?v=r54xOzr0VDA

(Das funzt auch rotierend: http://www.youtube.com/watch?v=uwCx0GrFykU)

Da immer nur eine LED leuchtet, eignet sich diese Ansteuerung nur für Anzeigen bei denen es nicht so sehr auf die maximale Helligkeit der Leds ankommt.

Gruß

mic

M1C
13.01.2010, 17:39
hi
kann man nicht die LEDs einzeln ansteuern und schnell hintereinander an und ausmachen?
zB: Y1 auf high und dann immer Y4 und Y6 abwechselnt auf High / Low
Dann sollten doch die LED 2 und 3 circa gleichhell leuchten, oder?
EDIT²: Achso wegen der 2. LED.... hmm

Mal eine Frage nebenbei: Wenn ich einen IO-Pin als input setze kann ich den dann auch als GND verwenden?

Das Charlieplexen schau ich mir mal an =)
EDIT: Kenn jemand ein "gutes" Simulations-Programm für Schaltkreise? (DigitalSimultor kennt keine LEDs -.-)
mfG

radbruch
13.01.2010, 17:57
Hallo


kann man nicht die LEDs einzeln ansteuern und schnell hintereinander an und ausmachen?
Genau so funktioniert das. Bei meinen Beispielvideos (und all den anderen Videos bei Youtube zu dem Thema) wir das so gemacht.

Es werden dabei alle drei Zustände der AVR-Pins verwendet: High, Low und Eingang (ohne PullUp, auch Z-State genannt). Lies dich mal ein, das ist ein interessantes Thema ;)

Zur Ansicht hier mein Arbeitscode für 12 LEDs an den LEDs der RP6-Base ohne ISR (sollte auch mit der RP6-Lib funktionieren). Es wird ein statisches Bitmuster ausgegeben:

// Lauflicht mit 12 LEDs an 4 Pins mit Charlieplexing 1.3.2008 mic

#include "rblib.h"
#include "rblib.c"

volatile uint16_t bitmuster;
uint8_t p=0, bit=0;

int main(void)
{
rblib_init();
DDRC&=~SL1; PORTC&=~SL1; //SL1 off
DDRC&=~SL2; PORTC&=~SL2; //SL2 off
DDRB&=~SL4; PORTB&=~SL4; //SL4 off
DDRB&=~SL5; PORTB&=~SL5; //SL5 off
bitmuster=0b110011001100;
//bitmuster=0b111111111111;

while(1)
{
if((bitmuster & (1<<bit))==1){
DDRC|=SL1; PORTC|=SL1; //SL1 high
DDRC|=SL2; PORTC&=~SL2; //SL2 low
DDRB&=~SL4; PORTB&=~SL4; //SL4 off
DDRB&=~SL5; PORTB&=~SL5; //SL5 off
}
if((bitmuster & (1<<bit))==2){
DDRC|=SL1; PORTC|=SL1; //SL1 high
DDRB|=SL4; PORTB&=~SL4; //SL4 low
DDRC&=~SL2; PORTC&=~SL2; //SL2 off
DDRB&=~SL5; PORTB&=~SL5; //SL5 off
}
if((bitmuster & (1<<bit))==4){
DDRC|=SL1; PORTC|=SL1; //SL1 high
DDRB|=SL5; PORTB&=~SL5; //SL5 low
DDRC&=~SL2; PORTC&=~SL2; //SL2 off
DDRB&=~SL4; PORTB&=~SL4; //SL4 off
}
if((bitmuster & (1<<bit))==8){
DDRC|=SL2; PORTC|=SL2; //SL2 high
DDRC|=SL1; PORTC&=~SL1; //SL1 low
DDRB&=~SL4; PORTB&=~SL4; //SL4 off
DDRB&=~SL5; PORTB&=~SL5; //SL5 off
}
if((bitmuster & (1<<bit))==16){
DDRC|=SL2; PORTC|=SL2; //SL2 high
DDRB|=SL4; PORTB&=~SL4; //SL4 low
DDRC&=~SL1; PORTC&=~SL1; //SL1 off
DDRB&=~SL5; PORTB&=~SL5; //SL5 off
}
if((bitmuster & (1<<bit))==32){
DDRC|=SL2; PORTC|=SL2; //SL2 high
DDRB|=SL5; PORTB&=~SL5; //SL5 low
DDRC&=~SL1; PORTC&=~SL1; //SL1 off
DDRB&=~SL4; PORTB&=~SL4; //SL4 off
}
if((bitmuster & (1<<bit))==64){
DDRB|=SL4; PORTB|=SL4; //SL4 high
DDRC|=SL1; PORTC&=~SL1; //SL1 low
DDRC&=~SL2; PORTC&=~SL2; //SL2 off
DDRB&=~SL5; PORTB&=~SL5; //SL5 off
}
if((bitmuster & (1<<bit))==128){
DDRB|=SL4; PORTB|=SL4; //SL4 high
DDRC|=SL2; PORTC&=~SL2; //SL2 low
DDRC&=~SL1; PORTC&=~SL1; //SL1 off
DDRB&=~SL5; PORTB&=~SL5; //SL5 off
}
if((bitmuster & (1<<bit))==256){
DDRB|=SL4; PORTB|=SL4; //SL4 high
DDRB|=SL5; PORTB&=~SL5; //SL5 low
DDRC&=~SL2; PORTC&=~SL2; //SL2 off
DDRC&=~SL1; PORTC&=~SL1; //SL1 off
}
if((bitmuster & (1<<bit))==512){
DDRB|=SL5; PORTB|=SL5; //SL5 high
DDRC|=SL1; PORTC&=~SL1; //SL1 low
DDRC&=~SL2; PORTC&=~SL2; //SL2 off
DDRB&=~SL4; PORTB&=~SL4; //SL4 off
}
if((bitmuster & (1<<bit))==1024){
DDRB|=SL5; PORTB|=SL5; //SL5 high
DDRC|=SL2; PORTC&=~SL2; //SL2 low
DDRC&=~SL1; PORTC&=~SL1; //SL1 off
DDRB&=~SL4; PORTB&=~SL4; //SL4 off
}
if((bitmuster & (1<<bit))==2048){
DDRB|=SL5; PORTB|=SL5; //SL5 high
DDRB|=SL4; PORTB&=~SL4; //SL4 low
DDRC&=~SL1; PORTC&=~SL1; //SL1 off
DDRC&=~SL2; PORTC&=~SL2; //SL2 off
}
if(bit<12) bit++; else bit=0;
}
return 0;
}

Mit ISR (und minimaler Lib) und Lauflicht. Das ist der Nightrider-Code aus den Videos:

// Lauflicht mit 12 LEDs an 4 Pins mit Charlieplexing 1.3.2008 mic

#include "rblib.h"
#include "rblib.c"

uint16_t bitmuster;
uint16_t demo1[]={
0b100000000001, 0b010000000010, 0b001000000100, 0b000100001000, 0b000010010000,
0b000001100000, 0b000010010000, 0b000100001000, 0b001000000100, 0b010000000010 };
uint16_t demo2[]={
0b110000000011, 0b011000000110, 0b001100001100, 0b000110011000, 0b000011110000,
0b000001100000, 0b000011110000, 0b000110011000, 0b001100001100, 0b011000000110,
0b110000000011, 0b100000000001 };
uint16_t demo3[]={
0b100000000000, 0b110000000000, 0b011100000000, 0b001110000000, 0b000111000000,
0b000011100000, 0b000001110000, 0b000000111000, 0b000000011100, 0b000000001110,
0b000000000111, 0b000000000011, 0b000000000001 };
uint8_t repeat, i;

int main(void)
{
rblib_init();
DDRC&=~SL1; PORTC&=~SL1; //SL1 off
DDRC&=~SL2; PORTC&=~SL2; //SL2 off
DDRB&=~SL4; PORTB&=~SL4; //SL4 off
DDRB&=~SL5; PORTB&=~SL5; //SL5 off
cli();
TCCR0 = (0 << WGM00) | (1 << WGM01); // CTC-Mode
TCCR0 |= (0 << COM00) | (0 << COM01); // ohne OCR-Pin
TCCR0 |= (0 << CS02) | (1 << CS01) | (0 << CS00); // prescaler /8
TIMSK = (1 << OCIE0); // Interrupt ein
OCR0 = 199;
sei();

while(1)
{
repeat=5;
while(repeat--) for(i=0; i<10; bitmuster=demo1[i++]){ delay(255); delay(255); }
repeat=5;
while(repeat--) for(i=0; i<10; bitmuster=~demo1[i++]){ delay(255); delay(255); }
repeat=5;
while(repeat--) for(i=0; i<12; bitmuster=demo2[i++]){ delay(255); }
repeat=5;
while(repeat--) for(i=0; i<12; bitmuster=~demo2[i++]){ delay(255); }
repeat=5;
while(repeat--) for(i=0; i<13; bitmuster=demo3[i++]){ delay(255); delay(255); }
repeat=5;
while(repeat--) for(i=0; i<13; bitmuster=~demo3[i++]){ delay(255); delay(255); }
}
return 0;
}
ISR (TIMER0_COMP_vect)
{
static uint8_t bit=0;
if((bitmuster & (1<<bit))==1){
DDRC|=SL1; PORTC|=SL1; //SL1 high
DDRC|=SL2; PORTC&=~SL2; //SL2 low
DDRB&=~SL4; PORTB&=~SL4; //SL4 off
DDRB&=~SL5; PORTB&=~SL5; //SL5 off
}
if((bitmuster & (1<<bit))==2){
DDRC|=SL1; PORTC|=SL1; //SL1 high
DDRB|=SL4; PORTB&=~SL4; //SL4 low
DDRC&=~SL2; PORTC&=~SL2; //SL2 off
DDRB&=~SL5; PORTB&=~SL5; //SL5 off
}
if((bitmuster & (1<<bit))==4){
DDRC|=SL1; PORTC|=SL1; //SL1 high
DDRB|=SL5; PORTB&=~SL5; //SL5 low
DDRC&=~SL2; PORTC&=~SL2; //SL2 off
DDRB&=~SL4; PORTB&=~SL4; //SL4 off
}
if((bitmuster & (1<<bit))==8){
DDRC|=SL2; PORTC|=SL2; //SL2 high
DDRC|=SL1; PORTC&=~SL1; //SL1 low
DDRB&=~SL4; PORTB&=~SL4; //SL4 off
DDRB&=~SL5; PORTB&=~SL5; //SL5 off
}
if((bitmuster & (1<<bit))==16){
DDRC|=SL2; PORTC|=SL2; //SL2 high
DDRB|=SL4; PORTB&=~SL4; //SL4 low
DDRC&=~SL1; PORTC&=~SL1; //SL1 off
DDRB&=~SL5; PORTB&=~SL5; //SL5 off
}
if((bitmuster & (1<<bit))==32){
DDRC|=SL2; PORTC|=SL2; //SL2 high
DDRB|=SL5; PORTB&=~SL5; //SL5 low
DDRC&=~SL1; PORTC&=~SL1; //SL1 off
DDRB&=~SL4; PORTB&=~SL4; //SL4 off
}
if((bitmuster & (1<<bit))==64){
DDRB|=SL4; PORTB|=SL4; //SL4 high
DDRC|=SL1; PORTC&=~SL1; //SL1 low
DDRC&=~SL2; PORTC&=~SL2; //SL2 off
DDRB&=~SL5; PORTB&=~SL5; //SL5 off
}
if((bitmuster & (1<<bit))==128){
DDRB|=SL4; PORTB|=SL4; //SL4 high
DDRC|=SL2; PORTC&=~SL2; //SL2 low
DDRC&=~SL1; PORTC&=~SL1; //SL1 off
DDRB&=~SL5; PORTB&=~SL5; //SL5 off
}
if((bitmuster & (1<<bit))==256){
DDRB|=SL4; PORTB|=SL4; //SL4 high
DDRB|=SL5; PORTB&=~SL5; //SL5 low
DDRC&=~SL2; PORTC&=~SL2; //SL2 off
DDRC&=~SL1; PORTC&=~SL1; //SL1 off
}
if((bitmuster & (1<<bit))==512){
DDRB|=SL5; PORTB|=SL5; //SL5 high
DDRC|=SL1; PORTC&=~SL1; //SL1 low
DDRC&=~SL2; PORTC&=~SL2; //SL2 off
DDRB&=~SL4; PORTB&=~SL4; //SL4 off
}
if((bitmuster & (1<<bit))==1024){
DDRB|=SL5; PORTB|=SL5; //SL5 high
DDRC|=SL2; PORTC&=~SL2; //SL2 low
DDRC&=~SL1; PORTC&=~SL1; //SL1 off
DDRB&=~SL4; PORTB&=~SL4; //SL4 off
}
if((bitmuster & (1<<bit))==2048){
DDRB|=SL5; PORTB|=SL5; //SL5 high
DDRB|=SL4; PORTB&=~SL4; //SL4 low
DDRC&=~SL1; PORTC&=~SL1; //SL1 off
DDRC&=~SL2; PORTC&=~SL2; //SL2 off
}
if(bit<11) bit++; else bit=0;
}

Gruß

mic