Page 1 of 1

Overheat code

Posted: Sat Aug 04, 2012 3:59 pm
by grafspee1217
Here is what I am trying to do. I have temp probe 1 on my lights and temp probe 2 in my sump. I want to be able to turn on a fan to cool the lights when they reach a certain temp and turn on a chiller when the tank temp reaches a certain temp. Here is what I have so far.
#include <ReefAngel_Features.h>
#include <Globals.h>
#include <RA_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <InternalEEPROM.h>
#include <RA_NokiaLCD.h>
#include <RA_ATO.h>
#include <RA_Joystick.h>
#include <LED.h>
#include <RA_TempSensor.h>
#include <Relay.h>
#include <RA_PWM.h>
#include <Timer.h>
#include <Memory.h>
#include <InternalEEPROM.h>
#include <RA_Colors.h>
#include <RA_CustomColors.h>
#include <Salinity.h>
#include <RF.h>
#include <IO.h>
#include <ORP.h>
#include <AI.h>
#include <ReefAngel.h>

////// Place global variable code below here


////// Place global variable code above here


void setup()
{
    // This must be the first line
    ReefAngel.Init(); //Initialize controller
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = Port5Bit | Port6Bit | Port7Bit | Port8Bit;
    ReefAngel.FeedingModePortsE[0] = 0;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port7Bit | Port8Bit;
    ReefAngel.WaterChangePortsE[0] = 0;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = 0;
    ReefAngel.LightsOnPortsE[0] = 0;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port1Bit;
    ReefAngel.OverheatShutoffPortsE[0] = 0;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;
    // Set the Overheat temperature setting
    InternalMemory.OverheatTemp_write( 820 );


    // Ports that are always on
      ReefAngel.Relay.On( Port8 );

    ////// Place additional initialization code below here
    

    ////// Place additional initialization code above here
}

void loop()
{
    ReefAngel.StandardHeater( Port1,751,761 );
    ReefAngel.StandardATO( Port2,360 );
    ReefAngel.StandardLights( Port3,21,0,9,0 );
    ReefAngel.Wavemaker( Port5,60 );
    ReefAngel.Wavemaker( Port6,60 );
    ReefAngel.Relay.DelayedOn( Port7,3 );
    ReefAngel.StandardLights( Box1_Port1,8,0,22,0 );
    ReefAngel.StandardLights( Box1_Port2,22,0,8,0 );
    ReefAngel.StandardLights( Box1_Port3,8,30,21,30 );
    ReefAngel.StandardLights( Box1_Port4,9,0,21,0 );
    ReefAngel.StandardFan( Box1_Port7,790,850 );
    ReefAngel.StandardLights( Box1_Port8,21,59,8,1 );
    ReefAngel.PWM.SetDaylight( PWMSlope(8,30,21,0,10,100,120,10) );
    ReefAngel.PWM.SetActinic( PWMSlope(8,0,22,0,10,100,60,10) );
    ////// Place your custom code below here
    

    ////// Place your custom code above here

    // This should always be the last line
    ReefAngel.Portal( "grafspee1217" );
    ReefAngel.ShowInterface();
}

