10-23-14, 07:10 PM | #11 |
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.. |
|
|