- 3D-Druck Einstieg und Tipps         
Ergebnis 1 bis 10 von 12

Thema: Anfänger Meine Schaltung macht merkwürdige Sachen

Baum-Darstellung

Vorheriger Beitrag Vorheriger Beitrag   Nächster Beitrag Nächster Beitrag
  1. #4
    Neuer Benutzer Öfters hier
    Registriert seit
    09.05.2008
    Ort
    Berlin
    Alter
    38
    Beiträge
    21
    Nein Das Programm ist ein ganz anderes (selbst geschrieben). Aber ich habs ja auf dem STK500 Ausprobiert Und da läuft es ohne probleme. Der Kosmos kasten ist in Punkto verbindungen immer eins A gelaufen und ich habe die leds und schalter alle einzeln ausprobiert.
    Die LEDs sind mit 470Ohmwiederstnden an den Adapter gebunden und dann zurück auf GND.
    Am Kosmos kasten kanns nicht liegen. Der IC lauft auf dem STK500(vor und nachher. Nur mit Adapter macht er werkwürdige Sachen.
    Hier der Code:
    Code:
    #include <avr/io.h>          // (1)
    #ifndef F_CPU
    /* Definiere F_CPU, wenn F_CPU nicht bereits vorher definiert 
       (z.B. durch Übergabe als Parameter zum Compiler innerhalb 
       des Makefiles). Zusätzlich Ausgabe einer Warnung, die auf die
       "nachträgliche" Definition hinweist */
    #define F_CPU 3686400UL     /* Quarz mit 3.6864 Mhz */
    #endif
    #include <util/delay.h>     /* in älteren avr-libc Versionen <avr/delay.h> */ 
    
    
    
    void long_delay(uint16_t ms) {
        for(; ms>0; ms--) _delay_ms(1);
    }
    
    void knightrider (void)
    {
    	DDRD = 0x00;
    	DDRD = 0xff;        // Port b alle pins auf ausgang
    	PORTD ^= ( 1 << PD0 );
    	PORTD ^= ( 1 << PD1 );
    	PORTD ^= ( 1 << PD2 );
    	PORTD ^= ( 1 << PD3 );
    	PORTD ^= ( 1 << PD4 );
    	PORTD ^= ( 1 << PD5 );
    	PORTD ^= ( 1 << PD6 );
    	PORTD ^= ( 1 << PD7 );
    	
    	DDRB=0;				//set all PartB to input
    	
    	
     	PORTD ^= ( 1 << PD0 );
    	
        while(bit_is_set(PINB,0)) {
    		long_delay(30);
    		PORTD ^= ( 1 << PD1 );
    		long_delay(30);
    		PORTD ^= ( 1 << PD2 );
            long_delay(30);
    		PORTD ^= ( 1 << PD3 );
    		PORTD ^= ( 1 << PD0 );
    		long_delay(30);
    		PORTD ^= ( 1 << PD4 );
    		PORTD ^= ( 1 << PD1 );  
    		long_delay(30);
    		PORTD ^= ( 1 << PD5 );
    		PORTD ^= ( 1 << PD2 );
    		long_delay(30);
    		PORTD ^= ( 1 << PD6 );
    		PORTD ^= ( 1 << PD3 );  
    		long_delay(30);
    		PORTD ^= ( 1 << PD7 );
    		PORTD ^= ( 1 << PD4 );
    		long_delay(30);
    		PORTD ^= ( 1 << PD5 );
    		long_delay(30);
    		PORTD ^= ( 1 << PD6 );
    		long_delay(30);
    		PORTD ^= ( 1 << PD5 );
    		long_delay(30);
    		PORTD ^= ( 1 << PD6 );
    		long_delay(30);
    		PORTD ^= ( 1 << PD7 );
    		PORTD ^= ( 1 << PD4 );
    		long_delay(30);
    		PORTD ^= ( 1 << PD6 );
    		PORTD ^= ( 1 << PD3 );
    		long_delay(30);
    		PORTD ^= ( 1 << PD5 );
    		PORTD ^= ( 1 << PD2 );
    		long_delay(30);
    		PORTD ^= ( 1 << PD4 );
    		PORTD ^= ( 1 << PD1 );
    		long_delay(30);
    		PORTD ^= ( 1 << PD3 );
    		PORTD ^= ( 1 << PD0 );
    		long_delay(30);
    		PORTD ^= ( 1 << PD2 );
    		long_delay(30);
    		PORTD ^= ( 1 << PD1 );
    	}
    	PORTD ^= ( 1 << PD0 );
    }
    
    void blink()
    {
    	DDRD =0x00;
    	DDRD =0xff;        // Port b alle pins auf ausgang
    	PORTD ^= ( 1 << PD0 );
    	PORTD ^= ( 1 << PD1 );
    	PORTD ^= ( 1 << PD2 );
    	PORTD ^= ( 1 << PD3 );
    	PORTD ^= ( 1 << PD4 );
    	PORTD ^= ( 1 << PD5 );
    	PORTD ^= ( 1 << PD6 );
    	PORTD ^= ( 1 << PD7 );//aus
    	long_delay(200);
    	PORTD ^= ( 1 << PD0 );
    	PORTD ^= ( 1 << PD1 );
    	PORTD ^= ( 1 << PD2 );
    	PORTD ^= ( 1 << PD3 );
    	PORTD ^= ( 1 << PD4 );
    	PORTD ^= ( 1 << PD5 );
    	PORTD ^= ( 1 << PD6 );
    	PORTD ^= ( 1 << PD7 );//an
    	long_delay(50);
    	
    	PORTD ^= ( 1 << PD0 );
    	PORTD ^= ( 1 << PD1 );
    	PORTD ^= ( 1 << PD2 );
    	PORTD ^= ( 1 << PD3 );
    	PORTD ^= ( 1 << PD4 );
    	PORTD ^= ( 1 << PD5 );
    	PORTD ^= ( 1 << PD6 );
    	PORTD ^= ( 1 << PD7 );//aus
    	long_delay(40);
    
    	PORTD ^= ( 1 << PD0 );
    	PORTD ^= ( 1 << PD1 );
    	PORTD ^= ( 1 << PD2 );
    	PORTD ^= ( 1 << PD3 );
    	PORTD ^= ( 1 << PD4 );
    	PORTD ^= ( 1 << PD5 );
    	PORTD ^= ( 1 << PD6 );
    	PORTD ^= ( 1 << PD7 );//an
    	long_delay(30);
    
    	PORTD ^= ( 1 << PD0 );
    	PORTD ^= ( 1 << PD1 );
    	PORTD ^= ( 1 << PD2 );
    	PORTD ^= ( 1 << PD3 );
    	PORTD ^= ( 1 << PD4 );
    	PORTD ^= ( 1 << PD5 );
    	PORTD ^= ( 1 << PD6 );
    	PORTD ^= ( 1 << PD7 );//aus
    	long_delay(20);
    
    	PORTD ^= ( 1 << PD0 );
    	PORTD ^= ( 1 << PD1 );
    	PORTD ^= ( 1 << PD2 );
    	PORTD ^= ( 1 << PD3 );
    	PORTD ^= ( 1 << PD4 );
    	PORTD ^= ( 1 << PD5 );
    	PORTD ^= ( 1 << PD6 );
    	PORTD ^= ( 1 << PD7 );//an
    	long_delay(10);
    	
    	PORTD ^= ( 1 << PD0 );
    	PORTD ^= ( 1 << PD1 );
    	PORTD ^= ( 1 << PD2 );
    	PORTD ^= ( 1 << PD3 );
    	PORTD ^= ( 1 << PD4 );
    	PORTD ^= ( 1 << PD5 );
    	PORTD ^= ( 1 << PD6 );
    	PORTD ^= ( 1 << PD7 );//aus
    	long_delay(10);
    	
    	PORTD ^= ( 1 << PD0 );
    	PORTD ^= ( 1 << PD1 );
    	PORTD ^= ( 1 << PD2 );
    	PORTD ^= ( 1 << PD3 );
    	PORTD ^= ( 1 << PD4 );
    	PORTD ^= ( 1 << PD5 );
    	PORTD ^= ( 1 << PD6 );
    	PORTD ^= ( 1 << PD7 );//an
    	long_delay(10);
    	
    	PORTD ^= ( 1 << PD0 );
    	PORTD ^= ( 1 << PD1 );
    	PORTD ^= ( 1 << PD2 );
    	PORTD ^= ( 1 << PD3 );
    	PORTD ^= ( 1 << PD4 );
    	PORTD ^= ( 1 << PD5 );
    	PORTD ^= ( 1 << PD6 );
    	PORTD ^= ( 1 << PD7 );//aus
    	long_delay(10);
    	
    	PORTD ^= ( 1 << PD0 );
    	PORTD ^= ( 1 << PD1 );
    	PORTD ^= ( 1 << PD2 );
    	PORTD ^= ( 1 << PD3 );
    	PORTD ^= ( 1 << PD4 );
    	PORTD ^= ( 1 << PD5 );
    	PORTD ^= ( 1 << PD6 );
    	PORTD ^= ( 1 << PD7 );//an
    	long_delay(500);
    	
    	PORTD ^= ( 1 << PD0 );
    	PORTD ^= ( 1 << PD1 );
    	PORTD ^= ( 1 << PD2 );
    	PORTD ^= ( 1 << PD3 );
    	PORTD ^= ( 1 << PD4 );
    	PORTD ^= ( 1 << PD5 );
    	PORTD ^= ( 1 << PD6 );
    	PORTD ^= ( 1 << PD7 );//aus
    	DDRD =0x00;
    }
    
    void boot()
    {
    	DDRD =0x00;
    	DDRD =0xff;        // Port b alle pins auf ausgang
    	PORTD ^= ( 1 << PD0 );
    	PORTD ^= ( 1 << PD1 );
    	PORTD ^= ( 1 << PD2 );
    	PORTD ^= ( 1 << PD3 );
    	PORTD ^= ( 1 << PD4 );
    	PORTD ^= ( 1 << PD5 );
    	PORTD ^= ( 1 << PD6 );
    	PORTD ^= ( 1 << PD7 );
    	
    	PORTD ^= ( 1 << PD0 );
    	long_delay(100);
    	PORTD ^= ( 1 << PD1 );
        long_delay(100);
    	PORTD ^= ( 1 << PD2 );
    	long_delay(100);
    	PORTD ^= ( 1 << PD3 );
    	long_delay(100);
    	PORTD ^= ( 1 << PD4 );
        long_delay(100);
    	PORTD ^= ( 1 << PD5 );
    	long_delay(100);
    	PORTD ^= ( 1 << PD6 );
    	long_delay(100);
    	PORTD ^= ( 1 << PD7 );
        long_delay(500);
    	
    	PORTD ^= ( 1 << PD0 );
    	PORTD ^= ( 1 << PD1 );
    	PORTD ^= ( 1 << PD2 );
    	PORTD ^= ( 1 << PD3 );
    	PORTD ^= ( 1 << PD4 );
    	PORTD ^= ( 1 << PD5 );
    	PORTD ^= ( 1 << PD6 );
    	PORTD ^= ( 1 << PD7 );
    
    	
    		
    } 
    
    int main( void )
    {
    	boot();
    	blink();
    	DDRD=0;
        while(1)
    	{
    		if (bit_is_clear(PINB, 1))
    		{
    			knightrider();
    		}
    		if (bit_is_clear(PINB, 2))
    		{
    			blink();
    		}
    		if (bit_is_clear(PINB, 3))
    		{
    			boot();
    		}
    	}
        return 0;
    }
    könnte es daran liegen das ich jetzt einen Quarz drinnhabe den ich vorher nicht drinn hatte.(und nicht ins programm geschrieben habe)
    Das Layout häng ich auch noch mit dran. die Lötpunkte außen gehen an die nägel. Oben links ist minus rechts Plus.
    Die Teile von oben nach unten sind:
    Elko 470µF
    keramikkondensator 100nf(hatte nur noch zwei der obere fehlt)
    7805
    keramikkondensator 100nf
    100k Widerstand
    IC Sockel
    Quarz 16MHz
    zwei Keramik kondensatoren 22pF

    Der Pin unter minus ist ne 5V+ Stromzufuhr.
    Angehängte Grafiken Angehängte Grafiken

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •  

Solar Speicher und Akkus Tests