Page 1 of 1

how to I/O revers ATO

Posted: Thu Nov 29, 2012 9:57 pm
by bigHUN
This was working on my RA and somehow got reversed on RA+. Doing now my float switches one by one.
Stuck with the I/O port #2 - ATO.
At this stage the waterlevel is high, so the I/O port#2 is ON, and I don't know how to code ATO OFF.
when the I/O#2 is OFF (low waterlevel) to turn the ATO ON with timer let say 60 second.
How to do this work around? Thanks in advance.........

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 <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.AddStandardMenu();  // Add Standard Menu

    // Ports toggled in Feeding Mode
  ReefAngel.FeedingModePorts = Port1Bit | Port8Bit;
  // Ports toggled in Water Change Mode
  ReefAngel.WaterChangePorts = Port1Bit | Port5Bit | Port6Bit | Port8Bit;
  // Ports toggled when Lights On / Off menu entry selected
  ReefAngel.LightsOnPorts = Port3Bit | Port4Bit | Port5Bit | Port6Bit | Port8Bit;
  // 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( 265 );


  // Ports that are always on
  ReefAngel.Relay.On( Port7 );
  ReefAngel.Relay.On( Port8 );

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


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

void loop()
{
  ReefAngel.StandardATO( Port1,62 );
  ReefAngel.StandardHeater( Port2,240,255 );
  ReefAngel.StandardLights( Port3,8,55,20,5 );
  ReefAngel.StandardLights( Port4,11,5,15,55 );
  if (hour()>=9 && hour()<20)
  {
    ReefAngel.Wavemaker( Port5,5 );
    ReefAngel.Relay.Set(Port6,!ReefAngel.Relay.Status(Port5));
  }
  else
  {
    ReefAngel.Relay.Off(Port5);
    ReefAngel.Relay.Off(Port6);
  }
  ReefAngel.PWM.SetChannel( 0, PWMParabola(9,5,19,55,15,100,15) );
  ReefAngel.PWM.SetChannel( 1, PWMParabola(10,5,18,55,15,100,15) );
  ReefAngel.PWM.SetChannel( 2, PWMParabola(11,5,15,55,15,100,15) );
  ReefAngel.PWM.SetChannel( 3, PWMParabola(11,35,17,55,15,100,15) );
  ReefAngel.PWM.SetChannel( 4, PWMParabola(18,35,3,5,15,100,15) );
  ////// Place your custom code below here

  //Float #1

  if (ReefAngel.IO.GetChannel(1)) // if float 1 is triggered
  {
    ReefAngel.Relay.Off(Port8); // Turn Return off
    ReefAngel.Relay.Off(Port7); // Turn Skimmer off
    BuzzerOn(); // Turn Buzzer on
  }

  //Float #2
  if (ReefAngel.IO.GetChannel(2)) // if float 2 is triggered
  {
    ReefAngel.Relay.On(Port1); // Turn AutoTopOff on
    ReefAngel.Timer[1].Start(); // Start/Trigger timer
  }

  // Float #3
  if (ReefAngel.IO.GetChannel(3)) // if float 3 is triggered
    BuzzerOn(); // Turn Buzzer on

    // Float #4
  // if (ReefAngel.IO.GetChannel(4)) // if float 4 is triggered
  //   ReefAngel.Relay.On(Port7); // Turn Skimmer off

  // Float #5
  // if (ReefAngel.IO.GetChannel(5)) // if float 5 is triggered
  {
  // ReefAngel.Relay.Off(Port8); // Turn Return off  
  //  BuzzerOn(); // Turn Buzzer on
  } 



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

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

void DrawCustomMain()
{
  int x,y;
  char text[10];
  // Dimming Expansion
  x = 15;
  y = 2;
  for ( int a=0;a<6;a++ )
  {
    if ( a>2 ) x = 75;
    if ( a==3 ) y = 2;
    ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x,y,"Ch :" );
    ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x+12,y,a );
    ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x+24,y,ReefAngel.PWM.GetChannelValue(a) );
    y += 10;
  }
  pingSerial();

  // I/O Expansion
  byte bkcolor;
  x = 14;
  y = 39;
  for ( int a=0;a<6;a++ )
  {
    ReefAngel.LCD.DrawCircleOutline( x+(a*20),y,4,COLOR_MEDIUMORCHID );
    if ( ReefAngel.IO.GetChannel(a) ) bkcolor=COLOR_WHITE; 
    else bkcolor=COLOR_GRAY;
    ReefAngel.LCD.FillCircle( x+(a*20),y,2,bkcolor );
  }
  pingSerial();

  // Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
  ReefAngel.LCD.DrawMonitor( 15, 53, ReefAngel.Params,
  ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
  ReefAngel.LCD.DrawMonitor( 15, 53, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
  pingSerial();

  // Main Relay Box
  byte TempRelay = ReefAngel.Relay.RelayData;
  TempRelay &= ReefAngel.Relay.RelayMaskOff;
  TempRelay |= ReefAngel.Relay.RelayMaskOn;
  ReefAngel.LCD.DrawOutletBox( 12, 90, TempRelay );
  pingSerial();

  // Date and Time
  ReefAngel.LCD.DrawDate( 6, 122 );
  pingSerial();
}

void DrawCustomGraph()
{
}

void BuzzerOn()
{
  ReefAngel.PWM.SetActinic((now()%2)*100);
}


Re: how to I/O revers ATO

Posted: Fri Nov 30, 2012 5:58 am
by rimai
You were missing the setup of the timer on the setup() section and also what to do when the timer is triggered.
Also, whenever you use the port in your custom code, generally you shouldn't use it as a function, so I commented ReefAngel.StandardATO( Port1,62 );

Try this:

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 <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.AddStandardMenu();  // Add Standard Menu

    // Ports toggled in Feeding Mode
  ReefAngel.FeedingModePorts = Port1Bit | Port8Bit;
  // Ports toggled in Water Change Mode
  ReefAngel.WaterChangePorts = Port1Bit | Port5Bit | Port6Bit | Port8Bit;
  // Ports toggled when Lights On / Off menu entry selected
  ReefAngel.LightsOnPorts = Port3Bit | Port4Bit | Port5Bit | Port6Bit | Port8Bit;
  // 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( 265 );


  // Ports that are always on
  ReefAngel.Relay.On( Port7 );
  ReefAngel.Relay.On( Port8 );

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

  ReefAngel.Timer[1].SetInterval(60);

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

void loop()
{
//  ReefAngel.StandardATO( Port1,62 );
  ReefAngel.StandardHeater( Port2,240,255 );
  ReefAngel.StandardLights( Port3,8,55,20,5 );
  ReefAngel.StandardLights( Port4,11,5,15,55 );
  if (hour()>=9 && hour()<20)
  {
    ReefAngel.Wavemaker( Port5,5 );
    ReefAngel.Relay.Set(Port6,!ReefAngel.Relay.Status(Port5));
  }
  else
  {
    ReefAngel.Relay.Off(Port5);
    ReefAngel.Relay.Off(Port6);
  }
  ReefAngel.PWM.SetChannel( 0, PWMParabola(9,5,19,55,15,100,15) );
  ReefAngel.PWM.SetChannel( 1, PWMParabola(10,5,18,55,15,100,15) );
  ReefAngel.PWM.SetChannel( 2, PWMParabola(11,5,15,55,15,100,15) );
  ReefAngel.PWM.SetChannel( 3, PWMParabola(11,35,17,55,15,100,15) );
  ReefAngel.PWM.SetChannel( 4, PWMParabola(18,35,3,5,15,100,15) );
  ////// Place your custom code below here

  //Float #1

  if (ReefAngel.IO.GetChannel(1)) // if float 1 is triggered
  {
    ReefAngel.Relay.Off(Port8); // Turn Return off
    ReefAngel.Relay.Off(Port7); // Turn Skimmer off
    BuzzerOn(); // Turn Buzzer on
  }

  //Float #2
  if (ReefAngel.IO.GetChannel(2)) // if float 2 is triggered
  {
    ReefAngel.Relay.On(Port1); // Turn AutoTopOff on
    ReefAngel.Timer[1].Start(); // Start/Trigger timer
  }

  // Float #3
  if (ReefAngel.IO.GetChannel(3)) // if float 3 is triggered
    BuzzerOn(); // Turn Buzzer on

    // Float #4
  // if (ReefAngel.IO.GetChannel(4)) // if float 4 is triggered
  //   ReefAngel.Relay.On(Port7); // Turn Skimmer off

  // Float #5
  // if (ReefAngel.IO.GetChannel(5)) // if float 5 is triggered
  {
  // ReefAngel.Relay.Off(Port8); // Turn Return off  
  //  BuzzerOn(); // Turn Buzzer on
  } 

  // Timer 1
  if (ReefAngel.Timer[1].IsTriggered())
    ReefAngel.Relay.Off(Port1); // Turn AutoTopOff off


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

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

void DrawCustomMain()
{
  int x,y;
  char text[10];
  // Dimming Expansion
  x = 15;
  y = 2;
  for ( int a=0;a<6;a++ )
  {
    if ( a>2 ) x = 75;
    if ( a==3 ) y = 2;
    ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x,y,"Ch :" );
    ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x+12,y,a );
    ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x+24,y,ReefAngel.PWM.GetChannelValue(a) );
    y += 10;
  }
  pingSerial();

  // I/O Expansion
  byte bkcolor;
  x = 14;
  y = 39;
  for ( int a=0;a<6;a++ )
  {
    ReefAngel.LCD.DrawCircleOutline( x+(a*20),y,4,COLOR_MEDIUMORCHID );
    if ( ReefAngel.IO.GetChannel(a) ) bkcolor=COLOR_WHITE; 
    else bkcolor=COLOR_GRAY;
    ReefAngel.LCD.FillCircle( x+(a*20),y,2,bkcolor );
  }
  pingSerial();

  // Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
  ReefAngel.LCD.DrawMonitor( 15, 53, ReefAngel.Params,
  ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
  ReefAngel.LCD.DrawMonitor( 15, 53, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
  pingSerial();

  // Main Relay Box
  byte TempRelay = ReefAngel.Relay.RelayData;
  TempRelay &= ReefAngel.Relay.RelayMaskOff;
  TempRelay |= ReefAngel.Relay.RelayMaskOn;
  ReefAngel.LCD.DrawOutletBox( 12, 90, TempRelay );
  pingSerial();

  // Date and Time
  ReefAngel.LCD.DrawDate( 6, 122 );
  pingSerial();
}

void DrawCustomGraph()
{
}

void BuzzerOn()
{
  ReefAngel.PWM.SetActinic((now()%2)*100);
}


Re: how to I/O revers ATO

Posted: Fri Nov 30, 2012 7:54 am
by bigHUN
Thank you Roberto, I will give it a try tonight.
What is confusing me the display on RA+, showing both the float #1 and #2 have the same, circle with fill:
- #1 circle is fill with waterlevel high, if waterlevel drops than no fill, and shots OFF the relays #7 and 8
- #2 circle is fill with waterlevel high, if waterlevel drops than no fill, and turns relay #1 ON (ATO with timout)
(I have these 4 floats bonded to a tube from day one, and only change from RA to RA+ interprets the I/O differently?)
Im lerning every day but seeing still long way to go.....Thanks again

Re: how to I/O revers ATO

Posted: Fri Nov 30, 2012 6:37 pm
by bigHUN
Many thanks Roberto, working
but
seem to me I have an other other problem....
finally got some time to connect the dimming module to the LED drivers....I see the lights are not full power...toke me some time to realize....
the module is outputting 1.47-1.5 Volt instead of 10V or whatever supposto be even when I manualy switch to "Lights ON", (the Amps seem to me about right but could not finetune on the driver, to big of a jump when turning the pot). It is your powersupply (measured 10ish Volt correct) and meanwhell ELN 60-48D.
Is there anything I can do on my side with the dimming module or you want it back?
also, my first ph probe........ I spent several bags of calibration fluid this week the thing just jumps back to 5.1 even in the glass of saltwater.... I bought ground probe for the tank, still the same.

Re: how to I/O revers ATO

Posted: Fri Nov 30, 2012 7:31 pm
by rimai
Is the screen showing 15%?
That's about right at 1.47-1.5V

Re: how to I/O revers ATO

Posted: Fri Nov 30, 2012 10:20 pm
by bigHUN
you are right again :shock:
OMG I thought turning to "Lights ON" will jump back to 100% but actually to 15% only? because its is night time. Or, that 15% is a last known value?
* How that line shall look, from any position along the day, turning "Lights ON" would jump to a predefined value, let say 96% ???? (as you can see for trial and error I use random numbers easy to track)
but again, look at the channel #4 (moonlight) started 6.35 pm shall be ON about 8.15 pm when I placed the post.....but the 1.5 V could not give enough juce for a blink...or this your moonlight kit needs more Volts?

Re: how to I/O revers ATO

Posted: Sat Dec 01, 2012 4:13 am
by rimai
What do you mean as "Lights ON"?
Are you overriding the ports on Android?

Re: how to I/O revers ATO

Posted: Sat Dec 01, 2012 9:15 am
by bigHUN
I don't really understand the overrride, but let me say...in the sub-menu we have "Lights ON" and "lights OFF""
so, it is sort of override, right?
so, if I select "Lights ON" where it goes? to last known value? or to "100% all "lights ON"
- just try it today morning 10.45 am when all four dimming modules show 15% (relay 5-6 were ON) the total amount of light was way stronger than
- last night 11 pm, (relay ports 5-6 were OFF) the dimming modules show 15% and I turn the "lights ON" they came pretty low,
so
1. ) how to set the function in submenu "Lights ON" default let say 96% or 100% I don't mind, regardless what is a last or current value along the day?

