ATO timeout

Do you have a question on how to do something.
Ask in here.
Post Reply
dangrymidget
Posts: 25
Joined: Thu Mar 01, 2012 8:17 pm

ATO timeout

Post by dangrymidget »

Encountered a new problem, but one i expected. My code is working the way i want it to, the bottom float is activating the pump when needed and the top float is shutting it down and activating the buzzer (we manually trigger the backup to test the buzzer). The problem is the auto-timeout for the bottom float is too short. It doesn't give the pump enough time to fill. Is there a way I can disable the auto-timeout so that the pump will only shut off if one of the floats is triggered?

Here's my code:

Code: Select all

/*
#define FONT_8X16
#define NUMBERS_8x16
#define DisplayImages
#define DateTimeSetup
#define DirectTempSensor
#define DisplayLEDPWM
#define wifi
#define StandardLightSetup
#define SaveRelayState
#define RelayExp
#define InstalledRelayExpansionModules 1
#define WDT
#define PWMEXPANSION
#define CUSTOM_MAIN
#define RFEXPANSION
#define FONT_8x16
#define NUMBERS_8x16
*/

#include <Salinity.h>
#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 <RF.h>
#include <IO.h>
#include <ORP.h>
#include <ReefAngel.h>
#include <avr/wdt.h>


byte x,y;
char text[10];
byte hightemp=0;
byte highfloat=0;
byte buzzer=0;

#define LEDPWM0 0
#define LEDPWM1 1
#define LEDPWM2 2
#define LEDPWM3 3

byte PWMChannel[]={
0,0,0,0,0,0};


int v;

void DrawCustomGraph()
{
}

void DrawCustomMain()
{
        //Top Banner
        ReefAngel.LCD.DrawText(COLOR_BLACK, COLOR_SKYBLUE, 23, 2, " Civiello Reef "); 
        
        // Display T1 Header Text
        ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,8,14,"Tank");
  
        // Display the T1 Temp Value
        char text[7];
        ConvertNumToString(text, ReefAngel.Params.Temp[T2_PROBE], 10);
        ReefAngel.LCD.Clear(255, 4, 21, 37, 37);
        ReefAngel.LCD.DrawLargeText(COLOR_CORNFLOWERBLUE, 255, 4, 24, text, Num8x16);
        pingSerial();

        // Display the T2 Header Text
        ReefAngel.LCD.DrawText(COLOR_CRIMSON,255,52,14,"Lights");
  
        // Display the T2 Temp Value
        ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
        ReefAngel.LCD.Clear(255, 52, 21, 75, 37);
        ReefAngel.LCD.DrawLargeText(COLOR_CRIMSON, 255, 52, 24, text, Num8x16);
        pingSerial();

        // Display pH Header Text
        ReefAngel.LCD.DrawText(COLOR_INDIGO,255,108,14,"pH");
  
        // Display pH Value
        ConvertNumToString(text, ReefAngel.Params.PH, 100);
        ReefAngel.LCD.Clear(255, 94, 21, 106, 37);
        ReefAngel.LCD.DrawLargeText(COLOR_INDIGO, 255, 94, 24, text, Num8x16);
        pingSerial();
                
        // Display PMW Expansion Channel Headers and % Values
        ReefAngel.LCD.Clear(DefaultFGColor,5,43,127,43); // Draw divider
        ReefAngel.LCD.DrawText(COLOR_MAGENTA,DefaultBGColor,31,48,"LED Dimming");

        x=15;
        y=58;
        ReefAngel.LCD.DrawText(COLOR_LIMEGREEN,DefaultBGColor,x,y,"Day:");
        ConvertNumToString(text, ReefAngel.PWM.GetDaylightValue(), 1);
        strcat(text,"  ");
        ReefAngel.LCD.DrawText(COLOR_LIMEGREEN,DefaultBGColor,x+24,y,text);

        x=75;
        y=58;
        ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,DefaultBGColor,x,y,"Act:");
        ConvertNumToString(text, ReefAngel.PWM.GetActinicValue(), 1);
        strcat(text,"  ");
        ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,DefaultBGColor,x+24,y,text);


        x=15;
        y=68;
        for (int a=1;a<5;a++)
        {
          if (a>2) x=75;
          if (a==3) y=68;
          ReefAngel.LCD.DrawText(COLOR_MAGENTA,DefaultBGColor,x,y,"Ch :");
          ReefAngel.LCD.DrawText(COLOR_MAGENTA,DefaultBGColor,x+12,y,a);
          ConvertNumToString(text, ReefAngel.PWM.GetChannelValue(a), 1);
          strcat(text,"  ");
          ReefAngel.LCD.DrawText(COLOR_MAGENTA,DefaultBGColor,x+24,y,text);
          y+=10;
        }
        pingSerial();
        
        // Display Main Relay Box
        byte TempRelay = ReefAngel.Relay.RelayData;
        TempRelay &= ReefAngel.Relay.RelayMaskOff;
        TempRelay |= ReefAngel.Relay.RelayMaskOn;
        ReefAngel.LCD.DrawOutletBox(13, 100, TempRelay);
        pingSerial();
        
        //Draw Date & Time
        ReefAngel.LCD.DrawDate(6, 123);
        pingSerial();
}
void setup()
{
  ReefAngel.Init();  //Initialize controller
  ReefAngel.Relay.On(Port8);
}

