Heater Function behaviour changed

Do you have a question on how to do something.
Ask in here.
Post Reply
sabo
Posts: 129
Joined: Tue Sep 24, 2013 3:18 am

Heater Function behaviour changed

Post by sabo »

I havent changed this part of my code for a long time, and suddenly my heaters are switching with T1 values. Its worked on T2 for two years but changed when I reuploaded my code because I have been having issues with my ethernet module. I just changed my controller board because I thought it may be related. I *think* it has solved my ethernet issue (this all started a while back after a big electrical storm). So I have three temp probes, T1 is house temp, T2 and T3 are in the sump.I want (and used to have) the heaters switching on T2, now whatever I set in my code, the heaters are always switching on T1. Has something changed in the libraries or something? Can someone cast an eye over my code and see what is going on for me please.

Code: Select all

#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 <PH.h>
#include <WaterLevel.h>
#include <Humidity.h>
#include <DCPump.h>
#include <ReefAngel.h>
#include <WiFiAlert.h>

// Define Custome Memory Locations

#define Mem_B_SkimmerWL      100
#define Mem_B_PHDayPower     101
#define Mem_B_PHNightPower   102
#define Mem_B_PHDuration     103
#define Mem_I_ChillerPumpT   104
#define Mem_B_CPumpMax       106
#define Mem_B_CPumpMin       107

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

#define Return       1
#define Pwm_Exp      2
#define ATI          3
#define Modem        4
#define Jebao1_Rhs   5
#define Jebao2_Rhs   6
#define Jebao1_Lhs   7
#define Jebao2_Lhs   8

#define ATO         Box1_Port1
#define Fuge_Led    Box1_Port2
#define Heater1     Box1_Port3
#define Doser       Box1_Port4
#define Heater2     Box1_Port5
#define Skimmer     Box1_Port6
#define Swabby      Box1_Port7
#define CPump       Box1_Port8

#define MH1         Box2_Port1
#define MH2         Box2_Port2
#define Actinics    Box2_Port3
#define Day         Box2_Port4
#define Fan         Box2_Port5
#define Unused      Box2_Port6
#define Unused      Box2_Port7
#define Unused      B0x2_Port8

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


