ATO switch reverse code.

Do you have a question on how to do something.
Ask in here.
Post Reply
Visser
Posts: 9
Joined: Tue Jan 14, 2014 4:46 am
Location: Brits, South africa

ATO switch reverse code.

Post by Visser »

Hi guys. This is my first post as I'm a brand new RA user & looking for some advice on a coding problem I have. (I'm a true coding noob so please bare with me...)

I have a question regarding coding my high ato switch to work in reverse.
Reason for this is... I have 2x float switches wired in series in my return chamber (both mounted upside down (wires on bottom), & one mounted lower than other) lower switch is main switch, & top switch is failsafe if the first one fails.


My question is this... how can I code the single HIGH ATO switch to act in reverse. (switching ON port8 when float touches "wired side"/bottom & switching OFF when it reaches the opposite end/top)


I want to use the LOW ATO switch in the top-up reservoir at the bottom to deactivate port8 (mounted in normal position with wires on top, so no problem there) when the reservoir is empty to prevent my pump from running dry...


I did try the advice in some older posts, but seems to be an older type of code... :|


My current code to follow. Please help me by altering my code (or indicating how I can change it) to incorporate the reversed ato high function please.

Thanks in advance guys!
Visser
Posts: 9
Joined: Tue Jan 14, 2014 4:46 am
Location: Brits, South africa

Re: ATO switch reverse code.

Post by Visser »

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>

////// 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

    ReefAngel.Use2014Screen();  // Let's use 2014 Screen 
    ReefAngel.AddPHExpansion();  // pH Expansion Module
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = Port1Bit;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port8Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = Port2Bit;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port4Bit | Port5Bit | Port6Bit;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;
    // Set the Overheat temperature setting
    InternalMemory.OverheatTemp_write( 280 );


    // Ports that are always on
    ReefAngel.Relay.On( Port1 );
    ReefAngel.Relay.On( Port2 );
    ReefAngel.Relay.On( Port3 );
    ReefAngel.Relay.On( Port4 );

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

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

void loop()
{
    ReefAngel.StandardLights( Port5,1,0,3,0 );
    ReefAngel.StandardHeater( Port6,245,250 );
    ReefAngel.StandardFan( Port7,257,265 );
    ReefAngel.SingleATO( false,Port8,30,0 );
    ReefAngel.SingleATO( true,Port8,0,0 );
    ////// Place your custom code below here
    

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

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

User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: ATO switch reverse code.

Post by lnevo »

You can use ReverseATOHigh(); anywhere in your code...but you may be missing a line in the feature.txt file for it to work. If you can find my push request on the github repo it should have the info that needs to be added...or search the forum. I helped someone else with it a while back.

I'm away from home so cant look it up at the moment...
Visser
Posts: 9
Joined: Tue Jan 14, 2014 4:46 am
Location: Brits, South africa

Re: ATO switch reverse code.

Post by Visser »

lnevo wrote:You can use ReverseATOHigh(); anywhere in your code...but you may be missing a line in the feature.txt file for it to work. If you can find my push request on the github repo it should have the info that needs to be added...or search the forum. I helped someone else with it a while back.

I'm away from home so cant look it up at the moment...
Thanks @inevo. sorry. Ive got no idea what the push request on github is... (Maybe I missed something somewhere.) Do you perhaps just have a link to the github? Will try to find it from there...
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: ATO switch reverse code.

Post by Sacohen »

Another, possible, option would be to flip the float around.
Remove the clip on the ATO, flip the float over and put the clip back on.

that may work the way you want it to.
Seagals
Posts: 127
Joined: Wed Aug 01, 2012 7:06 am

Re: ATO switch reverse code.

Post by Seagals »

Sacohen wrote:Another, possible, option would be to flip the float around.
Remove the clip on the ATO, flip the float over and put the clip back on.

that may work the way you want it to.
+1 - I tried doing it thru the code - didn't work for me but than again I am a novice - I did the above worked like a charm. If interested I think inevo is referring to a post entitled 'ato signal on portal'. try a search on that it may help.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

ATO switch reverse code.

Post by lnevo »

This is the line that needs to be added in feature.txt (in the link below.)

If using the latest libraries the ReverseATOHigh() function should be in there. It doesnt matter where you put it. If you get a compile error its because you need to follow the link below.

http://forum.reefangel.com/viewtopic.php?t=3652#p30674

I always liked doing something i software vs hardware where possible :)
Visser
Posts: 9
Joined: Tue Jan 14, 2014 4:46 am
Location: Brits, South africa

Re: ATO switch reverse code.

Post by Visser »

Thanks for the link inevo. I checked the feature.txt & the whole reverse code was in there as per the github post.

Now... Where do I change the code in my .INO to reverse the float switch function for only my high ato float?

Thanks
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: ATO switch reverse code.

Post by lnevo »

