10-23-14, 07:10 PM | #261 |
Master EcoRenovator
Join Date: Mar 2014
Location: Florissant, Colorado
Posts: 599
Thanks: 814
Thanked 59 Times in 55 Posts
|
Whew! took hours, lots of stuff don't work in a ISR (Interrupt Service Routine)
delay(x) , lcd.print, & biggest pain was Compiler was optimizing out various "delay for loops" that I tried, even with index declaired volatile. I wanted about 30 sec. delay between Compressor off & water pumps off. analogRead didn't optimize out! This WORKS! Code:
//done in setup: attachInterrupt(1, Stop_Compressor_ISR, RISING);// Attach Interrupt // (IRQ1 is on Digital Pin 3) Pin 3 going high (+) sets Interrupt 1 // This is Master signal to STOP HP Compressor, by denergizing R3 // with a short power cycle to Solar pump, which picks a relay // N/O point connects Arduino +5v to Digital Pin 3 // Digital Pin 3 has a 10K pulldown resistor to Gnd. // This allows the water pumps to continue after Compressor is off // After a delay the master will power off this Slave Arduino // This would be a normal ending sequence for HP satisfying Load void Stop_Compressor_ISR() { //#define Max_Long_int_number 2147483647 #define Big_number 250000 long Z; int Y; detachInterrupt(1); digitalWrite (HP_RLY_R3, HIGH); //Compressor OFF for (Z = 0; Z < Big_number; Z++) {analogRead(1);} //delay about 30 sec. digitalWrite (HP_RLY_R2, HIGH); //Pumps OFF digitalWrite (ALIVE_RLY_R1, HIGH); //Alive OFF do{Y = Y;} while (Y == Y); //hang forever } Last edited by buffalobillpatrick; 10-23-14 at 07:30 PM.. |
10-23-14, 07:21 PM | #262 |
Master EcoRenovator
Join Date: Mar 2014
Location: Florissant, Colorado
Posts: 599
Thanks: 814
Thanked 59 Times in 55 Posts
|
Question:
If a water pump does stop working while HP is running, what is best sequence for shutting down? Turn off Compressor & pumps together OR Compressor 1st & then delay before turning off pumps? |
10-23-14, 07:56 PM | #263 |
Supreme EcoRenovator
|
Oh no. What? Whoa...
This is why I am trying to stay away from interrupt and library calls. God save your soul. Last edited by jeff5may; 10-23-14 at 08:01 PM.. |
The Following User Says Thank You to jeff5may For This Useful Post: | buffalobillpatrick (10-24-14) |
10-23-14, 11:59 PM | #264 |
Master EcoRenovator
Join Date: Mar 2014
Location: Florissant, Colorado
Posts: 599
Thanks: 814
Thanked 59 Times in 55 Posts
|
Hard to figure out when code looks correct & compiles, but just acts like No-ops.
From Nick Gammon, an Oz Arduino expert: "The compiler optimizes, that is well-known. Variables shared between an ISR and "main" code should be declared volatile. Attempts to make loops by doing something with non-volatile variables are frequently optimized away." Last edited by buffalobillpatrick; 10-24-14 at 12:40 AM.. |
10-24-14, 09:45 AM | #265 | |
Supreme EcoRenovator
Join Date: Mar 2009
Location: Portland, OR
Posts: 4,004
Thanks: 303
Thanked 724 Times in 534 Posts
|
Quote:
In my opinion, having a water pump fail is an emergency condition. Of course shut down the compressor first, then whether you allow the pumps to run on a bit longer or not is of little consequence, because your heating system will be going down until the failed pump is remedied or replaced. -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 (10-24-14) |
10-24-14, 09:48 AM | #266 | |
Supreme EcoRenovator
Join Date: Mar 2009
Location: Portland, OR
Posts: 4,004
Thanks: 303
Thanked 724 Times in 534 Posts
|
Quote:
-AC
__________________
I'm not an HVAC technician. In fact, I'm barely even a hacker... |
|
10-24-14, 11:32 AM | #267 |
Master EcoRenovator
Join Date: Mar 2014
Location: Florissant, Colorado
Posts: 599
Thanks: 814
Thanked 59 Times in 55 Posts
|
A/C Thanks, No on physical simulator test fixture.
In example, this compiles but don't work (no delay) even though Z & Y are not sharred outside this ISR Code:
#define Big_number 500000 long Z; long Y; for (Z = 0; Z < Big_number; Z++) { for (Y = 0; Y < 10000; Y++) {Z = Z;} } This however works (delays) volatile is key here, even though Z & Y are not sharred outside this ISR Code:
#define Big_number 500000 volatile long Z; volatile long Y; for (Z = 0; Z < Big_number; Z++) { for (Y = 0; Y < 10000; Y++) {Z = Z;} } Last edited by buffalobillpatrick; 10-24-14 at 01:25 PM.. |
10-24-14, 11:49 AM | #268 | |
Supreme EcoRenovator
|
Quote:
The condenser hx is not as important. However, having the pump run as well will reduce the high side pressure and pinch off the residual flow faster. |
|
The Following User Says Thank You to jeff5may For This Useful Post: | buffalobillpatrick (10-24-14) |
10-24-14, 12:06 PM | #269 |
Master EcoRenovator
Join Date: Mar 2014
Location: Florissant, Colorado
Posts: 599
Thanks: 814
Thanked 59 Times in 55 Posts
|
Rewrite of estimate_COP to make it easier to understand & relate to Climatemaster graph
I would rather try to closely estimate COP, than to use trouble prone flow sensors. Code:
// COP estimation // http://www.climatemaster.com/downloads/RP881.pdf // p19 graph for model TMW036 W/W float estimate_COP (void) { int cop; int ESWT; int ELWT; int DELTA_T; float COP; ESWT = (Read_10K_NTC (SOURCE_IN_sensor)); lcd.clear(); lcd.home (); // go home lcd.print(F("ESWT=")); lcd.print(ESWT); custom_delay(); //Delay 5 sec. & Checks Water SRC OUT ELWT = (Read_10K_NTC (LOAD_IN_sensor)); lcd.clear(); lcd.home (); // go home lcd.print(F("ELWT=")); lcd.print(ELWT); custom_delay(); //Delay 5 sec. & Checks Water SRC OUT if (ESWT > ELWT) //if source is hotter than load { cop = 80; //force high COP } else { DELTA_T = ELWT - ESWT; lcd.clear(); lcd.home (); // go home lcd.print(F("DELTA_T=")); lcd.print(DELTA_T); custom_delay(); //Delay 5 sec. & Checks Water SRC OUT if (ELWT <= 70) //don't use constrain so graph lines on //Climatemaster graph in Fig 2-11 p19 //can be interpolated past ends //by map function, which only works on whole ints, not floats { cop = map(DELTA_T, 10, 50, 73, 44); } else if (ELWT <= 75) { cop = map(DELTA_T, 15, 55, 69, 41); } else if (ELWT <= 80) { cop = map(DELTA_T, 20, 60, 65, 38); //this maps the top blue line // on graph } else if (ELWT <= 85) { cop = map(DELTA_T, 25, 65, 61, 36); } else if (ELWT <= 90) { cop = map(DELTA_T, 30, 70, 57, 33); } else if (ELWT <= 95) { cop = map(DELTA_T, 35, 75, 53, 30); } else if (ELWT <= 100) { cop = map(DELTA_T, 40, 80, 49, 28); //this maps the middle red line //on graph } else if (ELWT <= 105) { cop = map(DELTA_T, 45, 85, 46, 26); } else if (ELWT <= 110) { cop = map(DELTA_T, 50, 90, 43, 25); } else if (ELWT <= 115) { cop = map(DELTA_T, 55, 95, 40, 23); } else if (ELWT <= 120) { cop = map(DELTA_T, 60, 100, 37, 22); //this maps the bottom green line //on graph } else if (ELWT <= 125) { cop = map(DELTA_T, 65, 105, 34, 21); } else {STOP();} } COP = cop / 10.0; return (COP); } Last edited by buffalobillpatrick; 10-24-14 at 12:45 PM.. |
10-24-14, 12:37 PM | #270 |
Master EcoRenovator
Join Date: Mar 2014
Location: Florissant, Colorado
Posts: 599
Thanks: 814
Thanked 59 Times in 55 Posts
|
I'm doing this "esoteric" master quick pulse of Solar tank pump to cause Int 1
because I'm out of pins on Master Arduino, and the AC power line for Solar pump will run between house & shop where this Slave Adruino will reside. In any case I think that using Int 1 as a quick way to Shut Down of HP from remote Master on "Normal HP satisfying Load" OR "Downshifting to boiler" is the best way. Last edited by buffalobillpatrick; 10-24-14 at 01:03 PM.. |
|
|