void setup()
{
    // This must be the first line
    ReefAngel.Init();  //Initialize controller
    ReefAngel.SetTemperatureUnit( Celsius );  // set to Celsius Temperature
    
    ReefAngel.AddStandardMenu();  // Add Standard Menu

    ReefAngel.Use2014Screen();  // Let's use 2014 Screen
    ReefAngel.AddWaterLevelExpansion();  // Water Level Expansion Module
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = 0;
    ReefAngel.FeedingModePortsE[0] = 0;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = 0;
    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.OverheatShutoffPortsE[1] = Port1Bit | Port2Bit;
    ReefAngel.OverheatShutoffPortsE[0] = Port3Bit | Port5Bit;
    // Use T2 probe as temperature and overheat functions
    ReefAngel.TempProbe = T2_PROBE;
    ReefAngel.OverheatProbe = T2_PROBE;
    // Set the Overheat temperature setting
    InternalMemory.OverheatTemp_write( 280 );


    // Ports that are always on
    ReefAngel.Relay.On( Pwm_Exp );
    ReefAngel.Relay.On( Return );
    ReefAngel.Relay.On( ATI );
    ReefAngel.Relay.On( Doser );
    ReefAngel.Relay.On( CPump );
    ReefAngel.Relay.On( Modem );
    ReefAngel.Relay.On( Skimmer );

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

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

void loop()
{
    ReefAngel.MHLights( MH1 );
    ReefAngel.MHLights( MH2 );
    ReefAngel.ActinicLights( Actinics );
    ReefAngel.DayLights( Day );
    ReefAngel.ActinicLights( Fuge_Led );
    ReefAngel.ActinicLights( Fan );
    ReefAngel.StandardHeater( Heater1 );
    ReefAngel.StandardHeater( Heater2 ); 
    ReefAngel.WaterLevelATO( ATO );
    

    ////// Place your custom code below here
    
    CheckPower();
      
    ReefAngel.DosingPumpRepeat1(Swabby);
    
    if (ReefAngel.LowATO.IsActive())
      {
        ReefAngel.Relay.Off(Skimmer);
      }
    else
      {
        ReefAngel.Relay.On(Skimmer);
      }
      
    if (hour()>=6 && hour()<12)
      {
         ReefAngel.PWM.SetDaylight( ReefCrestMode(InternalMemory.read(Mem_B_PHDayPower),InternalMemory.read(Mem_B_PHDuration),true) );
         ReefAngel.PWM.SetActinic( ReefCrestMode(InternalMemory.read(Mem_B_PHDayPower),InternalMemory.read(Mem_B_PHDuration),true) );
         ReefAngel.Relay.Off( Jebao1_Lhs );
         ReefAngel.Relay.Off( Jebao2_Lhs );
         ReefAngel.Relay.On( Jebao1_Rhs );
         ReefAngel.Relay.On( Jebao2_Rhs );
      }
    else if (hour()>=12 && hour()<18)
      {
        ReefAngel.PWM.SetChannel( 0, ReefCrestMode(InternalMemory.read(Mem_B_PHDayPower),InternalMemory.read(Mem_B_PHDuration),true) );
        ReefAngel.PWM.SetChannel( 1, ReefCrestMode(InternalMemory.read(Mem_B_PHDayPower),InternalMemory.read(Mem_B_PHDuration),true) );
        ReefAngel.Relay.Off( Jebao1_Rhs );
        ReefAngel.Relay.Off( Jebao2_Rhs );
        ReefAngel.Relay.On( Jebao1_Lhs );
        ReefAngel.Relay.On( Jebao2_Lhs );
      }
    else if (hour()>=18 && hour()<24)
      {
        ReefAngel.PWM.SetDaylight( ReefCrestMode(InternalMemory.read(Mem_B_PHNightPower),InternalMemory.read(Mem_B_PHDuration),true) );
        ReefAngel.PWM.SetActinic( ReefCrestMode(InternalMemory.read(Mem_B_PHNightPower),InternalMemory.read(Mem_B_PHDuration),true) );
        ReefAngel.Relay.Off( Jebao1_Lhs );
        ReefAngel.Relay.Off( Jebao2_Lhs );
        ReefAngel.Relay.On( Jebao1_Rhs );
        ReefAngel.Relay.On( Jebao2_Rhs );
      }
    else
      {
        ReefAngel.PWM.SetChannel( 0, ReefCrestMode(InternalMemory.read(Mem_B_PHNightPower),InternalMemory.read(Mem_B_PHDuration),true) );
        ReefAngel.PWM.SetChannel( 1, ReefCrestMode(InternalMemory.read(Mem_B_PHNightPower),InternalMemory.read(Mem_B_PHDuration),true) );
        ReefAngel.Relay.Off( Jebao1_Rhs );
        ReefAngel.Relay.Off( Jebao2_Rhs );
        ReefAngel.Relay.On( Jebao1_Lhs );
        ReefAngel.Relay.On( Jebao2_Lhs );
      }


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

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

void CheckPower() {
  static boolean powerOutage=false;
  static WiFiAlert powerAlert;

  // Power Outage - turn off everything
  if (!ReefAngel.Relay.IsRelayPresent(EXP1_RELAY)) // Expansion Relay NOT present
  {
    powerOutage=true;
    powerAlert.Send("Power+outage!");
  }

  // Power Restored - Turn things back on
  if (powerOutage && ReefAngel.Relay.IsRelayPresent(EXP1_RELAY))
  {
    LastStart=now();
    powerOutage=false;
    powerAlert.Send("Power+restored.",true);
  }
}
sabo
Posts: 129
Joined: Tue Sep 24, 2013 3:18 am

Re: Heater Function behaviour changed

Post by sabo »

For now I have just unplugged the house temp probe and my sump probe becomes T1, so it works, but i'm curious as to why this has changed. I'm feeling stumped!
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Heater Function behaviour changed

Post by lnevo »

I think I changed something when using StandardHeater. Try changing it to StandardHeater2
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Heater Function behaviour changed

Post by lnevo »

Yeah, so definitely my fault. Code has been fixed and issue/pull request created. If you want to test you can download from my github

https://github.com/lnevo/Libraries/tree/fix_temp

There's a Download Zip link on that page.
sabo
Posts: 129
Joined: Tue Sep 24, 2013 3:18 am

Re: Heater Function behaviour changed

Post by sabo »

Thanks Inevo, just edited that function and all works as expected. Cheers
Civics14
Posts: 95
Joined: Fri Nov 14, 2014 8:27 am

Re: Heater Function behaviour changed

Post by Civics14 »

I am so glad I found this thread, I just recently changed my programming and couldn't figure out for the life of me what happened in my code that caused my heater not to work.

I'm not a programming guru, so in order to fix this, do I open the file "ReefAngel.cpp" and remove the line "StandardHeater(T1_PROBE, HeaterRelay, LowTemp, HighTemp);" and replace it with "StandardHeater(TempProbe, HeaterRelay, LowTemp, HighTemp);" ?

Thanks
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Heater Function behaviour changed

Post by lnevo »

Exactly. Sorry about that :(

Roberto can we get that patch pushed out?
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Heater Function behaviour changed

Post by rimai »

Yeah, I'm currently working on updating the IDE to the newest IDE version 1.6.8 and some things changed along the way that required some changes to our libraries too.
The newest IDE had a few functionalities that I thought was worth the update.
Roberto.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Heater Function behaviour changed

Post by lnevo »

Cool, like what?
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Heater Function behaviour changed

Post by rimai »

I liked the line numbers and the serial monitor that keeps open.
It also has a library manager that allows for easy update of our libraries.
Roberto.
Civics14
Posts: 95
Joined: Fri Nov 14, 2014 8:27 am

Re: Heater Function behaviour changed

Post by Civics14 »

what program do i need to open .cpp files to make this change?
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Heater Function behaviour changed

Post by lnevo »

Textedit or notepad if on windows
Post Reply