View Single Post
Old 12-27-14, 10:40 PM   #300
jeff5may
Supreme EcoRenovator
 
Join Date: Jan 2010
Location: elizabethtown, ky, USA
Posts: 2,428
Thanks: 431
Thanked 619 Times in 517 Posts
Send a message via Yahoo to jeff5may
Default

Quote:
Originally Posted by AC_Hacker View Post
BBP,

I was beginning to worry that you'd partied yourself right into the Great Refrigerant Reservoir in the sky... good to hear from you.

Regarding the controller project, I've gone through the available code(s) with the Arduino compiler, and also with the Arduino Simulator, and I'm pretty much at a standstill... I really have no idea if anything works in the available code(s) and with my limited programming experience, I'm not getting far with analyzing the code either.

Also there have been reliability issues reported regarding the flow sensors, so for this, the most basic controller, I am leaving out "pump flow verification".

I built a basic test fixture that I'll use for GPC#1.

Here's a photo:



I have it set up and tested and have verified that all the hardware elements are in place and working.

I have two lm35 type temp sensors, and have verified that they can send temperature data through the USB serial link. They are quite accurate, and in agreement.

I have tested that all the relevant inputs are correctly initialized and working.

I have tested that all the relevant outputs are correctly initialized and working and I can successfully send AC power to the 4 light bulbs.

The light bulbs are (L to R):

(compressor) (insidePump) (outsidePump) (axillary option).

Here's the code I've come up with.

It goes through it's power-up 2 minute wait (shortened to 15 sec for testing) successfully.

It then waits for the 5 volt "heat demand" signal

It then sequentially lights each of the bulbs in series for about 10 seconds each, in endless repetition.

Also the temperature sensor hardware, and code is working but I have commented out that code for now.



Code:
/*
  * General Purpose Controller for a water-to-water heat pump, basic version)
  * Provides for:
  *     2 minute startup dalay for compressor protection
  *     Temperature monitoring of: 
  *         Evaporator HX temp
  *         Storage Tank Temp
  *     Controlling line voltage power to appropriate components:
  *         Outside loop pump
  *         Inside loop pump
  *         Compressor
  *         NOTE: Indoor operation is assumed, no compressor crankcase heater.
  *
  * PIN ASSIGNMENTS:
  * Digital Pins:
  *    D0 (reserved for USB & serial communication RX)
  *    D1 (reserved for USB & serial communication TX)
  *    D2 (* reserved for input loop flow data *)
  *    D3 (* reserved for output loop flow data *)
  *    D4 user input request for heat
  *    D5 output to Compressor SSR 
  *    D6 output to Inside Loop Pump SSR 
  *    D7 output to Outside Loop Pump SSR 
  *    D8 output to Auxillary Output SSR
  *    D9 (* not used *)
  *    D10 (* not used *)
  *    D11 (* not used *)
  *    D12 (* not used *)
  *    D13 LED (onboard)
  * Analog Pins:
  *    A0  input Temperature of Evaporator HX
  *    A1  input Temperature of Condenser Tank
  *    A2 (* not used *)
  *    A3 (* not used *)
  *    A4 (* not used *)
  *    A5 (* not used *)
  *
  */

#define  One_Sec              1000
#define  Quarter_Min         15000
#define  Half_Min            30000
#define  One_Min             60000
#define  Two_Min            120000
#define  Startup_delay      Quarter_Min

 float temp_in_celsius_0 = 0, 
       temp_in_celsius_1 = 1,  
       temp_in_kelvin_0 = 0,   
       temp_in_kelvin_1 = 0, 
       temp_in_fahrenheit_0 = 0,  
       temp_in_fahrenheit_1 = 0;
 
 // Associating Variable Names with pins      
 int HeatDemand = 4;
 int Compressor = 5;
 int inPump = 6;
 int outPump = 7;
 int auxOut = 8;
 int LED = 13;

 void setup()
  
 
 {
// Setting the mode of the digital pins   
pinMode(HeatDemand, INPUT); 
pinMode(Compressor, OUTPUT); 
pinMode(inPump, OUTPUT); 
pinMode(outPump, OUTPUT);
pinMode(auxOut, OUTPUT);
pinMode(LED, OUTPUT);  
   
   // Initialize print 
   Serial.begin(115200); 
   // 
// ****************** Startup Delay to Protect Compressor ********************
   Serial.print("begin startup delay");
   delay(15000);
   Serial.println(", end startup delay");
// ***************************** End Startup Delay ***************************   

 }

