New Reef Angel is Awesome
Posted: Thu Dec 20, 2012 12:55 am
I received my reef angel last week and I have started messing with coding some the last couple of days. I read a C++ tutorial but have no prior programming experience. Most of the code came from the forums but the tutorial helped to understand it. Thanks everyone for all the help you have provided without even talking to me yet
Anyway what i would like is somebody experienced to review my code. I have it controlling the tunzes for now since I cant really mess anything up in the tank with that but I'm scared to put everything on the controller until I have somebody look it over.
I want tunze control with a night mode which seems to be working
I want alk to dose on the hour between 11pm and 3pm the next day for ~1 minute
I dont know how big of a span I should give my heater does this look ok?
Ports are:
1 Heater
2 Cal Doser
3 Alk Doser
4 Return Pump
5 Right Tunze
6 Left Tunze
7 Actinic Leds
8 Mhs
Heres the code I'm using:
Anyway what i would like is somebody experienced to review my code. I have it controlling the tunzes for now since I cant really mess anything up in the tank with that but I'm scared to put everything on the controller until I have somebody look it over.
I want tunze control with a night mode which seems to be working
I want alk to dose on the hour between 11pm and 3pm the next day for ~1 minute
I dont know how big of a span I should give my heater does this look ok?
Ports are:
1 Heater
2 Cal Doser
3 Alk Doser
4 Return Pump
5 Right Tunze
6 Left Tunze
7 Actinic Leds
8 Mhs
Heres the code I'm using:
Code: Select all
#include <ReefAngel_Features.h>
#include <Globals.h>
#include <RA_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <InternalEEPROM.h>
#include <RA_NokiaLCD.h>
#include <RA_ATO.h>
#include <RA_Joystick.h>
#include <LED.h>
#include <RA_TempSensor.h>
#include <Relay.h>
#include <RA_PWM.h>
#include <Timer.h>
#include <Memory.h>
#include <InternalEEPROM.h>
#include <RA_Colors.h>
#include <RA_CustomColors.h>
#include <Salinity.h>
#include <RF.h>
#include <IO.h>
#include <ORP.h>
#include <AI.h>
#include <PH.h>
#include <WaterLevel.h>
#include <ReefAngel.h>
////// Place global variable code below here
////// Place global variable code above here
void setup()
{
// This must be the first line
ReefAngel.Init(); //Initialize controller
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = Port4Bit | Port6Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port4Bit | Port6Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port7Bit | Port8Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port1Bit | Port6Bit | Port8Bit;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Set the Overheat temperature setting
InternalMemory.OverheatTemp_write( 841 );
// Ports that are always on
ReefAngel.Relay.On( Port4 );
ReefAngel.Relay.On( Port5 );
ReefAngel.Relay.On( Port6 );
}
////// Place additional initialization code below here
////// Place additional initialization code above here
//Tunze short pulse functions
byte TunzeShortPulse(byte PulseMinSpeed, byte PulseMaxSpeed, int PulseDuration, boolean PulseSync)
{
byte tspeed=0;
PulseMinSpeed=constrain(PulseMinSpeed,0,100);
PulseMaxSpeed=constrain(PulseMaxSpeed,0,100);
tspeed=(millis()%(PulseDuration*2)<PulseDuration?PulseMinSpeed:PulseMaxSpeed);
if (PulseSync)
return tspeed;
else
return (tspeed==PulseMinSpeed)?PulseMaxSpeed:PulseMinSpeed;
}
void loop()
{
ReefAngel.StandardHeater( Port1,807,813 );
ReefAngel.StandardLights( Port2,19,0,19,17 );
ReefAngel.StandardLights( Port7,15,0,23,0 );
ReefAngel.StandardLights( Port8,16,0,22,0 );
//night mode for tunzes
if ( (hour() >=23) || (hour() <=12) )
{
ReefAngel.PWM.SetActinic( TunzeShortPulse(30,30,10,true) );
ReefAngel.PWM.SetDaylight( TunzeShortPulse(30,50,5,false) );
}
else
{
//day mode for tunzes
ReefAngel.PWM.SetActinic( TunzeShortPulse(30,50,2,true) );
ReefAngel.PWM.SetDaylight( TunzeShortPulse(30,90,2,false) );
}
//Night time alk dosing
if ( ((hour() >= 23) || (hour() <= 15)) &&
(minute() == 0) &&
(second() <= 59) )
{
ReefAngel.Relay.On(Port3);
}
else
{
ReefAngel.Relay.Off(Port3);
}
////// Place your custom code below here
////// Place your custom code above here
// This should always be the last line
ReefAngel.AddWifi();
ReefAngel.ShowInterface();
}