void loop()
{
  ReefAngel.SingleATOLow(Port6);  //Setup Port1 as Auto Top-Off function with on/off
    if (ReefAngel.HighATO.IsActive()) ReefAngel.Relay.Off(Port6); //upper float set as shut off fail safe
  //Temp
  ReefAngel.StandardHeater(Port5,780,785);  // Setup Heater to turn on at 78.0F and off at 78.5F
  ReefAngel.StandardHeater(Port4,780,785);  // Setup Heater to turn on at 78.0F and off at 78.5F
  ReefAngel.StandardFan(Port2,790,785);  // Setup Chiller to turn on at 79.0F and off at 78.5F
  
  //Lights
  ReefAngel.StandardLights(Port3,21,30,10,30);  //Refugium schedule 8:30pm - 10:30am
  //Actinics 
  ReefAngel.PWM.SetActinic(PWMSlope(13,00,19,00,15,25,120,0)); //lights on at 1:00pm off at 7:00pm from 15% to 25% over 120 min
  //Day
  ReefAngel.PWM.SetDaylight(PWMSlope(13,30,19,30,15,25,120,0)); //lights on at 1:30am off at 7:30pm from 15% to 25% over 120 min  
  if (ReefAngel.Params.Temp[T1_PROBE]>1500)
  {  
    ReefAngel.Relay.Off(Port1); //day
    ReefAngel.Relay.Off(Port7); //act
    hightemp=1;
  }
  if (ReefAngel.Params.Temp[T1_PROBE]<1400)
  {
    ReefAngel.StandardLights(Port7,12,30,19,30); //Actinic port on at 12:30am of att 7:30pm
    ReefAngel.StandardLights(Port1,13,00,20,00); //Daylight port on at 1:00am off at 8:00pm
    hightemp=0;
  }
  
  if (ReefAngel.HighATO.IsActive()) highfloat=1; else highfloat=0;
  
  //Buzzer
  buzzer=highfloat + hightemp;
  if (buzzer>1) buzzer=1;
  ReefAngel.PWM.SetChannel(5,buzzer*100); 
  
  //Moon
  ReefAngel.PWM.SetChannel(1,MoonPhase());
  ReefAngel.PWM.SetChannel(2,MoonPhase());
  ReefAngel.PWM.SetChannel(3,MoonPhase());
  ReefAngel.PWM.SetChannel(4,MoonPhase());
  ReefAngel.ShowInterface(); // Draws the standard graphical user interface
}
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: ATO timeout

Post by binder »

What is the timeout you have for the SingleATOLow?
dangrymidget
Posts: 25
Joined: Thu Mar 01, 2012 8:17 pm

Re: ATO timeout

Post by dangrymidget »

I didn't set one, its whatever the default value is
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: ATO timeout

Post by binder »

dangrymidget wrote:I didn't set one, its whatever the default value is
The default is 60 seconds. That number can be increased to 255 seconds (4 minutes and 15 seconds).
dangrymidget
Posts: 25
Joined: Thu Mar 01, 2012 8:17 pm

Re: ATO timeout

Post by dangrymidget »

that would work just fine, how do i set it?
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: ATO timeout

Post by binder »