void DrawCustomMain()
{
    int x,y;
    char text[10];
    // Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
    ReefAngel.LCD.DrawMonitor( 15, 62, ReefAngel.Params,
    ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
    ReefAngel.LCD.DrawMonitor( 15, 62, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
    pingSerial();

    // Main Relay Box
    byte TempRelay = ReefAngel.Relay.RelayData;
    TempRelay &= ReefAngel.Relay.RelayMaskOff;
    TempRelay |= ReefAngel.Relay.RelayMaskOn;
    ReefAngel.LCD.DrawOutletBox( 12, 93, TempRelay );
    pingSerial();

    // Relay Expansion
    TempRelay = ReefAngel.Relay.RelayDataE[0];
    TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
    TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
    ReefAngel.LCD.DrawOutletBox( 12, 106, TempRelay );
    pingSerial();

    // Date and Time
    ReefAngel.LCD.DrawDate( 6, 122 );
    pingSerial();
}

void DrawCustomGraph()
{
    ReefAngel.LCD.DrawGraph( 5, 5 );
}


Re: Overheat code

Posted: Sat Aug 04, 2012 4:20 pm
by rimai
You will want to change this:

Code: Select all

    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;
To this:

Code: Select all

    ReefAngel.TempProbe = T2_PROBE;
    ReefAngel.OverheatProbe = T2_PROBE;
This will make your heater and chiller start working based on T2, which is your sump probe.

Which port is the hood fan?

Re: Overheat code

Posted: Sat Aug 04, 2012 6:27 pm
by grafspee1217
My heater is on port 1. The chiller is on Box 1 port 7. The fan hood I will put on Box 1 port 6.

Re: Overheat code

Posted: Sat Aug 04, 2012 6:46 pm
by rimai
Add this to your code for the fan:

Code: Select all

  if (ReefAngel.Params.Temp[T1_PROBE]>0)
  {
    if (ReefAngel.Params.Temp[T1_PROBE] >= 810) ReefAngel.Relay.On(Box1_Port6); 
    if (ReefAngel.Params.Temp[T1_PROBE] <= 800) ReefAngel.Relay.Off(Box1_Port6);
  }

Re: Overheat code

Posted: Sat Aug 04, 2012 6:54 pm
by grafspee1217
Does that go in the loop or setup section?

Re: Overheat code

Posted: Sat Aug 04, 2012 6:58 pm
by rimai
loop()

Re: Overheat code

Posted: Sat Aug 04, 2012 7:48 pm
by grafspee1217
Thanks, I've been noticing the wavemaker ports have been cycling. I thought I selected constant when I used the wizard. Is that what the code shows?
ReefAngel.Wavemaker( Port5,60 );
ReefAngel.Wavemaker( Port6,60 );

I'm wondering what the 60 stands for? Might I be better of setting port 5 and 6 for always on?

Re: Overheat code

Posted: Sat Aug 04, 2012 7:52 pm
by rimai
60 means it will cycle every 60 seconds.
If you want them not to cycle, you need to set them to always on in the wizard.

Re: Overheat code

Posted: Sat Aug 11, 2012 7:38 am
by grafspee1217
Roberto,
Benn doing a little tweeking. So far everything works except the hood fan. I wanted the fans to come on at 85 degrees and off at 79. I noticed they were on and the temp of the lights was only 80. Here is what I have so far...
#include <ReefAngel_Features.h>
#include <Globals.h>
#include <RA_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <InternalEEPROM.h>
#include <RA_NokiaLCD.h>
#include <RA_ATO.h>
#include <RA_Joystick.h>
#include <LED.h>
#include <RA_TempSensor.h>
#include <Relay.h>
#include <RA_PWM.h>
#include <Timer.h>
#include <Memory.h>
#include <InternalEEPROM.h>
#include <RA_Colors.h>
#include <RA_CustomColors.h>
#include <Salinity.h>
#include <RF.h>
#include <IO.h>
#include <ORP.h>
#include <AI.h>
#include <ReefAngel.h>

////// Place global variable code below here


////// Place global variable code above here


void setup()
{
    // This must be the first line
    ReefAngel.Init(); //Initialize controller
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = Port5Bit | Port6Bit | Port7Bit | Port8Bit;
    ReefAngel.FeedingModePortsE[0] = 0;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port7Bit | Port8Bit;
    ReefAngel.WaterChangePortsE[0] = 0;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = 0;
    ReefAngel.LightsOnPortsE[0] = 0;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port1Bit;
    ReefAngel.OverheatShutoffPortsE[0] = 0;
    // The T3 probe is tank temperature and overheat functions
    ReefAngel.TempProbe = T3_PROBE;
    ReefAngel.OverheatProbe = T3_PROBE;
    // Overheat temperature setting
    InternalMemory.OverheatTemp_write( 830 );


    // Ports that are always on Pump-8 Wavemakers-5&6
      ReefAngel.Relay.On( Port8 );
      ReefAngel.Relay.On( Port5 );
      ReefAngel.Relay.On( Port6 );

    ////// Place additional initialization code below here
    

    ////// Place additional initialization code above here
}

void loop()
{
    ReefAngel.StandardHeater( Port1,751,761 );
    ReefAngel.StandardATO( Port2,360 );
    ReefAngel.StandardLights( Port3,21,0,9,0 );
    //ReefAngel.Wavemaker( Port5,60 );
    //ReefAngel.Wavemaker( Port6,60 );
    ReefAngel.Relay.DelayedOn( Port7,3 );
    //Actinic Lights
    ReefAngel.StandardLights( Box1_Port1,8,0,22,0 );
    //Moon Light Driver
    ReefAngel.StandardLights( Box1_Port2,22,0,8,0 );
    //Morning Lights
    ReefAngel.StandardLights( Box1_Port3,8,30,21,30 );
    //High Noon Lights
    ReefAngel.StandardLights( Box1_Port4,9,0,21,0 );
    // This next line will run cooling fans for the tank
    ReefAngel.StandardFan( Box1_Port5,790,815 );
    //Moon Light 9V
    ReefAngel.StandardLights( Box1_Port8,21,59,8,1 );
    ReefAngel.PWM.SetDaylight( PWMSlope(9,0,21,0,10,100,120,10) );
    ReefAngel.PWM.SetActinic( PWMSlope(8,0,22,0,10,100,60,10) );
    ////// Place your custom code below here
          if (ReefAngel.Params.Temp[T1_PROBE]>0)
      {
        if (ReefAngel.Params.Temp[T1_PROBE] >= 850) ReefAngel.Relay.On(Box1_Port7);
        if (ReefAngel.Params.Temp[T1_PROBE] <= 790) ReefAngel.Relay.Off(Box1_Port7);
      }

    ////// Place your custom code above here

    // This should always be the last line
    ReefAngel.Portal( "grafspee1217" );
    ReefAngel.ShowInterface();
}

void DrawCustomMain()
{
    int x,y;
    char text[10];
    // Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
    ReefAngel.LCD.DrawMonitor( 15, 62, ReefAngel.Params,
    ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
    ReefAngel.LCD.DrawMonitor( 15, 62, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
    pingSerial();

    // Main Relay Box
    byte TempRelay = ReefAngel.Relay.RelayData;
    TempRelay &= ReefAngel.Relay.RelayMaskOff;
    TempRelay |= ReefAngel.Relay.RelayMaskOn;
    ReefAngel.LCD.DrawOutletBox( 12, 93, TempRelay );
    pingSerial();

    // Relay Expansion
    TempRelay = ReefAngel.Relay.RelayDataE[0];
    TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
    TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
    ReefAngel.LCD.DrawOutletBox( 12, 106, TempRelay );
    pingSerial();

    // Date and Time
    ReefAngel.LCD.DrawDate( 6, 122 );
    pingSerial();
}

void DrawCustomGraph()
{
    ReefAngel.LCD.DrawGraph( 5, 5 );
}


Re: Overheat code

Posted: Sat Aug 11, 2012 8:55 am
by rimai
Well, if you set them to turn off at 80, they should be on if they are on the downwards path.
The hood temp went to 85, turned the fan on. It will stay on until it reached 79. That's the temp you chose to turn off. So, they will stay on from 85 all the way down to 79. When it reaches 79, that's when it will turn off.
With fans off, the hood temp will start increasing again and it won't turn on until it reaches 85 again and the cycle repeats.
If this is not how you would like it to work, please explain exactly how you envision it to be working.

Re: Overheat code

Posted: Sat Aug 11, 2012 9:12 am
by grafspee1217
Thats exactly how I want it to work. I noticed the fans running this morning when the lights first came on. The temp never had a chance to reach 85. I didn't know if the code was correct or if the line of code for the hood fan was interfering somehow with the code for the chiller

Re: Overheat code

Posted: Sat Aug 11, 2012 9:52 am
by rimai
Yes, you can remove that line as it is not doing anything.
The custom code is the one controlling the port.
Maybe it never got down to 79?
You can used a cup with cold water to bring down and your hand to bring it up to test it and make sure it is working properly.

Re: Overheat code

Posted: Sat Aug 11, 2012 9:54 am
by rimai
After second thought, yes, you must remove it as it is interfering.
Sorry.

Re: Overheat code

Posted: Sat Aug 11, 2012 10:12 am
by grafspee1217
ok hold on, noob here. This line in the setup tells the controller that probe 3 is the tank water temp...
ReefAngel.TempProbe = T3_PROBE;
ReefAngel.OverheatProbe = T3_PROBE;
So the controller should turn on the chiller based on the following...

ReefAngel.StandardFan( Box1_Port5,790,815 );


This is the line that should control the hood fan which is probe 1...
if (ReefAngel.Params.Temp[T1_PROBE]>0)
{
if (ReefAngel.Params.Temp[T1_PROBE] >= 850) ReefAngel.Relay.On(Box1_Port7);
if (ReefAngel.Params.Temp[T1_PROBE] <= 790) ReefAngel.Relay.Off(Box1_Port7);

Which line do I remove?
}

Re: Overheat code

Posted: Sat Aug 11, 2012 10:22 am
by rimai
You are good :)
I misread your code.
I read Box1_Port7 instead of Box1_Port5 and thought you were using the same port on both functions.
Disregard what I said... Sorry to create a confusion.
Test the fan with a cup of cold water to drop the temp and use hot water or your hands to raise it and see if it is working as it should.

Re: Overheat code

Posted: Mon Aug 13, 2012 4:14 pm
by grafspee1217
I got home today and found the tank temp above 83.... not good. The chiller was not running yet the head unit display showed the socket active. I unplugged the chiller from the relay box and plugged in a small air pump and it didnt run. I tried the chiller directly into the wall socket and it works. This rules out the chiller being the problem. I used an ice cube and cooled the tank temp probe and watched the display. When the temp drops below 79 (chiller off set point) the display turns the socket red. When I warm the probe above 82 (chiller on set point), the display shows the socket green. I checked the portal temp chart and compared it to the relay activity and they both correspond to what should be happening. I don't hear the relay box click when the display turns the socket on. I tried unplugging the head unit and that socket will sometimes work and sometimes not. Relay box bad or could there still be a problem with the code?

Re: Overheat code

Posted: Mon Aug 13, 2012 4:42 pm
by rimai
Looks like you have a bad relay. You will need to send it in for repair. PM me.