Salinity Temp Compensate's Reading

Expansion modules and attachments
Post Reply
Dugong
Posts: 12
Joined: Fri Nov 23, 2012 6:00 am

Salinity Temp Compensate's Reading

Post by Dugong »

So, according to this post http://forum.reefangel.com/viewtopic.php?p=7386#p7386, it could be done using the following code:

Code: Select all

  double SalCompensation;
  if (TempSensor.unit)
    SalCompensation=Params.Salinity/(1+((Params.Temp[T1_PROBE]-250)*0.0024));
  else
    SalCompensation=Params.Salinity/(1+((Params.Temp[T1_PROBE]-770)*0.001333));
  Params.Salinity=round(SalCompensation);
And I'm planning to calibrate the salinity probe using the solution with 25C temperature. The question is, where do I put above code? Is it in the setup() function? Thanks.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Salinity Temp Compensate's Reading

Post by rimai »

Do you plan on calibrating at 25C and monitoring at various different temperature ranges?
Roberto.
Dugong
Posts: 12
Joined: Fri Nov 23, 2012 6:00 am

Re: Salinity Temp Compensate's Reading

Post by Dugong »

rimai wrote:Do you plan on calibrating at 25C and monitoring at various different temperature ranges?
Yep.. that is it.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Salinity Temp Compensate's Reading

Post by rimai »

Please post your code.
Roberto.
Dugong
Posts: 12
Joined: Fri Nov 23, 2012 6:00 am

Re: Salinity Temp Compensate's Reading

Post by Dugong »

here they are:

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 <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
    ReefAngel.SetTemperatureUnit( Celsius );  // set to Celsius Temperature

    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = Port4Bit | Port8Bit;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port3Bit | Port4Bit | Port5Bit | Port8Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = Port1Bit | Port2Bit;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port2Bit | Port8Bit;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;
    // Set the Overheat temperature setting
    InternalMemory.OverheatTemp_write( 350 );


    // Ports that are always on
    ReefAngel.Relay.On( Port3 );
    ReefAngel.Relay.On( Port5 );
    ReefAngel.Relay.On( Port6 );
    ReefAngel.Relay.On( Port7 );

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

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

void loop()
{
    //blue light, on 5:20 PM, off 1 AM,  7 hours 40 minutes
    //ReefAngel.StandardLights( Port1,17,20,1,0 );
    
    //blue light on 3:00 PM, off 10:00 PM, 7 hours
    ReefAngel.StandardLights( Port1,15,0,22,0 );
    
    //white light, on 6:20 PM, off 00:01 AM, 5 hours 40 minutes
    //ReefAngel.StandardLights( Port2,18,20,0,1 );
    
    //white light, on 4:00 PM, off 9:00 PM, 5 hours
    ReefAngel.StandardLights( Port2,16,0,21,0 );
    
    //skimmer delay
    ReefAngel.Relay.DelayedOn( Port4,10 );
    ReefAngel.SingleATO( true,Port8,240,0 );
    ////// Place your custom code below here
    

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

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

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

    // Salinity
    ReefAngel.LCD.DrawText( COLOR_DARKKHAKI,DefaultBGColor,15,66, "SAL:" );
    ReefAngel.LCD.DrawText( COLOR_DARKKHAKI,DefaultBGColor,39,66, ReefAngel.Params.Salinity );
    pingSerial();

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

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

void DrawCustomGraph()
{
}
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Salinity Temp Compensate's Reading

Post by rimai »

Try this:

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 <ReefAngel.h>

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

double SalCompensation=0;
////// 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

  // Ports toggled in Feeding Mode
  ReefAngel.FeedingModePorts = Port4Bit | Port8Bit;
  // Ports toggled in Water Change Mode
  ReefAngel.WaterChangePorts = Port3Bit | Port4Bit | Port5Bit | Port8Bit;
  // Ports toggled when Lights On / Off menu entry selected
  ReefAngel.LightsOnPorts = Port1Bit | Port2Bit;
  // Ports turned off when Overheat temperature exceeded
  ReefAngel.OverheatShutoffPorts = Port2Bit | Port8Bit;
  // Use T1 probe as temperature and overheat functions
  ReefAngel.TempProbe = T1_PROBE;
  ReefAngel.OverheatProbe = T1_PROBE;
  // Set the Overheat temperature setting
  InternalMemory.OverheatTemp_write( 350 );


  // Ports that are always on
  ReefAngel.Relay.On( Port3 );
  ReefAngel.Relay.On( Port5 );
  ReefAngel.Relay.On( Port6 );
  ReefAngel.Relay.On( Port7 );

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


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

void loop()
{
  //blue light, on 5:20 PM, off 1 AM,  7 hours 40 minutes
  //ReefAngel.StandardLights( Port1,17,20,1,0 );

  //blue light on 3:00 PM, off 10:00 PM, 7 hours
  ReefAngel.StandardLights( Port1,15,0,22,0 );

  //white light, on 6:20 PM, off 00:01 AM, 5 hours 40 minutes
  //ReefAngel.StandardLights( Port2,18,20,0,1 );

  //white light, on 4:00 PM, off 9:00 PM, 5 hours
  ReefAngel.StandardLights( Port2,16,0,21,0 );

  //skimmer delay
  ReefAngel.Relay.DelayedOn( Port4,10 );
  ReefAngel.SingleATO( true,Port8,240,0 );
  ////// Place your custom code below here


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

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

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

  // Salinity

  if (ReefAngel.TempSensor.unit)
    SalCompensation=ReefAngel.Params.Salinity/(1+((ReefAngel.Params.Temp[T1_PROBE]-250)*0.0024));
  else
    SalCompensation=ReefAngel.Params.Salinity/(1+((ReefAngel.Params.Temp[T1_PROBE]-770)*0.001333));
  ReefAngel.LCD.DrawText( COLOR_DARKKHAKI,DefaultBGColor,15,66, "SAL:" );
  ReefAngel.LCD.DrawText( COLOR_DARKKHAKI,DefaultBGColor,39,66, round(SalCompensation) );
  pingSerial();

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

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

void DrawCustomGraph()
{
}


Roberto.
Post Reply