STM32F103C8T6_WIFI_Heating_system
Dependencies: mbed mbed-STM32F103C8T6 eeprom_flash Watchdog PinDetect DS1820
- Bluepill STM32F103C8T6 Heating system
- _This project is core part of bigger heating system project!_
Features
- Reading temperature from four DS18B20 sensors
- Making a decision about switching on/off heater and pomp
- Executing simple user commands from UART
- Storing state parameters to program memory (EEPROM emulation)
Diff: temp_controller/temp_controller.cpp
- Revision:
- 46:0d60fbcfb245
- Parent:
- 45:abc682827659
- Child:
- 48:4ec055c066b4
--- a/temp_controller/temp_controller.cpp Sun Sep 23 15:04:46 2018 +0000 +++ b/temp_controller/temp_controller.cpp Sun Sep 23 16:42:17 2018 +0000 @@ -118,6 +118,11 @@ void process_temp() { + //pc.printf("State %d|%d|%d|%d|%d\r\n", temp_error[0], temp_error[1], temp_error[2], temp_error[3], temp_error[4] ); + //pc.printf("Temp %3.1f|%3.1f|%3.1f|%3.1f|%3.1f\r\n", temp[0], temp[1], temp[2], temp[3], temp[4] ); + //pc.printf("RAM_config=%X, FLASH_config=%X\r\n", eeprom_config_value ,readEEPROMWord(0)); + //pc.printf("======================================="); + switch(working_mode) { case 0: // 0 - OFF - heating off, pomp and heater are OFF @@ -126,34 +131,27 @@ break; case 1: // 1 - ECO - eco heating - - set_pomp_and_heater_by(temp); - - //pc.printf("State %d|%d|%d|%d|%d\r\n", temp_error[0], temp_error[1], temp_error[2], temp_error[3], temp_error[4] ); - //pc.printf("Temp %3.1f|%3.1f|%3.1f|%3.1f|%3.1f\r\n", temp[0], temp[1], temp[2], temp[3], temp[4] ); - //pc.printf("RAM_config=%X, FLASH_config=%X\r\n", eeprom_config_value ,readEEPROMWord(0)); - //pc.printf("======================================="); - pomp_OFF = !pomp_OFF; - heater_OFF = !heater_OFF; + set_pomp_and_heater_eco_mode(temp); break; case 2: - - set_pomp_and_heater_by(temp); // 2 - STANDART - standart heating - pomp_OFF = 1; - heater_OFF = 1; + set_pomp_and_heater_by(temp); break; case 3: - // 3 - SIMULATOR - simulator mode - work on simulated_temp - set_pomp_and_heater_by(simulated_temp); + // 3 - ECO SIMULATOR - simulator mode - work on simulated_temp + set_pomp_and_heater_eco_mode(simulated_temp); break; case 4: - // 4 - POMP - pomp is ON, heater is OFF + // 4 - SIMULATOR - simulator mode - work on simulated_temp + set_pomp_and_heater_by(simulated_temp); + break; + case 5: + // 5 - POMP - pomp is ON, heater is OFF pomp_OFF = 0; heater_OFF = 1; break; - case 5: - // 5 - FULL - pomp and heater are ON + case 6: + // 6 - FULL - pomp and heater are ON pomp_OFF = 0; heater_OFF = 0; break; @@ -279,4 +277,79 @@ //__disable_irq(); //pc.printf("Temp %3.1f|%3.1f|%3.1f|%3.1f|%3.1f\r\n", *(work_temp), *(work_temp + 1), *(work_temp + 2), *(work_temp + 3), *(work_temp + 4) ); //__enable_irq(); +}; + +void set_pomp_and_heater_eco_mode(float * work_temp){ + + unsigned char min_mebel_temp = 10; + unsigned char min_litos_temp = 7; + unsigned char min_back_water_temp = 7; + unsigned char max_hot_water_temp = 25; + + float outdoor = *(work_temp); + float litos = *(work_temp + 1); + float mebel = *(work_temp + 2); + float hot_water = *(work_temp + 3); + float back_water = *(work_temp + 4); + + if (outdoor > litos) { + //============================================ summer mode + // system off + pomp_OFF = 1; + heater_OFF = 1; + + } else if (outdoor < 3) { + //============================================ winter mode + pomp_OFF = 0; + if (mebel < min_mebel_temp || + litos < min_litos_temp || + back_water < min_back_water_temp) { + // when if somewhere is colder than it must be + if (hot_water > max_hot_water_temp) { + heater_OFF = 1; + } else { + if ( heater_OFF == 1 ) { + if (hot_water < (max_hot_water_temp - 10)) { + heater_OFF = 0; + } else { + heater_OFF = 1; + }; + } else { + heater_OFF = 0; + }; + }; + } else { + heater_OFF = 1; + }; + + } else { + //========================================demi season mode + if (mebel < min_mebel_temp || + litos < min_litos_temp || + back_water < min_back_water_temp) { + // when if somewhere is colder than it must be + pomp_OFF = 0; + if ( hot_water > (max_hot_water_temp - 5) ) { + heater_OFF = 1; + } else { + if ( heater_OFF == 1 ) { + if ( hot_water < (min_back_water_temp + 3) ) { + heater_OFF = 0; + } else { + heater_OFF = 1; + }; + } else { + heater_OFF = 0; + }; + }; + } else { + heater_OFF = 1; + if ( hot_water > min_back_water_temp ) { + pomp_OFF = 0; + } else { + pomp_OFF = 1; + }; + }; + + }; }; \ No newline at end of file