08-04-14, 02:07 AM | #161 |
Lurking Renovator
Join Date: Jan 2012
Location: NE Portland, Oregon
Posts: 3
Thanks: 0
Thanked 1 Time in 1 Post
|
Hi all,
I have not investigated this device fully but I really like the look of it. It takes the 3 year old Arduino Deumilanove architecture and puts some nice inputs/outputs for HVAC applications: - 8 relay outputs 10 A, 250 VAC - 4 Opto-isolated inputs 5 to 30 VDC - 3 Analog inputs (10 bit), jumper selectable for 0 to 5 VDC or 0 to 20 mA I can't post a URL but it is a sparkfun product #9526 relay I/O board |
The Following User Says Thank You to hydronics For This Useful Post: | buffalobillpatrick (08-04-14) |
08-04-14, 11:56 AM | #162 |
Master EcoRenovator
Join Date: Mar 2014
Location: Florissant, Colorado
Posts: 599
Thanks: 814
Thanked 59 Times in 55 Posts
|
A/C suggested that I post this:
Code:
/******************************************************** * * ARDUINO MASTER HEAT SYSTEM Controller. * * 3 Heat sources: Solar, Heat Pump (HP), & Boiler, * Heats 2 Load tanks: DHW & Buffer (BT). * * The priority of Heat Source used is: Solar, Heat Pump, Boiler * so as to minimize cost. * * DHW has prority over BT * The DHW Tank temperature is maintained within limits set by 2 pots. * * If Winter SW is on, the BT temperature is maintained within limits * set by Outdoor Reset (ODR) calculation to minimize BT temperature. * * The DHW_HP section can be skipped with DHW HP SKIP Switch on. * The Solar_HP section can be skipped with Solar HP SKIP Switch on. * * If Solar is not raising Load temp. then code Downshifts to using HP. * If HP is not raising Load temp. then code Downshifts to using Boiler. * * * INPUTS: * * Winter switch //control switches * DHW HP SKIP switch * SOLAR HP SKIP switch * * HP ALIVE Signal from HP Slave * * BUFFER_tank_lo_pot //control pots * BUFFER_tank_hi_pot * BUFFER_Delta_pot * DHW_Delta_pot * DHW_target_pot * Solar_lo_pot * Solar_med_pot * Solar_hi_pot * * OUTDOOR_sensor //10K NTC Thermisters * BUFFER_tank_sensor * SOLAR_tank_sensor * DHW_tank_sensor * * MQ-2_GAS_sensor * * * OUTPUTS: * * LCD Display: Status & Progression through code * * BO_HEAT_CALL_RLY_R1 Boiler heat call Relay 1 * DHW_P2_RLY_R2 DHW Pump Relay 2 * BT_P3_RLY_R3 Buffer tank Pump Relay 3 * SOLAR_P4_RLY_R4 Solar tank Pump Relay 4 * HP_HEAT_CALL_RLY_R5 Heat Pump call Relay 5, * Powers on Slave HP Arduino * * ********************************************************/ #include <Wire.h> #include <LCD.h> #include <LiquidCrystal_I2C.h> #define I2C_ADDR 0x3F // <<----- Add your address here. Find it from I2C Scanner #define BACKLIGHT_PIN 3 //define LCD digital pins #define En_pin 2 #define Rw_pin 1 //can't use 0 & 1 Tx Rx #define Rs_pin 0 #define D4_pin 4 #define D5_pin 5 //can use 2 -> 12 below in code #define D6_pin 6 #define D7_pin 7 LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin); #define SDA A4 //RESERVE I2C for LCD #define SCL A5 #define mux_analog_in A0 // multiplexer to Arduino analog in pin A0 #define WINTER_SW 15 //A1, D15 Winter sw #define DHW_HP_SKIP_SW 16 //A2. D16 DHW HP SKIP sw #define SOLAR_HP_SKIP_SW 17 //A3, D17 SOLAR HP SKIP sw // D0 = RX, D1 = TX, reserved // digital output pin relay control #define BO_HEAT_CALL_RLY_R1 2 // Boiler heat call Relay Songle 10A #define DHW_P2_RLY_R2 3 // DHW Pump2 Relay D1202 2.5A #define BT_P3_RLY_R3 4 // Buffer tank Pump3 Relay D1202 2.5A //Split R1 & R5 into seperate groups //as songle relay coil = 90ma //each group can source 150 mA. max //group 1 ends with D4 //group 2 starts with D5 #define SOLAR_P4_RLY_R4 5 // Solar tank Pump4 Relay D1202 2.5A #define HP_HEAT_CALL_RLY_R5 6 // Heat Pump call Relay Songle 10A //define digital output pins for MUX // multiplexer address select lines (A/B/C/D) const byte mux_address_A = 7; const byte mux_address_B = 8; const byte mux_address_C = 9; const byte mux_address_D = 10; const byte mux_enable = 13; // multiplexer enable #define ALARM 11 // D11 PWM OUTPUT to Audible Alarm #define HP_ALIVE 12 // D12 input from SLAVE Arduino, HP ALIVE R1 #define BUFFER_tank_lo_pot 0 //analog signals into MUX #define BUFFER_tank_hi_pot 1 // these are not analog pins on Arduino #define BUFFER_Delta_pot 2 #define DHW_Delta_pot 3 #define DHW_target_pot 4 #define Solar_lo_pot 5 #define Solar_med_pot 6 #define Solar_hi_pot 7 #define OUTDOOR_sensor 8 //analog signals into MUX #define BUFFER_tank_sensor 9 // these are not analog pins on Arduino #define SOLAR_tank_sensor 10 #define DHW_tank_sensor 11 //#define HP_Source_IN_sensor 12 //#define HP_Source_OUT_sensor 13 //#define HP_Load_IN_sensor 14 #define MQ2_GAS_sensor 15 #define GAS_LIMIT 30 //Out Door Reset parameters #define OUTDOOR_hi_control_temp 60.0 //House don't require heat #define OUTDOOR_lo_control_temp -20.0 //Minimum expected OD temp float OUTDOOR_range; float BUFFER_tank_range; float ODR_ratio; // 8 POTS must be adjusted with testing int Solar_lo_cntl_temp_pot; // These are read & stored in Sertup code int Solar_med_cntl_temp_pot; int Solar_hi_cntl_temp_pot; int DHW_tank_target_temp_pot; int BUFFER_tank_hi_limit_pot; int BUFFER_tank_lo_limit_pot; int DHW_delta_pot; int BUFFER_delta_pot; int OUTDOOR_temp; int SOLAR_tank_temp; int DHW_tank_temp; int BUFFER_tank_temp; int BUFFER_tank_target_temp; //int HP_Source_IN_temp; //int HP_Source_OUT_temp; //int HP_Load_IN_temp; //int HP_Load_OUT_temp; unsigned long T1; unsigned long T2; unsigned long TT; int I; int START_T; int NOW_T; int sensor_data; boolean WINTER_SW_BOOL = false; boolean DHW_HP_SKIP_BOOL = false; boolean SOLAR_HP_SKIP_BOOL = false; boolean DHW_DOWNSHIFT_BOOL1 = false; boolean DHW_DOWNSHIFT_BOOL2 = false; boolean BT_DOWNSHIFT_BOOL1 = false; boolean BT_DOWNSHIFT_BOOL2 = false; void setup(void) { pinMode (mux_analog_in, INPUT); //MUX DATA INPUT pinMode (mux_address_A, OUTPUT); // multiplexer address select lines (A/B/C/D) pinMode (mux_address_B, OUTPUT); pinMode (mux_address_C, OUTPUT); pinMode (mux_address_D, OUTPUT); pinMode (mux_enable, OUTPUT); // multiplexer enable pinMode (ALARM, OUTPUT); // Audible Alarm pinMode(BO_HEAT_CALL_RLY_R1, OUTPUT); //digital output to relays pinMode(DHW_P2_RLY_R2, OUTPUT); //digital output to relays pinMode(BT_P3_RLY_R3, OUTPUT); //digital output to relays pinMode(SOLAR_P4_RLY_R4, OUTPUT); //digital output to relays pinMode(HP_HEAT_CALL_RLY_R5, OUTPUT); //digital output to relays pinMode(WINTER_SW, INPUT); //Winter switch pinMode(DHW_HP_SKIP_SW, INPUT); //DHW HP SKIP switch pinMode(SOLAR_HP_SKIP_SW, INPUT); //SOLAR HP SKIP switch pinMode(HP_ALIVE, INPUT); //HP ALIVE digitalWrite (BO_HEAT_CALL_RLY_R1, HIGH); //OFF digitalWrite (DHW_P2_RLY_R2, HIGH); //OFF digitalWrite (BT_P3_RLY_R3, HIGH); //OFF digitalWrite (SOLAR_P4_RLY_R4, HIGH); //OFF digitalWrite (HP_HEAT_CALL_RLY_R5, HIGH); //OFF digitalWrite (ALARM, HIGH); //OFF // Serial.begin(9600); // start serial communication // custom_delay_5sec(); //Delay 5 sec. & Check for GAS //time to enable monitor window Last edited by buffalobillpatrick; 08-04-14 at 01:17 PM.. |
08-04-14, 11:58 AM | #163 |
Master EcoRenovator
Join Date: Mar 2014
Location: Florissant, Colorado
Posts: 599
Thanks: 814
Thanked 59 Times in 55 Posts
|
Setup Code:
Code:
// Serial.println(F("........Hello world!.......")); // delay(100); lcd.begin (16,2); // <<----- My LCD is 16x2 lcd.clear(); //Switch on the backlight lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE); lcd.setBacklight(HIGH); lcd.clear(); lcd.home (); // go home lcd.print(F("BBP HEAT SYSTEM")); lcd.setCursor(0,1); lcd.print(F("MASTER CONTROLER")); custom_delay_5sec(); //Delay 5 sec. & Check for GAS lcd.clear(); lcd.home (); // go home lcd.print(F("START SETUP")); custom_delay_5sec(); //Delay 5 sec. & Check for GAS if (digitalRead(WINTER_SW) == HIGH) { WINTER_SW_BOOL = true; lcd.clear(); lcd.home (); // go home lcd.print(F("WINTER SW = ON")); lcd.setCursor(0,1); lcd.print(F("KEEP BT HOT !!!!")); custom_delay_5sec(); //Delay 5 sec. & Check for GAS } else { WINTER_SW_BOOL = false; lcd.clear(); lcd.home (); // go home lcd.print(F("WINTER SW = OFF")); lcd.setCursor(0,1); //clear 2nd line lcd.print(F("BT IS NOT USED")); custom_delay_5sec(); //Delay 5 sec. & Check for GAS } if (digitalRead(DHW_HP_SKIP_SW) == HIGH) { DHW_HP_SKIP_BOOL = true; lcd.clear(); lcd.home (); // go home lcd.print(F("DHW_HP_SKIP = ON")); lcd.setCursor(0,1); lcd.print(F("HP DONT HEAT DHW")); custom_delay_5sec(); //Delay 5 sec. & Check for GAS } else { DHW_HP_SKIP_BOOL = false; lcd.clear(); lcd.home (); // go home lcd.print(F("DHW_HP_SKIP= OFF")); lcd.setCursor(0,1); lcd.print(F("HP MAY HEAT DHW")); custom_delay_5sec(); //Delay 5 sec. & Check for GAS } if (digitalRead(SOLAR_HP_SKIP_SW) == HIGH) { SOLAR_HP_SKIP_BOOL = true; lcd.clear(); lcd.home (); // go home lcd.print(F("SOL_HP_SKIP=ON")); lcd.setCursor(0,1); lcd.print(F("SOL&HP SKIPED")); custom_delay_5sec(); //Delay 5 sec. & Check for GAS } else { SOLAR_HP_SKIP_BOOL = false; lcd.clear(); lcd.home (); // go home lcd.print(F("SOL_HP_SKIP=OFF")); lcd.setCursor(0,1); lcd.print(F("SOL&HP ENABLED")); custom_delay_5sec(); //Delay 5 sec. & Check for GAS } lcd.clear(); lcd.home (); // go home lcd.print(F("Read 8 Cntl Pots")); custom_delay_5sec(); //Delay 5 sec. & Check for GAS //read the 8 control pots BUFFER_tank_hi_limit_pot = (readSensor_F (BUFFER_tank_hi_pot)); //BUFFER_tank_hi_limit_pot = 130; //debug BUFFER_tank_lo_limit_pot = (readSensor_F (BUFFER_tank_lo_pot)); //BUFFER_tank_lo_limit_pot = 85; //debug BUFFER_delta_pot = ((readSensor_F (BUFFER_Delta_pot)) / 10); //BUFFER_delta_pot = 5; //debug DHW_delta_pot = ((readSensor_F (DHW_Delta_pot)) / 10); //DHW_delta_pot = 4; //debug Solar_lo_cntl_temp_pot = (readSensor_F (Solar_lo_pot)); //Solar_lo_cntl_temp_pot = 39; //debug Solar_med_cntl_temp_pot = (readSensor_F (Solar_med_pot)); // Solar_med_cntl_temp_pot = 85; //debug Solar_hi_cntl_temp_pot = (readSensor_F (Solar_hi_pot)); //Solar_hi_cntl_temp_pot = 149; //debug DHW_tank_target_temp_pot = (readSensor_F (DHW_target_pot));; //DHW_tank_target_temp_pot = 138; //debug lcd.clear(); lcd.home (); // go home lcd.print(F("BT Hi Pot = ")); lcd.print(BUFFER_tank_hi_limit_pot); lcd.setCursor(0,1); lcd.print(F("BT Lo Pot = ")); lcd.print(BUFFER_tank_lo_limit_pot); custom_delay_5sec(); //Delay 5 sec. & Check for GAS lcd.clear(); lcd.home (); // go home lcd.print(F("BT Delta Pot =")); lcd.print(BUFFER_delta_pot); lcd.setCursor(0,1); lcd.print(F("DHW Delta Pot=")); lcd.print(DHW_delta_pot); custom_delay_5sec(); //Delay 5 sec. & Check for GAS lcd.clear(); lcd.home (); // go home lcd.print(F("Solar Lo Pot=")); lcd.print(Solar_lo_cntl_temp_pot); lcd.setCursor(0,1); lcd.print(F("Solar MedPot=")); lcd.print(Solar_med_cntl_temp_pot); custom_delay_5sec(); //Delay 5 sec. & Check for GAS lcd.clear(); lcd.home (); // go home lcd.print(F("Solar HiPot=")); lcd.print(Solar_hi_cntl_temp_pot); lcd.setCursor(0,1); lcd.print(F("DHW Tgt Pot=")); lcd.print(DHW_tank_target_temp_pot); custom_delay_5sec(); //Delay 5 sec. & Check for GAS OUTDOOR_temp = (readSensor_F (OUTDOOR_sensor)); BUFFER_tank_temp = (readSensor_F (BUFFER_tank_sensor)); lcd.clear(); lcd.home (); // go home lcd.print(F("OD Temp = ")); lcd.print(OUTDOOR_temp); lcd.setCursor(0,1); lcd.print(F("BT Temp = ")); lcd.print(BUFFER_tank_temp); custom_delay_5sec(); //Delay 5 sec. & Check for GAS SOLAR_tank_temp = (readSensor_F (SOLAR_tank_sensor)); DHW_tank_temp = (readSensor_F (DHW_tank_sensor)); lcd.clear(); lcd.home (); // go home lcd.print(F("SOLAR Temp = ")); lcd.print(SOLAR_tank_temp); lcd.setCursor(0,1); lcd.print(F("DHW Temp = ")); lcd.print(DHW_tank_temp); custom_delay_5sec(); //Delay 5 sec. & Check for GAS if (WINTER_SW_BOOL == true) //Run this section if Winter Sw is ON { OUTDOOR_range = ( OUTDOOR_hi_control_temp - OUTDOOR_lo_control_temp ); BUFFER_tank_range = ( BUFFER_tank_hi_limit_pot - BUFFER_tank_lo_limit_pot ); ODR_ratio = ( BUFFER_tank_range / OUTDOOR_range ); lcd.clear(); lcd.home (); // go home lcd.print(F("ODR Ratio = ")); lcd.print(ODR_ratio); custom_delay_5sec(); //Delay 5 sec. & Check for GAS lcd.clear(); lcd.home (); // go home lcd.print(F("ODR Ratio Means:")); lcd.setCursor(0,1); lcd.print(F("IF OD Temp Drops")); custom_delay_5sec(); //Delay 5 sec. & Check for GAS lcd.clear(); lcd.home (); // go home lcd.print(F("By 1 *F, Then")); lcd.setCursor(0,1); lcd.print(F("BT Tgt Goes Up")); custom_delay_5sec(); //Delay 5 sec. & Check for GAS lcd.clear(); lcd.home (); // go home lcd.print(F("By ")); lcd.print(ODR_ratio); lcd.print(F(" *F")); custom_delay_5sec(); //Delay 5 sec. & Check for GAS } //end Winter Sw = true lcd.clear(); lcd.home (); // go home lcd.print(F("END SETUP")); custom_delay_5sec(); //Delay 5 sec. & Check for GAS } //end setup Last edited by buffalobillpatrick; 08-04-14 at 01:12 PM.. |
08-04-14, 12:01 PM | #164 |
Master EcoRenovator
Join Date: Mar 2014
Location: Florissant, Colorado
Posts: 599
Thanks: 814
Thanked 59 Times in 55 Posts
|
Main Loop part 1
Code:
void loop () { //DHW has 1st priority DHW_CODE: DHW_tank_temp = (readSensor_F (DHW_tank_sensor)); DHW_tank_temp = 130; //debug lcd.clear(); lcd.home (); // go home lcd.print(F("DHW TANK = ")); lcd.print(DHW_tank_temp); custom_delay_5sec(); //Delay 5 sec. & Check for GAS //Test if DHW needs to start heating if ( DHW_tank_temp < ( DHW_tank_target_temp_pot - DHW_delta_pot )) { do //while DHW_tank_temp < DHW_tank_target_temp_pot { lcd.clear(); lcd.home (); // go home lcd.print(F("DHW NEEDS HEAT")); custom_delay_5sec(); //Delay 5 sec. & Check for GAS if (SOLAR_HP_SKIP_BOOL == false) { //Run this section if SOLAR HP SKIP = OFF SOLAR_tank_temp = (readSensor_F (SOLAR_tank_sensor)); SOLAR_tank_temp = 150; //debug lcd.clear(); lcd.home (); // go home lcd.print(F("Solar Tank = ")); lcd.print(SOLAR_tank_temp); custom_delay_5sec(); //Delay 5 sec. & Check for GAS //Is Solar Hot enough for Solar -> DHW Direct //AND Is Downshift Bool1 false if (( SOLAR_tank_temp >= Solar_hi_cntl_temp_pot ) && ( DHW_DOWNSHIFT_BOOL1 == false )) { digitalWrite (BO_HEAT_CALL_RLY_R1, HIGH); digitalWrite (DHW_P2_RLY_R2, LOW); //ON digitalWrite (BT_P3_RLY_R3, HIGH); digitalWrite (SOLAR_P4_RLY_R4, LOW); //ON digitalWrite (HP_HEAT_CALL_RLY_R5, HIGH); lcd.clear(); lcd.home (); // go home lcd.print(F("Solar -> DHW")); lcd.setCursor(0,1); lcd.print(F("R2 & R4 ON")); custom_delay_5sec(); //Delay 5 sec. & Check for GAS START_T = (readSensor_F (DHW_tank_sensor)); START_T = 131; //debug //for (I=0; I< 120; I++) //delay up to 20 min. before testing gain for (I=0; I< 1; I++) //debug { custom_delay_5sec(); //Delay 5 sec. & Check for GAS DHW_tank_temp = (readSensor_F (DHW_tank_sensor)); DHW_tank_temp = 131; //debug lcd.clear(); lcd.home (); // go home lcd.print(F("DHW TANK = ")); lcd.print(DHW_tank_temp); custom_delay_5sec(); //Delay 5 sec. & Check for GAS if ( DHW_tank_temp >= DHW_tank_target_temp_pot ) {goto DHW_HOT;} } //end delay loop NOW_T = (readSensor_F (DHW_tank_sensor)); NOW_T = 131; //debug FORCE DOWNSHIFT 1 if ( NOW_T > START_T ) //Gaining temp? { DHW_DOWNSHIFT_BOOL1 = false; lcd.clear(); lcd.home (); // go home lcd.print(F("DHW_SHIFT1=FALSE")); custom_delay_5sec(); //Delay 5 sec. & Check for GAS } else { DHW_DOWNSHIFT_BOOL1 = true; lcd.clear(); lcd.home (); // go home lcd.print(F("DHW_SHIFT1=TRUE")); custom_delay_5sec(); //Delay 5 sec. & Check for GAS } //end if gaining temp } //end if Solar Hot enough for direct heating //Is Solar Hot enough for HP -> DHW //AND Is DHW Downshift Bool2 false //AND Is DHW HP SKIP Switch Off else if (( SOLAR_tank_temp >= Solar_med_cntl_temp_pot ) && ( DHW_DOWNSHIFT_BOOL2 == false ) && ( DHW_HP_SKIP_BOOL == false )) { digitalWrite (BO_HEAT_CALL_RLY_R1, HIGH); digitalWrite (DHW_P2_RLY_R2, LOW); // HP -> DHW digitalWrite (BT_P3_RLY_R3, HIGH); digitalWrite (SOLAR_P4_RLY_R4, HIGH); digitalWrite (HP_HEAT_CALL_RLY_R5, LOW); //HP ON lcd.clear(); lcd.home (); // go home lcd.print(F("HP -> DHW")); lcd.setCursor(0,1); lcd.print(F("R2 & R5 ON")); custom_delay_5sec(); //Delay 5 sec. & Check for GAS START_T = (readSensor_F (DHW_tank_sensor)); START_T = 132; //debug //for (I=0; I< 120; I++) //delay up to 20 min. before testing gain for (I=0; I< 1; I++) //debug { custom_delay_5sec(); //Delay 5 sec. & Check for GAS // if (digitalRead(HP_ALIVE) == LOW) {goto DHW_SHIFT2;} debug DHW_tank_temp = (readSensor_F (DHW_tank_sensor)); DHW_tank_temp = 132; //debug lcd.clear(); lcd.home (); // go home lcd.print(F("DHW TANK = ")); lcd.print(DHW_tank_temp); custom_delay_5sec(); //Delay 5 sec. & Check for GAS if ( DHW_tank_temp >= DHW_tank_target_temp_pot ) {goto DHW_HOT;} } //end delay loop NOW_T = (readSensor_F (DHW_tank_sensor)); NOW_T = 132; //debug Force DOWNSHIFT 2 if ( NOW_T > START_T ) //Gaining temp? { DHW_DOWNSHIFT_BOOL2 = false; lcd.clear(); lcd.home (); // go home lcd.print(F("DHW_SHIFT2=FALSE")); custom_delay_5sec(); //Delay 5 sec. & Check for GAS } else { DHW_SHIFT2: DHW_DOWNSHIFT_BOOL2 = true; lcd.clear(); lcd.home (); // go home lcd.print(F("DHW_SHIFT2=TRUE")); custom_delay_5sec(); //Delay 5 sec. & Check for GAS } } //end if Solar Hot enough for HP -> DHW } //end if SOLAR HP SKIP = OFF if (( SOLAR_HP_SKIP_BOOL == true ) or (( DHW_DOWNSHIFT_BOOL1 == true ) && ( DHW_DOWNSHIFT_BOOL2 == true )) or (( DHW_DOWNSHIFT_BOOL1 == true ) && ( DHW_HP_SKIP_BOOL == true ))) { // BOILER -> DHW digitalWrite (BO_HEAT_CALL_RLY_R1, LOW); //ON digitalWrite (DHW_P2_RLY_R2, LOW); //ON digitalWrite (BT_P3_RLY_R3, HIGH); digitalWrite (SOLAR_P4_RLY_R4, HIGH); digitalWrite (HP_HEAT_CALL_RLY_R5, HIGH); lcd.clear(); lcd.home (); // go home lcd.print(F("Boiler -> DHW")); lcd.setCursor(0,1); lcd.print(F("R1 & R2 ON")); custom_delay_5sec(); //Delay 5 sec. & Check for GAS //for (I=0; I< 60; I++) //delay 10 min for (I=0; I< 1; I++) //debug { custom_delay_5sec(); //Delay 5 sec. & Check for GAS } DHW_tank_temp = (readSensor_F (DHW_tank_sensor)); DHW_tank_temp = 140; //debug if ( DHW_tank_temp >= DHW_tank_target_temp_pot ) {goto DHW_HOT;} lcd.clear(); lcd.home (); // go home lcd.print(F("DHW TANK = ")); lcd.print(DHW_tank_temp); custom_delay_5sec(); //Delay 5 sec. & Check for GAS } //end if BOILER -> DHW } while ( DHW_tank_temp < DHW_tank_target_temp_pot ); } //end if if DHW needs to start heating DHW_HOT: DHW_DOWNSHIFT_BOOL1 = false; DHW_DOWNSHIFT_BOOL2 = false; lcd.clear(); lcd.home (); // go home lcd.print(F("DHW is Hot")); custom_delay_5sec(); //Delay 5 sec. & Check for GAS digitalWrite (BO_HEAT_CALL_RLY_R1, HIGH); //turn off relays digitalWrite (DHW_P2_RLY_R2, HIGH); digitalWrite (BT_P3_RLY_R3, HIGH); digitalWrite (SOLAR_P4_RLY_R4, HIGH); digitalWrite (HP_HEAT_CALL_RLY_R5, HIGH); lcd.clear(); lcd.home (); // go home lcd.print(F("TurnOff all Rlys")); custom_delay_5sec(); //Delay 5 sec. & Check for GAS |
08-04-14, 12:03 PM | #165 |
Master EcoRenovator
Join Date: Mar 2014
Location: Florissant, Colorado
Posts: 599
Thanks: 814
Thanked 59 Times in 55 Posts
|
Main Loop part 2
Code:
// Buffer Tank Control Code WINTER_SW_BOOL = true; //debug if (WINTER_SW_BOOL == true) //Run this section if Winter Sw is ON { DHW_tank_temp = (readSensor_F (DHW_tank_sensor)); DHW_tank_temp = 137; //debug DHW HOT STAY HERE lcd.clear(); lcd.home (); // go home lcd.print(F("DHW TANK = ")); lcd.print(DHW_tank_temp); custom_delay_5sec(); //Delay 5 sec. & Check for GAS if (( DHW_tank_temp ) < ( DHW_tank_target_temp_pot - DHW_delta_pot )) { BT_DOWNSHIFT_BOOL1 = false; BT_DOWNSHIFT_BOOL2 = false; lcd.clear(); lcd.home (); //BREAK OUT OF BT CODE lcd.print(F("GOTO DHW CODE")); //GOTO DHW CODE custom_delay_5sec(); //Delay 5 sec. & Check for GAS goto DHW_CODE; } lcd.clear(); lcd.home (); // go home lcd.print(F("DHW HOT")); lcd.setCursor(0,1); lcd.print(F("RUN BT CODE")); custom_delay_5sec(); //Delay 5 sec. & Check for GAS OUTDOOR_temp = (readSensor_F (OUTDOOR_sensor)); OUTDOOR_temp = 57; //debug lcd.clear(); lcd.home (); // go home lcd.print(F("OD Temp = ")); lcd.print(OUTDOOR_temp); custom_delay_5sec(); //Delay 5 sec. & Check for GAS // Calculate Buffer Tank Target Temp based on ODR parameters BUFFER_tank_target_temp = ( BUFFER_tank_lo_limit_pot + (( OUTDOOR_hi_control_temp - OUTDOOR_temp ) * ODR_ratio )); BUFFER_tank_temp = (readSensor_F (BUFFER_tank_sensor)); BUFFER_tank_temp = 79; //debug lcd.clear(); lcd.home (); // go home lcd.print(F("BT Tgt = ")); lcd.print(BUFFER_tank_target_temp); lcd.setCursor(0,1); lcd.print(F("BT Temp = ")); lcd.print(BUFFER_tank_temp); custom_delay_5sec(); //Delay 5 sec. & Check for GAS //Test if BT needs to start heating if ( BUFFER_tank_temp < ( BUFFER_tank_target_temp - BUFFER_delta_pot )) { lcd.clear(); lcd.home (); // go home lcd.print(F("BT NEEDS HEAT")); custom_delay_5sec(); //Delay 5 sec. & Check for GAS do //while BUFFER_tank_temp < BUFFER_tank_target_temp_pot { if (SOLAR_HP_SKIP_BOOL == false) { //Run this section if SOLAR HP SKIP is OFF SOLAR_tank_temp = (readSensor_F (SOLAR_tank_sensor)); SOLAR_tank_temp = 140; //debug lcd.clear (); lcd.home (); // go home lcd.print(F("Solar Tank = ")); lcd.print(SOLAR_tank_temp); custom_delay_5sec(); //Delay 5 sec. & Check for GAS //Is Solar Tank is hot enough for Solar -> BT, Direct //AND Is BT Downshift Bool1 false if (( SOLAR_tank_temp >= ( BUFFER_tank_target_temp + (BUFFER_delta_pot * 5)) && ( BT_DOWNSHIFT_BOOL1 == false ))) { digitalWrite (BO_HEAT_CALL_RLY_R1, HIGH); digitalWrite (DHW_P2_RLY_R2, HIGH); digitalWrite (BT_P3_RLY_R3, LOW); //ON digitalWrite (SOLAR_P4_RLY_R4, LOW); //ON digitalWrite (HP_HEAT_CALL_RLY_R5, HIGH); lcd.clear(); lcd.home (); // go home lcd.print(F("SOLAR -> BT")); lcd.setCursor(0,1); lcd.print(F("R3 & R4 ON")); custom_delay_5sec(); //Delay 5 sec. & Check for GAS START_T = (readSensor_F (BUFFER_tank_sensor)); START_T = 80; //debug for (I=0; I< 1; I++) //debug //for (I=0; I< 180; I++) //delay up to 30 min. before testing gain { custom_delay_5sec(); //Delay 5 sec. & Check for GAS BUFFER_tank_temp = (readSensor_F (BUFFER_tank_sensor)); BUFFER_tank_temp = 80; //debug lcd.clear(); lcd.home (); // go home lcd.print(F("BT Temp = ")); lcd.print(BUFFER_tank_temp); custom_delay_5sec(); //Delay 5 sec. & Check for GAS if ( BUFFER_tank_temp >= BUFFER_tank_target_temp ) {goto BT_HOT;} } //end delay loop NOW_T = (readSensor_F (BUFFER_tank_sensor)); NOW_T = 80; //debug FORCE DOWNSHIFT 1 if ( NOW_T > START_T ) //Gaining temp? { BT_DOWNSHIFT_BOOL1 = false; lcd.clear(); lcd.home (); // go home lcd.print(F("BT_SHIFT1=FALSE")); custom_delay_5sec(); //Delay 5 sec. & Check for GAS } else { BT_DOWNSHIFT_BOOL1 = true; lcd.clear(); lcd.home (); // go home lcd.print(F("BT_SHIFT1=TRUE")); custom_delay_5sec(); //Delay 5 sec. & Check for GAS } } //end if Solar Hot enough for Direct Heating //Is Solar Tank is hot enough to run HP -> BT //AND Is Downshift Bool2 false else if (( SOLAR_tank_temp >= Solar_lo_cntl_temp_pot ) && ( BT_DOWNSHIFT_BOOL2 == false )) { digitalWrite (BO_HEAT_CALL_RLY_R1, HIGH); digitalWrite (DHW_P2_RLY_R2, HIGH); digitalWrite (BT_P3_RLY_R3, LOW); //ON digitalWrite (SOLAR_P4_RLY_R4, HIGH); digitalWrite (HP_HEAT_CALL_RLY_R5, LOW); //HP ON lcd.clear(); lcd.home (); // go home lcd.print(F("HP -> BT")); lcd.setCursor(0,1); lcd.print(F("R3 & R5 ON")); custom_delay_5sec(); //Delay 5 sec. & Check for GAS START_T = (readSensor_F (BUFFER_tank_sensor)); START_T = 81; //debug //for (I=0; I< 180; I++) //delay up to 30 min. before testing gain for (I=0; I< 1; I++) //debug { custom_delay_5sec(); //Delay 5 sec. & Check for GAS custom_delay_5sec(); //Delay 5 sec. & Check for GAS // if (digitalRead(HP_ALIVE) == LOW) {goto BT_SHIFT2;} //debug BUFFER_tank_temp = (readSensor_F (BUFFER_tank_sensor)); BUFFER_tank_temp = 81; //debug lcd.clear(); lcd.home (); // go home lcd.print(F("BT Temp = ")); lcd.print(BUFFER_tank_temp); custom_delay_5sec(); //Delay 5 sec. & Check for GAS if ( BUFFER_tank_temp >= BUFFER_tank_target_temp ) {goto BT_HOT;} } //end delay loop NOW_T = (readSensor_F (BUFFER_tank_sensor)); NOW_T = 81; //debug FORCE DOWNSHIFT 2 if ( NOW_T > START_T ) //Gaining temp? { BT_DOWNSHIFT_BOOL2 = false; lcd.clear(); lcd.home (); // go home lcd.print(F("BT_SHIFT2=FALSE")); custom_delay_5sec(); //Delay 5 sec. & Check for GAS } else { BT_SHIFT2: BT_DOWNSHIFT_BOOL2 = true; lcd.clear(); lcd.home (); // go home lcd.print(F("BT_SHIFT2=TRUE")); custom_delay_5sec(); //Delay 5 sec. & Check for GAS } } //end if Solar Hot enough for HP -> BT } //end if SOLAR HP SKIP = OFF if ((SOLAR_HP_SKIP_BOOL == true) or ((BT_DOWNSHIFT_BOOL1 == true) && (BT_DOWNSHIFT_BOOL2 == true))) //Solar tank < minimum temp { // use boiler to heat Buffer Tank digitalWrite (BO_HEAT_CALL_RLY_R1, LOW); //turn on Boiler Heat Call R1 digitalWrite (DHW_P2_RLY_R2, HIGH); digitalWrite (BT_P3_RLY_R3, LOW); //ON digitalWrite (SOLAR_P4_RLY_R4, HIGH); digitalWrite (HP_HEAT_CALL_RLY_R5, HIGH); lcd.clear(); lcd.home (); // go home lcd.print(F("Boiler -> BT")); lcd.setCursor(0,1); lcd.print(F("R1 & R3 ON")); custom_delay_5sec(); //Delay 5 sec. & Check for GAS BUFFER_tank_temp = (readSensor_F (BUFFER_tank_sensor)); BUFFER_tank_temp = 90; //debug if ( BUFFER_tank_temp >= BUFFER_tank_target_temp ) {goto BT_HOT;} lcd.clear(); lcd.home (); // go home lcd.print(F("BT Temp = ")); lcd.print(BUFFER_tank_temp); custom_delay_5sec(); //Delay 5 sec. & Check for GAS } //end if Boiler -> Buffer Tank } while ( BUFFER_tank_temp < BUFFER_tank_target_temp ); } //end if BT Needs Heat BT_HOT: lcd.clear(); lcd.home (); // go home lcd.print(F("BT HOT ENOUGH")); custom_delay_5sec(); //Delay 5 sec. & Check for GAS BT_DOWNSHIFT_BOOL1 = false; BT_DOWNSHIFT_BOOL2 = false; digitalWrite (BO_HEAT_CALL_RLY_R1, HIGH); //turn off relays digitalWrite (DHW_P2_RLY_R2, HIGH); digitalWrite (BT_P3_RLY_R3, HIGH); digitalWrite (SOLAR_P4_RLY_R4, HIGH); digitalWrite (HP_HEAT_CALL_RLY_R5, HIGH); lcd.clear(); lcd.home (); // go home lcd.print(F("TurnOff all Rlys")); custom_delay_5sec(); //Delay 5 sec. & Check for GAS Serial.println(F("...................................")); } //end if Winter switch = true } //end forever loop Last edited by buffalobillpatrick; 08-04-14 at 01:10 PM.. |
08-04-14, 12:08 PM | #166 |
Master EcoRenovator
Join Date: Mar 2014
Location: Florissant, Colorado
Posts: 599
Thanks: 814
Thanked 59 Times in 55 Posts
|
Functions:
Code:
int readSensor_F (const byte which_sensor) { #define sample_cnt 100 float alpha = 0.9; // factor to tune float average = 0.0; int I; float steinhart; // resistance at 25 degrees C #define THERMISTORNOMINAL 10000 // temp. for nominal resistance (almost always 25 C) #define TEMPERATURENOMINAL 25 // The beta coefficient of the thermistor (usually 3000-4000) #define BCOEFFICIENT 3892 // the value of the series resistor #define SERIESRESISTOR 10000 digitalWrite (mux_enable, HIGH); //disable delay(10); // select correct MUX channel digitalWrite (mux_address_A, (which_sensor & 1) ? HIGH : LOW); digitalWrite (mux_address_B, (which_sensor & 2) ? HIGH : LOW); digitalWrite (mux_address_C, (which_sensor & 4) ? HIGH : LOW); digitalWrite (mux_address_D, (which_sensor & 8) ? HIGH : LOW); digitalWrite (mux_enable, LOW); //enable delay(10); for (I=0; I< sample_cnt; I++) { average = alpha * analogRead(mux_analog_in) + (1-alpha) * average; delay(10); } // convert the value to resistance average = 1023 / average - 1; average = SERIESRESISTOR / average; steinhart = average / THERMISTORNOMINAL; // (R/Ro) steinhart = log(steinhart); // ln(R/Ro) steinhart /= BCOEFFICIENT; // 1/B * ln(R/Ro) steinhart += 1.0 / (TEMPERATURENOMINAL + 273.15); // + (1/To) steinhart = 1.0 / steinhart; // Invert steinhart -= 273.15; // convert to C return (round(steinhart * 1.8) + 32); // round to whole number // & convert to F } // end of readSensor_F void custom_delay_5sec (void) //Delay 5 sec. & Check for GAS // If so, RESETS RLYS, Sets ALARM, & HANGS FOREVER { int I; //T1 = millis(); //This takes 1.8us delay(3965); //Test if GAS LIMIT EXCEEDED sensor_data = (readSensor_F (MQ2_GAS_sensor)); sensor_data = map(sensor_data, 0, 1023, 0, 100); if (sensor_data > GAS_LIMIT) { digitalWrite (BO_HEAT_CALL_RLY_R1, HIGH); //turn off relays digitalWrite (DHW_P2_RLY_R2, HIGH); digitalWrite (BT_P3_RLY_R3, HIGH); digitalWrite (SOLAR_P4_RLY_R4, HIGH); digitalWrite (HP_HEAT_CALL_RLY_R5, HIGH); lcd.clear(); lcd.home (); // go home lcd.print(F("GAS LIMIT MET")); lcd.setCursor(0,1); lcd.print(F("TurnOff all Rlys")); delay(5000); lcd.clear(); lcd.home (); // go home lcd.print(F("HANG FOREVER")); do{ beep(200);} while (I == I); //hang } //end if GAS LIMIT /* T2 = millis(); TT = T2 - T1; lcd.clear(); lcd.home (); // go home lcd.print(TT); // 5 sec delay(10000); */ } //end custom_delay function void beep(unsigned char delayms) { analogWrite(ALARM, 255); // Almost any value can be used except 0 // experiment to get the best tone delay(delayms); // wait for a delayms ms analogWrite(ALARM, 0); // 0 turns it off delay(delayms); // wait for a delayms ms } Last edited by buffalobillpatrick; 08-11-14 at 12:06 PM.. |
08-06-14, 12:19 PM | #167 |
Supreme EcoRenovator
Join Date: Mar 2009
Location: Portland, OR
Posts: 4,004
Thanks: 303
Thanked 723 Times in 534 Posts
|
Hey BBP,
I'm not sure just how your heat pump controller setup is arranged. I believe you indicated that you have three Uno's working together, is that right? But I don't know which is doing what, and how are they co-ordinated. Do you have some kind of top level diagram that explains your setup? -AC
__________________
I'm not an HVAC technician. In fact, I'm barely even a hacker... |
08-06-14, 01:16 PM | #168 |
Master EcoRenovator
Join Date: Mar 2014
Location: Florissant, Colorado
Posts: 599
Thanks: 814
Thanked 59 Times in 55 Posts
|
2 Arduinos in Heating system. (I play with more)
Master powers up Slave HP Controller via R5 when HP is needed, or powers off Slave when not. Slave tells Master that it is powered on & functioning via "HP ALIVE Signal" which is active within 10 seconds of its Power On. This is done in Slave by energizing ALIVE_RLY_R1 via its pin D4 The Slave frequently calls its custom_delay function, which: Delays 5 sec. & Checks Source Out water temperature & GAS Level inside HP If GAS LIMIT is EXCEEDED, then Audible Alarm is activated & ALIVE_RLY_R1 is reset via pin D4. or if Source out is too cold to run HP, then ALIVE_RLY_R1 is reset via pin D4. The Master reads this "HP ALIVE Signal" on its pin D12 in its code after powering On Slave if "HP ALIVE Signal" is found to be "OFF" then the Master powers off Slave by de-energizing R5 and "Downshifts" from using HP to using Boiler. Last edited by buffalobillpatrick; 08-06-14 at 01:23 PM.. |
The Following User Says Thank You to buffalobillpatrick For This Useful Post: | AC_Hacker (08-06-14) |
08-07-14, 11:18 AM | #169 |
Supreme EcoRenovator
Join Date: Mar 2009
Location: Portland, OR
Posts: 4,004
Thanks: 303
Thanked 723 Times in 534 Posts
|
Arduino Duo Clone
Just to make sure I'm working within the bounds of a cheap DIY heat pump controller, I bought the cheapest Arduino Uno clone that I could find.
I got mine HERE, for $6.94, free shipping. There are plenty of other choices at similar prices. This photo compare it to my older Arduino (right), but I compared it to a diagram of a real Uno, and it compares favorably, but maybe with a few improvements... The clone has a row of plated-through holes that are inboard of the shield-mounting sockets. These holes could make it handy to attach leads to and from analog & digital I/O devices. The reset switch has been locate to the edge of the board, very handy, plated-through holes are available for a serial hookup. When I hooked the clone to my PC, I got a message that a driver was required, and the automatic driver search for failed. Then I thrashed about on the Internet until I finally found one HERE. The ZIP contains some bizarre Chinese utility that I couldn't figure out, but there is a folder that does do the job. I juat attempted to upload just the correct utility, but it exceeded the meager allotment of bytes (sorry guys). Anyway, the driver worked, even on my Win7_64 system, and I'm off & running. I tried loading up Ko_deZ Heat Pump Controller sketch, and all seems well. Now, on to some real software... -AC
__________________
I'm not an HVAC technician. In fact, I'm barely even a hacker... |
The Following User Says Thank You to AC_Hacker For This Useful Post: | buffalobillpatrick (08-11-14) |
08-09-14, 01:09 PM | #170 |
Supreme EcoRenovator
Join Date: Mar 2009
Location: Portland, OR
Posts: 4,004
Thanks: 303
Thanked 723 Times in 534 Posts
|
LCD-button display is working...
I thrashed around trying to get the LCD-button display working, and it wouldn't...
So I downloaded the newest stable Arduino IDE, and tried again and everything is working just fine. It was easier getting the display to work than it was taking a photo of the working display. Seems to have something to do with polarized light, because I had to take this photo through the lense of some polarizing sunglasses, with the lens rotated "just so" in order for the characters to show up properly. To the eye, the characters are quite nice and visible and very easy to read. * * * So jeff5may, it's time to start working with the menu software you cooked up. Can you just drop it into a "CODE" window here in the thread?? -AC
__________________
I'm not an HVAC technician. In fact, I'm barely even a hacker... |
The Following User Says Thank You to AC_Hacker For This Useful Post: | buffalobillpatrick (08-11-14) |
|
|