Re: Reversing the ATO code
Posted: Tue Jun 07, 2011 11:59 pm
I've been saying these switches were coded backwards for a while, but I think people thought I was that crazy old man in the village
Community discussion about Reef Angel Controllers and reefing related subjects
https://forum.reefangel.com/
make it 2 crazy old men in the village hehealexwbush wrote:I've been saying these switches were coded backwards for a while, but I think people thought I was that crazy old man in the village
Trying to get this working but I'm getting the following error when compiling:binder wrote: It sounds like you want the water level to be at the low switch with the high one as a backup. So going back to your initial request, here would be some logic for you: (This will assume both switches are wired with their wires at the top)You can just copy and paste this function into your PDE file. Then inside your loop function, you can call it like this:Code: Select all
void ATOFailSafe(byte port) { // Check for the low switch /* If the Low switch is active, meaning the float is opposite the end with the two wires, we are empty so we should turn on the pump. Otherwise, we are full, so turn off the port. */ if ( ReefAngel.LowATO.IsActive() ) { ReefAngel.LowATO.StartTopping(); ReefAngel.Relay.On(port); } else { ReefAngel.LowATO.StopTopping(); ReefAngel.Relay.Off(port); } if ( ReefAngel.LowATO.IsTopping() && ! ReefAngel.HighATO.IsActive() ) { // We have a problem /* The pump is running and topping but the low switch isn't shutting off the port. We must shutoff the port ourself. */ ReefAngel.Relay.Off(port); // Trigger some sort of alert, maybe an email or text message /* We did not indicate that the port is not topping anymore, we could do that manually OR we could not do it and replace the switch and have the controller do it for us. It's completely up to the user. At this point, it shouldn't matter because there is a problem with the switch and that needs to be addressed. */ } }
This should handle your failsafe redundancy.Code: Select all
void loop() { // other functions ATOFailSafe(Port1); }
NOTE: This code does not use the timeouts at all and it does not use the hour interval. You would use this function instead of using the SingleATO or StandardATO functions.
Edited to indicate proper functionality with both wires at the top (coming out of the water) which is the reverse of how the SingleATO function works. SingleATO was based off of the high switch mounting/positioning from the StandardATO function.
curt
Code: Select all
// Autogenerated file by RAGen (v1.0.4.92), (09/08/2011 09:54)
// default_ragen_pde_all_ato_test.pde
//
// This version designed for v0.8.5 Beta 12 or later
/* The following features are enabled for this PDE File:
#define DisplayImages
#define WavemakerSetup
#define DateTimeSetup
#define VersionMenu
#define DirectTempSensor
#define DisplayLEDPWM
#define StandardLightSetup
*/
#include <ReefAngel_Features.h>
#include <ReefAngel_Globals.h>
#include <ReefAngel_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <ReefAngel_EEPROM.h>
#include <ReefAngel_NokiaLCD.h>
#include <ReefAngel_ATO.h>
#include <ReefAngel_Joystick.h>
#include <ReefAngel_LED.h>
#include <ReefAngel_TempSensor.h>
#include <ReefAngel_Relay.h>
#include <ReefAngel_PWM.h>
#include <ReefAngel_Timer.h>
#include <ReefAngel_Memory.h>
#include <ReefAngel.h>
#define Daylight 1
#define ATO 2
//#define Chiller 2
#define Heater 3
#define Return 4
#define WavemakerL 5
#define WavemakerR 6
#define LED 7
#define Refugium 8
void setup()
void ATOFailSafe(byte ATO) //changed port to ATO
{
// Check for the low switch
/*
If the Low switch is active, meaning the float is opposite the end with the two wires,
we are empty so we should turn on the pump. Otherwise, we are full, so turn off the port.
*/
if ( ReefAngel.LowATO.IsActive() )
{
ReefAngel.LowATO.StartTopping();
ReefAngel.Relay.On(ATO);
}
else
{
ReefAngel.LowATO.StopTopping();
ReefAngel.Relay.Off(ATO);
}
if ( ReefAngel.LowATO.IsTopping() && ! ReefAngel.HighATO.IsActive() )
{
// We have a problem
/*
The pump is running and topping but the low switch isn't shutting off the port.
We must shutoff the port ourself.
*/
ReefAngel.Relay.Off(ATO);
// Trigger some sort of alert, maybe an email or text message
/*
We did not indicate that the port is not topping anymore, we could do that manually
OR we could not do it and replace the switch and have the controller do it for us.
It's completely up to the user.
At this point, it shouldn't matter because there is a problem with the switch and that
needs to be addressed.
*/
}
{
randomSeed(analogRead(0)); //wm stuff
ReefAngel.Init(); //Initialize controller
ReefAngel.FeedingModePorts = B00001000;
ReefAngel.WaterChangePorts = B00000000;
ReefAngel.OverheatShutoffPorts = B00000101;
ReefAngel.LightsOnPorts = B00000001;
// Ports that are always on
ReefAngel.Relay.On(Return); //port 4
//wm stuff
ReefAngel.Timer[1].SetInterval(random(15,35));
ReefAngel.Timer[1].Start();
ReefAngel.Relay.On(WavemakerL);
}
}
void loop()
{
ReefAngel.ShowInterface();
ReefAngel.StandardGUI(); //web connection
// ReefAngel.StandardFan(Chiller,775,783); Removed for ATO function
ReefAngel.StandardHeater(Heater,768,771);
ReefAngel.StandardLights(Daylight,9,0,19,30); //Daylight schedule 9:00am - 7:30pm
ReefAngel.StandardLights(Refugium,21,0,9,0); //Refugium schedule 9:00pm - 9:00am
ReefAngel.StandardLights(LED,8,30,22,0); //LED schedule 8:30am - 10:00pm
ATOFailSafe(ATO); //ATO Stuff
//Wavemaker stuff
if ( ReefAngel.Timer[1].IsTriggered() )
{
ReefAngel.Timer[1].SetInterval(random(15,30));
ReefAngel.Timer[1].Start();
ReefAngel.Relay.Toggle(WavemakerL); //port 5
ReefAngel.Relay.Toggle(WavemakerR); //port 6
}
/* Old ATO stuff
if(ReefAngel.LowATO.IsActive())
{
ReefAngel.Relay.On(ATO); //port 7
}
else
{
ReefAngel.Relay.Off(ATO);
}
*/
}
Code: Select all
#define LED 7
Hmm, changed LED to Moonlight and I still get the same error(s). It compiles without the ATO code binder suggested (including the define LED reference) which is what I've been running for a while now with no issues.rimai wrote:You can't use:It's a reserved word for a the LED Class Sorry.Code: Select all
#define LED 7
Choose a different name
Code: Select all
// Autogenerated file by RAGen (v1.0.4.92), (09/08/2011 09:54)
// ATO_TEST.pde
//
// This version designed for v0.8.5 Beta 12 or later
/* The following features are enabled for this PDE File:
#define DisplayImages
#define WavemakerSetup
#define DateTimeSetup
#define VersionMenu
#define DirectTempSensor
#define DisplayLEDPWM
#define StandardLightSetup
*/
#include <ReefAngel_Features.h>
#include <ReefAngel_Globals.h>
#include <ReefAngel_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <ReefAngel_EEPROM.h>
#include <ReefAngel_NokiaLCD.h>
#include <ReefAngel_ATO.h>
#include <ReefAngel_Joystick.h>
#include <ReefAngel_LED.h>
#include <ReefAngel_TempSensor.h>
#include <ReefAngel_Relay.h>
#include <ReefAngel_PWM.h>
#include <ReefAngel_Timer.h>
#include <ReefAngel_Memory.h>
#include <ReefAngel.h>
#define Daylight 1
#define AutoTopOff 2
//#define Chiller 2
#define Heater 3
#define Return 4
#define WavemakerL 5
#define WavemakerR 6
#define LED1 7
#define Refugium 8
void setup()
{
randomSeed(analogRead(0)); //wm stuff
ReefAngel.Init(); //Initialize controller
ReefAngel.FeedingModePorts = B00001000;
ReefAngel.WaterChangePorts = B00000000;
ReefAngel.OverheatShutoffPorts = B00000101;
ReefAngel.LightsOnPorts = B00000001;
// Ports that are always on
ReefAngel.Relay.On(Return); //port 4
//wm stuff
ReefAngel.Timer[1].SetInterval(random(15,35));
ReefAngel.Timer[1].Start();
ReefAngel.Relay.On(WavemakerL);
}
void loop()
{
ReefAngel.ShowInterface();
// ReefAngel.StandardFan(Chiller,775,783); Removed for ATO function
ReefAngel.StandardHeater(Heater,768,771);
ReefAngel.StandardLights(Daylight,9,0,19,30); //Daylight schedule 9:00am - 7:30pm
ReefAngel.StandardLights(Refugium,21,0,9,0); //Refugium schedule 9:00pm - 9:00am
ReefAngel.StandardLights(LED1,8,30,22,0); //LED schedule 8:30am - 10:00pm
ATOFailSafe(AutoTopOff); //ATO Stuff
//Wavemaker stuff
if ( ReefAngel.Timer[1].IsTriggered() )
{
ReefAngel.Timer[1].SetInterval(random(15,30));
ReefAngel.Timer[1].Start();
ReefAngel.Relay.Toggle(WavemakerL); //port 5
ReefAngel.Relay.Toggle(WavemakerR); //port 6
}
/* Old ATO stuff
if(ReefAngel.LowATO.IsActive())
{
ReefAngel.Relay.On(ATO); //port 7
}
else
{
ReefAngel.Relay.Off(ATO);
}
*/
}
void ATOFailSafe(byte ATO) //changed port to ATO
{
// Check for the low switch
/*
If the Low switch is active, meaning the float is opposite the end with the two wires,
we are empty so we should turn on the pump. Otherwise, we are full, so turn off the port.
*/
if ( ReefAngel.LowATO.IsActive() )
{
ReefAngel.LowATO.StartTopping();
ReefAngel.Relay.On(ATO);
}
else
{
ReefAngel.LowATO.StopTopping();
ReefAngel.Relay.Off(ATO);
}
if ( ReefAngel.LowATO.IsTopping() && ! ReefAngel.HighATO.IsActive() )
{
// We have a problem
/*
The pump is running and topping but the low switch isn't shutting off the port.
We must shutoff the port ourself.
*/
ReefAngel.Relay.Off(ATO);
// Trigger some sort of alert, maybe an email or text message
/*
We did not indicate that the port is not topping anymore, we could do that manually
OR we could not do it and replace the switch and have the controller do it for us.
It's completely up to the user.
At this point, it shouldn't matter because there is a problem with the switch and that
needs to be addressed.
*/
}
}