First I'm very happy with RA+, it has a great job with my 100g tank for a year.
I just change WP40 from PWM port to ATO port. (added a dimming-able LED), every thing works fine(high low port working in PWM), but need some programming support.
previous i can check WP40 working level with ReefAngel.PWM.GetDaylightValue() function. but i can't find one for ATO port (High Low).
is there any similar function can check ATO port working condition? thanks
Get ATO port Value
Re: Get ATO port Value
I don't think there is a good way to do it in the libraries as using the ATO ports for output isn't really built in.
What I would do is store the output of your wave maker commands in a variable so you can reference. can you post the code?
What I would do is store the output of your wave maker commands in a variable so you can reference. can you post the code?
Re: Get ATO port Value
Could you use analogRead(lowATOPin) ?
Or no, because it's set to output?
--Colin
Or no, because it's set to output?
--Colin
Re: Get ATO port Value
it seems doesn't work. the value flash from 45X~57X. in 8pm.cosmith71 wrote:Could you use analogRead(lowATOPin) ?
Or no, because it's set to output?
--Colin
here is my 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>
// Define Relay Ports by Name
#define Return 8
#define Skimmer 3
#define LED1 5
#define Wavepump2 4
#define Wavepump1 6
#define SumpLED 2
#define CoolingPump 1
#define LED2 7
////// Place global variable code below here
byte wpMode;
////// 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
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = Port8Bit | Port4Bit | Port6Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = 0;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = 0;
// Ports turned off when Overheat temperature exceeded
//ReefAngel.OverheatShutoffPorts = Port4Bit; should be redefine to new ports
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Set the Overheat temperature setting
InternalMemory.OverheatTemp_write( 285 );
// Ports that are always on
ReefAngel.Relay.On(Return);
ReefAngel.Relay.On(Wavepump1);
ReefAngel.Relay.On(Wavepump2);
ReefAngel.Relay.On(LED1);
ReefAngel.Relay.On(SumpLED);
ReefAngel.Relay.On(LED2);
ReefAngel.Relay.On(CoolingPump);
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
//ReefAngel.StandardATO(ATOPump,60 );
//ReefAngel.StandardHeater(Heater,235,255 );
ReefAngel.Relay.DelayedOn(Skimmer,3 );
ReefAngel.StandardLights(SumpLED,19,0,8,0 );
ReefAngel.StandardLights(LED1,8,29,23,31 );
ReefAngel.StandardLights(LED2,8,29,23,31 );
//ReefAngel.StandardLights(SumpAirPump,6,0,18,0 ); //Try out stage, SumpAirPump always on
////// Place your custom code below here
static boolean powerOutage=false;
ReefAngel.UseFlexiblePhCalibration();
// Power Outage - turn off everything
if (!ReefAngel.Relay.IsRelayPresent(MAIN_RELAY)) // Main Relay NOT present
{
powerOutage=true;
ReefAngel.Relay.Off(Return);
ReefAngel.Relay.Off(Skimmer);
ReefAngel.Relay.Off(LED1);
//ReefAngel.Relay.Off(Heater);
ReefAngel.Relay.Off(Wavepump1);
ReefAngel.Relay.Off(Wavepump2);
ReefAngel.Relay.Off(SumpLED);
ReefAngel.Relay.Off(LED2);
}
// Power Restored - Turn things back on
if (powerOutage && ReefAngel.Relay.IsRelayPresent(MAIN_RELAY))
{
LastStart=now();
powerOutage=false;
ReefAngel.Relay.On(Return);
ReefAngel.Relay.On(Skimmer);
ReefAngel.Relay.On(Wavepump1);
ReefAngel.Relay.On(Wavepump2);
ReefAngel.Relay.On(CoolingPump);
}
// Turn off Skimmer if Return pump has been shutoff.
if (!ReefAngel.Relay.Status(Return)) {
ReefAngel.Relay.Off(Skimmer);
}else {
ReefAngel.Relay.DelayedOn(Skimmer);
}
static time_t feeding;
// LED light setup
ReefAngel.PWM.SetDaylight(PWMSlope(8,30,23,30, 10,60,150,0));
ReefAngel.PWM.SetActinic(PWMSlope(8,30,23,30, 10,75,180,0));
// Time schedule first
if (hour()>=8 && hour()<11) {
pinMode(highATOPin,OUTPUT); //high ATO port
analogWrite(highATOPin,TidalSwellMode(65,true)*2.55); // TidalSwell at 45% on sync mode
pinMode(lowATOPin,OUTPUT); //high ATO port
analogWrite(lowATOPin,TidalSwellMode(65,false)*2.55); // TidalSwell at 45% on anti-sync mode
wpMode=1;
}
else if (hour()>=15 && hour()<19) {
pinMode(highATOPin,OUTPUT); //high ATO port
analogWrite(highATOPin,(millis()%800>400?70:0)*2.55); // W1 Mode
pinMode(lowATOPin,OUTPUT); //high ATO port
analogWrite(lowATOPin,30*2.55); // TidalSwell at 30% on anti-sync mode
wpMode=6;
}
else if ( (hour()>=11 && hour()<15) ) {
pinMode(highATOPin,OUTPUT); //high ATO port
analogWrite(highATOPin,NutrientTransportMode(40,60,600,true )*2.55); // Nutrient Transport on sync mode
pinMode(lowATOPin,OUTPUT); //high ATO port
analogWrite(lowATOPin,NutrientTransportMode(40,60,600,false)*2.55); // Nutrient Transport on anti-sync mode
wpMode=3;
}
else if (hour()>=19 && hour()<21) {
pinMode(highATOPin,OUTPUT); //high ATO port
analogWrite(highATOPin,NutrientTransportMode(40,60,600,true )*2.55); // Nutrient Transport on sync mode
pinMode(lowATOPin,OUTPUT); //high ATO port
analogWrite(lowATOPin,NutrientTransportMode(40,60,600,false)*2.55); // Nutrient Transport on anti-sync mode
wpMode=3;
}
else if (hour()>=21 && hour()<23) {
pinMode(highATOPin,OUTPUT); //high ATO port
analogWrite(highATOPin,TidalSwellMode(60,true)*2.55); // TidalSwell at 60% on sync mode
pinMode(lowATOPin,OUTPUT); //high ATO port
analogWrite(lowATOPin,TidalSwellMode(60,false)*2.55); // TidalSwell at 60% on anti-sync mode
wpMode=1;
}
else {
pinMode(highATOPin,OUTPUT); //high ATO port
analogWrite(highATOPin,SineMode(20,30,40,true)*2.55); //SineMode from 30% to 40% for 20 seconds on sync mode
pinMode(lowATOPin,OUTPUT); //high ATO port
analogWrite(lowATOPin,SineMode(20,30,40,false)*2.55); //SineMode from 30% to 40% for 20 seconds on anti-sync mode
wpMode=4;
}
// If we are feeding override the schedule
if (ReefAngel.DisplayedMenu==FEEDING_MODE) {
pinMode(highATOPin,OUTPUT); //high ATO port
analogWrite(highATOPin,20*2.55);
pinMode(highATOPin,OUTPUT); //high ATO port
analogWrite(highATOPin,20*2.55);
wpMode=0;
feeding=now();
}
// If we have finished feeding, start NTM for 3 hours
if (now()-feeding < 3*SECS_PER_HOUR) {
pinMode(highATOPin,OUTPUT); //high ATO port
analogWrite(highATOPin,NutrientTransportMode(35,45,600,true )*2.55); // Nutrient Transport on sync mode
pinMode(lowATOPin,OUTPUT); //high ATO port
analogWrite(lowATOPin,NutrientTransportMode(35,45,600,false)*2.55); // Nutrient Transport on anti-sync mode
wpMode=3;
}
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "sesame" );
ReefAngel.ShowInterface();
}
void DrawCustomMain()
{
// Change the 30 to adjust the horizontal position of the text on the screen, max 20-21 chars
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 90, 2, "Sesame");
ReefAngel.LCD.DrawDate(6, 118);
ReefAngel.LCD.DrawMonitor(15, 68, ReefAngel.Params,
ReefAngel.PWM.GetDaylightValue(),
ReefAngel.PWM.GetActinicValue());
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 110, 78, analogRead(highATOPin));
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 110, 88, analogRead(lowATOPin));
// WP40 Mode
int x, y;
ReefAngel.LCD.DrawText(0,255,x,y,"RF:");
ReefAngel.LCD.Clear(DefaultBGColor,x,y,128-x,y+8);
if (wpMode == 0) ReefAngel.LCD.DrawText(COLOR_BLUE,255,x+4,y+2,"Feeding");
else if (wpMode == 1) ReefAngel.LCD.DrawText(COLOR_BLUE,255,x+4,y+2,"Tidal Swell");
else if (wpMode == 2) ReefAngel.LCD.DrawText(COLOR_BLUE,255,x+4,y+2,"Reef Crest");
else if (wpMode == 3) ReefAngel.LCD.DrawText(COLOR_BLUE,255,x+4,y+2,"Nutrient");
else if (wpMode == 4) ReefAngel.LCD.DrawText(COLOR_BLUE,255,x+4,y+2,"Sine Wave");
else if (wpMode == 5) ReefAngel.LCD.DrawText(COLOR_BLUE,255,x+4,y+2,"Long Pluse");
else if (wpMode == 6) ReefAngel.LCD.DrawText(COLOR_BLUE,255,x+4,y+2,"W1 Mode");
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox(12, 101, TempRelay);
}
void DrawCustomGraph()
{
ReefAngel.LCD.DrawGraph(5, 11);
}
Re: Get ATO port Value
Yeah, the more I think about it, I realize that would never work.
The best thing to do is like Lee suggested and just put whatever value you're setting it to in a variable. Looking back, that's what I did when I was using an ATO port for a Jaebo pump.
--Colin
The best thing to do is like Lee suggested and just put whatever value you're setting it to in a variable. Looking back, that's what I did when I was using an ATO port for a Jaebo pump.
--Colin
Re: Get ATO port Value
Its what the libraries are doing for the daylight/actinic port anyway, they dont read the port to get it, just returns the value you set.
Re: Get ATO port Value
understand. highly suggest to put these libraries in next gen of RA+.lnevo wrote:Its what the libraries are doing for the daylight/actinic port anyway, they dont read the port to get it, just returns the value you set.