dangrymidget wrote:that would work just fine, how do i set it?
You need to either use the android app or iphone app (I think this can do it).
You could use the java status app (http://forum.reefangel.com/viewtopic.php?f=8&t=246)
Or you could manually set it via a custom web address (the same way the other apps do it).

You will want to update the "ATO Timeout" value since you are using the low ato port.
dangrymidget
Posts: 25
Joined: Thu Mar 01, 2012 8:17 pm

Re: ATO timeout

Post by dangrymidget »

I don't have a wi-fi module, is there a way to do it with out one?
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: ATO timeout

Post by rimai »

use the java status app mentioned above.
Roberto.
dangrymidget
Posts: 25
Joined: Thu Mar 01, 2012 8:17 pm

Re: ATO timeout

Post by dangrymidget »

I'm having trouble getting the java app to connect, according to ardunio i'm load code through COM3. I figured out how to change what i need, i just can't connect.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: ATO timeout

Post by rimai »

Oh, nevermind.... I forgot the java app only works on wifi for now :(
Let's just write the value with code then. Much simpler.
Your setup should be like this:

Code: Select all

void setup()
{
  ReefAngel.Init();  //Initialize controller
  InternalMemory.ATOTimeout_write(255);
  ReefAngel.Relay.On(Port8);
}
Roberto.
dangrymidget
Posts: 25
Joined: Thu Mar 01, 2012 8:17 pm

Re: ATO timeout

Post by dangrymidget »

awesome thanks for the help
Last edited by dangrymidget on Fri Apr 06, 2012 6:45 pm, edited 1 time in total.
dangrymidget
Posts: 25
Joined: Thu Mar 01, 2012 8:17 pm

Re: ATO timeout

Post by dangrymidget »

one last question, is there a way i can set the buzzer to go off if the ATO does timeout?
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: ATO timeout

Post by rimai »

Yes, where do you have it plugged into?
Roberto.
dangrymidget
Posts: 25
Joined: Thu Mar 01, 2012 8:17 pm

Re: ATO timeout

Post by dangrymidget »

its plugged into port6, here's my code for it and for my buzzer

Code: Select all

  ReefAngel.SingleATOLow(Port6);  //Setup Port1 as Auto Top-Off function with on/off
    if (ReefAngel.HighATO.IsActive()) ReefAngel.Relay.Off(Port6); //upper float set as shut off fail safe

if (ReefAngel.HighATO.IsActive()) highfloat=1; else highfloat=0;
  
  //Buzzer
  buzzer=highfloat + hightemp;
  if (buzzer>1) buzzer=1;
  ReefAngel.PWM.SetChannel(5,buzzer*100); 
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: ATO timeout

Post by rimai »

I mean where is the buzzer plugged into?
Roberto.
dangrymidget
Posts: 25
Joined: Thu Mar 01, 2012 8:17 pm

Re: ATO timeout

Post by dangrymidget »

channel 5 of the pwm module
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: ATO timeout

Post by rimai »

You need to enable the feature Exceed Flagging:
Open RAGen
Move to Features tab and checkmark Exceed Flagging

Then, use this code:

Code: Select all

  ReefAngel.SingleATOLow(Port6);  //Setup Port1 as Auto Top-Off function with on/off
  if (ReefAngel.HighATO.IsActive()) ReefAngel.Relay.Off(Port6); //upper float set as shut off fail safe

  if (ReefAngel.HighATO.IsActive()) highfloat=1;   
  else highfloat=0;

  if (InternalMemory.read(ATO_Exceed_Flag)) atoflag=1;   
  else atoflag=0;
  //Buzzer
  buzzer=highfloat + hightemp + atoflag;
  if (buzzer>1) buzzer=1;
  ReefAngel.PWM.SetChannel(5,buzzer*100); 
Make sure to declare atoflag variable above setup():

Code: Select all

byte atoflag;
Roberto.
dangrymidget
Posts: 25
Joined: Thu Mar 01, 2012 8:17 pm

Re: ATO timeout

Post by dangrymidget »

Once again thanks for all the help.
dangrymidget
Posts: 25
Joined: Thu Mar 01, 2012 8:17 pm

Re: ATO timeout

Post by dangrymidget »

our buzzer has been going off none stop (we had to disconnect it) since i uploaded this code, is there something i missed or do i have something extra?

Code: Select all

/*
#define FONT_8X16
#define NUMBERS_8x16
#define DisplayImages
#define DateTimeSetup
#define DirectTempSensor
#define DisplayLEDPWM
#define wifi
#define StandardLightSetup
#define SaveRelayState
#define WDT
#define PWMEXPANSION
#define CUSTOM_MAIN
#define FONT_8x16
#define NUMBERS_8x16
*/

#include <Salinity.h>
#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 <RF.h>
#include <IO.h>
#include <ORP.h>
#include <ReefAngel.h>
#include <avr/wdt.h>


byte x,y;
char text[10];
byte hightemp=0;
byte highfloat=0;
byte buzzer=0;
byte atoflag;

#define LEDPWM0 0
#define LEDPWM1 1
#define LEDPWM2 2
#define LEDPWM3 3

byte PWMChannel[]={
0,0,0,0,0,0};


int v;

void DrawCustomGraph()
{
}

void DrawCustomMain()
{
        //Top Banner
        ReefAngel.LCD.DrawText(COLOR_BLACK, COLOR_SKYBLUE, 23, 2, " Civiello Reef "); 
        
        // Display T1 Header Text
        ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,8,14,"Tank");
  
        // Display the T1 Temp Value
        char text[7];
        ConvertNumToString(text, ReefAngel.Params.Temp[T2_PROBE], 10);
        ReefAngel.LCD.Clear(255, 4, 21, 37, 37);
        ReefAngel.LCD.DrawLargeText(COLOR_CORNFLOWERBLUE, 255, 4, 24, text, Num8x16);
        pingSerial();

        // Display the T2 Header Text
        ReefAngel.LCD.DrawText(COLOR_CRIMSON,255,52,14,"Lights");
  
        // Display the T2 Temp Value
        ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
        ReefAngel.LCD.Clear(255, 52, 21, 75, 37);
        ReefAngel.LCD.DrawLargeText(COLOR_CRIMSON, 255, 52, 24, text, Num8x16);
        pingSerial();

        // Display pH Header Text
        ReefAngel.LCD.DrawText(COLOR_INDIGO,255,108,14,"pH");
  
        // Display pH Value
        ConvertNumToString(text, ReefAngel.Params.PH, 100);
        ReefAngel.LCD.Clear(255, 94, 21, 106, 37);
        ReefAngel.LCD.DrawLargeText(COLOR_INDIGO, 255, 94, 24, text, Num8x16);
        pingSerial();
                
        // Display PMW Expansion Channel Headers and % Values
        ReefAngel.LCD.Clear(DefaultFGColor,5,43,127,43); // Draw divider
        ReefAngel.LCD.DrawText(COLOR_MAGENTA,DefaultBGColor,31,48,"LED Dimming");

        x=15;
        y=58;
        ReefAngel.LCD.DrawText(COLOR_LIMEGREEN,DefaultBGColor,x,y,"Day:");
        ConvertNumToString(text, ReefAngel.PWM.GetDaylightValue(), 1);
        strcat(text,"  ");
        ReefAngel.LCD.DrawText(COLOR_LIMEGREEN,DefaultBGColor,x+24,y,text);

        x=75;
        y=58;
        ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,DefaultBGColor,x,y,"Act:");
        ConvertNumToString(text, ReefAngel.PWM.GetActinicValue(), 1);
        strcat(text,"  ");
        ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,DefaultBGColor,x+24,y,text);


        x=15;
        y=68;
        for (int a=1;a<5;a++)
        {
          if (a>2) x=75;
          if (a==3) y=68;
          ReefAngel.LCD.DrawText(COLOR_MAGENTA,DefaultBGColor,x,y,"Ch :");
          ReefAngel.LCD.DrawText(COLOR_MAGENTA,DefaultBGColor,x+12,y,a);
          ConvertNumToString(text, ReefAngel.PWM.GetChannelValue(a), 1);
          strcat(text,"  ");
          ReefAngel.LCD.DrawText(COLOR_MAGENTA,DefaultBGColor,x+24,y,text);
          y+=10;
        }
        pingSerial();
        
        // Display Main Relay Box
        byte TempRelay = ReefAngel.Relay.RelayData;
        TempRelay &= ReefAngel.Relay.RelayMaskOff;
        TempRelay |= ReefAngel.Relay.RelayMaskOn;
        ReefAngel.LCD.DrawOutletBox(13, 100, TempRelay);
        pingSerial();
        
        //Draw Date & Time
        ReefAngel.LCD.DrawDate(6, 123);
        pingSerial();
}
void setup()
{
  ReefAngel.Init();  //Initialize controller
  InternalMemory.ATOTimeout_write(255);
  ReefAngel.Relay.On(Port8);
}