Re: how to I/O revers ATO

Posted: Sat Dec 01, 2012 10:18 am
by rimai
Ahhh I see now,
You are using the standard menu.
You can change the settings on the android or iphone app or we can set it in your code.
Which one do you prefer?

Re: how to I/O revers ATO

Posted: Sat Dec 01, 2012 10:19 am
by rimai
I think you can even use the joystick and go to LED PWM to set that up. Try it and see if it works.

Re: how to I/O revers ATO

Posted: Sat Dec 01, 2012 11:00 am
by bigHUN
I don't have the WiFi module, my house is completely hardwired (IPs starting from fridge to satellite).....if exist I would definitely get myself one of those IP modules.....
I don't know yet what is a difference between setting in RA+, but I guess I would hard code it in the *.ino file....
this code as seen in post coming from my first wizard trial. going to see what the LED PWM will do in the submenu.
My understanding was to have the *.ino file in backup in my PC just for a case (I was looking but don't see how can I pull out the program from RA+ back to PC), so if I change anything in the RA+ controller itself could be lost in the accident.

Re: how to I/O revers ATO

Posted: Sat Dec 01, 2012 2:48 pm
by bigHUN
Roberto?
the first is needed at all when the second is defined? if not, I may have a good use for the two relay (#3 and #4) spots? and just one power cable to feed all four drivers?

ReefAngel.StandardLights( Port3,8,55,20,5 );
ReefAngel.StandardLights( Port4,11,5,15,55 );
......................................................................................................................
ReefAngel.PWM.SetChannel( 0, PWMParabola(9,5,19,55,15,100,15) );
ReefAngel.PWM.SetChannel( 1, PWMParabola(10,5,18,55,15,100,15) );
ReefAngel.PWM.SetChannel( 2, PWMParabola(11,5,15,55,15,100,15) );
ReefAngel.PWM.SetChannel( 3, PWMParabola(11,35,17,55,15,100,15) );
ReefAngel.PWM.SetChannel( 4, PWMParabola(18,35,3,5,15,100,15) );

Re: how to I/O revers ATO

Posted: Sat Dec 01, 2012 5:24 pm
by rimai
It's not recommended to plug more than 2 drivers on a single port.
You will end up wearing it out and they will stick with the inrush current.

Re: how to I/O revers ATO

Posted: Sat Dec 01, 2012 8:49 pm
by bigHUN
Roberto?
1.) I sad the first (two StandardLights) lines and the second (five SetChannel) lines both are needed to control the lights?

2.) I was waiting for a 24 hour cycle to see how the clock is changing the Light cycle slope.
The channel #4 is not moving at all....right now is 22.45 (10.45 pm) still showing 15%
that is why last night I could not turn ON the moonlight.

Re: how to I/O revers ATO

Posted: Sun Dec 02, 2012 5:20 am
by rimai
You can control each channel independently.
None of the slope or parabola can cross over to next day.
They must start and end in the same day.

Re: how to I/O revers ATO

Posted: Wed Dec 05, 2012 7:31 pm
by bigHUN
just to say THANKS Roberto

Re: how to I/O revers ATO

Posted: Wed Dec 05, 2012 7:40 pm
by rimai
:)