Custom code, please help

Do you have a question on how to do something.
Ask in here.
d0lph1n
Posts: 121
Joined: Tue Dec 06, 2011 10:16 am

Re: Custom code, please help

Post by d0lph1n »

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;
}
Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Custom code, please help

Post by rimai »

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.
Roberto.
d0lph1n
Posts: 121
Joined: Tue Dec 06, 2011 10:16 am

Re: Custom code, please help

Post by d0lph1n »

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
Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Custom code, please help

Post by rimai »

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.
Roberto.
d0lph1n
Posts: 121
Joined: Tue Dec 06, 2011 10:16 am

Re: Custom code, please help

Post by d0lph1n »

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;
}
Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Custom code, please help

Post by rimai »

You don't need to upload memory settings anymore, so just forget about it.
Your code will be a little tricky to reduce.
Roberto.
d0lph1n
Posts: 121
Joined: Tue Dec 06, 2011 10:16 am

Re: Custom code, please help

Post by d0lph1n »

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;
}
Image
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: Custom code, please help

Post by lnevo »

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.
d0lph1n
Posts: 121
Joined: Tue Dec 06, 2011 10:16 am

Re: Custom code, please help

Post by d0lph1n »

Thanks a lot.
Image
d0lph1n
Posts: 121
Joined: Tue Dec 06, 2011 10:16 am

Re: Custom code, please help

Post by d0lph1n »

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;
}
Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Custom code, please help

Post by rimai »

Code: Select all

ReefAngel.SingleATO(true,Box1_Port8,180,2);
This code only enables the ATO to work once every 2 hours. even if it works for only half a second, it would only allow to pump again after 2 hours.
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.
d0lph1n
Posts: 121
Joined: Tue Dec 06, 2011 10:16 am

Re: Custom code, please help

Post by d0lph1n »

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?
Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Custom code, please help

Post by rimai »

That's the 180 in that function.
Here is a reference of that function:
http://www.easte.net/RA/html/class_reef ... 545a376e92
Roberto.
d0lph1n
Posts: 121
Joined: Tue Dec 06, 2011 10:16 am

Re: Custom code, please help

Post by d0lph1n »

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()
{
}
Image
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: Custom code, please help

Post by lnevo »

You can take out the PWMSlopeOvernight now and just use PWMSlope which now supports overnight or normal mode :)
d0lph1n
Posts: 121
Joined: Tue Dec 06, 2011 10:16 am

Re: Custom code, please help

Post by d0lph1n »

lnevo wrote:You can take out the PWMSlopeOvernight now and just use PWMSlope which now supports overnight or normal mode :)
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?
Last edited by d0lph1n on Mon May 13, 2013 1:49 pm, edited 1 time in total.
Image
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: Custom code, please help

Post by lnevo »

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 :)
d0lph1n
Posts: 121
Joined: Tue Dec 06, 2011 10:16 am

Re: Custom code, please help

Post by d0lph1n »

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");
}
Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Custom code, please help

Post by rimai »

Looks good :)
Roberto.
d0lph1n
Posts: 121
Joined: Tue Dec 06, 2011 10:16 am

Re: Custom code, please help

Post by d0lph1n »

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
Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Custom code, please help

Post by rimai »

That is an old internal memory file.
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();
}

It will also configure the board for your old screen.
Roberto.
d0lph1n
Posts: 121
Joined: Tue Dec 06, 2011 10:16 am

Re: Custom code, please help

Post by d0lph1n »

Thank you Roberto. It works great. I appreciate it
Image
d0lph1n
Posts: 121
Joined: Tue Dec 06, 2011 10:16 am

Re: Custom code, please help

Post by d0lph1n »

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?
Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Custom code, please help

Post by rimai »

Not sure what you are trying to do... :(
Roberto.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: Custom code, please help

Post by lnevo »

He wants to ato the vinegar+kalk when ph is less than 8.1 and ato ro/di otherwise
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Custom code, please help

Post by rimai »

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:

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.
d0lph1n
Posts: 121
Joined: Tue Dec 06, 2011 10:16 am

Re: Custom code, please help

Post by d0lph1n »

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.
Image
d0lph1n
Posts: 121
Joined: Tue Dec 06, 2011 10:16 am

Re: Custom code, please help

Post by d0lph1n »

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?
Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Custom code, please help

Post by rimai »

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.
Roberto.
d0lph1n
Posts: 121
Joined: Tue Dec 06, 2011 10:16 am

Re: Custom code, please help

Post by d0lph1n »

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
Image
Post Reply