void loop()
{
  //ATO
  ReefAngel.SingleATOLow(Port6);  //Setup Port1 as Auto Top-Off function with on/off
  if (ReefAngel.HighATO.IsActive()) ReefAngel.Relay.Off(Port6); //upper float set as shut off fail safe
  if (ReefAngel.HighATO.IsActive()) highfloat=1;
  else highfloat=0;
  if (InternalMemory.read(ATO_Exceed_Flag)) atoflag=1;
  else atoflag=0;

  //Temp
  ReefAngel.StandardHeater(Port5,780,785);  // Setup Heater to turn on at 78.0F and off at 78.5F
  ReefAngel.StandardHeater(Port4,780,785);  // Setup Heater to turn on at 78.0F and off at 78.5F
  ReefAngel.StandardFan(Port2,790,785);  // Setup Chiller to turn on at 79.0F and off at 78.5F
  
  //Lights
  ReefAngel.StandardLights(Port3,20,00,8,00);  //Refugium schedule 8:30pm - 8:00am
  //Actinics 
  ReefAngel.PWM.SetActinic(PWMSlope(11,00,20,00,15,30,120,0)); //lights on at 11:30am off at 7:00pm from 15% to 30% over 120 min
  //Day
  ReefAngel.PWM.SetDaylight(PWMSlope(11,30,20,00,15,35,120,0)); //lights on at 11:30am off at 7:00pm from 15% to 35% over 120 min  
  if (ReefAngel.Params.Temp[T1_PROBE]>1500)
  {  
    ReefAngel.Relay.Off(Port1); //day
    ReefAngel.Relay.Off(Port7); //act
    hightemp=1;
  }
  if (ReefAngel.Params.Temp[T1_PROBE]<1400)
  {
    ReefAngel.StandardLights(Port7,11,30,20,30); //Actinic port on at 11:30am of att 7:30pm
    ReefAngel.StandardLights(Port1,11,30,20,30); //Daylight port on at 11:30am off at 7:30pm
    hightemp=0;
  }
  
  //Buzzer
  buzzer=highfloat + hightemp + atoflag;
  if (buzzer>1) buzzer=1;
  ReefAngel.PWM.SetChannel(5,buzzer*100); 
  
  //Moon
  ReefAngel.PWM.SetChannel(1,MoonPhase());
  ReefAngel.PWM.SetChannel(2,MoonPhase());
  ReefAngel.PWM.SetChannel(3,MoonPhase());
  ReefAngel.PWM.SetChannel(4,MoonPhase());
  ReefAngel.ShowInterface(); // Draws the standard graphical user interface
}

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

