Re: Icecap Module
Posted: Mon Feb 29, 2016 4:01 pm
Great, thanks. Could you post your whole code?
Community discussion about Reef Angel Controllers and reefing related subjects
http://forum.reefangel.com/
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 <Tide.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 <PAR.h>
#include <ReefAngel.h>
#include <SunLocation.h>
#define debug_flow 1
#define debug_lights 1
////// Place global variable code below here
#define Return 1
#define Skimmer 2
#define Heater 3
#define SumpLight 4
#define Unused 6
#define Scrubber 5
#define PowerStrip 7
#define ATO 8
#define SumpTemp T1_PROBE
#define DisplayTemp T2_PROBE
////// Place global variable code above here
Tide tide;
SunLocation sunLocation;
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 = Port1Bit | Port2Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port8Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = 0;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port3Bit;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Ports that are always on
ReefAngel.Relay.On( Port1 );
ReefAngel.Relay.On( Port6 );
////// Place additional initialization code below here
ReefAngel.CustomLabels[0]="Return";
ReefAngel.CustomLabels[1]="Skimmer";
ReefAngel.CustomLabels[2]="Heater";
ReefAngel.CustomLabels[3]="Fuge Light";
ReefAngel.CustomLabels[4]="Unused";
ReefAngel.CustomLabels[5]="Scrubber";
ReefAngel.CustomLabels[6]="Power Strip";
ReefAngel.CustomLabels[7]="ATO";
tide.Init(40,10,30);
tide.SetWaveLength(12+SECS_PER_HOUR);
sunLocation.Init(25.7753,80.2089);
sunLocation.SetOffset(8,0,8,0);
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.Relay.DelayedOn( Port2 );
ReefAngel.StandardHeater( Port3, 785, 805 );
ReefAngel.StandardLights( Port4, 20,0,9,0);
////// Place your custom code below here
//setVortech();
//
// turn the scrubber led on at 5pm and off at 5am
ReefAngel.StandardLights(Port5,17,0,5,0);
sunLocation.CheckAndUpdate();
setLED();
setMoon();
setMaxspect();
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "oftheangels" );
ReefAngel.ShowInterface();
}
void setLED()
{
#if debug_flow == 1
Serial.print("Rise Hour: ");
Serial.print(sunLocation.GetRiseHour());
Serial.print(" Rise Minute: ");
Serial.print(sunLocation.GetRiseMinute());
Serial.print(" Set Hour: ");
Serial.print(sunLocation.GetSetHour());
Serial.print(" Set Minute: ");
Serial.print(sunLocation.GetSetMinute());
Serial.println();
#endif
ReefAngel.PWM.SetActinic(PWMParabola(sunLocation.GetRiseHour(),sunLocation.GetRiseMinute(),sunLocation.GetSetHour() ,sunLocation.GetSetMinute(),0,50,0));
ReefAngel.PWM.SetDaylight(PWMParabola(sunLocation.GetRiseHour(),sunLocation.GetRiseMinute(),sunLocation.GetSetHour(),sunLocation.GetSetMinute(),10,60,0));
}
void setMoon()
{
#ifdef debug_lights == 1
Serial.print("Daylight: ");
Serial.print(sunLocation.IsDaytime());
Serial.print(" MoonPhase: ");
Serial.print(MoonPhase());
Serial.println();
#endif
if (sunLocation.IsDaytime())
ReefAngel.PWM.SetChannel(0, 0);
else
ReefAngel.PWM.SetChannel( 0, MoonPhase() );
}
void setVortech()
{
// Pumps for night mode, start with lagoon, short pulse most of the day
if (ReefAngel.DisplayedMenu!=FEEDING_MODE || ReefAngel.DisplayedMenu!=WATERCHANGE_MODE)
{
if (hour() > 9 || hour() < 17)
ReefAngel.RF.SetMode(ReefCrest,40,0);
else
ReefAngel.RF.SetMode(LongWave, 40, 0);
}
}
void setMaxspect()
{
int reverse_speed=0;
int forward_speed=45;
if (ReefAngel.DisplayedMenu==FEEDING_MODE) {
forward_speed = NutrientTransportMode(25,50,1500,false);
reverse_speed = 0;
} else if (ReefAngel.DisplayedMenu==WATERCHANGE_MODE) {
//
// shut off maxspect during water changes.
forward_speed = 0;
reverse_speed = 0;
} else {
//
// swap between forward and reverse every 10 seconds
#if 0
reverse_speed = ShortPulseMode(0,100,10000,false);
if (reverse_speed == 100)
//
// while we are going in reverse increase the speed to 45-60
forward_speed = ShortPulseMode(30,60,5000,false);
else
//
// while we are going forward set speed to 25-40 to keep
// from blowing corals off the rocks
forward_speed = ShortPulseMode(25,40,5000, false);
#endif
forward_speed = tide.CalcTide();
}
#if debug_flow == 1
Serial.print("Forward Speed: ");
Serial.print(forward_speed);
Serial.print(" Reverse Speed: ");
Serial.print(reverse_speed);
Serial.println();
#endif
ReefAngel.PWM.SetChannel(2,reverse_speed); // set the pump direction
ReefAngel.PWM.SetChannel(1,forward_speed); // set the pump speed
}
Will this cable allow forward and reverse?rimai wrote:You should be able to use the DCPump modes.Ismaclst wrote:I have the maxspect gyre and was thinking about purchasing the Icecap module to go with it. Has anyone else bought this? Does it come with the cable you need to connect to the RA? I'm assuming you can use any of the DC pump modes?
The Kessil cable in the webstore should be able to be used with the Icecap module too
Thanks for your help. I was getting some errors when I added what you told me to. I figured out that I needed to add these, too.oftheangels wrote:Here you go. Keep in mind I'm a RA newbie:
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 <Tide.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 <PAR.h> #include <ReefAngel.h> #include <SunLocation.h> #define debug_flow 1 #define debug_lights 1 ////// Place global variable code below here #define Return 1 #define Skimmer 2 #define Heater 3 #define SumpLight 4 #define Unused 6 #define Scrubber 5 #define PowerStrip 7 #define ATO 8 #define SumpTemp T1_PROBE #define DisplayTemp T2_PROBE ////// Place global variable code above here Tide tide; SunLocation sunLocation; 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 = Port1Bit | Port2Bit; // Ports toggled in Water Change Mode ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port8Bit; // Ports toggled when Lights On / Off menu entry selected ReefAngel.LightsOnPorts = 0; // Ports turned off when Overheat temperature exceeded ReefAngel.OverheatShutoffPorts = Port3Bit; // Use T1 probe as temperature and overheat functions ReefAngel.TempProbe = T1_PROBE; ReefAngel.OverheatProbe = T1_PROBE; // Ports that are always on ReefAngel.Relay.On( Port1 ); ReefAngel.Relay.On( Port6 ); ////// Place additional initialization code below here ReefAngel.CustomLabels[0]="Return"; ReefAngel.CustomLabels[1]="Skimmer"; ReefAngel.CustomLabels[2]="Heater"; ReefAngel.CustomLabels[3]="Fuge Light"; ReefAngel.CustomLabels[4]="Unused"; ReefAngel.CustomLabels[5]="Scrubber"; ReefAngel.CustomLabels[6]="Power Strip"; ReefAngel.CustomLabels[7]="ATO"; tide.Init(40,10,30); tide.SetWaveLength(12+SECS_PER_HOUR); sunLocation.Init(25.7753,80.2089); sunLocation.SetOffset(8,0,8,0); ////// Place additional initialization code above here } void loop() { ReefAngel.Relay.DelayedOn( Port2 ); ReefAngel.StandardHeater( Port3, 785, 805 ); ReefAngel.StandardLights( Port4, 20,0,9,0); ////// Place your custom code below here //setVortech(); // // turn the scrubber led on at 5pm and off at 5am ReefAngel.StandardLights(Port5,17,0,5,0); sunLocation.CheckAndUpdate(); setLED(); setMoon(); setMaxspect(); ////// Place your custom code above here // This should always be the last line ReefAngel.Portal( "oftheangels" ); ReefAngel.ShowInterface(); } void setLED() { #if debug_flow == 1 Serial.print("Rise Hour: "); Serial.print(sunLocation.GetRiseHour()); Serial.print(" Rise Minute: "); Serial.print(sunLocation.GetRiseMinute()); Serial.print(" Set Hour: "); Serial.print(sunLocation.GetSetHour()); Serial.print(" Set Minute: "); Serial.print(sunLocation.GetSetMinute()); Serial.println(); #endif ReefAngel.PWM.SetActinic(PWMParabola(sunLocation.GetRiseHour(),sunLocation.GetRiseMinute(),sunLocation.GetSetHour() ,sunLocation.GetSetMinute(),0,50,0)); ReefAngel.PWM.SetDaylight(PWMParabola(sunLocation.GetRiseHour(),sunLocation.GetRiseMinute(),sunLocation.GetSetHour(),sunLocation.GetSetMinute(),10,60,0)); } void setMoon() { #ifdef debug_lights == 1 Serial.print("Daylight: "); Serial.print(sunLocation.IsDaytime()); Serial.print(" MoonPhase: "); Serial.print(MoonPhase()); Serial.println(); #endif if (sunLocation.IsDaytime()) ReefAngel.PWM.SetChannel(0, 0); else ReefAngel.PWM.SetChannel( 0, MoonPhase() ); } void setVortech() { // Pumps for night mode, start with lagoon, short pulse most of the day if (ReefAngel.DisplayedMenu!=FEEDING_MODE || ReefAngel.DisplayedMenu!=WATERCHANGE_MODE) { if (hour() > 9 || hour() < 17) ReefAngel.RF.SetMode(ReefCrest,40,0); else ReefAngel.RF.SetMode(LongWave, 40, 0); } } void setMaxspect() { int reverse_speed=0; int forward_speed=45; if (ReefAngel.DisplayedMenu==FEEDING_MODE) { forward_speed = NutrientTransportMode(25,50,1500,false); reverse_speed = 0; } else if (ReefAngel.DisplayedMenu==WATERCHANGE_MODE) { // // shut off maxspect during water changes. forward_speed = 0; reverse_speed = 0; } else { // // swap between forward and reverse every 10 seconds #if 0 reverse_speed = ShortPulseMode(0,100,10000,false); if (reverse_speed == 100) // // while we are going in reverse increase the speed to 45-60 forward_speed = ShortPulseMode(30,60,5000,false); else // // while we are going forward set speed to 25-40 to keep // from blowing corals off the rocks forward_speed = ShortPulseMode(25,40,5000, false); #endif forward_speed = tide.CalcTide(); } #if debug_flow == 1 Serial.print("Forward Speed: "); Serial.print(forward_speed); Serial.print(" Reverse Speed: "); Serial.print(reverse_speed); Serial.println(); #endif ReefAngel.PWM.SetChannel(2,reverse_speed); // set the pump direction ReefAngel.PWM.SetChannel(1,forward_speed); // set the pump speed }
Code: Select all
Tide tide;
Code: Select all
#include <Tide.h>
YesIsmaclst wrote:Will this cable allow forward and reverse?rimai wrote:You should be able to use the DCPump modes.Ismaclst wrote:I have the maxspect gyre and was thinking about purchasing the Icecap module to go with it. Has anyone else bought this? Does it come with the cable you need to connect to the RA? I'm assuming you can use any of the DC pump modes?
The Kessil cable in the webstore should be able to be used with the Icecap module too
Happy to help! That's what's great about this community and open source in general... RA ROCKS!Ismaclst wrote:Thanks for your help. I was getting some errors when I added what you told me to. I figured out that I needed to add these, too.oftheangels wrote:Here you go. Keep in mind I'm a RA newbie:
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 <Tide.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 <PAR.h> #include <ReefAngel.h> #include <SunLocation.h> #define debug_flow 1 #define debug_lights 1 ////// Place global variable code below here #define Return 1 #define Skimmer 2 #define Heater 3 #define SumpLight 4 #define Unused 6 #define Scrubber 5 #define PowerStrip 7 #define ATO 8 #define SumpTemp T1_PROBE #define DisplayTemp T2_PROBE ////// Place global variable code above here Tide tide; SunLocation sunLocation; 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 = Port1Bit | Port2Bit; // Ports toggled in Water Change Mode ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port8Bit; // Ports toggled when Lights On / Off menu entry selected ReefAngel.LightsOnPorts = 0; // Ports turned off when Overheat temperature exceeded ReefAngel.OverheatShutoffPorts = Port3Bit; // Use T1 probe as temperature and overheat functions ReefAngel.TempProbe = T1_PROBE; ReefAngel.OverheatProbe = T1_PROBE; // Ports that are always on ReefAngel.Relay.On( Port1 ); ReefAngel.Relay.On( Port6 ); ////// Place additional initialization code below here ReefAngel.CustomLabels[0]="Return"; ReefAngel.CustomLabels[1]="Skimmer"; ReefAngel.CustomLabels[2]="Heater"; ReefAngel.CustomLabels[3]="Fuge Light"; ReefAngel.CustomLabels[4]="Unused"; ReefAngel.CustomLabels[5]="Scrubber"; ReefAngel.CustomLabels[6]="Power Strip"; ReefAngel.CustomLabels[7]="ATO"; tide.Init(40,10,30); tide.SetWaveLength(12+SECS_PER_HOUR); sunLocation.Init(25.7753,80.2089); sunLocation.SetOffset(8,0,8,0); ////// Place additional initialization code above here } void loop() { ReefAngel.Relay.DelayedOn( Port2 ); ReefAngel.StandardHeater( Port3, 785, 805 ); ReefAngel.StandardLights( Port4, 20,0,9,0); ////// Place your custom code below here //setVortech(); // // turn the scrubber led on at 5pm and off at 5am ReefAngel.StandardLights(Port5,17,0,5,0); sunLocation.CheckAndUpdate(); setLED(); setMoon(); setMaxspect(); ////// Place your custom code above here // This should always be the last line ReefAngel.Portal( "oftheangels" ); ReefAngel.ShowInterface(); } void setLED() { #if debug_flow == 1 Serial.print("Rise Hour: "); Serial.print(sunLocation.GetRiseHour()); Serial.print(" Rise Minute: "); Serial.print(sunLocation.GetRiseMinute()); Serial.print(" Set Hour: "); Serial.print(sunLocation.GetSetHour()); Serial.print(" Set Minute: "); Serial.print(sunLocation.GetSetMinute()); Serial.println(); #endif ReefAngel.PWM.SetActinic(PWMParabola(sunLocation.GetRiseHour(),sunLocation.GetRiseMinute(),sunLocation.GetSetHour() ,sunLocation.GetSetMinute(),0,50,0)); ReefAngel.PWM.SetDaylight(PWMParabola(sunLocation.GetRiseHour(),sunLocation.GetRiseMinute(),sunLocation.GetSetHour(),sunLocation.GetSetMinute(),10,60,0)); } void setMoon() { #ifdef debug_lights == 1 Serial.print("Daylight: "); Serial.print(sunLocation.IsDaytime()); Serial.print(" MoonPhase: "); Serial.print(MoonPhase()); Serial.println(); #endif if (sunLocation.IsDaytime()) ReefAngel.PWM.SetChannel(0, 0); else ReefAngel.PWM.SetChannel( 0, MoonPhase() ); } void setVortech() { // Pumps for night mode, start with lagoon, short pulse most of the day if (ReefAngel.DisplayedMenu!=FEEDING_MODE || ReefAngel.DisplayedMenu!=WATERCHANGE_MODE) { if (hour() > 9 || hour() < 17) ReefAngel.RF.SetMode(ReefCrest,40,0); else ReefAngel.RF.SetMode(LongWave, 40, 0); } } void setMaxspect() { int reverse_speed=0; int forward_speed=45; if (ReefAngel.DisplayedMenu==FEEDING_MODE) { forward_speed = NutrientTransportMode(25,50,1500,false); reverse_speed = 0; } else if (ReefAngel.DisplayedMenu==WATERCHANGE_MODE) { // // shut off maxspect during water changes. forward_speed = 0; reverse_speed = 0; } else { // // swap between forward and reverse every 10 seconds #if 0 reverse_speed = ShortPulseMode(0,100,10000,false); if (reverse_speed == 100) // // while we are going in reverse increase the speed to 45-60 forward_speed = ShortPulseMode(30,60,5000,false); else // // while we are going forward set speed to 25-40 to keep // from blowing corals off the rocks forward_speed = ShortPulseMode(25,40,5000, false); #endif forward_speed = tide.CalcTide(); } #if debug_flow == 1 Serial.print("Forward Speed: "); Serial.print(forward_speed); Serial.print(" Reverse Speed: "); Serial.print(reverse_speed); Serial.println(); #endif ReefAngel.PWM.SetChannel(2,reverse_speed); // set the pump direction ReefAngel.PWM.SetChannel(1,forward_speed); // set the pump speed }
Code: Select all
Tide tide;
Code: Select all
#include <Tide.h>
Code: Select all
ReefAngel.cpp: if (DCPump.FeedingSpeed < 100)
ReefAngel.cpp: SyncSpeed=DCPump.FeedingSpeed;
ReefAngel.cpp: AntiSyncSpeed=DCPump.FeedingSpeed;
Code: Select all
byte setMaxspect(byte minSpeed, byte maxSpeed, boolean PulseSync)
{
int reverse_speed=0;
int forward_speed=minSpeed;
// swap between forward and reverse every X seconds
reverse_speed = ShortPulseMode(0,100,ReefAngel.DCPump.Duration*2,true);
if (reverse_speed == 100) {
//
// while we are going in reverse increase the speed by 10
forward_speed = ShortPulseMode(minSpeed+10, maxSpeed+10,ReefAngel.DCPump.Duration,true);
} else {
//
// while we are going forward set speed to 25-40 to keep
// from blowing corals off the rocks
forward_speed = ShortPulseMode(minSpeed,maxSpeed, ReefAngel.DCPump.Duration, true);
}
if (PulseSync) {
return forward_speed;
} else {
return reverse_speed;
}
}
lnevo wrote:Here, this should do nicely. The only thing I learned from here is that we need to add in the libraries either to let each function decide its speeds under different modes like feeding and waterchange OR we add a FeedingAntiSyncSpeed and WaterChangeAntiSyncSpeed variables. For now I took that part out of the function. You could always implement it manually if you like by not using those variables, or maybe we can just manage it in the libraries too, I'd have to look closer how that works.
The libraries do this:Anyway, here's the function a little more simplifiedCode: Select all
ReefAngel.cpp: if (DCPump.FeedingSpeed < 100) ReefAngel.cpp: SyncSpeed=DCPump.FeedingSpeed; ReefAngel.cpp: AntiSyncSpeed=DCPump.FeedingSpeed;
I like how you simplified it. This may be a stupid and obvious question, but how do you set the max and min speed for forward and reverse?
Code: Select all
byte setMaxspect(byte minSpeed, byte maxSpeed, boolean PulseSync) { int reverse_speed=0; int forward_speed=minSpeed; // swap between forward and reverse every X seconds reverse_speed = ShortPulseMode(0,100,ReefAngel.DCPump.Duration*2,true); if (reverse_speed == 100) { // // while we are going in reverse increase the speed by 10 forward_speed = ShortPulseMode(minSpeed+10, maxSpeed+10,ReefAngel.DCPump.Duration,true); } else { // // while we are going forward set speed to 25-40 to keep // from blowing corals off the rocks forward_speed = ShortPulseMode(minSpeed,maxSpeed, ReefAngel.DCPump.Duration, true); } if (PulseSync) { return forward_speed; } else { return reverse_speed; } }
rimai wrote:You should be able to use the DCPump modes.Ismaclst wrote:I have the maxspect gyre and was thinking about purchasing the Icecap module to go with it. Has anyone else bought this? Does it come with the cable you need to connect to the RA? I'm assuming you can use any of the DC pump modes?
The Kessil cable in the webstore should be able to be used with the Icecap module too
Code: Select all
tide.Init(40,10,30);
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 <Tide.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 <PAR.h>
#include <ReefAngel.h>
////// Place global variable code below here
////// Place global variable code above here
Tide tide;
void setup()
{
// This must be the first line
ReefAngel.Init(); //Initialize controller
ReefAngel.Use2014Screen(); // Let's use 2014 Screen
ReefAngel.DDNS("Damien");
ReefAngel.AddMultiChannelWaterLevelExpansion(); // Multi-Channel Water Level Expanion Module
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = Port1Bit | Port6Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port6Bit | Port7Bit | Port8Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port5Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port3Bit;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
ReefAngel.Relay.Set(Port8, now()%6*SECS_PER_HOUR<30*SECS_PER_MIN);
// Set the Overheat temperature setting
InternalMemory.OverheatTemp_write( 800 );
InternalMemory.WaterLevelMax_write(1800);
// Feeeding and Water Change mode speed
// Ports that are always on
ReefAngel.Relay.On( Port1 );
ReefAngel.Relay.On( Port6 );
tide.Init(55,10,30);
tide.SetWaveLength(12+SECS_PER_HOUR);
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.StandardHeater( Port3,780,785 );
ReefAngel.WaterLevelATO(4,Port4,240,28,31);
////// Place your custom code below here
if (ReefAngel.WaterLevel.GetLevel(1)<5) //Disable the port until overriden manually
ReefAngel.Relay.Override(Port8,0); //Saltwater Reservoir
if (ReefAngel.WaterLevel.GetLevel(1)>80) // Set port back to auto
ReefAngel.Relay.Override(Port8,2);
if (ReefAngel.WaterLevel.GetLevel(2)>80) //Overflow
ReefAngel.Relay.Off(Port1);
else
ReefAngel.Relay.On(Port1);
if (ReefAngel.WaterLevel.GetLevel(3)>87) //ATO Reservoir
ReefAngel.Relay.Off(Port5);
if (ReefAngel.WaterLevel.GetLevel(3)<1)
ReefAngel.Relay.On(Port5);
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "Ismaclst" );
ReefAngel.ShowInterface();
}
byte setMaxspect(byte minSpeed, byte maxSpeed, boolean PulseSync)
{
int reverse_speed=0;
int forward_speed=45;
// swap between forward and reverse every X seconds
reverse_speed = ShortPulseMode(0,100,ReefAngel.DCPump.Duration*2,true);
if (reverse_speed == 100) {
//
// while we are going in reverse increase the speed by 10
forward_speed = ShortPulseMode(35+10, 60+10,ReefAngel.DCPump.Duration,true);
} else {
//
// while we are going forward set speed to 25-40 to keep
// from blowing corals off the rocks
forward_speed = ShortPulseMode(35,70, ReefAngel.DCPump.Duration, true);
}
if (PulseSync) {
return forward_speed;
} else {
return reverse_speed;
}
}
Did you ever get a chance to look into this more?lnevo wrote:You added the function but you have to call it. Same with the tide you set. We have to tie them together now.
You need to add the following now to set your dimming channels.
I need to be on the computer to give you the right code. I also made some mistakes that I need to fix in the setMaspect function.
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 <Tide.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 <PAR.h>
#include <ReefAngel.h>
////// Place global variable code below here
////// Place global variable code above here
Tide tide;
void setup()
{
// This must be the first line
ReefAngel.Init(); //Initialize controller
ReefAngel.Use2014Screen(); // Let's use 2014 Screen
ReefAngel.DDNS("Damien");
ReefAngel.AddMultiChannelWaterLevelExpansion(); // Multi-Channel Water Level Expanion Module
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = Port1Bit | Port6Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port6Bit | Port7Bit | Port8Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port5Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port3Bit;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Set the Overheat temperature setting
InternalMemory.OverheatTemp_write( 800 );
InternalMemory.WaterLevelMax_write(1800);
// Feeeding and Water Change mode speed
// Ports that are always on
ReefAngel.Relay.On( Port1 );
ReefAngel.Relay.On( Port6 );
tide.Init(55,10,30);
tide.SetWaveLength(12+SECS_PER_HOUR);
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.StandardHeater( Port3,780,785 );
ReefAngel.WaterLevelATO(4,Port4,240,28,31);
ReefAngel.Relay.Set(Port8, (now()%(6*SECS_PER_HOUR))<(30*SECS_PER_MIN));
////// Place your custom code below here
if (ReefAngel.WaterLevel.GetLevel(1)<5) //Disable the port until overriden manually
ReefAngel.Relay.Override(Port8,0); //Saltwater Reservoir
if (ReefAngel.WaterLevel.GetLevel(1)>80) // Set port back to auto
ReefAngel.Relay.Override(Port8,2);
if (ReefAngel.WaterLevel.GetLevel(2)>80) //Overflow
ReefAngel.Relay.Off(Port1);
else
ReefAngel.Relay.On(Port1);
ReefAngel.Relay.Off(Port5); // Set Default to off
if (ReefAngel.WaterLevel.GetLevel(3)>87) //ATO Reservoir
ReefAngel.Relay.Off(Port5);
if (ReefAngel.WaterLevel.GetLevel(3)<1)
ReefAngel.Relay.On(Port5);
////// Place your custom code above here
ReefAngel.PWM.SetDaylight(setMaxspect(tide.GetSpeed(),tide.GetSpeed()/2,true)); // Set the Speed
ReefAngel.PWM.SetActinic(setMaxspect(tide.GetSpeed(),tide.GetSpeed()/2,false)); // Set the direction - speeds here are irrelevant actually.
// This should always be the last line
ReefAngel.Portal( "Ismaclst" );
ReefAngel.ShowInterface();
}
byte setMaxspect(byte minSpeed, byte maxSpeed, boolean PulseSync)
{
int reverse_speed=0;
int forward_speed=45;
// swap between forward and reverse every X seconds
reverse_speed = ShortPulseMode(0,100,ReefAngel.DCPump.Duration*2,true);
if (reverse_speed == 100) {
//
// while we are going in reverse increase the speed by 10
forward_speed = ShortPulseMode(minSpeed+10, maxSpeed+10,ReefAngel.DCPump.Duration,true);
} else {
//
// while we are going forward set speed to 25-40 to keep
// from blowing corals off the rocks
forward_speed = ShortPulseMode(minSpeed,maxSpeed, ReefAngel.DCPump.Duration, true);
}
if (PulseSync) {
return forward_speed;
} else {
return reverse_speed;
}
}