You can add the function anywhere. It's only used to detecti and enable the definition. So just put ReverseATOHigh(); unless its ReverseHighATO(); lol

I forget which..check my INO if you want...one will compile one wont :)
Visser
Posts: 9
Joined: Tue Jan 14, 2014 4:46 am
Location: Brits, South africa

Re: ATO switch reverse code.

Post by Visser »

Thanks inevo!

I managed to get it reversed in the code... But then also tried removing the clip from switch, & turning the float around, & that worked fantastic! (didnt think it would work, lol). Thanks all for the advice... Will probably have another question in a couple days when I finally get my wifi connected!
Visser
Posts: 9
Joined: Tue Jan 14, 2014 4:46 am
Location: Brits, South africa

Float switch on custom main screen?

Post by Visser »

Hi guys. Ive got another question regarding float switches.

I wrote/copied some code for my custom main screen which ended up pretty nice, but I cant seem to get the code right to show my float switch status on the main screen.
Anyone have some code that I can use to copy in my code that can show this?

My current custom screen:
Image


How I want it to look (more or less. Not fussy about looks, just want to see float status):
Image


My custom screen code:

Code: Select all

////// Place global variable code below here
    int avgph[10];
    unsigned long totalavgph=0;
    byte avgindex=0;

void DrawCustomMain()
    {
      byte x;
      byte y = 2;
      char text[7];

      // *********** CHANGE TEMP READOUT COLOR DEPENDENT ON FAN AND HEATER STATUS ***********
      int TempColor;        // Color for drawing temperature
      boolean FanOn = ReefAngel.Relay.Status(Port7);    // Get the status of the fan relay
      boolean HeatOn = ReefAngel.Relay.Status(Port6);   // Get the status of the heater relay
      if (HeatOn) 
      {
        TempColor = COLOR_NAVY;    // Blue text, too cold, heater is on
      }
      if (FanOn)   
      {
          TempColor = COLOR_RED;   // Red text, too warm, fan is on
      }
      if (!HeatOn && !FanOn) 
      {
          TempColor = COLOR_GREEN;  // Green text, no fan or heater on
      }
      // ***********************************************************************************
     
      ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 30, 2, "CJ's PICO REEF");       // Put a banner at the top
      ReefAngel.LCD.DrawDate(6, 119);                                                      // Put the date and time at the bottom
      ReefAngel.LCD.Clear(COLOR_BLACK, 1, 11, 132, 11);                                    // Draw a black line under the banner
      x = 6;
      y += MENU_START_ROW+1;                                                               // MENU_START_ROW is 10, according to globals.h, so y=2+10+1=13
      ReefAngel.LCD.DrawText(COLOR_BLUE, COLOR_WHITE, x, y+5, "Pico Temp   PH");
      ConvertNumToString(text, ReefAngel.Params.PH, 100);                                  // Get pH reading and convert
      ReefAngel.LCD.DrawLargeText(PHColor, DefaultBGColor, x+75, y+18, text, Font8x16);    // Put pH on the screen
      ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);                       // Get T1 temp and convert
      y += MENU_START_ROW*1.3;
      x = 6;
      ReefAngel.LCD.DrawHugeNumbers(COLOR_WHITE, TempColor, x, y, text);                   // Draw the temperature, white numbers on a colored background
      x += 6;
      y += MENU_START_ROW*1.2;
      ReefAngel.LCD.DrawText(COLOR_BLUE, COLOR_WHITE, x, y+5, "Room Temp");
      ConvertNumToString(text, ReefAngel.Params.Temp[T2_PROBE], 10);                       // Get T2 temp and convert
      y += MENU_START_ROW*1.2;
      x = 6;
      ReefAngel.LCD.DrawHugeNumbers(COLOR_WHITE, TempColor, x, y, text);                   // Draw the temperature, white numbers on a colored background
      x += 6;
      y += MENU_START_ROW*1.2;
      
      
      
      byte TempRelay = ReefAngel.Relay.RelayData;                                          // Code for drawing the relay box
      TempRelay &= ReefAngel.Relay.RelayMaskOff;
      TempRelay |= ReefAngel.Relay.RelayMaskOn;
      ReefAngel.LCD.DrawOutletBox(12, 100, TempRelay);

   }
void DrawCustomGraph()
{
}
////// Place global variable code above here
Thanks in advance guys!
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: ATO switch reverse code.

Post by Sacohen »

I pulled this from Lee's PDE.

Code: Select all

  if (ReefAngel.HighATO.IsActive()) {
    ReefAngel.LCD.FillCircle(55,y+3,5,COLOR_GREEN);
  } else {
    ReefAngel.LCD.FillCircle(55,y+3,5,COLOR_RED);
  }
  
  if (ReefAngel.LowATO.IsActive()) {
    ReefAngel.LCD.FillCircle(70,y+3,5,COLOR_GREEN);
  } else {
    ReefAngel.LCD.FillCircle(70,y+3,5,COLOR_RED);
  }
