Salinity Module - How to Enable?

Expansion modules and attachments
Post Reply
btorrenga
Posts: 100
Joined: Mon Apr 16, 2012 10:22 pm

Salinity Module - How to Enable?

Post by btorrenga »

I am trying to get my salinity module configured. I added #include <Salinity.h> in my ino file, and #define SALINITYEXPANSION in my features file. The compiler does not note that it detects the salinity module, unlike when I compile the example code. What am I missing?

Code: Select all

/* The following features are enabled for this File: 
#define SALINITYEXPANSION
#define DisplayImages
#define SetupExtras
#define OverheatSetup
#define DateTimeSetup
#define VersionMenu
#define wifi
#define SaveRelayState
#define RelayExp
#define InstalledRelayExpansionModules 1
#define DosingPumpIntervalSetup
#define WDT
#define CUSTOM_MENU
#define CUSTOM_MENU_ENTRIES 9
#define CUSTOM_MAIN
#define COLORS_PDE
#define ENABLE_ATO_LOGGING
#define ENABLE_EXCEED_FLAGS
#define IOEXPANSION
#define FONT_8x8
#define FONT_8x16
#define FONT_12x16
#define NUMBERS_8x8
#define NUMBERS_8x16
#define NUMBERS_12x16
#define NUMBERS_16x16
#define CUSTOM_VARIABLES

*/
#include <ReefAngel_Features.h>
#include <RA_Colors.h>
#include <RA_CustomColors.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 <Timer.h>
#include <Memory.h>
#include <IO.h>
#include <ReefAngel.h>
#include <RA_PWM.h>
#include <avr/pgmspace.h>
#include <Salinity.h>
////// Place global variable code below here
// Initialize Buzzer variables
// the follow variables is a long because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long buzzerinterval = 1000;           // interval at which to sound buzzer (milliseconds)
long previousMillis = 0;

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


prog_char menu1_label[] PROGMEM = "Feeding";
prog_char menu2_label[] PROGMEM = "Water Change";
prog_char menu3_label[] PROGMEM = "ATO Clear";
prog_char menu4_label[] PROGMEM = "Overheat Clear";
prog_char menu5_label[] PROGMEM = "PH Calibration";
prog_char menu6_label[] PROGMEM = "Date / Time";
prog_char menu7_label[] PROGMEM = "Version";
prog_char menu8_label[] PROGMEM = "Turn ON/OFF Skimmer";
prog_char menu9_label[] PROGMEM = "Turn Off Skimmer";
// Group the menu entries together
PROGMEM const char *menu_items[] = {
menu1_label, menu2_label, menu3_label,
menu4_label, menu5_label, menu6_label,
menu7_label, menu8_label, menu9_label
};
    
