08-15-14, 01:42 PM | #201 |
Master EcoRenovator
Join Date: Mar 2014
Location: Florissant, Colorado
Posts: 599
Thanks: 814
Thanked 59 Times in 55 Posts
|
I don't mean to step on toes!
Only way I can understand someones code is to start messing with it. My changes: some time names & blocking_delay >= on delays Check my changes for being correct? Ormston_Rev02 Code:
#include <Thermistor.h> //Got tired of counting zeros #define One_Sec 1000 #define Half_Min 30000 #define One_Min 60000 #define Two_Min 120000 #define Five_Min 300000 #define Ten_Min 600000 #define Thirty_Min 1800000 double evaporator, condensor; //Variables for temperatures from thermistors float HpLPM; //Flow rate from flow meter in L/m float HpLPM1; //Flow rate from flow meter in L/m int minLPM = 3; //Minimum flowrate to run HP int minEv = 2; //Minimum evaporator temp int maxCon = 65; //Maximum condensor temp byte runHP = false; byte runCompressor = false; byte runOutPump = false; // pump to circulate water to house/tank byte runInPump = false; //fan in case of ASHP const int demandPin = 4; // input connected to external thermostat to request heat byte demand = false; // variable for reading if heat required from thermostat unsigned long blocking_Time; // Delay Time unsigned long hpStart_Time; // Time HP cycle started unsigned long hpStop_Time; // Time HP cycle stopped volatile int NbTopsFan; //measuring the rising edges of the signal volatile int NbTopsFan1; //measuring the rising edges of the signal int hallsensor = 2; //The pin location of the sensor int hallsensor1 = 3; //The pin location of the sensor byte led = 13; byte ledState = false; byte comp = 5; byte inPump = 6; byte outPump = 7; unsigned long prevMillis = 0; //used for led blinking Thermistor temp(0); Thermistor temp1(1); // ********************Temperature measurement starts here************** void readTemps() { //read all temperatures from thermistors evaporator = temp.getTemp(); condensor = temp1.getTemp(); } // ********************Temperature measurement ends here************** // ********************Flow meter reading starts here************** void hpFlow () //This is the function that the interupt calls { NbTopsFan++; //This function measures the rising and falling edge of the hall effect sensors signal } void hpFlow1 () //This is the function that the interupt calls { NbTopsFan1++; //This function measures the rising and falling edge of the hall effect sensors signal } void readFlows() { NbTopsFan = 0; //Set NbTops to 0 ready for calculations NbTopsFan1 = 0; //Set NbTops to 0 ready for calculations interrupts(); //Enables interrupts delay (One_Sec); //Wait 1 second noInterrupts(); //Disable interrupts HpLPM = (NbTopsFan / 2.75); HpLPM = (NbTopsFan1 / 2.75); } // ********************Flow meter reading ends here************** void setup() { pinMode(hallsensor, INPUT); //initializes digital pin 2 as an input pinMode(hallsensor1, INPUT); //initializes digital pin 3 as an input attachInterrupt(0, hpFlow, RISING); //and the interrupt is attached (1 for Leonardo 0 for mega/uno) attachInterrupt(1, hpFlow1, RISING); //and the interrupt is attached (0 for Leonardo 1 for mega/uno) pinMode(led, OUTPUT); pinMode(comp, OUTPUT); pinMode(inPump, OUTPUT); pinMode(outPump, OUTPUT); pinMode(demandPin, INPUT); blocking_Time = millis(); } void loop() { readTemps(); readFlows(); demand = digitalRead(demandPin); unsigned long current_Time = millis(); if ((demand == true) && (blocking_Time >= (current_Time - Two_Min))) //Wait 2 min. { if (runHP == false) hpStart_Time = current_Time; runHP = true; } else { if (runHP == true) hpStop_Time = current_Time; runHP = false; } //*****HP startup cycle******** if (runHP == true) runInPump = true; if ((runHP == true) && (hpStart_Time >= (current_Time - Half_Min) //Delay compressor start 30s && (HpLPM > minLPM))) //after starting in pump runCompressor = true; if ((runHP == true) && (hpStart_Time >= (current_Time - One_Min))) { runOutPump = true; //Delay out pump start 60s after starting in pump ledState = true; ///turn on pin 13 led after startup of HP } //*****HP shutdown cycle******** if (runHP == false) runCompressor = false; if ((runHP == false) && (hpStop_Time >= (current_Time - Two_Min))) runInPump = false; if ((runHP == false) && (hpStop_Time >= (current_Time - Five_Min))) //delay 5 min. { runOutPump = false; blocking_Time = current_Time; ledState = false; //turn off pin 13 led after shutdown of HP } //***Check flow rates above min*** if (HpLPM < minLPM || HpLPM1 < minLPM) { runCompressor = false; if (runHP == true) hpStop_Time = current_Time; blocking_Time = (current_Time + Ten_Min); //prevent cycle restart for 10m runHP = false; } //***Check evaporator/condensor above/below limits*** // not intended for defrost purposes, halts system for 30m if (evaporator < minEv || condensor > maxCon) { runCompressor = false; if (runHP == true) hpStop_Time = current_Time; blocking_Time = (current_Time + Thirty_Min); //prevent cycle restart for 30m runHP = false; } digitalWrite(led, ledState); digitalWrite(comp, runCompressor); digitalWrite(inPump, runInPump); digitalWrite(outPump, runOutPump); } Last edited by buffalobillpatrick; 08-15-14 at 02:21 PM.. |
08-15-14, 02:15 PM | #202 |
Master EcoRenovator
Join Date: Mar 2014
Location: Florissant, Colorado
Posts: 599
Thanks: 814
Thanked 59 Times in 55 Posts
|
Added: Read_10K_NTC_C
guessed at A0 & A1 for evap & cond input pins, change as required Ormston_Rev03 Code:
//Got tired of counting zeros #define One_Sec 1000 #define Half_Min 30000 #define One_Min 60000 #define Two_Min 120000 #define Five_Min 300000 #define Ten_Min 600000 #define Thirty_Min 1800000 #define evap_Sensor A0 //??? #define cond_Sensor A1 int evap_Temp, cond_Temp; //Variables for temperatures from thermistors float HpLPM; //Flow rate from flow meter in L/m float HpLPM1; //Flow rate from flow meter in L/m int minLPM = 3; //Minimum flowrate to run HP int minEv = 2; //Minimum evaporator temp int maxCon = 65; //Maximum condensor temp byte runHP = false; byte runCompressor = false; byte runOutPump = false; // pump to circulate water to house/tank byte runInPump = false; //fan in case of ASHP const int demandPin = 4; // input connected to external thermostat to request heat byte demand = false; // variable for reading if heat required from thermostat unsigned long blocking_Time; // Delay Time unsigned long hpStart_Time; // Time HP cycle started unsigned long hpStop_Time; // Time HP cycle stopped volatile int NbTopsFan; //measuring the rising edges of the signal volatile int NbTopsFan1; //measuring the rising edges of the signal int hallsensor = 2; //The pin location of the sensor int hallsensor1 = 3; //The pin location of the sensor byte led = 13; byte ledState = false; byte comp = 5; byte inPump = 6; byte outPump = 7; unsigned long prevMillis = 0; //used for led blinking // ********************Temperature measurement starts here************** void readTemps() { //read all temperatures from thermistors in C evap_Temp = (Read_10K_NTC_C (evap_Sensor)); cond_Temp = (Read_10K_NTC_C (cond_Sensor)); } // ********************Temperature measurement ends here************** // ********************Flow meter reading starts here************** void hpFlow () //This is the function that the interupt calls { NbTopsFan++; //This function measures the rising and falling edge of the hall effect sensors signal } void hpFlow1 () //This is the function that the interupt calls { NbTopsFan1++; //This function measures the rising and falling edge of the hall effect sensors signal } void readFlows() { NbTopsFan = 0; //Set NbTops to 0 ready for calculations NbTopsFan1 = 0; //Set NbTops to 0 ready for calculations interrupts(); //Enables interrupts delay (One_Sec); //Wait 1 second noInterrupts(); //Disable interrupts HpLPM = (NbTopsFan / 2.75); HpLPM = (NbTopsFan1 / 2.75); } // ********************Flow meter reading ends here************** int Read_10K_NTC_C (int which_sensor) { #define sample_cnt 30 float alpha = 0.9; // factor to tune float average = 0.0; float steinhart; int I; // 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 for (I=0; I< sample_cnt; I++) { average = alpha * analogRead(which_sensor) + (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 return (round(steinhart)); // round to whole number, return int } // end of Read_10K_NTC void setup() { pinMode(evap_Sensor, INPUT); //init pinMode(cond_Sensor, INPUT); //init pinMode(hallsensor, INPUT); //initializes digital pin 2 as an input pinMode(hallsensor1, INPUT); //initializes digital pin 3 as an input attachInterrupt(0, hpFlow, RISING); //and the interrupt is attached (1 for Leonardo 0 for mega/uno) attachInterrupt(1, hpFlow1, RISING); //and the interrupt is attached (0 for Leonardo 1 for mega/uno) pinMode(led, OUTPUT); pinMode(comp, OUTPUT); pinMode(inPump, OUTPUT); pinMode(outPump, OUTPUT); pinMode(demandPin, INPUT); blocking_Time = millis(); } void loop() { readTemps(); readFlows(); demand = digitalRead(demandPin); unsigned long current_Time = millis(); if ((demand == true) && (blocking_Time >= (current_Time - Two_Min))) //Wait 2 min. { if (runHP == false) hpStart_Time = current_Time; runHP = true; } else { if (runHP == true) hpStop_Time = current_Time; runHP = false; } //*****HP startup cycle******** if (runHP == true) runInPump = true; if ((runHP == true) && (hpStart_Time >= (current_Time - Half_Min) //Delay compressor start 30s && (HpLPM > minLPM))) //after starting in pump runCompressor = true; if ((runHP == true) && (hpStart_Time >= (current_Time - One_Min))) { runOutPump = true; //Delay out pump start 60s after starting in pump ledState = true; ///turn on pin 13 led after startup of HP } //*****HP shutdown cycle******** if (runHP == false) runCompressor = false; if ((runHP == false) && (hpStop_Time >= (current_Time - Two_Min))) runInPump = false; if ((runHP == false) && (hpStop_Time >= (current_Time - Five_Min))) //delay 5 min. { runOutPump = false; blocking_Time = current_Time; ledState = false; //turn off pin 13 led after shutdown of HP } //***Check flow rates above min*** if (HpLPM < minLPM || HpLPM1 < minLPM) { runCompressor = false; if (runHP == true) hpStop_Time = current_Time; blocking_Time = (current_Time + Ten_Min); //prevent cycle restart for 10m runHP = false; } //***Check evaporator/condensor above/below limits*** // not intended for defrost purposes, halts system for 30m if (evap_Temp < minEv || cond_Temp > maxCon) { runCompressor = false; if (runHP == true) hpStop_Time = current_Time; blocking_Time = (current_Time + Thirty_Min); //prevent cycle restart for 30m runHP = false; } digitalWrite(led, ledState); digitalWrite(comp, runCompressor); digitalWrite(inPump, runInPump); digitalWrite(outPump, runOutPump); } Last edited by buffalobillpatrick; 08-15-14 at 02:23 PM.. |
08-15-14, 04:50 PM | #203 | |
Supreme EcoRenovator
Join Date: Mar 2009
Location: Portland, OR
Posts: 4,004
Thanks: 303
Thanked 724 Times in 534 Posts
|
Quote:
Just loaded & compiled Ormston_Rev03. Compiles just fine. I still don't have Thermistors hooked up, or anything else but power. I'm not seeing any signs of life... maybe that's a good thing. -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-16-14) |
08-15-14, 05:08 PM | #204 |
Supreme EcoRenovator
Join Date: Mar 2009
Location: Portland, OR
Posts: 4,004
Thanks: 303
Thanked 724 Times in 534 Posts
|
I think I spoke too soon...
I didn't watch long enough. After reset, I see a quiescent period of 2 minutes, which is good. Then I see SSR 3 come on continuously I also see SSR 2 come on at regular intervals of about 1 second on, 3 seconds off. As I write, I'm now seeing both SSRs come on at regular intervals of about 1 second on, 3 seconds off. There may have been other pattern, but I was busy typing... * * * Ormston, What kind of connections do you have for your flow meters?? I went by some of our larger supply houses, and couldn't find anything. Best, -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-16-14) |
08-15-14, 07:01 PM | #205 | |
Apprentice EcoRenovator
Join Date: Mar 2013
Location: UK
Posts: 131
Thanks: 13
Thanked 35 Times in 32 Posts
|
Quote:
Parallel thread but seems to seal with plenty of PTFE tape. My flow sensor is now completely dead, was installed last Oct/Nov so not very reliable. Steve |
|
The Following User Says Thank You to Ormston For This Useful Post: | buffalobillpatrick (08-16-14) |
08-15-14, 07:39 PM | #206 |
Supreme EcoRenovator
Join Date: Mar 2009
Location: Portland, OR
Posts: 4,004
Thanks: 303
Thanked 724 Times in 534 Posts
|
What are the brass connectors that attach directly to the sensor called?
__________________
I'm not an HVAC technician. In fact, I'm barely even a hacker... |
08-15-14, 09:57 PM | #207 | |
Banned
Join Date: Aug 2014
Location: US
Posts: 150
Thanks: 7
Thanked 5 Times in 5 Posts
|
Quote:
The o-ring also acts as a spring to keep the thread under tension so it doesn't vibrate loose. Go to a small hardware store and hand-fit an o-ring from their selection. Home Depot/Lowe's would not have o-rings by the piece like this. |
|
The Following User Says Thank You to ICanHas For This Useful Post: | buffalobillpatrick (08-16-14) |
08-16-14, 02:44 PM | #208 | |
Supreme EcoRenovator
Join Date: Mar 2009
Location: Portland, OR
Posts: 4,004
Thanks: 303
Thanked 724 Times in 534 Posts
|
Quote:
The thread is BSP as you said, which is extraordinarily hard to find in the US. I've come to the conclusion that the fitting, and the way it seals, with the two smoothly machined faces separated by a gasket, is really a good system, but it doesn't seem to be employed in the US. Mikesolar made some very relevant posts HERE, and HERE, that have given me sufficient information to find out just how difficult it is to get these parts, here in the land of the free, home of the brave, blah, blah, blah. On your joint, I think that you could have eliminated part "C", and just connected "B" directly to your sensor with a proper gasket to seal between the parallel flat faces of your sensor and what ever it was that allowed pipe "A" to be tightened down with nut "B". But anyway if the failure rate you are experiencing is typical, it really makes me wonder... I did find an ultrasonic flowsensor HERE that does look very interesting, no moving parts, it also looks like minimum flow restriction, but the cost might be brutal. More later... -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-16-14) |
08-16-14, 02:58 PM | #209 |
Supreme EcoRenovator
Join Date: Mar 2009
Location: Portland, OR
Posts: 4,004
Thanks: 303
Thanked 724 Times in 534 Posts
|
BBP,
I loaded your monster code (combined all 5 parts) into the Arduino simulator, and after I gave it "LCD.h", it just started chugging away with no errors that I could see. Probably no surprise to you... -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-16-14) |
08-16-14, 03:06 PM | #210 | |
Apprentice EcoRenovator
Join Date: Mar 2013
Location: UK
Posts: 131
Thanks: 13
Thanked 35 Times in 32 Posts
|
Quote:
A is 22mm copper pipe (metric equivalent or 3/4 though not sure how close in size they are), it sits inside B/C with an olive as a seal(compression fitting). Known as a 3/4 female iron. BSP - F/I - Female Iron - Straight Compression Fitting | eBay |
|
The Following 2 Users Say Thank You to Ormston For This Useful Post: |
|
|