// velocity measurement - target ATmega32 #define XTAL 8e6 #define F_CPU XTAL #include #include #include #include #include "..\..\includes\BitUtilities.h" #include "..\..\includes\LCD_display_on_Port_C.h" #include "..\..\includes\LED_display_degrees.h" // Deklarationen Drehzahlmessung // volatile double sec = 0; volatile double n = 0; volatile double n_max = 200; // Sollwert max. Drehzahl Rotor volatile unsigned char run = 0; // 0 = stop, 1 = run volatile unsigned int ctr = 0; // counter latch char t1[8]; // text1 for LCD display // Deklarationen Windgeschwindigkeitsmessung // #define calibrator 210.0 // (Anemometer) char str2[5]; unsigned int gatetime = 2500; // in ms float value; ISR (TIMER1_COMPA_vect) // Compare Match { if (run) {run = 0; ctr =1; sec = 100;} } ISR (TIMER1_CAPT_vect) // Capture Event { if (run) {ctr = ICR1; sec = ctr/(F_CPU/256.0); run = 0;} else {sbi(PORTB, 0); TCNT1 = 0; run = 1;} } int main() { // D I S P L A Y - A N Z E I G E // lcd_init(); lcd_send(COMMAND, LCD_CLEAR); lcd_send(COMMAND, LCD_CLEAR); lcd_set_cursor(1, 0); lcd_write("R:"); lcd_set_cursor(1, 5); lcd_write("rpm"); lcd_set_cursor(1, 9); lcd_write("W:"); lcd_set_cursor(1, 13); lcd_write("m/s"); // I N I T I A L I S I E R U N G D R E H Z A H L M E S S U N G R O T O R // TIMSK |= (1< n_max) { PORTB = 0b010000; } else { PORTB = 0b000000; } } } // While-Schleife return 0; }