Everything I've tried that involves the wavemaker or the random() function causes me to run into "Sketch too big". I ran a simple setup before.
So I wanted to ask if anyone had an elegant solution for something I've settled on:
I want to run two pumps.
Day time:
Both randomized on their own timers, to be on for random X minutes, and then OFF for random Y minutes.
The pumps will run on timers independently by themselves.
At night:
One pump will be ON for two hours, the other OFF for two hours, and switches back and forth this way. No randomization needed.
Two pumps, randomized
-
rimai
- Posts: 12857
- Joined: Fri Mar 18, 2011 6:47 pm
-
neuro
- Posts: 50
- Joined: Mon Nov 19, 2012 9:22 pm
Re: Two pumps, randomized
robert,
The following code is what i currently have. it doesn't have any of the randomized wavemaker()/random() functions I was playing around with. Can you see anything I should (or should not) be doing?
The following code is what i currently have. it doesn't have any of the randomized wavemaker()/random() functions I was playing around with. Can you see anything I should (or should not) be doing?
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>
/*
// ports by name
#define halide 1
#define actinics 2
#define mainPump 3
#define skimmer 4
#define pump1 5
#define pump2 6
#define doser1 7
#define doser2 8
#define ato Box1_Port1
#define gfo Box1_Port2
#define unused3 Box1_Port3
#define unused4 Box1_Port4
#define pump3 Box1_Port5
#define pump4 Box1_Port6
#define heater1 Box1_Port7
#define heater2 Box1_Port8
*/
#define halide 1
#define actinics 2
#define unused3 3
#define unused4 4
#define pump1 5
#define pump4 6
#define doser1 7
#define doser2 8
#define ato Box1_Port1
#define heater1 Box1_Port2
#define skimmer Box1_Port3
#define heater2 Box1_Port4
#define pump2 Box1_Port5
#define pump3 Box1_Port6
#define gfo Box1_Port7
#define mainPump Box1_Port8
////// 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
// mainPump, skimmer, pump1, pump2, pump3, pump4, ato, gfo
ReefAngel.FeedingModePorts = Port5Bit | Port6Bit;
ReefAngel.FeedingModePortsE[0] = Port1Bit | Port3Bit | Port5Bit | Port6Bit | Port7Bit | Port8Bit;
// Ports toggled in Water Change Mode
// mainPump, Skimmer, all 4 pumps, all 2 dosers, ato, gfo
ReefAngel.WaterChangePorts = Port5Bit | Port6Bit | Port7Bit | Port8Bit;
ReefAngel.WaterChangePortsE[0] = Port1Bit | Port3Bit | Port5Bit | Port6Bit | Port7Bit | Port8Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port1Bit | Port2Bit;
ReefAngel.LightsOnPortsE[0] = 0;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit | Port4Bit;
ReefAngel.OverheatShutoffPortsE[0] = Port2Bit;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Ports that are always on
ReefAngel.Relay.On( mainPump );
ReefAngel.Relay.On( skimmer );
ReefAngel.Relay.Off( pump1 );
ReefAngel.Relay.Off( pump2 );
ReefAngel.Relay.Off( pump3 );
ReefAngel.Relay.Off( pump4 );
ReefAngel.Relay.On( gfo );
ReefAngel.Relay.Off( unused3 );
ReefAngel.Relay.Off( unused4 );
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.DayLights( halide );
ReefAngel.ActinicLights( actinics );
ReefAngel.DosingPumpRepeat1( doser1 );
ReefAngel.DosingPumpRepeat2( doser2 );
ReefAngel.StandardATO( ato );
ReefAngel.StandardHeater( heater1 );
ReefAngel.StandardHeater( heater2 );
ReefAngel.PWM.DaylightPWMParabola();
ReefAngel.PWM.ActinicPWMParabola();
////// Place your custom code below here
ReefAngel.Relay.DelayedOn( skimmer );
ReefAngel.Relay.DelayedOn( gfo );
static byte dayPumpMask = 5; // 0101
static byte nightPumpMask = 8; // 1000
static unsigned long cycleInterval = now();
int cycle = cycleInterval-now();
if ((hour() > 8) && (hour() < 21)) //from 8pm-9am
{
pumpSet(dayPumpMask);
if (cycle < 0)
{
cycleInterval += 1800; // every half hour
dayPumpMask = (dayPumpMask >> 1) | (dayPumpMask << 3); // Rotate right
}
}
else
//if ((hour() >= 21) || (hour() <= 8)) //from 9p-8a
{
pumpSet(nightPumpMask);
if (cycle < 0)
{
cycleInterval += 7200; // every 2 hours
nightPumpMask = (nightPumpMask >> 1) | (nightPumpMask << 3); // Rotate right
}
}
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "neuro" );
ReefAngel.ShowInterface();
}
void DrawCustomMain()
{
int x,y;
char text[10];
// Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 62, ReefAngel.Params,
ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 62, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
pingSerial();
// Main Relay Box
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox( 12, 93, TempRelay );
pingSerial();
// Relay Expansion
TempRelay = ReefAngel.Relay.RelayDataE[0];
TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
ReefAngel.LCD.DrawOutletBox( 12, 107, TempRelay );
pingSerial();
// Date and Time
ReefAngel.LCD.DrawDate( 6, 122 );
pingSerial();
}
void DrawCustomGraph()
{
ReefAngel.LCD.DrawGraph( 5, 5 );
}
void pumpSet(byte pumpMask)
{
ReefAngel.Relay.Set(pump1, pumpMask & 8); // 1000
ReefAngel.Relay.Set(pump2, pumpMask & 4); // 0100
ReefAngel.Relay.Set(pump3, pumpMask & 2); // 0010
ReefAngel.Relay.Set(pump4, pumpMask & 1); // 0001
}
-
rimai
- Posts: 12857
- Joined: Fri Mar 18, 2011 6:47 pm
Re: Two pumps, randomized
Yeah 
You are just using up all the memory.
I would recommend an upgrade.
The other thing you can try is using hard coded settings, which should bring it down a little.
You are just using up all the memory.
I would recommend an upgrade.
The other thing you can try is using hard coded settings, which should bring it down a little.
Roberto.
-
neuro
- Posts: 50
- Joined: Mon Nov 19, 2012 9:22 pm
Re: Two pumps, randomized
thanks robert, how much more memory would i be getting?
-
rimai
- Posts: 12857
- Joined: Fri Mar 18, 2011 6:47 pm
-
neuro
- Posts: 50
- Joined: Mon Nov 19, 2012 9:22 pm
Re: Two pumps, randomized
thanks robert, i'll consider it