/* 
 void loop(){
 delay(Two_Min); 
 }
*/ 
 
 void loop()
{
 Serial.print("Activating Compressor");
  digitalWrite(Compressor, HIGH);
  delay(5000);
 Serial.println(", Deactivating Compressor");
  digitalWrite(Compressor, LOW);
  delay(500);

 Serial.print("Activating inPump");     
  digitalWrite(inPump, HIGH);
  delay(5000);
 Serial.println(", Deactivating inPump"); 
  digitalWrite(inPump, LOW);
  delay(500);

 Serial.print("Activating outPump");
  digitalWrite(outPump, HIGH);
  delay(5000);
 Serial.println(", Deactivating outPump"); 
  digitalWrite(outPump, LOW);
  delay(500);

 Serial.print("Activating Auxillary Output");
  digitalWrite(auxOut, HIGH);
  delay(5000);
 Serial.println(", Deactivating Auxillary Output"); 
  digitalWrite(auxOut, LOW);
  delay(500);  
 
// Serial.println("starting loop");
 

// {

   //Reads the input and converts it to Kelvin degrees
   temp_in_kelvin_0 = analogRead(0) * 0.004882812 * 100; 
   
   //Reads the input and converts it to Kelvin degrees
   temp_in_kelvin_1 = analogRead(1) * 0.004882812 * 100;

/*   
   Converts Kelvin to Celsius minus 2.5 degrees error
   temp_in_celsius_0 = temp_in_kelvin_0 - 2.5 - 273.15; 
   
   Converts Kelvin to Celsius minus 2.5 degrees error
   temp_in_celsius_1 = temp_in_kelvin_1 - 2.5 - 273.15; 
*/   

   //Converts Kelvin to Celsius minus 2.5 degrees error  
   temp_in_fahrenheit_0 = ((temp_in_kelvin_0 - 2.5) * 9 / 5) - 459.67;
   
   //Converts Kelvin to Celsius minus 2.5 degrees error  
   temp_in_fahrenheit_1 = ((temp_in_kelvin_1 - 2.5) * 9 / 5) - 459.67;
   
   
/*
   //Print the temperature in Celsius to the serial port
   Serial.print("Celsius_0: ");
   Serial.print(temp_in_celsius_0); 

   //Print the temperature in Celsius to the serial port
   Serial.print("Celsius_1: ");
   Serial.println(temp_in_celsius_1);   
*/

   //Print the temperature in Fahrenheit to the serial port
   Serial.print("Temp_0: "); Serial.print(temp_in_fahrenheit_0);Serial.print(" deg.F"); Serial.print(", Temp_1: "); Serial.print(temp_in_fahrenheit_1);Serial.print(" deg.F");
   Serial.println();   


   delay(One_Sec); 
 }
I'm only going to have:
  • 2 minute delay at power on (maybe a blinking LED to indicate)
  • "on and waiting" (maybe a 'breathing' LED pattern to indicate)
  • respond to request for heat (true)
  • test for evaporator HX => 34 F = true (variable here)
  • test for storage tank temp =< 90 F = true (variable here)
  • if any of the above go false, then
  • cut power to compressor AND
  • keep running pumps for an additional 60 seconds (variable here)
  • return to initial "on and waiting"

So, I'm not really a programmer, and I'm not quite sure how to proceed at this point. I do know that if I read and try and test (and repeat), that I'll eventually get it to work.


I could use some help.

Best,

-AC
Here's an example sketch that reads the hall effect flow sensors you are planning on using:

http://diyhacking.com/projects/FlowMeterDIY.ino

The main article is here:

Measure Water Flow Rate and Quantity Arduino DIY Project - DIY Hacking

It seems you have decided to go the way BBP has, using interrupts to count pulses. It is less code intensive to use this method, but you have to remember that there are multiple things that can be going on at any given time. With the simplistic nature of your device, it might not give you much trouble. One interrupt for measuring evap side flow, one interrupt for measuring condenser side flow.

Sorry it took so long for me to reply to this post. I had the general idea that you and BBP had worked out an algorithm that worked for both of you. If you need some coding done, I can help.
jeff5may is offline   Reply With Quote