EcoRenovator  

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


Blog 60+ Home Energy Saving Tips Recent Posts Search Today's Posts Mark Forums Read


Reply
 
Thread Tools Display Modes
Old 08-15-14, 12:42 PM   #201
buffalobillpatrick
Master EcoRenovator
 
Join Date: Mar 2014
Location: Florissant, Colorado
Posts: 599
Thanks: 814
Thanked 59 Times in 55 Posts
Default

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

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 01:23 PM..
buffalobillpatrick is offline   Reply With Quote
Old 08-15-14, 03:50 PM   #203
AC_Hacker
Supreme EcoRenovator
 
AC_Hacker's Avatar
 
Join Date: Mar 2009
Location: Portland, OR
Posts: 4,004
Thanks: 303
Thanked 723 Times in 534 Posts
Default

Quote:
Originally Posted by buffalobillpatrick View Post
Added: Read_10K_NTC_C
guessed at A0 & A1 for evap & cond input pins, change as required

Ormston_Rev03
PPB,

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

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...
AC_Hacker is offline   Reply With Quote
The Following User Says Thank You to AC_Hacker For This Useful Post:
buffalobillpatrick (08-16-14)
Old 08-15-14, 06:01 PM   #205
Ormston
Apprentice EcoRenovator
 
Join Date: Mar 2013
Location: UK
Posts: 131
Thanks: 13
Thanked 35 Times in 32 Posts
Default

Quote:
Originally Posted by AC_Hacker View Post

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
This is my setup, 3/4" version and I'm sure it's 3/4 BSP.
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
Attached Thumbnails
Click image for larger version

Name:	IMG_20140815_233842760.jpg
Views:	455
Size:	251.3 KB
ID:	4563  
Ormston is offline   Reply With Quote
The Following User Says Thank You to Ormston For This Useful Post:
buffalobillpatrick (08-16-14)
Old 08-15-14, 06:39 PM   #206
AC_Hacker
Supreme EcoRenovator
 
AC_Hacker's Avatar
 
Join Date: Mar 2009
Location: Portland, OR
Posts: 4,004
Thanks: 303
Thanked 723 Times in 534 Posts
Default

Quote:
Originally Posted by Ormston View Post
This is my setup, 3/4" version and I'm sure it's 3/4 BSP.
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
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...
AC_Hacker is offline   Reply With Quote
Old 08-15-14, 08:57 PM   #207
ICanHas
Banned
 
Join Date: Aug 2014
Location: US
Posts: 150
Thanks: 7
Thanked 5 Times in 5 Posts
Default

Quote:
Originally Posted by Ormston View Post
This is my setup, 3/4" version and I'm sure it's 3/4 BSP.
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
I would set it up like this with an o-ring just as it is intended. This being the pump's male end and the green being the o-ring. PTFE is not harmful, but NEVER use pipe dope on plastic parts. It can weaken and fracture the parts down the road.


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.
ICanHas is offline   Reply With Quote
The Following User Says Thank You to ICanHas For This Useful Post:
buffalobillpatrick (08-16-14)
Old 08-16-14, 01:44 PM   #208
AC_Hacker
Supreme EcoRenovator
 
AC_Hacker's Avatar
 
Join Date: Mar 2009
Location: Portland, OR
Posts: 4,004
Thanks: 303
Thanked 723 Times in 534 Posts
Default

Quote:
Originally Posted by Ormston View Post
This is my setup, 3/4" version and I'm sure it's 3/4 BSP.
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 flow sensor issue is really slowing me down.

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
Attached Thumbnails
Click image for larger version

Name:	Ormston Sensor joint.jpg
Views:	987
Size:	30.7 KB
ID:	4564  
__________________
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 (08-16-14)
Old 08-16-14, 01:58 PM   #209
AC_Hacker
Supreme EcoRenovator
 
AC_Hacker's Avatar
 
Join Date: Mar 2009
Location: Portland, OR
Posts: 4,004
Thanks: 303
Thanked 723 Times in 534 Posts
Default

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...
AC_Hacker is offline   Reply With Quote
The Following User Says Thank You to AC_Hacker For This Useful Post:
buffalobillpatrick (08-16-14)
Old 08-16-14, 02:06 PM   #210
Ormston
Apprentice EcoRenovator
 
Join Date: Mar 2013
Location: UK
Posts: 131
Thanks: 13
Thanked 35 Times in 32 Posts
Default

Quote:
Originally Posted by AC_Hacker View Post
The flow sensor issue is really slowing me down.

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
AC

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

Ormston is offline   Reply With Quote
The Following 2 Users Say Thank You to Ormston For This Useful Post:
AC_Hacker (08-16-14), buffalobillpatrick (08-16-14)
Reply


Thread Tools
Display Modes

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 11:58 PM.


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