From 1d322d1cd40b09fc3101d9b79d08490dcbba0038 Mon Sep 17 00:00:00 2001 From: Nathael Pajani Date: Thu, 13 Jun 2019 21:16:41 +0200 Subject: [PATCH] Scialys app v0.3.2 Fix manual forced heating Change fan command (always on when cmd != 0) Add version info on display --- v08/interface.c | 2 ++ v08/main.c | 35 ++++++++++++++++++++--------------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/v08/interface.c b/v08/interface.c index 289c062..c937307 100644 --- a/v08/interface.c +++ b/v08/interface.c @@ -639,6 +639,8 @@ void interface_update(char heat_mode) display_line(5, 0, line); snprintf(line, DISP_LLEN, "Mode: %c", heat_mode); display_line(6, 0, line); + snprintf(line, DISP_LLEN, "v0.8 - 0.3.2", heat_mode); + display_line(7, 0, line); /* Update Oled display */ ssd130x_display_full_screen(&display); diff --git a/v08/main.c b/v08/main.c index e46038a..bcfacd8 100644 --- a/v08/main.c +++ b/v08/main.c @@ -28,7 +28,7 @@ #include "uSD.h" -#define MODULE_VERSION 0x05 +#define MODULE_VERSION 0x08 #define MODULE_NAME "Scialys uC" @@ -39,7 +39,7 @@ /* Period (in ms) of the decrementer handler from the systick interrupt */ #define DEC_PERIOD 100 /* Period (in ms) of the handler for the command value update */ -#define CMD_UPD_PERIOD 200 +#define CMD_UPD_PERIOD 100 /* NOTE : All temperatures are stored as decidegrees */ /* Max water temperature. Internal protection which cannot be overriden by configuration */ @@ -78,6 +78,7 @@ uint32_t forced_heater_mode = 0; uint32_t forced_heater_delay = 0; uint32_t forced_heater_time = 0; +uint8_t manual_forced_heater = 0; uint8_t error_shutdown = 0; @@ -161,7 +162,7 @@ uint32_t moyenne_home = 0; static uint16_t snapval_solar = 0; static uint16_t snapval_home = 0; -#define NB_VAL 20 +#define NB_VAL 5 static void track_isnail_values(void) { static uint16_t isnail_solar_values[NB_VAL]; @@ -257,7 +258,7 @@ void zero_cross_detect(uint32_t gpio) } /* Handle the power command */ -#define CMD_UP_DELAY_RESET_VALUE 5 +#define CMD_UP_DELAY_RESET_VALUE 3 void handle_cmd_update(uint32_t curent_tick) { static uint8_t cmd = 0; @@ -286,6 +287,11 @@ void handle_cmd_update(uint32_t curent_tick) /* Forced heating mode */ if ((forced_heater_delay == 0) && (forced_heater_time > 0)) { cmd = FORCED_MODE_VALUE; + goto cmd_update_end; + } + if (manual_forced_heater > 0) { + cmd = FORCED_MODE_VALUE; + goto cmd_update_end; } /* Entering forced heating mode from temperature getting below threshold, * wait some delay before effective forced heating */ @@ -293,7 +299,8 @@ void handle_cmd_update(uint32_t curent_tick) forced_heater_delay = FORCED_HEATER_DELAY; forced_heater_time = FORCED_HEATER_DELAY + FORCED_HEATER_DURATION; } - } else if (moyenne_solar < (moyenne_home - 64)) { + } + if (moyenne_solar < (moyenne_home - 64)) { /* Low production mode */ if (cmd > 0) { cmd--; @@ -315,6 +322,13 @@ void handle_cmd_update(uint32_t curent_tick) } cmd_update_end: + if ((cmd > 0) || (force_fan == 1)) { + fan_on = 1; + gpio_set(fan_ctrl); + } else { + fan_on = 0; + gpio_clear(fan_ctrl); + } command_val = cmd; /* Set Control Output duty cycle */ set_ctrl_duty_cycle(100 - cmd); @@ -452,15 +466,6 @@ int main(void) (deci_degrees_disp < ((MAX_INTERNAL_TEMP) / 2))) { error_shutdown = 0; } - /* If internal temperature is above 32°C, then turn on fan. Turn off when back to under 28°C */ - if ((deci_degrees_power > FAN_ON_INTERNAL_TEMP_POWER) || (deci_degrees_disp > FAN_ON_INTERNAL_TEMP) || - (force_fan != 0)) { - fan_on = 1; - gpio_set(fan_ctrl); - } else if ((deci_degrees_power < FAN_OFF_INTERNAL_TEMP_POWER) && (deci_degrees_disp < FAN_OFF_INTERNAL_TEMP)) { - fan_on = 0; - gpio_clear(fan_ctrl); - } /* Get thermocouple value */ if (1) { @@ -514,7 +519,7 @@ int main(void) if (manual_activation_request == -1) { uprintf(UART0, "Entering manual forced mode for %d ticks\n", manual_activation_request); manual_activation_request = MANUAL_ACTIVATION_DURATION; - forced_heater_time = FORCED_HEATER_DURATION; + manual_forced_heater = 1; } if (manual_activation_request < 10) { uprintf(UART0, "Leaving manual forced mode\n"); -- 2.43.0