Custom code, please help
Re: Custom code, please help
The new relay box seems quieter than the old one. Nice.
I have few questions about my code:
- I tried to setup wavemaker on box1_port5&6 but the compiler gave me a file too big error. What am I doing wrong?
- to control a power head I'm using ReefAngel.StandardLights(Box1_Port8,20,0,22,0);. Can i use a more appropriate variable. I tried using ReefAngel.Relay.On code but it gave me an error.
- the new wizard produces new lines of code. What is the purpose of this command? ReefAngel.FeedingModePortsE[0] = 0; // I got it. it's for the 2nd relay ports.
- if I remove/disconnect the RA head unit, the relay boxes turn all the ports off. Is it possible to make them retain the current state or at least only few of the ports like pumps, skimmer, lights.
- is it possible to turn on specific ports during feeding? I'd like to have a circulation pump turn on for few minutes during feeding on port box1_port3.
- how to setup a timeout time for Dosing pumps?
Thank you.
===
Thne main code is:
/* The following features are enabled for this File:
#define VersionMenu
#define DisplayLEDPWM
#define wifi
#define WDT
#define SIMPLE_MENU
*/
#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 <ReefAngel.h>
void setup()
{
ReefAngel.Init();
ReefAngel.FeedingModePorts = Port8Bit;
ReefAngel.FeedingModePortsE[0] = 0;
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port8Bit | Port7Bit;
ReefAngel.WaterChangePortsE[0] = 0;
ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit | Port7Bit;
ReefAngel.WaterChangePortsE[0] = 0;
ReefAngel.LightsOnPorts = 0;
ReefAngel.Relay.On( Port8 );
ReefAngel.Relay.On( Box1_Port4 );
ReefAngel.Relay.On( Box1_Port5 );
ReefAngel.Relay.On( Box1_Port6 );
ReefAngel.Relay.On( Box1_Port7 );
ReefAngel.PHMin = 537;
ReefAngel.PHMax = 860;
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
InternalMemory.OverheatTemp_write( 830 );
}
void loop()
{
ReefAngel.StandardFan(Port5,787,793);
ReefAngel.StandardHeater(Port7,775,785);
ReefAngel.DosingPumpRepeat(Box1_Port1,0,120,2);
ReefAngel.DosingPumpRepeat(Box1_Port1,1,120,2);
if (hour() >= 10 && hour() < 20)
{
ReefAngel.StandardLights(Port1,11,1,19,0);
ReefAngel.StandardLights(Port3,11,0,19,0);
ReefAngel.StandardLights(Port4,10,0,19,59);
ReefAngel.StandardLights(Box1_Port3,11,0,19,0);
ReefAngel.PWM.SetDaylight(PWMSlope(11,0,19,0,0,0,180,0));
ReefAngel.PWM.SetActinic(PWMSlope(10,0,19,59,0,20,180,0));
}
else
{
ReefAngel.StandardLights(Port3,20,0,6,0);
ReefAngel.StandardLights(Port4,21,0,5,0);
ReefAngel.StandardLights(Port2,21,1,5,0);
ReefAngel.StandardLights(Box1_Port8,20,0,22,0);
ReefAngel.PWM.SetDaylight(PWMSlopeOvernight(20,0,6,0,0,20,180,0));
ReefAngel.PWM.SetActinic(PWMSlopeOvernight(21,0,5,0,0,0,180,0));
}
if (ReefAngel.Params.Temp[T2_PROBE] >= 1200 || ReefAngel.Params.Temp[T3_PROBE] >= 1200) {ReefAngel.Relay.On(Port6);}
if (ReefAngel.Params.Temp[T2_PROBE] < 1100 && ReefAngel.Params.Temp[T3_PROBE] < 1100) {ReefAngel.Relay.Off(Port6);}
ReefAngel.ShowInterface();
ReefAngel.Portal("d0lph1n","*****");
}
byte PWMSlopeOvernight(byte startHour, byte startMinute, byte endHour, byte
endMinute, byte startPWM, byte endPWM, byte Duration, byte oldValue)
{
unsigned long Start = previousMidnight(now())+((unsigned long)NumMins(startHour, startMinute)*60);
if (hour()<startHour) Start-=86400;
unsigned long StartD = Start + (Duration*60);
unsigned long End = nextMidnight(now())+((unsigned long)NumMins(endHour, endMinute)*60);
if (hour()<startHour) End-=86400;
unsigned long StopD = End - (Duration*60);
if ( now() >= Start && now() <= StartD )
return constrain(map(now(), Start, StartD, startPWM, endPWM),startPWM,
endPWM);
else if ( now() >= StopD && now() <= End )
{
byte v = constrain(map(now(), StopD, End, startPWM, endPWM),startPWM,
endPWM);
return endPWM-v+startPWM;
}
else if ( now() > StartD && now() < StopD )
return endPWM;
return oldValue;
}
I have few questions about my code:
- I tried to setup wavemaker on box1_port5&6 but the compiler gave me a file too big error. What am I doing wrong?
- to control a power head I'm using ReefAngel.StandardLights(Box1_Port8,20,0,22,0);. Can i use a more appropriate variable. I tried using ReefAngel.Relay.On code but it gave me an error.
- the new wizard produces new lines of code. What is the purpose of this command? ReefAngel.FeedingModePortsE[0] = 0; // I got it. it's for the 2nd relay ports.
- if I remove/disconnect the RA head unit, the relay boxes turn all the ports off. Is it possible to make them retain the current state or at least only few of the ports like pumps, skimmer, lights.
- is it possible to turn on specific ports during feeding? I'd like to have a circulation pump turn on for few minutes during feeding on port box1_port3.
- how to setup a timeout time for Dosing pumps?
Thank you.
===
Thne main code is:
/* The following features are enabled for this File:
#define VersionMenu
#define DisplayLEDPWM
#define wifi
#define WDT
#define SIMPLE_MENU
*/
#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 <ReefAngel.h>
void setup()
{
ReefAngel.Init();
ReefAngel.FeedingModePorts = Port8Bit;
ReefAngel.FeedingModePortsE[0] = 0;
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port8Bit | Port7Bit;
ReefAngel.WaterChangePortsE[0] = 0;
ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit | Port7Bit;
ReefAngel.WaterChangePortsE[0] = 0;
ReefAngel.LightsOnPorts = 0;
ReefAngel.Relay.On( Port8 );
ReefAngel.Relay.On( Box1_Port4 );
ReefAngel.Relay.On( Box1_Port5 );
ReefAngel.Relay.On( Box1_Port6 );
ReefAngel.Relay.On( Box1_Port7 );
ReefAngel.PHMin = 537;
ReefAngel.PHMax = 860;
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
InternalMemory.OverheatTemp_write( 830 );
}
void loop()
{
ReefAngel.StandardFan(Port5,787,793);
ReefAngel.StandardHeater(Port7,775,785);
ReefAngel.DosingPumpRepeat(Box1_Port1,0,120,2);
ReefAngel.DosingPumpRepeat(Box1_Port1,1,120,2);
if (hour() >= 10 && hour() < 20)
{
ReefAngel.StandardLights(Port1,11,1,19,0);
ReefAngel.StandardLights(Port3,11,0,19,0);
ReefAngel.StandardLights(Port4,10,0,19,59);
ReefAngel.StandardLights(Box1_Port3,11,0,19,0);
ReefAngel.PWM.SetDaylight(PWMSlope(11,0,19,0,0,0,180,0));
ReefAngel.PWM.SetActinic(PWMSlope(10,0,19,59,0,20,180,0));
}
else
{
ReefAngel.StandardLights(Port3,20,0,6,0);
ReefAngel.StandardLights(Port4,21,0,5,0);
ReefAngel.StandardLights(Port2,21,1,5,0);
ReefAngel.StandardLights(Box1_Port8,20,0,22,0);
ReefAngel.PWM.SetDaylight(PWMSlopeOvernight(20,0,6,0,0,20,180,0));
ReefAngel.PWM.SetActinic(PWMSlopeOvernight(21,0,5,0,0,0,180,0));
}
if (ReefAngel.Params.Temp[T2_PROBE] >= 1200 || ReefAngel.Params.Temp[T3_PROBE] >= 1200) {ReefAngel.Relay.On(Port6);}
if (ReefAngel.Params.Temp[T2_PROBE] < 1100 && ReefAngel.Params.Temp[T3_PROBE] < 1100) {ReefAngel.Relay.Off(Port6);}
ReefAngel.ShowInterface();
ReefAngel.Portal("d0lph1n","*****");
}
byte PWMSlopeOvernight(byte startHour, byte startMinute, byte endHour, byte
endMinute, byte startPWM, byte endPWM, byte Duration, byte oldValue)
{
unsigned long Start = previousMidnight(now())+((unsigned long)NumMins(startHour, startMinute)*60);
if (hour()<startHour) Start-=86400;
unsigned long StartD = Start + (Duration*60);
unsigned long End = nextMidnight(now())+((unsigned long)NumMins(endHour, endMinute)*60);
if (hour()<startHour) End-=86400;
unsigned long StopD = End - (Duration*60);
if ( now() >= Start && now() <= StartD )
return constrain(map(now(), Start, StartD, startPWM, endPWM),startPWM,
endPWM);
else if ( now() >= StopD && now() <= End )
{
byte v = constrain(map(now(), StopD, End, startPWM, endPWM),startPWM,
endPWM);
return endPWM-v+startPWM;
}
else if ( now() > StartD && now() < StopD )
return endPWM;
return oldValue;
}
Re: Custom code, please help
There is no way to have the ports on without the head unit on the main box.
The expansion box will retain the last state.
What do you mean timeout for dosing pump?
We can easily do Box1_Port3 turn on for the duration of the feeding mode, but if you are already having size issues, I don't think it will fit.
The expansion box will retain the last state.
What do you mean timeout for dosing pump?
We can easily do Box1_Port3 turn on for the duration of the feeding mode, but if you are already having size issues, I don't think it will fit.
Roberto.
Re: Custom code, please help
I mean, something to prevent the dose pump to pump more than X seconds, teh same fail-safe idea you implemented for the ato pump
Re: Custom code, please help
I'm not following.
The dosing pump is already limited by time and not by float switches.
The only reason we have timeout for ATO is because it is based on an external switch and not by time.
Your code is dosing 2 seconds. It's already limited to 2 seconds.
The dosing pump is already limited by time and not by float switches.
The only reason we have timeout for ATO is because it is based on an external switch and not by time.
Your code is dosing 2 seconds. It's already limited to 2 seconds.
Roberto.
Re: Custom code, please help
Hello Roberto,
If you can please:
1. help me clean my code and please let me know what variables to remove from mem and from the main code. For example I don't use the pH probe anymore. Why do I have so many powerslope variables in the mem code?
2. after upgrading to the latest libraries the code got too big. So it's kind of urgent bcz I can't upload the code anymore and the controller is nonoperational at this moment.
The following features were automatically added:
Watchdog Timer
Version Menu
The following features were detected:
Dimming Signal
Wifi Attachment
Relay Expansion Module
Number of Relay Expansion Modules: 1
Simple Menu
Binary sketch size: 33,306 bytes (of a 32,256 byte maximum)
processing.app.debug.RunnerException: Sketch too big; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing it.
at processing.app.Sketch.size(Sketch.java:1844)
at processing.app.Sketch.build(Sketch.java:1775)
at processing.app.Sketch.exportApplet(Sketch.java:1797)
at processing.app.Sketch.exportApplet(Sketch.java:1783)
at processing.app.Editor$DefaultExportHandler.run(Editor.java:2357)
at java.lang.Thread.run(Thread.java:619)
Thank you
===
Memory
// Autogenerated file by RAGen (v1.2.2.171), (04/14/2012 12:05)
// Memory_041412_1205.ino
//
// This file sets the default values to the Internal Memory
//
#include <ReefAngel_Features.h>
#include <Globals.h>
#include <Time.h>
#include <OneWire.h>
#include <RA_NokiaLCD.h>
#include <avr/pgmspace.h>
#include <InternalEEPROM.h>
#include <Wire.h>
#include <Memory.h>
RA_NokiaLCD e;
void setup()
{
e.Init();
e.Clear(COLOR_WHITE,0,0,132,132);
e.BacklightOn();
InternalMemory.StdLightsOnHour_write(22);
InternalMemory.StdLightsOnMinute_write(0);
InternalMemory.StdLightsOffHour_write(6);
InternalMemory.StdLightsOffMinute_write(0);
InternalMemory.DP1Timer_write(10);
InternalMemory.DP2Timer_write(10);
InternalMemory.FeedingTimer_write(3600);
InternalMemory.LCDTimer_write(600);
InternalMemory.OverheatTemp_write(1500);
InternalMemory.LEDPWMDaylight_write(0);
InternalMemory.LEDPWMActinic_write(0);
InternalMemory.HeaterTempOn_write(765);
InternalMemory.HeaterTempOff_write(770);
InternalMemory.ChillerTempOn_write(785);
InternalMemory.ChillerTempOff_write(770);
InternalMemory.ATOTimeout_write(60);
InternalMemory.PHMax_write(838);
InternalMemory.PHMin_write(542);
InternalMemory.DP1OnHour_write(20);
InternalMemory.DP1OnMinute_write(0);
InternalMemory.DP2OnHour_write(22);
InternalMemory.DP2OnMinute_write(30);
InternalMemory.ATOHourInterval_write(0);
InternalMemory.ATOHighHourInterval_write(0);
InternalMemory.ATOHighTimeout_write(60);
InternalMemory.DP1RepeatInterval_write(0);
InternalMemory.DP2RepeatInterval_write(0);
InternalMemory.PWMSlopeStartD_write(15);
InternalMemory.PWMSlopeEndD_write(100);
InternalMemory.PWMSlopeDurationD_write(60);
InternalMemory.PWMSlopeStartA_write(15);
InternalMemory.PWMSlopeEndA_write(100);
InternalMemory.PWMSlopeDurationA_write(60);
InternalMemory.RFMode_write(0);
InternalMemory.RFSpeed_write(100);
InternalMemory.RFDuration_write(10);
InternalMemory.PWMSlopeStart0_write(15);
InternalMemory.PWMSlopeEnd0_write(100);
InternalMemory.PWMSlopeDuration0_write(60);
InternalMemory.PWMSlopeStart1_write(15);
InternalMemory.PWMSlopeEnd1_write(100);
InternalMemory.PWMSlopeDuration1_write(60);
InternalMemory.PWMSlopeStart2_write(15);
InternalMemory.PWMSlopeEnd2_write(100);
InternalMemory.PWMSlopeDuration2_write(60);
InternalMemory.PWMSlopeStart3_write(15);
InternalMemory.PWMSlopeEnd3_write(100);
InternalMemory.PWMSlopeDuration3_write(60);
InternalMemory.PWMSlopeStart4_write(15);
InternalMemory.PWMSlopeEnd4_write(100);
InternalMemory.PWMSlopeDuration4_write(60);
InternalMemory.PWMSlopeStart5_write(15);
InternalMemory.PWMSlopeEnd5_write(100);
InternalMemory.PWMSlopeDuration5_write(60);
InternalMemory.IMCheck_write(0x5241494D);
}
void loop()
{
// display success screen
e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*2, "Internal Memory Set");
e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*4, "Now load your");
e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*5, " RA code file");
delay(5000);
}
====
/* The following features are enabled for this File:
#define VersionMenu
#define DisplayLEDPWM
#define wifi
#define WDT
#define SIMPLE_MENU
*/
#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 <ReefAngel.h>
void setup()
{
ReefAngel.Init();
ReefAngel.FeedingModePorts = Port6Bit;
ReefAngel.FeedingModePortsE[0] = Port4Bit | Port5Bit | Port8Bit;
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port6Bit | Port8Bit;
ReefAngel.WaterChangePortsE[0] = Port1Bit | Port2Bit | Port4Bit | Port5Bit | Port8Bit;
ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit;
ReefAngel.OverheatShutoffPortsE[0] = Port1Bit;
ReefAngel.LightsOnPorts = 0;
ReefAngel.Relay.On(Port6);
ReefAngel.Relay.On(Box1_Port1);
ReefAngel.Relay.On(Box1_Port3);
ReefAngel.Relay.On(Box1_Port4);
ReefAngel.PHMin = 537;
ReefAngel.PHMax = 860;
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
InternalMemory.OverheatTemp_write(810);
}
void loop()
{
ReefAngel.SingleATO(true,Box1_Port2,180,0);
ReefAngel.StandardFan(Box1_Port6,785,770);
ReefAngel.StandardHeater(Box1_Port1,765,770);
ReefAngel.DosingPumpRepeat(Box1_Port7,0,144,2);
ReefAngel.DosingPumpRepeat(Port8,1,144,2);
if (hour() >= 10 && hour() < 20)
{
ReefAngel.StandardLights(Port1,11,1,19,0);
ReefAngel.StandardLights(Port3,11,0,19,0);
ReefAngel.StandardLights(Port4,10,0,19,59);
ReefAngel.StandardLights(Box1_Port5,14,0,15,0);
ReefAngel.StandardLights(Box1_Port8,13,0,16,0);
ReefAngel.StandardLights(Port5,8,0,11,0);
ReefAngel.PWM.SetDaylight(PWMSlope(11,0,19,0,0,20,120,0));
ReefAngel.PWM.SetActinic(PWMSlope(10,0,19,59,0,20,180,0));
}
else
{
ReefAngel.StandardLights(Port2,21,1,5,0);
ReefAngel.StandardLights(Port3,20,0,6,0);
ReefAngel.StandardLights(Port4,21,0,5,0);
ReefAngel.StandardLights(Box1_Port5,1,0,2,0);
ReefAngel.StandardLights(Box1_Port8,1,0,4,0);
ReefAngel.StandardLights(Port5,19,0,22,0);
ReefAngel.PWM.SetDaylight(PWMSlopeOvernight(20,0,6,0,0,20,180,0));
ReefAngel.PWM.SetActinic(PWMSlopeOvernight(21,0,5,0,0,20,120,0));
}
if (ReefAngel.Params.Temp[T2_PROBE] >= 1200 || ReefAngel.Params.Temp[T3_PROBE] >= 1200) {ReefAngel.Relay.On(Port7);}
if (ReefAngel.Params.Temp[T2_PROBE] < 1100 && ReefAngel.Params.Temp[T3_PROBE] < 1100) {ReefAngel.Relay.Off(Port7);}
if (ReefAngel.Params.Temp[T2_PROBE] >= 1300 || ReefAngel.Params.Temp[T3_PROBE] >= 1300) {ReefAngel.Relay.Off(Port1);}
if (ReefAngel.Params.Temp[T2_PROBE] >= 1300 || ReefAngel.Params.Temp[T3_PROBE] >= 1300) {ReefAngel.Relay.Off(Port2);}
ReefAngel.ShowInterface();
ReefAngel.Portal("d0lph1n","====");
}
byte PWMSlopeOvernight(byte startHour, byte startMinute, byte endHour, byte
endMinute, byte startPWM, byte endPWM, byte Duration, byte oldValue)
{
unsigned long Start = previousMidnight(now())+((unsigned long)NumMins(startHour, startMinute)*60);
if (hour()<startHour) Start-=86400;
unsigned long StartD = Start + (Duration*60);
unsigned long End = nextMidnight(now())+((unsigned long)NumMins(endHour, endMinute)*60);
if (hour()<startHour) End-=86400;
unsigned long StopD = End - (Duration*60);
if ( now() >= Start && now() <= StartD )
return constrain(map(now(), Start, StartD, startPWM, endPWM),startPWM,
endPWM);
else if ( now() >= StopD && now() <= End )
{
byte v = constrain(map(now(), StopD, End, startPWM, endPWM),startPWM,
endPWM);
return endPWM-v+startPWM;
}
else if ( now() > StartD && now() < StopD )
return endPWM;
return oldValue;
}
If you can please:
1. help me clean my code and please let me know what variables to remove from mem and from the main code. For example I don't use the pH probe anymore. Why do I have so many powerslope variables in the mem code?
2. after upgrading to the latest libraries the code got too big. So it's kind of urgent bcz I can't upload the code anymore and the controller is nonoperational at this moment.
The following features were automatically added:
Watchdog Timer
Version Menu
The following features were detected:
Dimming Signal
Wifi Attachment
Relay Expansion Module
Number of Relay Expansion Modules: 1
Simple Menu
Binary sketch size: 33,306 bytes (of a 32,256 byte maximum)
processing.app.debug.RunnerException: Sketch too big; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing it.
at processing.app.Sketch.size(Sketch.java:1844)
at processing.app.Sketch.build(Sketch.java:1775)
at processing.app.Sketch.exportApplet(Sketch.java:1797)
at processing.app.Sketch.exportApplet(Sketch.java:1783)
at processing.app.Editor$DefaultExportHandler.run(Editor.java:2357)
at java.lang.Thread.run(Thread.java:619)
Thank you
===
Memory
// Autogenerated file by RAGen (v1.2.2.171), (04/14/2012 12:05)
// Memory_041412_1205.ino
//
// This file sets the default values to the Internal Memory
//
#include <ReefAngel_Features.h>
#include <Globals.h>
#include <Time.h>
#include <OneWire.h>
#include <RA_NokiaLCD.h>
#include <avr/pgmspace.h>
#include <InternalEEPROM.h>
#include <Wire.h>
#include <Memory.h>
RA_NokiaLCD e;
void setup()
{
e.Init();
e.Clear(COLOR_WHITE,0,0,132,132);
e.BacklightOn();
InternalMemory.StdLightsOnHour_write(22);
InternalMemory.StdLightsOnMinute_write(0);
InternalMemory.StdLightsOffHour_write(6);
InternalMemory.StdLightsOffMinute_write(0);
InternalMemory.DP1Timer_write(10);
InternalMemory.DP2Timer_write(10);
InternalMemory.FeedingTimer_write(3600);
InternalMemory.LCDTimer_write(600);
InternalMemory.OverheatTemp_write(1500);
InternalMemory.LEDPWMDaylight_write(0);
InternalMemory.LEDPWMActinic_write(0);
InternalMemory.HeaterTempOn_write(765);
InternalMemory.HeaterTempOff_write(770);
InternalMemory.ChillerTempOn_write(785);
InternalMemory.ChillerTempOff_write(770);
InternalMemory.ATOTimeout_write(60);
InternalMemory.PHMax_write(838);
InternalMemory.PHMin_write(542);
InternalMemory.DP1OnHour_write(20);
InternalMemory.DP1OnMinute_write(0);
InternalMemory.DP2OnHour_write(22);
InternalMemory.DP2OnMinute_write(30);
InternalMemory.ATOHourInterval_write(0);
InternalMemory.ATOHighHourInterval_write(0);
InternalMemory.ATOHighTimeout_write(60);
InternalMemory.DP1RepeatInterval_write(0);
InternalMemory.DP2RepeatInterval_write(0);
InternalMemory.PWMSlopeStartD_write(15);
InternalMemory.PWMSlopeEndD_write(100);
InternalMemory.PWMSlopeDurationD_write(60);
InternalMemory.PWMSlopeStartA_write(15);
InternalMemory.PWMSlopeEndA_write(100);
InternalMemory.PWMSlopeDurationA_write(60);
InternalMemory.RFMode_write(0);
InternalMemory.RFSpeed_write(100);
InternalMemory.RFDuration_write(10);
InternalMemory.PWMSlopeStart0_write(15);
InternalMemory.PWMSlopeEnd0_write(100);
InternalMemory.PWMSlopeDuration0_write(60);
InternalMemory.PWMSlopeStart1_write(15);
InternalMemory.PWMSlopeEnd1_write(100);
InternalMemory.PWMSlopeDuration1_write(60);
InternalMemory.PWMSlopeStart2_write(15);
InternalMemory.PWMSlopeEnd2_write(100);
InternalMemory.PWMSlopeDuration2_write(60);
InternalMemory.PWMSlopeStart3_write(15);
InternalMemory.PWMSlopeEnd3_write(100);
InternalMemory.PWMSlopeDuration3_write(60);
InternalMemory.PWMSlopeStart4_write(15);
InternalMemory.PWMSlopeEnd4_write(100);
InternalMemory.PWMSlopeDuration4_write(60);
InternalMemory.PWMSlopeStart5_write(15);
InternalMemory.PWMSlopeEnd5_write(100);
InternalMemory.PWMSlopeDuration5_write(60);
InternalMemory.IMCheck_write(0x5241494D);
}
void loop()
{
// display success screen
e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*2, "Internal Memory Set");
e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*4, "Now load your");
e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*5, " RA code file");
delay(5000);
}
====
/* The following features are enabled for this File:
#define VersionMenu
#define DisplayLEDPWM
#define wifi
#define WDT
#define SIMPLE_MENU
*/
#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 <ReefAngel.h>
void setup()
{
ReefAngel.Init();
ReefAngel.FeedingModePorts = Port6Bit;
ReefAngel.FeedingModePortsE[0] = Port4Bit | Port5Bit | Port8Bit;
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port6Bit | Port8Bit;
ReefAngel.WaterChangePortsE[0] = Port1Bit | Port2Bit | Port4Bit | Port5Bit | Port8Bit;
ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit;
ReefAngel.OverheatShutoffPortsE[0] = Port1Bit;
ReefAngel.LightsOnPorts = 0;
ReefAngel.Relay.On(Port6);
ReefAngel.Relay.On(Box1_Port1);
ReefAngel.Relay.On(Box1_Port3);
ReefAngel.Relay.On(Box1_Port4);
ReefAngel.PHMin = 537;
ReefAngel.PHMax = 860;
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
InternalMemory.OverheatTemp_write(810);
}
void loop()
{
ReefAngel.SingleATO(true,Box1_Port2,180,0);
ReefAngel.StandardFan(Box1_Port6,785,770);
ReefAngel.StandardHeater(Box1_Port1,765,770);
ReefAngel.DosingPumpRepeat(Box1_Port7,0,144,2);
ReefAngel.DosingPumpRepeat(Port8,1,144,2);
if (hour() >= 10 && hour() < 20)
{
ReefAngel.StandardLights(Port1,11,1,19,0);
ReefAngel.StandardLights(Port3,11,0,19,0);
ReefAngel.StandardLights(Port4,10,0,19,59);
ReefAngel.StandardLights(Box1_Port5,14,0,15,0);
ReefAngel.StandardLights(Box1_Port8,13,0,16,0);
ReefAngel.StandardLights(Port5,8,0,11,0);
ReefAngel.PWM.SetDaylight(PWMSlope(11,0,19,0,0,20,120,0));
ReefAngel.PWM.SetActinic(PWMSlope(10,0,19,59,0,20,180,0));
}
else
{
ReefAngel.StandardLights(Port2,21,1,5,0);
ReefAngel.StandardLights(Port3,20,0,6,0);
ReefAngel.StandardLights(Port4,21,0,5,0);
ReefAngel.StandardLights(Box1_Port5,1,0,2,0);
ReefAngel.StandardLights(Box1_Port8,1,0,4,0);
ReefAngel.StandardLights(Port5,19,0,22,0);
ReefAngel.PWM.SetDaylight(PWMSlopeOvernight(20,0,6,0,0,20,180,0));
ReefAngel.PWM.SetActinic(PWMSlopeOvernight(21,0,5,0,0,20,120,0));
}
if (ReefAngel.Params.Temp[T2_PROBE] >= 1200 || ReefAngel.Params.Temp[T3_PROBE] >= 1200) {ReefAngel.Relay.On(Port7);}
if (ReefAngel.Params.Temp[T2_PROBE] < 1100 && ReefAngel.Params.Temp[T3_PROBE] < 1100) {ReefAngel.Relay.Off(Port7);}
if (ReefAngel.Params.Temp[T2_PROBE] >= 1300 || ReefAngel.Params.Temp[T3_PROBE] >= 1300) {ReefAngel.Relay.Off(Port1);}
if (ReefAngel.Params.Temp[T2_PROBE] >= 1300 || ReefAngel.Params.Temp[T3_PROBE] >= 1300) {ReefAngel.Relay.Off(Port2);}
ReefAngel.ShowInterface();
ReefAngel.Portal("d0lph1n","====");
}
byte PWMSlopeOvernight(byte startHour, byte startMinute, byte endHour, byte
endMinute, byte startPWM, byte endPWM, byte Duration, byte oldValue)
{
unsigned long Start = previousMidnight(now())+((unsigned long)NumMins(startHour, startMinute)*60);
if (hour()<startHour) Start-=86400;
unsigned long StartD = Start + (Duration*60);
unsigned long End = nextMidnight(now())+((unsigned long)NumMins(endHour, endMinute)*60);
if (hour()<startHour) End-=86400;
unsigned long StopD = End - (Duration*60);
if ( now() >= Start && now() <= StartD )
return constrain(map(now(), Start, StartD, startPWM, endPWM),startPWM,
endPWM);
else if ( now() >= StopD && now() <= End )
{
byte v = constrain(map(now(), StopD, End, startPWM, endPWM),startPWM,
endPWM);
return endPWM-v+startPWM;
}
else if ( now() > StartD && now() < StopD )
return endPWM;
return oldValue;
}
Re: Custom code, please help
You don't need to upload memory settings anymore, so just forget about it.
Your code will be a little tricky to reduce.
Your code will be a little tricky to reduce.
Roberto.
Re: Custom code, please help
I reinstalled RA and reloaded the code. There are the following issues:
1. no more size issues just " “No Internal Memory Found". So I loaded the Initial Mem Settings which I simplified later.
2. at 77.5F StandarFan kicks on/off for 1 sec, very very annoying. If I artificially increase the temp above 77.5F the fan will kick in until it will cool it to 77.5F. Where is the problem i?
Here is my code:
Mem
#include <ReefAngel_Features.h>
#include <Globals.h>
#include <Time.h>
#include <OneWire.h>
#include <RA_NokiaLCD.h>
#include <avr/pgmspace.h>
#include <InternalEEPROM.h>
#include <Wire.h>
#include <Memory.h>
RA_NokiaLCD e;
void setup()
{
e.Init();
e.Clear(COLOR_WHITE,0,0,132,132);
e.BacklightOn();
InternalMemory.FeedingTimer_write(900);
InternalMemory.LCDTimer_write(600);
InternalMemory.IMCheck_write(0xCF06A31E);
e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL+20, MENU_START_ROW*3, "Memory Updated");
e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL+25, MENU_START_ROW*6, "You can now");
e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL+25, MENU_START_ROW*7, "upload your");
e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL+33, MENU_START_ROW*8, "INO code");
}
void loop()
{
}
===
/* The following features are enabled for this File:
#define VersionMenu
#define DisplayLEDPWM
#define wifi
#define WDT
#define SIMPLE_MENU
*/
#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 <ReefAngel.h>
void setup()
{
ReefAngel.Init();
ReefAngel.FeedingModePorts = Port6Bit;
ReefAngel.FeedingModePortsE[0] = Port4Bit | Port5Bit | Port8Bit;
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port6Bit | Port8Bit;
ReefAngel.WaterChangePortsE[0] = Port1Bit | Port2Bit | Port4Bit | Port5Bit | Port8Bit;
ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit;
ReefAngel.OverheatShutoffPortsE[0] = Port1Bit;
ReefAngel.LightsOnPorts = 0;
ReefAngel.Relay.On(Port6);
ReefAngel.Relay.On(Box1_Port1);
ReefAngel.Relay.On(Box1_Port3);
ReefAngel.Relay.On(Box1_Port4);
ReefAngel.PHMin = 537;
ReefAngel.PHMax = 860;
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
InternalMemory.OverheatTemp_write(800);
}
void loop()
{
ReefAngel.SingleATO(true,Box1_Port2,180,0);
ReefAngel.StandardFan(Box1_Port6,775,770);
ReefAngel.StandardHeater(Box1_Port1,765,770);
ReefAngel.DosingPumpRepeat(Box1_Port7,0,144,2);
ReefAngel.DosingPumpRepeat(Port8,1,144,2);
if (hour() >= 10 && hour() < 20)
{
ReefAngel.StandardLights(Port1,11,1,19,0);
ReefAngel.StandardLights(Port3,11,0,19,0);
ReefAngel.StandardLights(Port4,10,0,19,59);
ReefAngel.StandardLights(Box1_Port5,14,0,15,0);
ReefAngel.StandardLights(Box1_Port8,13,0,16,0);
ReefAngel.StandardLights(Port5,8,0,11,0);
ReefAngel.PWM.SetDaylight(PWMSlope(11,0,19,0,0,20,120,0));
ReefAngel.PWM.SetActinic(PWMSlope(10,0,19,59,0,20,180,0));
}
else
{
ReefAngel.StandardLights(Port2,21,1,5,0);
ReefAngel.StandardLights(Port3,20,0,6,0);
ReefAngel.StandardLights(Port4,21,0,5,0);
ReefAngel.StandardLights(Box1_Port5,1,0,2,0);
ReefAngel.StandardLights(Box1_Port8,1,0,4,0);
ReefAngel.StandardLights(Port5,19,0,22,0);
ReefAngel.PWM.SetDaylight(PWMSlopeOvernight(20,0,6,0,0,20,180,0));
ReefAngel.PWM.SetActinic(PWMSlopeOvernight(21,0,5,0,0,20,120,0));
}
if (ReefAngel.Params.Temp[T2_PROBE] >= 1200 || ReefAngel.Params.Temp[T3_PROBE] >= 1200) {ReefAngel.Relay.On(Port7);}
if (ReefAngel.Params.Temp[T2_PROBE] < 1100 && ReefAngel.Params.Temp[T3_PROBE] < 1100) {ReefAngel.Relay.Off(Port7);}
if (ReefAngel.Params.Temp[T2_PROBE] >= 1300 || ReefAngel.Params.Temp[T3_PROBE] >= 1300) {ReefAngel.Relay.Off(Port1);}
if (ReefAngel.Params.Temp[T2_PROBE] >= 1300 || ReefAngel.Params.Temp[T3_PROBE] >= 1300) {ReefAngel.Relay.Off(Port2);}
ReefAngel.ShowInterface();
ReefAngel.Portal("d0lph1n","");
}
byte PWMSlopeOvernight(byte startHour, byte startMinute, byte endHour, byte
endMinute, byte startPWM, byte endPWM, byte Duration, byte oldValue)
{
unsigned long Start = previousMidnight(now())+((unsigned long)NumMins(startHour, startMinute)*60);
if (hour()<startHour) Start-=86400;
unsigned long StartD = Start + (Duration*60);
unsigned long End = nextMidnight(now())+((unsigned long)NumMins(endHour, endMinute)*60);
if (hour()<startHour) End-=86400;
unsigned long StopD = End - (Duration*60);
if ( now() >= Start && now() <= StartD )
return constrain(map(now(), Start, StartD, startPWM, endPWM),startPWM,
endPWM);
else if ( now() >= StopD && now() <= End )
{
byte v = constrain(map(now(), StopD, End, startPWM, endPWM),startPWM,
endPWM);
return endPWM-v+startPWM;
}
else if ( now() > StartD && now() < StopD )
return endPWM;
return oldValue;
}
1. no more size issues just " “No Internal Memory Found". So I loaded the Initial Mem Settings which I simplified later.
2. at 77.5F StandarFan kicks on/off for 1 sec, very very annoying. If I artificially increase the temp above 77.5F the fan will kick in until it will cool it to 77.5F. Where is the problem i?
Here is my code:
Mem
#include <ReefAngel_Features.h>
#include <Globals.h>
#include <Time.h>
#include <OneWire.h>
#include <RA_NokiaLCD.h>
#include <avr/pgmspace.h>
#include <InternalEEPROM.h>
#include <Wire.h>
#include <Memory.h>
RA_NokiaLCD e;
void setup()
{
e.Init();
e.Clear(COLOR_WHITE,0,0,132,132);
e.BacklightOn();
InternalMemory.FeedingTimer_write(900);
InternalMemory.LCDTimer_write(600);
InternalMemory.IMCheck_write(0xCF06A31E);
e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL+20, MENU_START_ROW*3, "Memory Updated");
e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL+25, MENU_START_ROW*6, "You can now");
e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL+25, MENU_START_ROW*7, "upload your");
e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL+33, MENU_START_ROW*8, "INO code");
}
void loop()
{
}
===
/* The following features are enabled for this File:
#define VersionMenu
#define DisplayLEDPWM
#define wifi
#define WDT
#define SIMPLE_MENU
*/
#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 <ReefAngel.h>
void setup()
{
ReefAngel.Init();
ReefAngel.FeedingModePorts = Port6Bit;
ReefAngel.FeedingModePortsE[0] = Port4Bit | Port5Bit | Port8Bit;
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port6Bit | Port8Bit;
ReefAngel.WaterChangePortsE[0] = Port1Bit | Port2Bit | Port4Bit | Port5Bit | Port8Bit;
ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit;
ReefAngel.OverheatShutoffPortsE[0] = Port1Bit;
ReefAngel.LightsOnPorts = 0;
ReefAngel.Relay.On(Port6);
ReefAngel.Relay.On(Box1_Port1);
ReefAngel.Relay.On(Box1_Port3);
ReefAngel.Relay.On(Box1_Port4);
ReefAngel.PHMin = 537;
ReefAngel.PHMax = 860;
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
InternalMemory.OverheatTemp_write(800);
}
void loop()
{
ReefAngel.SingleATO(true,Box1_Port2,180,0);
ReefAngel.StandardFan(Box1_Port6,775,770);
ReefAngel.StandardHeater(Box1_Port1,765,770);
ReefAngel.DosingPumpRepeat(Box1_Port7,0,144,2);
ReefAngel.DosingPumpRepeat(Port8,1,144,2);
if (hour() >= 10 && hour() < 20)
{
ReefAngel.StandardLights(Port1,11,1,19,0);
ReefAngel.StandardLights(Port3,11,0,19,0);
ReefAngel.StandardLights(Port4,10,0,19,59);
ReefAngel.StandardLights(Box1_Port5,14,0,15,0);
ReefAngel.StandardLights(Box1_Port8,13,0,16,0);
ReefAngel.StandardLights(Port5,8,0,11,0);
ReefAngel.PWM.SetDaylight(PWMSlope(11,0,19,0,0,20,120,0));
ReefAngel.PWM.SetActinic(PWMSlope(10,0,19,59,0,20,180,0));
}
else
{
ReefAngel.StandardLights(Port2,21,1,5,0);
ReefAngel.StandardLights(Port3,20,0,6,0);
ReefAngel.StandardLights(Port4,21,0,5,0);
ReefAngel.StandardLights(Box1_Port5,1,0,2,0);
ReefAngel.StandardLights(Box1_Port8,1,0,4,0);
ReefAngel.StandardLights(Port5,19,0,22,0);
ReefAngel.PWM.SetDaylight(PWMSlopeOvernight(20,0,6,0,0,20,180,0));
ReefAngel.PWM.SetActinic(PWMSlopeOvernight(21,0,5,0,0,20,120,0));
}
if (ReefAngel.Params.Temp[T2_PROBE] >= 1200 || ReefAngel.Params.Temp[T3_PROBE] >= 1200) {ReefAngel.Relay.On(Port7);}
if (ReefAngel.Params.Temp[T2_PROBE] < 1100 && ReefAngel.Params.Temp[T3_PROBE] < 1100) {ReefAngel.Relay.Off(Port7);}
if (ReefAngel.Params.Temp[T2_PROBE] >= 1300 || ReefAngel.Params.Temp[T3_PROBE] >= 1300) {ReefAngel.Relay.Off(Port1);}
if (ReefAngel.Params.Temp[T2_PROBE] >= 1300 || ReefAngel.Params.Temp[T3_PROBE] >= 1300) {ReefAngel.Relay.Off(Port2);}
ReefAngel.ShowInterface();
ReefAngel.Portal("d0lph1n","");
}
byte PWMSlopeOvernight(byte startHour, byte startMinute, byte endHour, byte
endMinute, byte startPWM, byte endPWM, byte Duration, byte oldValue)
{
unsigned long Start = previousMidnight(now())+((unsigned long)NumMins(startHour, startMinute)*60);
if (hour()<startHour) Start-=86400;
unsigned long StartD = Start + (Duration*60);
unsigned long End = nextMidnight(now())+((unsigned long)NumMins(endHour, endMinute)*60);
if (hour()<startHour) End-=86400;
unsigned long StopD = End - (Duration*60);
if ( now() >= Start && now() <= StartD )
return constrain(map(now(), Start, StartD, startPWM, endPWM),startPWM,
endPWM);
else if ( now() >= StopD && now() <= End )
{
byte v = constrain(map(now(), StopD, End, startPWM, endPWM),startPWM,
endPWM);
return endPWM-v+startPWM;
}
else if ( now() > StartD && now() < StopD )
return endPWM;
return oldValue;
}
Re: Custom code, please help
ReefAngel.StandardFan(Box1_Port6,775,770);
The problem is this line. First off the parameters should be reversed. Low temp goes first then high temp.
ReefAngel.StandardFan(Box1_Port6,770,775);
This will turn the fan on at 77.5 until the temp reaches 77.0 and then turn off again.
The problem is this line. First off the parameters should be reversed. Low temp goes first then high temp.
ReefAngel.StandardFan(Box1_Port6,770,775);
This will turn the fan on at 77.5 until the temp reaches 77.0 and then turn off again.
Re: Custom code, please help
Today I realized that the ATO has stopped working.
I did the followings:
- replaced the ATO sensor with a brand new one.
- checked the ATO pump
- checked the power box plug: moved the ATO setup from box1_port2 to box1_port8
- if I unplug/plug the power of the RA controller, the ATO system works until Level Full but it refuses to start if Level Low unless I unplug the RA again.
What could be the problem?
How can I test the 2nd ATO port in single mode?
The RA libraries were updated last week. Btw, since the update, without touching the code, my code's size was too big so I had to remove the wifi code in order to fit in my RA's memory!!
Here is the latest ver of the code, without the wifi module:
===
/* The following features are enabled for this File:
#define VersionMenu
#define DisplayLEDPWM
#define WDT
#define SIMPLE_MENU
*/
#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 <ReefAngel.h>
void setup()
{
ReefAngel.Init();
ReefAngel.FeedingModePorts = Port6Bit;
ReefAngel.FeedingModePortsE[0] = Port4Bit | Port5Bit | Port8Bit;
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port6Bit | Port8Bit;
ReefAngel.WaterChangePortsE[0] = Port1Bit | Port8Bit | Port4Bit | Port5Bit;
ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit;
ReefAngel.OverheatShutoffPortsE[0] = Port1Bit;
ReefAngel.LightsOnPorts = 0;
ReefAngel.Relay.On(Port6);
ReefAngel.Relay.On(Box1_Port1);
ReefAngel.Relay.On(Box1_Port3);
ReefAngel.Relay.On(Box1_Port4);
ReefAngel.PHMin = 537;
ReefAngel.PHMax = 860;
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
InternalMemory.OverheatTemp_write(820);
}
void loop()
{
ReefAngel.SingleATO(true,Box1_Port8,180,2);
ReefAngel.StandardFan(Box1_Port6,775,785);
ReefAngel.StandardHeater(Box1_Port1,765,770);
ReefAngel.DosingPumpRepeat(Box1_Port7,0,144,2);
ReefAngel.DosingPumpRepeat(Port8,1,144,2);
if (hour() >= 10 && hour() < 20)
{
ReefAngel.StandardLights(Port1,11,1,19,0);
ReefAngel.StandardLights(Port3,11,0,19,0);
ReefAngel.StandardLights(Port4,10,0,19,59);
ReefAngel.StandardLights(Port5,8,0,11,0);
ReefAngel.PWM.SetDaylight(PWMSlope(11,0,19,0,0,20,120,0));
ReefAngel.PWM.SetActinic(PWMSlope(10,0,19,59,0,20,180,0));
}
else
{
ReefAngel.StandardLights(Port2,21,1,5,0);
ReefAngel.StandardLights(Port3,20,0,6,0);
ReefAngel.StandardLights(Port4,21,0,5,0);
ReefAngel.StandardLights(Port5,19,0,22,0);
ReefAngel.PWM.SetDaylight(PWMSlopeOvernight(20,0,6,0,0,20,180,0));
ReefAngel.PWM.SetActinic(PWMSlopeOvernight(21,0,5,0,0,20,120,0));
}
if (ReefAngel.Params.Temp[T2_PROBE] >= 1200 || ReefAngel.Params.Temp[T3_PROBE] >= 1200) {ReefAngel.Relay.On(Port7);}
if (ReefAngel.Params.Temp[T2_PROBE] < 1100 && ReefAngel.Params.Temp[T3_PROBE] < 1100) {ReefAngel.Relay.Off(Port7);}
if (ReefAngel.Params.Temp[T2_PROBE] >= 1300 || ReefAngel.Params.Temp[T3_PROBE] >= 1300) {ReefAngel.Relay.Off(Port1);}
if (ReefAngel.Params.Temp[T2_PROBE] >= 1300 || ReefAngel.Params.Temp[T3_PROBE] >= 1300) {ReefAngel.Relay.Off(Port2);}
ReefAngel.ShowInterface();
}
byte PWMSlopeOvernight(byte startHour, byte startMinute, byte endHour, byte
endMinute, byte startPWM, byte endPWM, byte Duration, byte oldValue)
{
unsigned long Start = previousMidnight(now())+((unsigned long)NumMins(startHour, startMinute)*60);
if (hour()<startHour) Start-=86400;
unsigned long StartD = Start + (Duration*60);
unsigned long End = nextMidnight(now())+((unsigned long)NumMins(endHour, endMinute)*60);
if (hour()<startHour) End-=86400;
unsigned long StopD = End - (Duration*60);
if ( now() >= Start && now() <= StartD )
return constrain(map(now(), Start, StartD, startPWM, endPWM),startPWM,
endPWM);
else if ( now() >= StopD && now() <= End )
{
byte v = constrain(map(now(), StopD, End, startPWM, endPWM),startPWM,
endPWM);
return endPWM-v+startPWM;
}
else if ( now() > StartD && now() < StopD )
return endPWM;
return oldValue;
}
I did the followings:
- replaced the ATO sensor with a brand new one.
- checked the ATO pump
- checked the power box plug: moved the ATO setup from box1_port2 to box1_port8
- if I unplug/plug the power of the RA controller, the ATO system works until Level Full but it refuses to start if Level Low unless I unplug the RA again.
What could be the problem?
How can I test the 2nd ATO port in single mode?
The RA libraries were updated last week. Btw, since the update, without touching the code, my code's size was too big so I had to remove the wifi code in order to fit in my RA's memory!!
Here is the latest ver of the code, without the wifi module:
===
/* The following features are enabled for this File:
#define VersionMenu
#define DisplayLEDPWM
#define WDT
#define SIMPLE_MENU
*/
#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 <ReefAngel.h>
void setup()
{
ReefAngel.Init();
ReefAngel.FeedingModePorts = Port6Bit;
ReefAngel.FeedingModePortsE[0] = Port4Bit | Port5Bit | Port8Bit;
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port6Bit | Port8Bit;
ReefAngel.WaterChangePortsE[0] = Port1Bit | Port8Bit | Port4Bit | Port5Bit;
ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit;
ReefAngel.OverheatShutoffPortsE[0] = Port1Bit;
ReefAngel.LightsOnPorts = 0;
ReefAngel.Relay.On(Port6);
ReefAngel.Relay.On(Box1_Port1);
ReefAngel.Relay.On(Box1_Port3);
ReefAngel.Relay.On(Box1_Port4);
ReefAngel.PHMin = 537;
ReefAngel.PHMax = 860;
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
InternalMemory.OverheatTemp_write(820);
}
void loop()
{
ReefAngel.SingleATO(true,Box1_Port8,180,2);
ReefAngel.StandardFan(Box1_Port6,775,785);
ReefAngel.StandardHeater(Box1_Port1,765,770);
ReefAngel.DosingPumpRepeat(Box1_Port7,0,144,2);
ReefAngel.DosingPumpRepeat(Port8,1,144,2);
if (hour() >= 10 && hour() < 20)
{
ReefAngel.StandardLights(Port1,11,1,19,0);
ReefAngel.StandardLights(Port3,11,0,19,0);
ReefAngel.StandardLights(Port4,10,0,19,59);
ReefAngel.StandardLights(Port5,8,0,11,0);
ReefAngel.PWM.SetDaylight(PWMSlope(11,0,19,0,0,20,120,0));
ReefAngel.PWM.SetActinic(PWMSlope(10,0,19,59,0,20,180,0));
}
else
{
ReefAngel.StandardLights(Port2,21,1,5,0);
ReefAngel.StandardLights(Port3,20,0,6,0);
ReefAngel.StandardLights(Port4,21,0,5,0);
ReefAngel.StandardLights(Port5,19,0,22,0);
ReefAngel.PWM.SetDaylight(PWMSlopeOvernight(20,0,6,0,0,20,180,0));
ReefAngel.PWM.SetActinic(PWMSlopeOvernight(21,0,5,0,0,20,120,0));
}
if (ReefAngel.Params.Temp[T2_PROBE] >= 1200 || ReefAngel.Params.Temp[T3_PROBE] >= 1200) {ReefAngel.Relay.On(Port7);}
if (ReefAngel.Params.Temp[T2_PROBE] < 1100 && ReefAngel.Params.Temp[T3_PROBE] < 1100) {ReefAngel.Relay.Off(Port7);}
if (ReefAngel.Params.Temp[T2_PROBE] >= 1300 || ReefAngel.Params.Temp[T3_PROBE] >= 1300) {ReefAngel.Relay.Off(Port1);}
if (ReefAngel.Params.Temp[T2_PROBE] >= 1300 || ReefAngel.Params.Temp[T3_PROBE] >= 1300) {ReefAngel.Relay.Off(Port2);}
ReefAngel.ShowInterface();
}
byte PWMSlopeOvernight(byte startHour, byte startMinute, byte endHour, byte
endMinute, byte startPWM, byte endPWM, byte Duration, byte oldValue)
{
unsigned long Start = previousMidnight(now())+((unsigned long)NumMins(startHour, startMinute)*60);
if (hour()<startHour) Start-=86400;
unsigned long StartD = Start + (Duration*60);
unsigned long End = nextMidnight(now())+((unsigned long)NumMins(endHour, endMinute)*60);
if (hour()<startHour) End-=86400;
unsigned long StopD = End - (Duration*60);
if ( now() >= Start && now() <= StartD )
return constrain(map(now(), Start, StartD, startPWM, endPWM),startPWM,
endPWM);
else if ( now() >= StopD && now() <= End )
{
byte v = constrain(map(now(), StopD, End, startPWM, endPWM),startPWM,
endPWM);
return endPWM-v+startPWM;
}
else if ( now() > StartD && now() < StopD )
return endPWM;
return oldValue;
}
Re: Custom code, please help
Code: Select all
ReefAngel.SingleATO(true,Box1_Port8,180,2);
To disable the 2 hour restriction, replace the 2 for 0.
To test the ports, you can use the ControllerTester code.
File->Sketchbook->Example Codes
Roberto.
Re: Custom code, please help
Thanks Roberto. Great support. I appreciate it.
I thought the last digit is for time-out in minutes.
How can I setup the ATO pump timeout, if the ato pump is on for more than X minutes to turn on the red light and to shutdown the ato pump?
I thought the last digit is for time-out in minutes.
How can I setup the ATO pump timeout, if the ato pump is on for more than X minutes to turn on the red light and to shutdown the ato pump?
Re: Custom code, please help
That's the 180 in that function.
Here is a reference of that function:
http://www.easte.net/RA/html/class_reef ... 545a376e92
Here is a reference of that function:
http://www.easte.net/RA/html/class_reef ... 545a376e92
Roberto.
Re: Custom code, please help
Also, since the latest library update, without modifying the code, I can't upload it to RA anymore, size too big.
here is the old code, including the wifi module. Is it possible to make it smaller, without losing the main functions? I'm not using the pH sensor anymore, so pH related code can go.
/* The following features are enabled for this File:
#define VersionMenu
#define DisplayLEDPWM
#define wifi
#define WDT
#define SIMPLE_MENU
*/
#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 <ReefAngel.h>
void setup()
{
ReefAngel.Init();
ReefAngel.FeedingModePorts = Port6Bit;
ReefAngel.FeedingModePortsE[0] = Port4Bit | Port5Bit | Port8Bit;
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port6Bit | Port8Bit;
ReefAngel.WaterChangePortsE[0] = Port1Bit | Port2Bit | Port4Bit | Port5Bit | Port8Bit;
ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit;
ReefAngel.OverheatShutoffPortsE[0] = Port1Bit;
ReefAngel.LightsOnPorts = 0;
ReefAngel.Relay.On(Port6);
ReefAngel.Relay.On(Box1_Port1);
ReefAngel.Relay.On(Box1_Port3);
ReefAngel.Relay.On(Box1_Port4);
ReefAngel.PHMin = 537;
ReefAngel.PHMax = 860;
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
InternalMemory.OverheatTemp_write(820);
}
void loop()
{
ReefAngel.SingleATO(true,Box1_Port2,180,2);
ReefAngel.StandardFan(Box1_Port6,775,785);
ReefAngel.StandardHeater(Box1_Port1,770,775);
ReefAngel.DosingPumpRepeat(Box1_Port7,0,144,2);
ReefAngel.DosingPumpRepeat(Port8,1,144,2);
if (hour() >= 10 && hour() < 20)
{
ReefAngel.StandardLights(Port1,11,1,19,0);
ReefAngel.StandardLights(Port3,11,0,19,0);
ReefAngel.StandardLights(Port4,10,0,19,59);
ReefAngel.StandardLights(Box1_Port5,14,0,15,0);
ReefAngel.StandardLights(Box1_Port8,13,0,16,0);
ReefAngel.StandardLights(Port5,8,0,11,0);
ReefAngel.PWM.SetDaylight(PWMSlope(11,0,19,0,0,20,120,0));
ReefAngel.PWM.SetActinic(PWMSlope(10,0,19,59,0,20,180,0));
}
else
{
ReefAngel.StandardLights(Port2,21,1,5,0);
ReefAngel.StandardLights(Port3,20,0,6,0);
ReefAngel.StandardLights(Port4,21,0,5,0);
ReefAngel.StandardLights(Box1_Port5,1,0,2,0);
ReefAngel.StandardLights(Box1_Port8,1,0,4,0);
ReefAngel.StandardLights(Port5,19,0,22,0);
ReefAngel.PWM.SetDaylight(PWMSlopeOvernight(20,0,6,0,0,20,180,0));
ReefAngel.PWM.SetActinic(PWMSlopeOvernight(21,0,5,0,0,20,120,0));
}
if (ReefAngel.Params.Temp[T2_PROBE] >= 1200 || ReefAngel.Params.Temp[T3_PROBE] >= 1200) {ReefAngel.Relay.On(Port7);}
if (ReefAngel.Params.Temp[T2_PROBE] < 1100 && ReefAngel.Params.Temp[T3_PROBE] < 1100) {ReefAngel.Relay.Off(Port7);}
if (ReefAngel.Params.Temp[T2_PROBE] >= 1300 || ReefAngel.Params.Temp[T3_PROBE] >= 1300) {ReefAngel.Relay.Off(Port1);}
if (ReefAngel.Params.Temp[T2_PROBE] >= 1300 || ReefAngel.Params.Temp[T3_PROBE] >= 1300) {ReefAngel.Relay.Off(Port2);}
ReefAngel.ShowInterface();
ReefAngel.Portal("d0lph1n","xxxxx");
}
byte PWMSlopeOvernight(byte startHour, byte startMinute, byte endHour, byte
endMinute, byte startPWM, byte endPWM, byte Duration, byte oldValue)
{
unsigned long Start = previousMidnight(now())+((unsigned long)NumMins(startHour, startMinute)*60);
if (hour()<startHour) Start-=86400;
unsigned long StartD = Start + (Duration*60);
unsigned long End = nextMidnight(now())+((unsigned long)NumMins(endHour, endMinute)*60);
if (hour()<startHour) End-=86400;
unsigned long StopD = End - (Duration*60);
if ( now() >= Start && now() <= StartD )
return constrain(map(now(), Start, StartD, startPWM, endPWM),startPWM,
endPWM);
else if ( now() >= StopD && now() <= End )
{
byte v = constrain(map(now(), StopD, End, startPWM, endPWM),startPWM,
endPWM);
return endPWM-v+startPWM;
}
else if ( now() > StartD && now() < StopD )
return endPWM;
return oldValue;
}
===
#include <ReefAngel_Features.h>
#include <Globals.h>
#include <Time.h>
#include <OneWire.h>
#include <RA_NokiaLCD.h>
#include <avr/pgmspace.h>
#include <InternalEEPROM.h>
#include <Wire.h>
#include <Memory.h>
RA_NokiaLCD e;
void setup()
{
e.Init();
e.Clear(COLOR_WHITE,0,0,132,132);
e.BacklightOn();
InternalMemory.FeedingTimer_write(900);
InternalMemory.LCDTimer_write(600);
InternalMemory.HeaterTempOn_write(765);
InternalMemory.HeaterTempOff_write(770);
InternalMemory.ChillerTempOn_write(785);
InternalMemory.ChillerTempOff_write(775);
InternalMemory.OverheatTemp_write(800);
InternalMemory.IMCheck_write(0xCF06A31E);
e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL+20, MENU_START_ROW*3, "Memory Updated");
e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL+25, MENU_START_ROW*6, "You can now");
e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL+25, MENU_START_ROW*7, "upload your");
e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL+33, MENU_START_ROW*8, "INO code");
}
void loop()
{
}
here is the old code, including the wifi module. Is it possible to make it smaller, without losing the main functions? I'm not using the pH sensor anymore, so pH related code can go.
/* The following features are enabled for this File:
#define VersionMenu
#define DisplayLEDPWM
#define wifi
#define WDT
#define SIMPLE_MENU
*/
#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 <ReefAngel.h>
void setup()
{
ReefAngel.Init();
ReefAngel.FeedingModePorts = Port6Bit;
ReefAngel.FeedingModePortsE[0] = Port4Bit | Port5Bit | Port8Bit;
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port6Bit | Port8Bit;
ReefAngel.WaterChangePortsE[0] = Port1Bit | Port2Bit | Port4Bit | Port5Bit | Port8Bit;
ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit;
ReefAngel.OverheatShutoffPortsE[0] = Port1Bit;
ReefAngel.LightsOnPorts = 0;
ReefAngel.Relay.On(Port6);
ReefAngel.Relay.On(Box1_Port1);
ReefAngel.Relay.On(Box1_Port3);
ReefAngel.Relay.On(Box1_Port4);
ReefAngel.PHMin = 537;
ReefAngel.PHMax = 860;
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
InternalMemory.OverheatTemp_write(820);
}
void loop()
{
ReefAngel.SingleATO(true,Box1_Port2,180,2);
ReefAngel.StandardFan(Box1_Port6,775,785);
ReefAngel.StandardHeater(Box1_Port1,770,775);
ReefAngel.DosingPumpRepeat(Box1_Port7,0,144,2);
ReefAngel.DosingPumpRepeat(Port8,1,144,2);
if (hour() >= 10 && hour() < 20)
{
ReefAngel.StandardLights(Port1,11,1,19,0);
ReefAngel.StandardLights(Port3,11,0,19,0);
ReefAngel.StandardLights(Port4,10,0,19,59);
ReefAngel.StandardLights(Box1_Port5,14,0,15,0);
ReefAngel.StandardLights(Box1_Port8,13,0,16,0);
ReefAngel.StandardLights(Port5,8,0,11,0);
ReefAngel.PWM.SetDaylight(PWMSlope(11,0,19,0,0,20,120,0));
ReefAngel.PWM.SetActinic(PWMSlope(10,0,19,59,0,20,180,0));
}
else
{
ReefAngel.StandardLights(Port2,21,1,5,0);
ReefAngel.StandardLights(Port3,20,0,6,0);
ReefAngel.StandardLights(Port4,21,0,5,0);
ReefAngel.StandardLights(Box1_Port5,1,0,2,0);
ReefAngel.StandardLights(Box1_Port8,1,0,4,0);
ReefAngel.StandardLights(Port5,19,0,22,0);
ReefAngel.PWM.SetDaylight(PWMSlopeOvernight(20,0,6,0,0,20,180,0));
ReefAngel.PWM.SetActinic(PWMSlopeOvernight(21,0,5,0,0,20,120,0));
}
if (ReefAngel.Params.Temp[T2_PROBE] >= 1200 || ReefAngel.Params.Temp[T3_PROBE] >= 1200) {ReefAngel.Relay.On(Port7);}
if (ReefAngel.Params.Temp[T2_PROBE] < 1100 && ReefAngel.Params.Temp[T3_PROBE] < 1100) {ReefAngel.Relay.Off(Port7);}
if (ReefAngel.Params.Temp[T2_PROBE] >= 1300 || ReefAngel.Params.Temp[T3_PROBE] >= 1300) {ReefAngel.Relay.Off(Port1);}
if (ReefAngel.Params.Temp[T2_PROBE] >= 1300 || ReefAngel.Params.Temp[T3_PROBE] >= 1300) {ReefAngel.Relay.Off(Port2);}
ReefAngel.ShowInterface();
ReefAngel.Portal("d0lph1n","xxxxx");
}
byte PWMSlopeOvernight(byte startHour, byte startMinute, byte endHour, byte
endMinute, byte startPWM, byte endPWM, byte Duration, byte oldValue)
{
unsigned long Start = previousMidnight(now())+((unsigned long)NumMins(startHour, startMinute)*60);
if (hour()<startHour) Start-=86400;
unsigned long StartD = Start + (Duration*60);
unsigned long End = nextMidnight(now())+((unsigned long)NumMins(endHour, endMinute)*60);
if (hour()<startHour) End-=86400;
unsigned long StopD = End - (Duration*60);
if ( now() >= Start && now() <= StartD )
return constrain(map(now(), Start, StartD, startPWM, endPWM),startPWM,
endPWM);
else if ( now() >= StopD && now() <= End )
{
byte v = constrain(map(now(), StopD, End, startPWM, endPWM),startPWM,
endPWM);
return endPWM-v+startPWM;
}
else if ( now() > StartD && now() < StopD )
return endPWM;
return oldValue;
}
===
#include <ReefAngel_Features.h>
#include <Globals.h>
#include <Time.h>
#include <OneWire.h>
#include <RA_NokiaLCD.h>
#include <avr/pgmspace.h>
#include <InternalEEPROM.h>
#include <Wire.h>
#include <Memory.h>
RA_NokiaLCD e;
void setup()
{
e.Init();
e.Clear(COLOR_WHITE,0,0,132,132);
e.BacklightOn();
InternalMemory.FeedingTimer_write(900);
InternalMemory.LCDTimer_write(600);
InternalMemory.HeaterTempOn_write(765);
InternalMemory.HeaterTempOff_write(770);
InternalMemory.ChillerTempOn_write(785);
InternalMemory.ChillerTempOff_write(775);
InternalMemory.OverheatTemp_write(800);
InternalMemory.IMCheck_write(0xCF06A31E);
e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL+20, MENU_START_ROW*3, "Memory Updated");
e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL+25, MENU_START_ROW*6, "You can now");
e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL+25, MENU_START_ROW*7, "upload your");
e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL+33, MENU_START_ROW*8, "INO code");
}
void loop()
{
}
Re: Custom code, please help
You can take out the PWMSlopeOvernight now and just use PWMSlope which now supports overnight or normal mode
Re: Custom code, please help
Thanks for your suggestion. Where can I find more info about Overnight vs normal mode or can you help me re-write the code please?lnevo wrote:You can take out the PWMSlopeOvernight now and just use PWMSlope which now supports overnight or normal mode
Last edited by d0lph1n on Mon May 13, 2013 1:49 pm, edited 1 time in total.
Re: Custom code, please help
If the start time is greater than the end time, it will automatically work now.
If the start time is less than the end time it reverse to the old default behavior. Nothing for you to change except have the start and end time be what you want
If the start time is less than the end time it reverse to the old default behavior. Nothing for you to change except have the start and end time be what you want
Re: Custom code, please help
Please let me know if the code below is correct:
/* The following features are enabled for this File:
#define VersionMenu
#define DisplayLEDPWM
#define wifi
#define WDT
#define SIMPLE_MENU
*/
#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 <ReefAngel.h>
void setup()
{
ReefAngel.Init();
ReefAngel.FeedingModePorts = Port6Bit;
ReefAngel.FeedingModePortsE[0] = Port4Bit | Port5Bit | Port8Bit;
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port6Bit | Port8Bit;
ReefAngel.WaterChangePortsE[0] = Port1Bit | Port8Bit | Port4Bit | Port5Bit;
ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit;
ReefAngel.OverheatShutoffPortsE[0] = Port1Bit;
ReefAngel.Relay.On(Port6);
ReefAngel.Relay.On(Box1_Port1);
ReefAngel.Relay.On(Box1_Port3);
ReefAngel.Relay.On(Box1_Port4);
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
InternalMemory.OverheatTemp_write(795);
}
void loop()
{
ReefAngel.SingleATO(true,Box1_Port8,180,2);
ReefAngel.StandardFan(Box1_Port6,775,785);
ReefAngel.StandardHeater(Box1_Port1,765,770);
ReefAngel.DosingPumpRepeat(Box1_Port7,0,144,2);
ReefAngel.DosingPumpRepeat(Port8,1,144,2);
if (hour() >= 10 && hour() < 20)
{
ReefAngel.StandardLights(Port1,11,1,19,0);
ReefAngel.StandardLights(Port3,11,0,19,0);
ReefAngel.StandardLights(Port4,10,0,19,59);
ReefAngel.StandardLights(Port5,8,0,11,0);
ReefAngel.PWM.SetDaylight(PWMSlope(11,0,19,0,0,20,120,0));
ReefAngel.PWM.SetActinic(PWMSlope(10,0,19,59,0,20,180,0));
}
else
{
ReefAngel.StandardLights(Port2,21,1,5,0);
ReefAngel.StandardLights(Port3,20,0,6,0);
ReefAngel.StandardLights(Port4,21,0,5,0);
ReefAngel.StandardLights(Port5,19,0,22,0);
ReefAngel.PWM.SetDaylight(PWMSlope(20,0,6,0,0,20,180,0));
ReefAngel.PWM.SetActinic(PWMSlope(21,0,5,0,0,20,120,0));
}
if (ReefAngel.Params.Temp[T2_PROBE] >= 1200 || ReefAngel.Params.Temp[T3_PROBE] >= 1200) {ReefAngel.Relay.On(Port7);}
if (ReefAngel.Params.Temp[T2_PROBE] < 1100 && ReefAngel.Params.Temp[T3_PROBE] < 1100) {ReefAngel.Relay.Off(Port7);}
if (ReefAngel.Params.Temp[T2_PROBE] >= 1300 || ReefAngel.Params.Temp[T3_PROBE] >= 1300) {ReefAngel.Relay.Off(Port1);}
if (ReefAngel.Params.Temp[T2_PROBE] >= 1300 || ReefAngel.Params.Temp[T3_PROBE] >= 1300) {ReefAngel.Relay.Off(Port2);}
ReefAngel.ShowInterface();
ReefAngel.Portal("d0lph1n","xxxxx");
}
/* The following features are enabled for this File:
#define VersionMenu
#define DisplayLEDPWM
#define wifi
#define WDT
#define SIMPLE_MENU
*/
#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 <ReefAngel.h>
void setup()
{
ReefAngel.Init();
ReefAngel.FeedingModePorts = Port6Bit;
ReefAngel.FeedingModePortsE[0] = Port4Bit | Port5Bit | Port8Bit;
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port6Bit | Port8Bit;
ReefAngel.WaterChangePortsE[0] = Port1Bit | Port8Bit | Port4Bit | Port5Bit;
ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit;
ReefAngel.OverheatShutoffPortsE[0] = Port1Bit;
ReefAngel.Relay.On(Port6);
ReefAngel.Relay.On(Box1_Port1);
ReefAngel.Relay.On(Box1_Port3);
ReefAngel.Relay.On(Box1_Port4);
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
InternalMemory.OverheatTemp_write(795);
}
void loop()
{
ReefAngel.SingleATO(true,Box1_Port8,180,2);
ReefAngel.StandardFan(Box1_Port6,775,785);
ReefAngel.StandardHeater(Box1_Port1,765,770);
ReefAngel.DosingPumpRepeat(Box1_Port7,0,144,2);
ReefAngel.DosingPumpRepeat(Port8,1,144,2);
if (hour() >= 10 && hour() < 20)
{
ReefAngel.StandardLights(Port1,11,1,19,0);
ReefAngel.StandardLights(Port3,11,0,19,0);
ReefAngel.StandardLights(Port4,10,0,19,59);
ReefAngel.StandardLights(Port5,8,0,11,0);
ReefAngel.PWM.SetDaylight(PWMSlope(11,0,19,0,0,20,120,0));
ReefAngel.PWM.SetActinic(PWMSlope(10,0,19,59,0,20,180,0));
}
else
{
ReefAngel.StandardLights(Port2,21,1,5,0);
ReefAngel.StandardLights(Port3,20,0,6,0);
ReefAngel.StandardLights(Port4,21,0,5,0);
ReefAngel.StandardLights(Port5,19,0,22,0);
ReefAngel.PWM.SetDaylight(PWMSlope(20,0,6,0,0,20,180,0));
ReefAngel.PWM.SetActinic(PWMSlope(21,0,5,0,0,20,120,0));
}
if (ReefAngel.Params.Temp[T2_PROBE] >= 1200 || ReefAngel.Params.Temp[T3_PROBE] >= 1200) {ReefAngel.Relay.On(Port7);}
if (ReefAngel.Params.Temp[T2_PROBE] < 1100 && ReefAngel.Params.Temp[T3_PROBE] < 1100) {ReefAngel.Relay.Off(Port7);}
if (ReefAngel.Params.Temp[T2_PROBE] >= 1300 || ReefAngel.Params.Temp[T3_PROBE] >= 1300) {ReefAngel.Relay.Off(Port1);}
if (ReefAngel.Params.Temp[T2_PROBE] >= 1300 || ReefAngel.Params.Temp[T3_PROBE] >= 1300) {ReefAngel.Relay.Off(Port2);}
ReefAngel.ShowInterface();
ReefAngel.Portal("d0lph1n","xxxxx");
}
Re: Custom code, please help
I upgraded the RA 6.1 board to Plus 2.1 and I was able to upload the custom program but the LCD is blank (sometimes I see a white horizontal line but it works fine with the old board) and during upload of the memory program the compiler displays the following error:
"The following features were automatically added:
Watchdog Timer
Version Menu
===
The following features were detected:
Simple Menu
C:\Users\Alex\Documents\Arduino\libraries\RA_NokiaLCD\RA_NokiaLCD.cpp: In member function 'void RA_NokiaLCD::SendCMD(byte)':
C:\Users\Alex\Documents\Arduino\libraries\RA_NokiaLCD\RA_NokiaLCD.cpp:709: error: 'ReefAngel' was not declared in this scope"
===
It's using the latest RA libraries 1.1.0
Here is the internal memory:
#include <ReefAngel_Features.h>
#include <Globals.h>
#include <Time.h>
#include <OneWire.h>
#include <RA_NokiaLCD.h>
#include <avr/pgmspace.h>
#include <InternalEEPROM.h>
#include <Wire.h>
#include <Memory.h>
RA_NokiaLCD e;
void setup()
{
e.Init();
e.Clear(COLOR_WHITE,0,0,132,132);
e.BacklightOn();
InternalMemory.FeedingTimer_write(900);
InternalMemory.LCDTimer_write(600);
InternalMemory.HeaterTempOn_write(765);
InternalMemory.HeaterTempOff_write(770);
InternalMemory.ChillerTempOn_write(785);
InternalMemory.ChillerTempOff_write(775);
InternalMemory.OverheatTemp_write(800);
InternalMemory.IMCheck_write(0xCF06A31E);
e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL+20, MENU_START_ROW*3, "Memory Updated");
e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL+25, MENU_START_ROW*6, "You can now");
e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL+25, MENU_START_ROW*7, "upload your");
e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL+33, MENU_START_ROW*8, "INO code");
}
void loop()
{
}
===
Thank you
"The following features were automatically added:
Watchdog Timer
Version Menu
===
The following features were detected:
Simple Menu
C:\Users\Alex\Documents\Arduino\libraries\RA_NokiaLCD\RA_NokiaLCD.cpp: In member function 'void RA_NokiaLCD::SendCMD(byte)':
C:\Users\Alex\Documents\Arduino\libraries\RA_NokiaLCD\RA_NokiaLCD.cpp:709: error: 'ReefAngel' was not declared in this scope"
===
It's using the latest RA libraries 1.1.0
Here is the internal memory:
#include <ReefAngel_Features.h>
#include <Globals.h>
#include <Time.h>
#include <OneWire.h>
#include <RA_NokiaLCD.h>
#include <avr/pgmspace.h>
#include <InternalEEPROM.h>
#include <Wire.h>
#include <Memory.h>
RA_NokiaLCD e;
void setup()
{
e.Init();
e.Clear(COLOR_WHITE,0,0,132,132);
e.BacklightOn();
InternalMemory.FeedingTimer_write(900);
InternalMemory.LCDTimer_write(600);
InternalMemory.HeaterTempOn_write(765);
InternalMemory.HeaterTempOff_write(770);
InternalMemory.ChillerTempOn_write(785);
InternalMemory.ChillerTempOff_write(775);
InternalMemory.OverheatTemp_write(800);
InternalMemory.IMCheck_write(0xCF06A31E);
e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL+20, MENU_START_ROW*3, "Memory Updated");
e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL+25, MENU_START_ROW*6, "You can now");
e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL+25, MENU_START_ROW*7, "upload your");
e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL+33, MENU_START_ROW*8, "INO code");
}
void loop()
{
}
===
Thank you
Re: Custom code, please help
That is an old internal memory file.
Use this instead:
It will also configure the board for your old screen.
Use this instead:
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 <AI.h>
#include <RF.h>
#include <IO.h>
#include <ORP.h>
#include <Salinity.h>
#include <PH.h>
#include <WaterLevel.h>
#include <ReefAngel.h>
void setup()
{
InternalMemory.LCDID_write(255);
InternalMemory.FeedingTimer_write(900);
InternalMemory.LCDTimer_write(600);
InternalMemory.HeaterTempOn_write(765);
InternalMemory.HeaterTempOff_write(770);
InternalMemory.ChillerTempOn_write(785);
InternalMemory.ChillerTempOff_write(775);
InternalMemory.OverheatTemp_write(800);
InternalMemory.IMCheck_write(0xCF06A31E);
ReefAngel.Init();
ReefAngel.LCD.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL+20, MENU_START_ROW*3, "Memory Updated");
ReefAngel.LCD.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL+25, MENU_START_ROW*6, "You can now");
ReefAngel.LCD.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL+25, MENU_START_ROW*7, "upload your");
ReefAngel.LCD.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL+33, MENU_START_ROW*8, "INO code") ;
}
void loop()
{
wdt_reset();
}
Roberto.
Re: Custom code, please help
Thank you Roberto. It works great. I appreciate it
Re: Custom code, please help
For the past weeks i switched from dosing Ca & Alk to dosing Kalk + vinegar solution. Now that the Ph probe is working properly with the new RA plus board i'd like the ato sensor(s) to control the kalk + vinegar dosing pump instead of water if the ph is lower than lets say 8.1
This the current config:
ReefAngel.SingleATO(true,Box1_Port2,180,2);
ReefAngel.DosingPumpRepeat(Port8,1,120,4);
If the ph is smaller than 8.1 then ReefAngel.SingleATO(true,Port8,180,1) else ReefAngel.SingleATO(true,Box1_Port2,180,2);
Is this doable? What are the risks?
This the current config:
ReefAngel.SingleATO(true,Box1_Port2,180,2);
ReefAngel.DosingPumpRepeat(Port8,1,120,4);
If the ph is smaller than 8.1 then ReefAngel.SingleATO(true,Port8,180,1) else ReefAngel.SingleATO(true,Box1_Port2,180,2);
Is this doable? What are the risks?
Re: Custom code, please help
He wants to ato the vinegar+kalk when ph is less than 8.1 and ato ro/di otherwise
Re: Custom code, please help
Ahh... I don't think it would work though.
I think the port would never shut off if it was on and ph raised above 8.1
Try like this:
I think the port would never shut off if it was on and ph raised above 8.1
Try like this:
Code: Select all
if (ReefAngel.Params.PH <= 810)
{
ReefAngel.SingleATO(true,Port8,180,1);
ReefAngel.Relay.Off(Box1_Port2);
}
else
{
ReefAngel.SingleATO(true,Box1_Port2,180,2);
ReefAngel.Relay.Off(Port8);
}
Roberto.
Re: Custom code, please help
Right, Inevo. Perfect. Roberto. Thanks. I'll give it a try asap.
Maybe I'm over complicating things. Maybe I should stay with the classic dosing method.
Maybe I'm over complicating things. Maybe I should stay with the classic dosing method.
Re: Custom code, please help
It works but it needs more tweaking.
If pH <=818 & ATO ON then the ATO controls the Kalk pump but if during this process ph>818 and the ATO still on, it stops pumping kalk and it doesn' start pumping fresh water without manually resetting the ATO sensor On/OFF
This is the existing code:
if (ReefAngel.Params.PH <= 818)
{
ReefAngel.SingleATO(true,Box1_Port7,70,0);
ReefAngel.Relay.Off(Box1_Port8);
}
else
{
ReefAngel.SingleATO(true,Box1_Port8,120,0);
ReefAngel.Relay.Off(Box1_Port7);
}
I think we have to introduce another IF that checks the ATO status.
We have the following variables:
Ph <= 818
Single ATO status = On/Off
ATO pump port = Box1_Port8
Kalk pump port = Box1_Port7
If ph <= 818
then
check ATO Status
{If ATO ON then
ReefAngel.SingleATO(true,Box1_Port7,70,1); # ATO pumps kalk
ReefAngel.Relay.Off(Box1_Port8);
else
ReefAngel.Relay.On(Box1_Port7); #Kalk pump ON
ReefAngel.Relay.Off(Box1_Port8);
}
else
{
ReefAngel.SingleATO(true,Box1_Port8,120,1); # ATO pumps fresh water
ReefAngel.Relay.Off(Box1_Port7);
It needs a check ATO Status refresh at this point.
}
What do you think?
If pH <=818 & ATO ON then the ATO controls the Kalk pump but if during this process ph>818 and the ATO still on, it stops pumping kalk and it doesn' start pumping fresh water without manually resetting the ATO sensor On/OFF
This is the existing code:
if (ReefAngel.Params.PH <= 818)
{
ReefAngel.SingleATO(true,Box1_Port7,70,0);
ReefAngel.Relay.Off(Box1_Port8);
}
else
{
ReefAngel.SingleATO(true,Box1_Port8,120,0);
ReefAngel.Relay.Off(Box1_Port7);
}
I think we have to introduce another IF that checks the ATO status.
We have the following variables:
Ph <= 818
Single ATO status = On/Off
ATO pump port = Box1_Port8
Kalk pump port = Box1_Port7
If ph <= 818
then
check ATO Status
{If ATO ON then
ReefAngel.SingleATO(true,Box1_Port7,70,1); # ATO pumps kalk
ReefAngel.Relay.Off(Box1_Port8);
else
ReefAngel.Relay.On(Box1_Port7); #Kalk pump ON
ReefAngel.Relay.Off(Box1_Port8);
}
else
{
ReefAngel.SingleATO(true,Box1_Port8,120,1); # ATO pumps fresh water
ReefAngel.Relay.Off(Box1_Port7);
It needs a check ATO Status refresh at this point.
}
What do you think?
Re: Custom code, please help
I think it is your restriction on the single ato function.
ReefAngel.SingleATO(true,Box1_Port8,120,1);
The last 1 means it will have to wait another hour to pump again.
Try zero instead.
ReefAngel.SingleATO(true,Box1_Port8,120,1);
The last 1 means it will have to wait another hour to pump again.
Try zero instead.
Roberto.
Re: Custom code, please help
Anyway, lets disregard this idea for now. It doesn't make too much sense in practice.
What's the safest way to dose kalk via Box1_Port7 if the ph drops below 818 but I also need a time out and a waiting period similar to the ATO function?
I built this code for now, is it ok? It will dose kalk for 20 seconds every 10 min until pH goes above 818, I hope. For my 8-9 gal of water, a 20 sec dose of kalk + vinegar+water (2g+15ml+1l) will increase the pH by 0.01-0.02
if (ReefAngel.Params.PH <= 818){ReefAngel.DosingPumpRepeat(Box1_Port7,0,10,20);}
if (ReefAngel.Params.PH >= 820){ReefAngel.Relay.Off(Box1_Port7);}
if (ReefAngel.Params.PH < 800){ReefAngel.Relay.Off(Box1_Port7);} #if it runs out of kalk or if the pH probe is damaged
What's the safest way to dose kalk via Box1_Port7 if the ph drops below 818 but I also need a time out and a waiting period similar to the ATO function?
I built this code for now, is it ok? It will dose kalk for 20 seconds every 10 min until pH goes above 818, I hope. For my 8-9 gal of water, a 20 sec dose of kalk + vinegar+water (2g+15ml+1l) will increase the pH by 0.01-0.02
if (ReefAngel.Params.PH <= 818){ReefAngel.DosingPumpRepeat(Box1_Port7,0,10,20);}
if (ReefAngel.Params.PH >= 820){ReefAngel.Relay.Off(Box1_Port7);}
if (ReefAngel.Params.PH < 800){ReefAngel.Relay.Off(Box1_Port7);} #if it runs out of kalk or if the pH probe is damaged