void MenuEntry1()
{
ReefAngel.FeedingModeStart();
}
void MenuEntry2()
{
ReefAngel.WaterChangeModeStart();
}
void MenuEntry3()
{
ReefAngel.ATOClear();
ReefAngel.DisplayMenuEntry("Clear ATO Timeout");
}
void MenuEntry4()
{
ReefAngel.OverheatClear();
ReefAngel.DisplayMenuEntry("Clear Overheat");
}
void MenuEntry5()
{
ReefAngel.SetupCalibratePH();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void MenuEntry6()
{
ReefAngel.SetupDateTime();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void MenuEntry7()
{
ReefAngel.DisplayVersion();
}
void MenuEntry8()
{
ReefAngel.Relay.Toggle(Box1_Port8);
ReefAngel.Relay.Write();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void MenuEntry9()
{
ReefAngel.Relay.Off(Box1_Port8);
ReefAngel.Relay.Write();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}

void DrawCustomMain()
{
  ReefAngel.LCD.DrawDate(6, 119);
  pingSerial();
#if defined DisplayLEDPWM && ! defined RemoveAllLights
  ReefAngel.LCD.DrawMonitor(15, 60, ReefAngel.Params,
  ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue());
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
  ReefAngel.LCD.DrawMonitor(15, 60, ReefAngel.Params);
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
  pingSerial();
  // draw main relay
  byte TempRelay = ReefAngel.Relay.RelayData;
  TempRelay &= ReefAngel.Relay.RelayMaskOff;
  TempRelay |= ReefAngel.Relay.RelayMaskOn;
  ReefAngel.LCD.DrawOutletBox(12, 93, TempRelay);
#ifdef RelayExp
  pingSerial();
  // draw 1st expansion relay
  TempRelay = ReefAngel.Relay.RelayDataE[0];
  TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
  TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
  ReefAngel.LCD.DrawOutletBox(12, 105, TempRelay);
#endif  // RelayExp
}
void DrawCustomGraph()
{
  // Change the 45 to adjust the horizontal position of the text 
  ReefAngel.LCD.DrawGraph(5, 5);
}


void CheckReservoirStatus(byte channel, byte pump)
{
    if ( ReefAngel.IO.GetChannel(channel) )
    {
        // If empty, shutoff the port, trigger alert
        ReefAngel.CustomVar[channel] = 1;
        ReefAngel.Relay.Off(pump);
    }
    else
    {
        // If not empty, turn on the port, clear alert
        ReefAngel.CustomVar[channel] = 0;
        ReefAngel.Relay.On(pump);
    }
}


void MyCustomATO(int ATOTimeout)
{
    /*
    This function works as follows:

    When it's time to topoff the system, we check the levels of each
    of the three reservoirs.  If a reservoir is empty, we set a custom
    flag to indicate it's empty on the portal and we do not start that
    pump.  Otherwise, we clear the custom flag for the reservoir and
    start the pump.
    The function monitors the switch levels like normal.
    Monitor the status of the reservoirs while topping off.
    When the high switch is triggered (aka, finished topping off), 
    ALL ports are turned off regardless of status (doesn't hurt to do this).
    If the timeout occurs, the LED light comes on and all ports are 
    turned off just like when we finish topping off.
    
    */
    unsigned long TempTimeout = ATOTimeout;
    TempTimeout *= 1000;

    if ( ReefAngel.LowATO.IsActive() && ( !ReefAngel.LowATO.IsTopping()) )
    {
        ReefAngel.LowATO.Timer = millis();
        ReefAngel.LowATO.StartTopping();

        // Check the level of each reservoir
        // If empty, set the alert and don't start topping off
        // otherwise if not empty, clear the alert and start topping
        CheckReservoirStatus(0, Port5);
        CheckReservoirStatus(1, Port6);
        CheckReservoirStatus(2, Box1_Port5);
    }

    // Monitor levels while topping off, to prevent a reservoir from running dry
    // Might need to remove this check here -- Nope, this seems to work fine.
    
    if ( ReefAngel.LowATO.IsTopping() )
    {
        CheckReservoirStatus(0, Port5);
        CheckReservoirStatus(1, Port6);
        CheckReservoirStatus(2, Box1_Port5);
    }

    if ( ReefAngel.HighATO.IsActive() )
    {
        ReefAngel.LowATO.StopTopping();  // stop the low ato timer
        ReefAngel.Relay.Off(Port5);
        ReefAngel.Relay.Off(Port6);
        ReefAngel.Relay.Off(Box1_Port5);
    }

    if ( (millis()-ReefAngel.LowATO.Timer > TempTimeout) && ReefAngel.LowATO.IsTopping() )
    {
        ReefAngel.LED.On();
#ifdef ENABLE_EXCEED_FLAGS
        InternalMemory.write(ATO_Exceed_Flag, 1);
#endif  // ENABLE_EXCEED_FLAGS
        ReefAngel.Relay.Off(Port5);
        ReefAngel.Relay.Off(Port6);
        ReefAngel.Relay.Off(Box1_Port5);
#ifdef ENABLE_ATO_LOGGING
        // bump the counter if a timeout occurs
        AtoEventCount++;
        if ( AtoEventCount >= MAX_ATO_LOG_EVENTS ) { AtoEventCount = 0; }
#endif  // ENABLE_ATO_LOGGING
    }
}

void setup()
{
    // This must be the first line
    ReefAngel.Init();  //Initialize controller
    // Initialize the custom menu
    ReefAngel.InitMenu(pgm_read_word(&(menu_items[0])),SIZE(menu_items));

    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = 0;
    ReefAngel.FeedingModePortsE[0] = Port4Bit | Port7Bit;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port2Bit | Port4Bit;
    ReefAngel.OverheatShutoffPortsE[0] = Port1Bit | Port2Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = Port4Bit;
    ReefAngel.LightsOnPortsE[0] = Port1Bit | Port3Bit;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port2Bit | Port5Bit | Port6Bit;
    ReefAngel.WaterChangePortsE[0] = Port2Bit | Port4Bit | Port5Bit | Port6Bit | Port8Bit;

    // Ports that are always on
    ReefAngel.Relay.On(Port3);
    ReefAngel.Relay.On(Box1_Port4);
    ReefAngel.Relay.On(Box1_Port7);
    ReefAngel.Relay.On(Box1_Port8);
    ////// Place additional initialization code below here
    ReefAngel.OverheatProbe = T1_PROBE; // Use Temperature probe 1 to check for overheat




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

void loop()
{
    // Specific functions that use Internal Memory values
    ReefAngel.StandardLights(Port1,23,0,2,0); // Moon lights on 23:00-02:00
    ReefAngel.StandardHeater(Port2,780,790); // 800w heater on at 78.0, off at 79.0
    ReefAngel.MHLights(Port4); // MH on 14:00-22:00, delay 15m if power fails
    ReefAngel.StandardLights(Port7,21,0,13,0); // Sump lights on 21:00-13:00
    ReefAngel.StandardLights(Port8);  //Was plant lights on 08:00-21:00, but now actinics
    ReefAngel.MHLights(Box1_Port1); // MH on 14:00-22:00, delay 15m if power fails
    ReefAngel.StandardHeater(Box1_Port2); // 250w heater on at 78.5, off at 79.0
    ReefAngel.StandardLights(Box1_Port3); // Actinics on 13:00-23:00
    ////// Place your custom code below here
    //ATO function
    MyCustomATO(InternalMemory.ATOTimeout_read());
    
    //Notify when sump level is low
    if ( ReefAngel.IO.GetChannel(4) )
    {
      ReefAngel.CustomVar[4]=1;
        // If the sump level is about to cavitate the pumps, then sound the alarm
        unsigned long currentMillis = millis();
        if(currentMillis - previousMillis > buzzerinterval) {
    // save the last time the buzzer turned on 
    previousMillis = currentMillis;   
    // if the buzzer is off turn it on and vice-versa:
    if (ReefAngel.PWM.GetDaylightValue() == 0)
      ReefAngel.PWM.SetDaylight(25);
    else
      ReefAngel.PWM.SetDaylight(0);
  }
    }
    else
    {
        // Turn the buzzer off when the sump level is above cavitation levels
        ReefAngel.PWM.SetDaylight(0);
        ReefAngel.CustomVar[4]=0;
    }

//If the ATO float switch is stuck, and the topoff pump timeout flag is set, then set C5=1
ReefAngel.CustomVar[5]=InternalMemory.read(ATO_Exceed_Flag);  //Note that this value should be either 0 or 1, but for some reason is 254 or 255.
    
//Vodka dosing 
      if ( ReefAngel.IO.GetChannel(3) )  //Check there is vodka in the reservoir
  {
    ReefAngel.Relay.Off(Box1_Port6);  //If no vodka, then set a variable and turn off the port
    ReefAngel.CustomVar[3]=1;
  }
  else  //If there is vodka, then dose
  {
    ReefAngel.CustomVar[3]=0;
    ReefAngel.DosingPumpRepeat1(Box1_Port6);
  }

//Monitor the water level in the display
ReefAngel.CustomVar[6]=ReefAngel.IO.GetChannel(5);
  
    ////// Place your custom code above here
    // This sends all the data to the portal
    // Do not add any custom code that changes any relay status after this line
    // The only code after this line should be the ShowInterface function
    ReefAngel.Portal("btorrenga");

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

Code: Select all

// AutoGenerated file by RAGen (v1.2.2.171), (06/23/2012 19:57)

/*
 * Copyright 2010-12 Curt Binder
 *
 * Licensed under the Apache License, Version 2.0 (the "License")
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


#ifndef __REEFANGEL_FEATURES_H__
#define __REEFANGEL_FEATURES_H__


#define DateTimeSetup
#define VersionMenu
#define DisplayLEDPWM
#define wifi
#define SaveRelayState
#define RelayExp
#define InstalledRelayExpansionModules 1
#define WDT
#define CUSTOM_MENU
#define CUSTOM_MENU_ENTRIES 9
#define CUSTOM_MAIN
#define ENABLE_ATO_LOGGING
#define ENABLE_EXCEED_FLAGS
#define SALINITYEXPANSION
#define IOEXPANSION
#define FONT_8x8
#define FONT_8x16
#define FONT_12x16
#define NUMBERS_8x8
#define NUMBERS_8x16
#define NUMBERS_12x16
#define NUMBERS_16x16
#define CUSTOM_VARIABLES


#endif  // __REEFANGEL_FEATURES_H__
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Salinity Module - How to Enable?

Post by rimai »

The features file gets overwritten with the newer auto selection of features.
Arduino looks for this keyword to enable the salinity feature:
ReefAngel.Params.Salinity
Roberto.
btorrenga
Posts: 100
Joined: Mon Apr 16, 2012 10:22 pm

Re: Salinity Module - How to Enable?

Post by btorrenga »

I see, thanks for the insight. I added ReefAngel.Params.Salinity to a comment, and that did the trick.
SuperDodge
Posts: 52
Joined: Sun Feb 12, 2012 11:16 am

Re: Salinity Module - How to Enable?

Post by SuperDodge »

rimai wrote:The features file gets overwritten with the newer auto selection of features.
Arduino looks for this keyword to enable the salinity feature:
ReefAngel.Params.Salinity
I think I missed something big. The features file doesn't get used anymore? Is there a thread somewhere that explains this to me so I can read up on it?
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Salinity Module - How to Enable?

Post by rimai »

My bad :(
I'll have something soon...
I have changed it so many times to improve that I never made a post.
I think I have it the way I envisioned it working now and it will be on the version 1.0 that will be released soon.
Roberto.
User avatar
mvwise
Posts: 48
Joined: Sat Apr 21, 2012 7:44 pm
Location: Burlington, Ontario, Canada

Re: Salinity Module - How to Enable?

Post by mvwise »

Received my salinity module today and noticed that the cord on the probe is on the short side. Do you have an extension available - would the PH extension be useable for the salinity probe?
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Salinity Module - How to Enable?

Post by rimai »

Yes, it works for them too.
Roberto.
00Warpig00
Posts: 289
Joined: Wed May 16, 2012 9:52 pm

Re: Salinity Module - How to Enable?

Post by 00Warpig00 »

I may need extensions cable for my Salinity and PH probes when my RA arrives. I am considering making my own extension cables for this purpose to do a custom length so I don't need to loop extra cable somewhere. I see the female/Male BNC connectors therefore I assume 75 Ohm impedance cable as typically BNC's are 75 Ohm connectors. Can you fill us in on the coaxial cable spec/type?

Nick
180G FOWLR
20GH QT#1
29G QT#2

Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Salinity Module - How to Enable?

Post by rimai »

Those would be just fine.
Roberto.
timmcq
Posts: 46
Joined: Tue Jun 05, 2012 6:24 pm

Re: Salinity Module - How to Enable?

Post by timmcq »

What other add-on modules are required, if any, in order to add the salinity module?
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Salinity Module - How to Enable?

Post by rimai »

There is no other module required.
You just have to keep in mind that you can only connect one expansion module to the relay box.
If you want to connect 2 or more expansion modules, you will beed the expansion hub.
Roberto.
Post Reply