EcoRenovator  

Go Back   EcoRenovator > Improvements > Geothermal & Heat Pumps
Advanced Search
 


Blog 60+ Home Energy Saving Tips Recent Posts


Reply
 
Thread Tools Display Modes
Old 10-23-14, 07:10 PM   #261
buffalobillpatrick
Master EcoRenovator
 
Join Date: Mar 2014
Location: Florissant, Colorado
Posts: 599
Thanks: 814
Thanked 59 Times in 55 Posts
Default

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..
buffalobillpatrick is offline   Reply With Quote
Old 10-23-14, 07:21 PM   #262
buffalobillpatrick
Master EcoRenovator
 
Join Date: Mar 2014
Location: Florissant, Colorado
Posts: 599
Thanks: 814
Thanked 59 Times in 55 Posts
Default

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?
buffalobillpatrick is offline   Reply With Quote
Old 10-23-14, 07:56 PM   #263
jeff5may
Supreme EcoRenovator
 
Join Date: Jan 2010
Location: elizabethtown, ky, USA
Posts: 2,431
Thanks: 431
Thanked 619 Times in 517 Posts
Send a message via Yahoo to jeff5may
Default

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..
jeff5may is offline   Reply With Quote
The Following User Says Thank You to jeff5may For This Useful Post:
buffalobillpatrick (10-24-14)
Old 10-23-14, 11:59 PM   #264
buffalobillpatrick
Master EcoRenovator
 
Join Date: Mar 2014
Location: Florissant, Colorado
Posts: 599
Thanks: 814
Thanked 59 Times in 55 Posts
Default

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..
buffalobillpatrick is offline   Reply With Quote
Old 10-24-14, 09:45 AM   #265
AC_Hacker
Supreme EcoRenovator
 
AC_Hacker's Avatar
 
Join Date: Mar 2009
Location: Portland, OR
Posts: 4,004
Thanks: 303
Thanked 724 Times in 534 Posts
Default

Quote:
Originally Posted by buffalobillpatrick View Post
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?
The reason to delay pump shutdown is to get the last few BTUs from each system heating cycle.

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...
AC_Hacker is offline   Reply With Quote
The Following User Says Thank You to AC_Hacker For This Useful Post:
buffalobillpatrick (10-24-14)
Old 10-24-14, 09:48 AM   #266
AC_Hacker
Supreme EcoRenovator
 
AC_Hacker's Avatar
 
Join Date: Mar 2009
Location: Portland, OR
Posts: 4,004
Thanks: 303
Thanked 724 Times in 534 Posts
Default

Quote:
Originally Posted by buffalobillpatrick View Post
Whew! took hours, lots of stuff don't work in a ISR (Interrupt Service Routine)
delay(x) , lcd.print, &
biggest pain was...
Do you have any kind of physical simulator test fixture?

-AC
__________________
I'm not an HVAC technician. In fact, I'm barely even a hacker...
AC_Hacker is offline   Reply With Quote
Old 10-24-14, 11:32 AM   #267
buffalobillpatrick
Master EcoRenovator
 
Join Date: Mar 2014
Location: Florissant, Colorado
Posts: 599
Thanks: 814
Thanked 59 Times in 55 Posts
Default

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;}
  }
Compiler must think "that don't make no kinda sense" why would anyone want to do this.

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..
buffalobillpatrick is offline   Reply With Quote
Old 10-24-14, 11:49 AM   #268
jeff5may
Supreme EcoRenovator
 
Join Date: Jan 2010
Location: elizabethtown, ky, USA
Posts: 2,431
Thanks: 431
Thanked 619 Times in 517 Posts
Send a message via Yahoo to jeff5may
Default

Quote:
Originally Posted by buffalobillpatrick View Post
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?
Always try to run the evaporator side pump for a minute or two after the compressor stops. This way you will have eliminated any chance of the residual refrigerant freezing the hx as it peters out. A lot can happen in a few minutes.

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.
jeff5may is offline   Reply With Quote
The Following User Says Thank You to jeff5may For This Useful Post:
buffalobillpatrick (10-24-14)
Old 10-24-14, 12:06 PM   #269
buffalobillpatrick
Master EcoRenovator
 
Join Date: Mar 2014
Location: Florissant, Colorado
Posts: 599
Thanks: 814
Thanked 59 Times in 55 Posts
Default

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..
buffalobillpatrick is offline   Reply With Quote
Old 10-24-14, 12:37 PM   #270
buffalobillpatrick
Master EcoRenovator
 
Join Date: Mar 2014
Location: Florissant, Colorado
Posts: 599
Thanks: 814
Thanked 59 Times in 55 Posts
Default

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..
buffalobillpatrick is offline   Reply With Quote
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 08:23 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Ad Management by RedTyger
Inactive Reminders By Icora Web Design