Page 1 of 1

ATO Timeout question

Posted: Mon Nov 17, 2014 7:40 am
by westonhull
Hello,
I am using the ATO switch as flood protection for external equipment. In theory, When there is a leak it will fill up tank that is holding equipment. When the level switch is made (float on bottom/wire on top) it shuts off the outlet. However, the way this code is wrote after 60 seconds it times out and it shuts off the outlet when there is no leak. Can I get rid of the timeout :?:

Thanks!
Wes

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>

// Initialize Buzzer variables
byte buzzer=0;
byte highfloatflag=0;

////// 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.Use2014Screen();  // Let's use 2014 Screen 
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = 0;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port2Bit | Port3Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = 0;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = 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( 830 );


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

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

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

void loop()
{
    ReefAngel.CO2Control( Port1,638,678 );
    ReefAngel.SingleATO( true,Port2,60,0 );
    highfloatflag = ReefAngel.HighATO.IsActive();
    buzzer = highfloatflag;
    if ( buzzer >= 1 ) buzzer = 100;
    ReefAngel.PWM.SetDaylight( buzzer );

    ////// Place your custom code below here
    

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

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

Re: ATO Timeout question

Posted: Mon Nov 17, 2014 9:00 am
by lnevo
Doesn't sound like you wan tto use the SingleATO command. That will turn on the port when the switch is not active and shut it off when the timeout runs out or if the float switch floats up to connect the circuit.

You could just do:

Code: Select all

ReefAngel.Relay.Set(Port2, !highfloatflag);
With that if the switch is normal, the port should be on, if the switch is active, the port will be off. If it doesn't work as expected, take out the !

Re: ATO Timeout question

Posted: Mon Nov 17, 2014 10:01 am
by westonhull
Hello,
And thanks for the reply. I just wanted to verify..
So you are saying remove the

Code: Select all

ReefAngel.SingleATO( true,Port2,60,0 );
And insert;

Code: Select all

ReefAngel.Relay.Set(Port2, !highfloatflag);
And if it doens't work as I would expect remove the ! point before the highfloatflag?

Thanks!
Wes

Re: ATO Timeout question

Posted: Mon Nov 17, 2014 11:34 am
by lnevo
Well also make sure it comes after you set highatoflag but yes.

Re: ATO Timeout question

Posted: Mon Nov 17, 2014 4:37 pm
by westonhull
Hello,
Thanks for the reply!
Ok, so I tried with the (!) but it didn't work. So I removed the (!) and it works for the switch but the buzzer keeps buzzing.

Code: Select all

ReefAngel.Relay.Set(Port2, highfloatflag);
I tried to change the > to a < thinking it was like PLC's 1 and 0's but I guess that wasn't the case.

Code: Select all

if ( buzzer >= 1 ) buzzer = 100;
Question for you?? When the you get the red or green light for ATO does green mean you have a high ATO or does it mean you don't have a high ATO? When you lift the float switch it goes green.
So what does the (!) do and why did you have it in there? Trying to learn this type of code. Thanks again!

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>

// Initialize Buzzer variables
byte buzzer=0;
byte highfloatflag=0;

////// 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.Use2014Screen();  // Let's use 2014 Screen 
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = 0;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port2Bit | Port3Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = 0;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = 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( 830 );


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

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

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

void loop()
{
    ReefAngel.CO2Control( Port1,638,678 );
    ReefAngel.Relay.Set(Port2, !highfloatflag);
    highfloatflag = ReefAngel.HighATO.IsActive();
    buzzer = highfloatflag;
    if ( buzzer >= 1 ) buzzer = 100;
    ReefAngel.PWM.SetDaylight( buzzer );

    ////// Place your custom code below here
    

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

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


Re: ATO Timeout question

Posted: Mon Nov 17, 2014 6:05 pm
by lnevo
Change >= to == 1. If it still doesnt do what you expect change it to !=

The ! Means NOT. The reason its always buzzing is because your test is greater than or equal to 1 or less than or equal to 1.

Since the atohighflag will be 0 or 1 we can just use an == or != test. Once we know the state you COULD change it to use < or > but i dont think you should use >= or <=. Does that make sense?

Re: ATO Timeout question

Posted: Tue Nov 18, 2014 11:06 am
by westonhull
Hello,
Ok well that kinda worked...

Code: Select all

if ( buzzer >= 1 ) buzzer = 100;
Original code

Code: Select all

if ( buzzer != 1 ) buzzer = 100;
100% volume on high but 1% on Low

Code: Select all

if ( buzzer > 1 ) buzzer = 100;
0% on High but 1% on Low

Code: Select all

if ( buzzer < 1 ) buzzer = 100;
100% on High but 1% on Low

Code: Select all

if ( buzzer < 0 ) buzzer = 100;
0 on High but 1% on Low

Code: Select all

if ( buzzer > 0 ) buzzer = 100;
100% on High but 0% on Low

any other idea's to obtain 100% on High and 0% on Low?

Thanks,
Wes

Re: ATO Timeout question

Posted: Tue Nov 18, 2014 1:59 pm
by lnevo
Ok I see where the probelm may be stemming from...

Let's do this:

Code: Select all

    ReefAngel.Relay.Set(Port2, !highfloatflag);
    highfloatflag = ReefAngel.HighATO.IsActive();
    if ( highfloatflag > 0 ) buzzer=100;  else buzzer=0;
    ReefAngel.PWM.SetDaylight( buzzer );

Re: ATO Timeout question

Posted: Tue Nov 18, 2014 5:11 pm
by westonhull
Hello,

Ok, So I tried this;

Code: Select all

    ReefAngel.Relay.Set(Port2, !highfloatflag);
    highfloatflag = ReefAngel.HighATO.IsActive();
    if ( highfloatflag > 0 ) buzzer=100;  else buzzer=0;
    ReefAngel.PWM.SetDaylight( buzzer );
What happened was it was 0% on High and 100% on Low

I tried

Code: Select all

if ( highfloatflag < 0 ) buzzer=100;  else buzzer=0;
And it was 0% both ways

I for sure thought your idea would have worked. It sounded like it made sense.

Thanks for the help!
Wes

Re: ATO Timeout question

Posted: Tue Nov 18, 2014 6:46 pm
by lnevo
Ok reason < 0 didn't work is because you aren't getting a negative number so it can't be less than 0... the above should take care of it. Plus I have an error in the code i gave you because highfloatflag is being set AFTER we set the port..

So let's simplify this...

Code: Select all

    highfloatflag = ReefAngel.HighATO.IsActive();
    ReefAngel.Relay.Set(Port2, !highfloatflag);
    if (highfloatflag) buzzer=100;  else buzzer=0;
    ReefAngel.PWM.SetDaylight( buzzer );
Basically we're using highfloatflag as a boolean and you can change it's declaration from byte to boolean if you like. So the new code says if highfloatflag is true which means the float switch is active we shut off the port and turn on the buzzer and if it's false it will keep the port on and buzzer will be 0. I'm pretty sure this will do the trick at this point.

Re: ATO Timeout question

Posted: Wed Nov 19, 2014 8:54 am
by westonhull
Hello,
First I want to thank you for sticking through this with me. Well I swapped around the lines and changed the highfloatflag. So the outlet is correct when it goes high it does shut off but the buzzer goes to 100% when the switch is low and goes to 0% on High. :evil: Not to sure what's the deal.

Thanks again!
Wes

Re: ATO Timeout question

Posted: Wed Nov 19, 2014 9:21 am
by lnevo
I told you what to do if that happens. Change == to !=

Can you please post the current code. And confirm that you tried both scenario?

Re: ATO Timeout question

Posted: Wed Nov 19, 2014 9:40 am
by westonhull
Sorry thought I did...

Here is the current code.

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>

// Initialize Buzzer variables
byte buzzer=0;
byte highfloatflag=0;

////// 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.Use2014Screen();  // Let's use 2014 Screen 
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = 0;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port2Bit | Port3Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = 0;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = 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( 830 );


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

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

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

void loop()
{
    ReefAngel.CO2Control( Port1,638,678 );
    highfloatflag = ReefAngel.HighATO.IsActive();
    ReefAngel.Relay.Set(Port2, highfloatflag);
    if (highfloatflag) buzzer = 100; else buzzer=0;
    ReefAngel.PWM.SetDaylight( buzzer );

    ////// Place your custom code below here
    

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

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

I tried the != 1 and that was 100% on high and 1% on low.
I thought I tried the == but I guess, I didn't write that one down on my pad. I'll let you know in a sec.

Thanks!

Re: ATO Timeout question

Posted: Wed Nov 19, 2014 10:50 am
by lnevo
There can be no 1% with the code we have:

if (highfloatflag) buzzer = 100; else buzzer=0;

Because no matter what it's getting set to 100 or 0.

From the conversations we had, the 1% was when we were doing < and > comparisons...

Re: ATO Timeout question

Posted: Wed Nov 19, 2014 10:54 am
by lnevo
Looking at your code if the outlet is working properly we will want to do this:

Code: Select all

    highfloatflag = ReefAngel.HighATO.IsActive();
    ReefAngel.Relay.Set(Port2, highfloatflag);
    if (highfloatflag) buzzer=0; else buzzer=100;
    ReefAngel.PWM.SetDaylight( buzzer );
We took away the == and != comparison...so that wasn't relevant. Sorry my bad.

Re: ATO Timeout question

Posted: Wed Nov 19, 2014 11:50 am
by westonhull
Hello,
Well that worked! You are way better at this than I am. Where did you learn this language from? Do you have any books for dummy's for this stuff, if so I need them to get them? Anyways, Here is the final code. Thanks for helping me!

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>

// Initialize Buzzer variables
byte buzzer=0;
byte highfloatflag=0;

////// 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.Use2014Screen();  // Let's use 2014 Screen 
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = 0;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port2Bit | Port3Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = 0;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = 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( 830 );


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

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

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

void loop()
{
    ReefAngel.CO2Control( Port1,638,678 );
    highfloatflag = ReefAngel.HighATO.IsActive();
    ReefAngel.Relay.Set(Port2, highfloatflag);
    if (highfloatflag) buzzer = 0; else buzzer=100;
    ReefAngel.PWM.SetDaylight( buzzer );

    ////// Place your custom code below here
    

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

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


Re: ATO Timeout question

Posted: Wed Nov 19, 2014 12:39 pm
by lnevo
The language is C. You can find many books and sites on the language. It's pretty straight forward. The challenge here I think was just the different approach that was taken with the comparison and a bit of brain fart on my end. :)