Re: ATO timeout

Post by rimai »

It's one of the checks you asked for.
Do you know which one it is?
You have 3 checks.

Code: Select all

buzzer=highfloat + hightemp + atoflag;
Roberto.
dangrymidget
Posts: 25
Joined: Thu Mar 01, 2012 8:17 pm

Re: ATO timeout

Post by dangrymidget »

i think its the atoflag, the problem didn't start till i added it
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: ATO timeout

Post by rimai »

Is your red status LED on?
Did you try clearing the ATO timeout flag?
Roberto.
dangrymidget
Posts: 25
Joined: Thu Mar 01, 2012 8:17 pm

Re: ATO timeout

Post by dangrymidget »

No status light, and did try clearing no difference
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: ATO timeout

Post by rimai »

I'm so sorry.
I made a mistake.
Replace this:

Code: Select all

  if (InternalMemory.read(ATO_Exceed_Flag)) atoflag=1;
With this:

Code: Select all

  if (InternalMemory.read(ATO_Single_Exceed_Flag)) atoflag=1;
You are using the single ATO and I coded to check for the standard ATO.
Roberto.
dangrymidget
Posts: 25
Joined: Thu Mar 01, 2012 8:17 pm

Re: ATO timeout

Post by dangrymidget »

Thanks for the help. wish i had caught that one.
Post Reply