EcoRenovator  

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


Blog 60+ Home Energy Saving Tips Recent Posts


 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 10-23-14, 07:10 PM   #11
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
 



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 02:13 AM.


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