diff --git a/prosjekt.X/fan_speeeed.c b/prosjekt.X/fan_speeeed.c index 21d0850..db41f07 100644 --- a/prosjekt.X/fan_speeeed.c +++ b/prosjekt.X/fan_speeeed.c @@ -99,10 +99,6 @@ ISR(AC1_AC_vect){ // AC1 vec flag ISR (TCA0_OVF_vect) { cli(); - // Calculate the fanspeed - fan1_history[fan1_history_index] = RPM_calculation(fan1_edge_counter,timer_period_ms); - fan2_history[fan2_history_index] = RPM_calculation(fan2_edge_counter,timer_period_ms); - // Increment the index, or reset if it is at the top if (fan1_history_index < 512) { fan1_history_index++; @@ -116,6 +112,10 @@ ISR (TCA0_OVF_vect) { fan2_history_index = 0; } + // Calculate the fanspeed + fan1_history[fan1_history_index] = RPM_calculation(fan1_edge_counter,timer_period_ms); + fan2_history[fan2_history_index] = RPM_calculation(fan2_edge_counter,timer_period_ms); + // Reset the edge counter fan1_edge_counter = 0; fan2_edge_counter = 0;