This is how it looks on his screen.
Image

See how it works.
I've never tried it myself.
Visser
Posts: 9
Joined: Tue Jan 14, 2014 4:46 am
Location: Brits, South africa

Re: ATO switch reverse code.

Post by Visser »

Thanks Steve & Lee! The code worked fantastic!!!
Sump + skimmer deactivated, Normal temps
Image

Sump & skimmer active, Normal temps
Image

Sump + skimmer deactivated, Low temps
Image

Sump + skimmer deactivated, Overhead temps
Image


Works like a charm. Thanks so much guys!!!
Here is the code if anyone wants to try.

Code: Select all

////// Place global variable code below here
    int avgph[10];
    unsigned long totalavgph=0;
    byte avgindex=0;

void DrawCustomMain()
    {
      byte x;
      byte y = 2;
      char text[7];

      // *********** CHANGE TEMP READOUT COLOR DEPENDENT ON FAN AND HEATER STATUS ***********
      int TempColor;        // Color for drawing temperature
      boolean FanOn = ReefAngel.Relay.Status(Port7);    // Get the status of the fan relay
      boolean HeatOn = ReefAngel.Relay.Status(Port6);   // Get the status of the heater relay
      if (HeatOn) 
      {
        TempColor = COLOR_NAVY;    // Blue text, too cold, heater is on
      }
      if (FanOn)   
      {
          TempColor = COLOR_RED;   // Red text, too warm, fan is on
      }
      if (!HeatOn && !FanOn) 
      {
          TempColor = COLOR_GREEN;  // Green text, no fan or heater on
      }
      // ***********************************************************************************
     
      ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 30, 2, "CJ's PICO REEF");       // Put a banner at the top
      ReefAngel.LCD.DrawDate(6, 119);                                                      // Put the date and time at the bottom
      ReefAngel.LCD.Clear(COLOR_BLACK, 1, 11, 132, 11);                                    // Draw a black line under the banner
      x = 6;
      y += MENU_START_ROW*1.0;                                                               // MENU_START_ROW is 10, according to globals.h, so y=2+10+1=13
      ReefAngel.LCD.DrawText(COLOR_BLUE, COLOR_WHITE, x, y+1, "Pico Temp   PH");
      x = 6;
      y = MENU_START_ROW*0.8;
      ConvertNumToString(text, ReefAngel.Params.PH, 100);                                  // Get pH reading and convert
      ReefAngel.LCD.DrawLargeText(PHColor, DefaultBGColor, x+73, y+12, text, Font8x16);    // Put pH on the screen
      ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);                       // Get T1 temp and convert
      x = 6;
      y += MENU_START_ROW*1.3;
      ReefAngel.LCD.DrawHugeNumbers(COLOR_WHITE, TempColor, x, y, text);                   // Draw the temperature, white numbers on a colored background
      x += 6;
      y += MENU_START_ROW*1.2;
      ReefAngel.LCD.DrawText(COLOR_BLUE, COLOR_WHITE, x-6, y+5, "Room Temp");
      ConvertNumToString(text, ReefAngel.Params.Temp[T2_PROBE], 10);                       // Get T2 temp and convert
      y += MENU_START_ROW*1.2;
      x = 6;
      ReefAngel.LCD.DrawHugeNumbers(COLOR_WHITE, TempColor, x, y, text);                   // Draw the temperature, white numbers on a colored background
      x += 6;
      y += MENU_START_ROW*2.2;

  ReefAngel.LCD.DrawLargeText(COLOR_INDIGO,DefaultBGColor,25,y,"Sump Level",Font8x8);            // Draw the Float switch status
  if (ReefAngel.HighATO.IsActive()) {
    ReefAngel.LCD.FillCircle(15,y+3,7,COLOR_RED);
  } else {
    ReefAngel.LCD.FillCircle(15,y+3,7,COLOR_GREEN);
  }
  x += 6;
      y += MENU_START_ROW*1.6;
  ReefAngel.LCD.DrawLargeText(COLOR_INDIGO,DefaultBGColor,25,y,"Skimmer Cup",Font8x8);
  if (ReefAngel.LowATO.IsActive()) {
    ReefAngel.LCD.FillCircle(15,y+3,7,COLOR_RED);
  } else {
    ReefAngel.LCD.FillCircle(15,y+3,7,COLOR_GREEN);
  }
      
      
      byte TempRelay = ReefAngel.Relay.RelayData;                                          // Code for drawing the relay box
      TempRelay &= ReefAngel.Relay.RelayMaskOff;
      TempRelay |= ReefAngel.Relay.RelayMaskOn;
      ReefAngel.LCD.DrawOutletBox(12, 100, TempRelay);
   }
void DrawCustomGraph()
{
}
////// Place global variable code above here
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: ATO switch reverse code.

Post by Sacohen »

Great. Glad it worked.
Post Reply