Commit 494ccbf9 authored by Alén Arias Vázquez's avatar Alén Arias Vázquez 😎

added sw filter to not update values hier that 4000.0 rpms

parent 2fdc7e88
Pipeline #4865 passed with stage
in 1 minute and 27 seconds
...@@ -52,8 +52,11 @@ static uint16_t iter __xMR; ...@@ -52,8 +52,11 @@ static uint16_t iter __xMR;
static uint16_t fan_ramp_up_count __xMR = 0; static uint16_t fan_ramp_up_count __xMR = 0;
#endif #endif
/* MAX Speed Datasheet: 3600.0 */
#define FAN_MAX_RPMS 4000.0
static volatile uint16_t tacho_cnt[3] __xMR; static volatile uint16_t tacho_cnt[3] __xMR;
static volatile uint16_t tacho_rpm[3] __xMR; static volatile uint16_t tacho_rpm[3] __xMR;
static volatile uint16_t tacho_rpm_prev[3] __xMR;
// when fan_cmdrpm is 0, setfrpms and temp_curve_points_y represent // when fan_cmdrpm is 0, setfrpms and temp_curve_points_y represent
// duty cycle (0 to 1000) // duty cycle (0 to 1000)
...@@ -233,7 +236,12 @@ void __xMR update_rpm() ...@@ -233,7 +236,12 @@ void __xMR update_rpm()
if (fan_installed[0]) { if (fan_installed[0]) {
tacho_rpm[0] = 60*tacho_cnt[0]/(1+fan_ppr[0]); tacho_rpm[0] = 60*tacho_cnt[0]/(1+fan_ppr[0]);
tacho_cnt[0] = 0; tacho_cnt[0] = 0;
frpms_lin[0] = float_to_linear(tacho_rpm[0]); if (tacho_rpm[0] <= FAN_MAX_RPMS) {
frpms_lin[0] = float_to_linear(tacho_rpm[0]);
tacho_rpm_prev[0] = tacho_rpm[0];
} else {
frpms_lin[0] = float_to_linear(tacho_rpm_prev[0]);
}
} else { } else {
tacho_rpm[0] = 0; tacho_rpm[0] = 0;
tacho_cnt[0] = 0; tacho_cnt[0] = 0;
...@@ -243,7 +251,12 @@ void __xMR update_rpm() ...@@ -243,7 +251,12 @@ void __xMR update_rpm()
if (fan_installed[1]) { if (fan_installed[1]) {
tacho_rpm[1] = 60*tacho_cnt[1]/(1+fan_ppr[1]); tacho_rpm[1] = 60*tacho_cnt[1]/(1+fan_ppr[1]);
tacho_cnt[1] = 0; tacho_cnt[1] = 0;
frpms_lin[1] = float_to_linear(tacho_rpm[1]); if (tacho_rpm[1] <= FAN_MAX_RPMS) {
frpms_lin[1] = float_to_linear(tacho_rpm[1]);
tacho_rpm_prev[1] = tacho_rpm[1];
} else {
frpms_lin[1] = float_to_linear(tacho_rpm_prev[1]);
}
} else { } else {
tacho_rpm[1] = 0; tacho_rpm[1] = 0;
tacho_cnt[1] = 0; tacho_cnt[1] = 0;
...@@ -253,7 +266,12 @@ void __xMR update_rpm() ...@@ -253,7 +266,12 @@ void __xMR update_rpm()
if (fan_installed[2]) { if (fan_installed[2]) {
tacho_rpm[2] = 60*tacho_cnt[2]/(1+fan_ppr[2]); tacho_rpm[2] = 60*tacho_cnt[2]/(1+fan_ppr[2]);
tacho_cnt[2] = 0; tacho_cnt[2] = 0;
frpms_lin[2] = float_to_linear(tacho_rpm[2]); if (tacho_rpm[2] <= FAN_MAX_RPMS) {
frpms_lin[2] = float_to_linear(tacho_rpm[2]);
tacho_rpm_prev[2] = tacho_rpm[2];
} else {
frpms_lin[2] = float_to_linear(tacho_rpm_prev[2]);
}
} else { } else {
tacho_rpm[2] = 0; tacho_rpm[2] = 0;
tacho_cnt[2] = 0; tacho_cnt[2] = 0;
...@@ -578,6 +596,11 @@ endless_loop(void) ...@@ -578,6 +596,11 @@ endless_loop(void)
int main(void) int main(void)
{ {
/* initialize previous value to 0 */
tacho_rpm_prev[0] = 0.0;
tacho_rpm_prev[1] = 0.0;
tacho_rpm_prev[2] = 0.0;
/* Initializes MCU, drivers and middleware */ /* Initializes MCU, drivers and middleware */
atmel_start_init(); atmel_start_init();
gpio_set_pin_pull_mode(ADDR0, GPIO_PULL_UP); gpio_set_pin_pull_mode(ADDR0, GPIO_PULL_UP);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment