#ifndef F_CPU #define F_CPU 4000000 #endif // Bibliotheken einbinden #include #include #include #include #include #include #include //#include TWI_Slave.h //#include LCD.h #ifndef TRUE #define TRUE 1 #define FALSE 0 #endif #ifndef Ct // c --> max.geschwindigkeit = 50m/s #define Ct 0,20 // t --> minimale Impulszeitinterval 1/238,3 Hz = 0,0041 s #endif // C * t = 0,20 s //Prototypen int xi_ti (); void umrechnung (); void I2Cinit (); void I2C_wait (); void I2C_send (); void init(); void intvar (); int CounterInit (); // Variablen volatile double Si_wert= 0; volatile double Geschwindigkeit_in_10min = 0.0; volatile double Standardabweichung = 0.0; volatile double ti_neu = 0.0; volatile double ti2_neu = 0.0; volatile double ti_alt = 0.0; volatile double Starttime =0.0; volatile double Endtime = 0.0; volatile int count = 0; volatile int count_1 = 0; volatile int n = 0; volatile int i = 0; ISR ( TIMER1_OVF_vect ) { Si_wert++; if ( Si_wert = TRUE) n++; } ISR( TIMER1_CAPT_vect ) { static unsigned char ErsteFlanke = TRUE; // Bei der ersten Flanke beginnt die Messung, es wird der momentane // Timer beim Input Capture als Startwert gesichert if( ErsteFlanke == TRUE ) { Starttime = ICR1; // Startzeit= ICR 1 Si_wert = 0; ErsteFlanke = FALSE; // Die naechste Flanke ist das Ende der Messung } // das ist die zweite Flanke im Messzyklus. Die Messung wird gestoppt else { Endtime = ICR1; // Stopzeit für die Messung= ICR1 ErsteFlanke = TRUE; // Bei der naechsten Flanke beginnt der naechste Messzyklus } } int xi_ti(void) { ti_alt = Endtime; ti_neu = ti_neu + ti_alt; ti2_neu = ti_neu * ti_neu + ti2_neu; } // Initialisierung des Atmega16l void init (void) { DDRD &= ~ (1<Taktfrequenz: 4MHz externer Quarz TIMSK = (1<