multiple wave pattern
multiple wave pattern
OK so I inserted some wave pattern codes does this look right? I'm not sure if there needs to be something in the void setup or void loop section or not. If so can you help me with that? The Things I added or changed are in bold
#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 = 0;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port5Bit | Port6Bit | Port7Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = 0;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit | Port3Bit | Port5Bit;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Set the Overheat temperature setting
InternalMemory.OverheatTemp_write( 820 );
// Ports that are always on
ReefAngel.Relay.On( Port7 );
ReefAngel.Relay.On( Port8 );
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.StandardLights( Port1,9,0,22,0 );
ReefAngel.StandardLights( Port2,10,45,21,15 );
ReefAngel.StandardLights( Port3,11,15,20,45 );
ReefAngel.StandardLights( Port4,22,0,2,0 );
ReefAngel.StandardHeater( Port5,775,780 );
ReefAngel.Relay.DelayedOn( Port6,5 );
////// Place your custom code below here
////// Place your custom code above here
byte ReefCrestMode(byte WaveSpeed, byte WaveOffset, boolean PulseSync)
{ if (hour()>=10 && hour()<14)
static unsigned long lastwavemillis=millis();
static int newspeed=WaveSpeed;
if ((millis()-lastwavemillis) > 5000)
{
if (random(100)<50) newspeed--; else newspeed++;
newspeed=constrain(newspeed,WaveSpeed-WaveOffset,WaveSpeed+WaveOffset);
newspeed=constrain(newspeed,0,60);
lastwavemillis=millis();
}
if (PulseSync)
return newspeed;
else
return WaveSpeed-(newspeed-WaveSpeed);
}
else (hour()>=14:01 && hour()<22)
byte SineMode(byte PulseMinSpeed, byte PulseMaxSpeed, int PulseDuration, boolean PulseSync) {
double x,y;
x=double(now()%(PulseDuration));
x/=PulseDuration;
x*=2.0*PI;
if (!PulseSync) x+=PI; // shift the sine wave for the right pump
y=sin(x);// y is now between -1 and 1
y+=1.0; // y is now between 0 and 2
y/=2.0; // y is now between 0 and 1
// now compute the tunze speed
y*=double(PulseMaxSpeed-PulseMinSpeed);
y+=double(PulseMinSpeed);
y+=0.5; // for proper rounding
// y is now between PulseMinSpeed and PulseMaxSpeed, constrain for safety
return constrain(byte(y),25,60);
}
// This should always be the last line
ReefAngel.Portal( "saltygxp" );
ReefAngel.ShowInterface();
}
#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 = 0;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port5Bit | Port6Bit | Port7Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = 0;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit | Port3Bit | Port5Bit;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Set the Overheat temperature setting
InternalMemory.OverheatTemp_write( 820 );
// Ports that are always on
ReefAngel.Relay.On( Port7 );
ReefAngel.Relay.On( Port8 );
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.StandardLights( Port1,9,0,22,0 );
ReefAngel.StandardLights( Port2,10,45,21,15 );
ReefAngel.StandardLights( Port3,11,15,20,45 );
ReefAngel.StandardLights( Port4,22,0,2,0 );
ReefAngel.StandardHeater( Port5,775,780 );
ReefAngel.Relay.DelayedOn( Port6,5 );
////// Place your custom code below here
////// Place your custom code above here
byte ReefCrestMode(byte WaveSpeed, byte WaveOffset, boolean PulseSync)
{ if (hour()>=10 && hour()<14)
static unsigned long lastwavemillis=millis();
static int newspeed=WaveSpeed;
if ((millis()-lastwavemillis) > 5000)
{
if (random(100)<50) newspeed--; else newspeed++;
newspeed=constrain(newspeed,WaveSpeed-WaveOffset,WaveSpeed+WaveOffset);
newspeed=constrain(newspeed,0,60);
lastwavemillis=millis();
}
if (PulseSync)
return newspeed;
else
return WaveSpeed-(newspeed-WaveSpeed);
}
else (hour()>=14:01 && hour()<22)
byte SineMode(byte PulseMinSpeed, byte PulseMaxSpeed, int PulseDuration, boolean PulseSync) {
double x,y;
x=double(now()%(PulseDuration));
x/=PulseDuration;
x*=2.0*PI;
if (!PulseSync) x+=PI; // shift the sine wave for the right pump
y=sin(x);// y is now between -1 and 1
y+=1.0; // y is now between 0 and 2
y/=2.0; // y is now between 0 and 1
// now compute the tunze speed
y*=double(PulseMaxSpeed-PulseMinSpeed);
y+=double(PulseMinSpeed);
y+=0.5; // for proper rounding
// y is now between PulseMinSpeed and PulseMaxSpeed, constrain for safety
return constrain(byte(y),25,60);
}
// This should always be the last line
ReefAngel.Portal( "saltygxp" );
ReefAngel.ShowInterface();
}
multiple wave pattern
No...it doesnt work that way...
First off you cant have a function (ie ReefCrestMode() ) inside another function (ie loop() )
Also the wave modes are now part of the libraries. Also you have to set a port that you want to use with the result of your wavefunction...
So look up some of the examples that have been posted..there is a tutorial posted as well and try again..
Im sure someone can post something here as well but on my phone right now..
First off you cant have a function (ie ReefCrestMode() ) inside another function (ie loop() )
Also the wave modes are now part of the libraries. Also you have to set a port that you want to use with the result of your wavefunction...
So look up some of the examples that have been posted..there is a tutorial posted as well and try again..
Im sure someone can post something here as well but on my phone right now..
Re: multiple wave pattern
So.........After 3 hours of reading and doing the same thing wrong 100 times I figured it out lol. When you said the wave functions were part of the libraries I was thinking you were talking about the Sketch Book example codes. So now that I figured it out here is what I have come up with. I'm hoping what I have done is right lol.lnevo wrote:No...it doesnt work that way...
First off you cant have a function (ie ReefCrestMode() ) inside another function (ie loop() )
Also the wave modes are now part of the libraries. Also you have to set a port that you want to use with the result of your wavefunction...
So look up some of the examples that have been posted..there is a tutorial posted as well and try again..
Im sure someone can post something here as well but on my phone right now..
#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 = 0;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port6Bit | Port7Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = 0;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit | Port3Bit;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Ports that are always on
ReefAngel.Relay.On( Port6 );
ReefAngel.Relay.On( Port7 );
ReefAngel.Relay.On( Port8 );
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.ActinicLights( Port1 );
ReefAngel.DayLights( Port2 );
ReefAngel.DayLights( Port3 );
ReefAngel.MoonLights( Port4 );
ReefAngel.StandardHeater( Port5 );
////// Place your custom code below here
////// Place your custom code above here
if (hour()>=10,01 && hour()<12)
ReefAngel.PWM.SetDaylight( ReefCrestMode(50,20,true) ); // ReefCrest at 50% +/- 20% on sync mode
else if (hour()>=12,01 && hour()<12,11)
ReefAngel.PWM.SetDaylight( NutrientTransportMode(30,60,6000,true) );
else if (hour()>=12,12 && hour()<14,12)
ReefAngel.PWM.SetDaylight( ReefCrestMode(50,20,true) );
else if (hour()>=14,13 && hour()<18)
ReefAngel.PWM.SetDaylight( SineMode(20,45,30,true) );
else if (hour()>=18,01 && hour()<18,11)
ReefAngel.PWM.SetDaylight( NutrientTransportMode(30,60,6000,true) );
else if (hour()>=18,12 && hour()<22)
ReefAngel.PWM.SetDaylight(SineMode(20,45,30,true) );
else if (hour()>=22,01 && hour ()<10)
ReefAngel.PWM.SetDaylight( LongPulseMode(15,35,120,true) );
// This should always be the last line
ReefAngel.Portal( "saltygxp" );
ReefAngel.ShowInterface();
}
multiple wave pattern
Better. But your if statements are wrong. You can't have hour()>=18,01 like that..you'd have to do hour() && minute() comparison...
Re: multiple wave pattern
OK so I'm pretty sure this isn't what you are talking about. can you give me an example please. I searched and cant find anything or i missed it. thanks very much for your help Inevo.lnevo wrote:Better. But your if statements are wrong. You can't have hour()>=18,01 like that..you'd have to do hour() && minute() comparison...
if (hour()>=10 && minute()<01) && hour()<12)
multiple wave pattern
You don't even need the minute in that statement...SaltyGXP wrote:OK so I'm pretty sure this isn't what you are talking about. can you give me an example please. I searched and cant find anything or i missed it. thanks very much for your help Inevo.lnevo wrote:Better. But your if statements are wrong. You can't have hour()>=18,01 like that..you'd have to do hour() && minute() comparison...
if (hour()>=10 && minute()<01) && hour()<12)
if (hour()>=10) && hour()<12)
That will run from 10:00-11:59
Re: multiple wave pattern
lnevo wrote:You don't even need the minute in that statement...SaltyGXP wrote:OK so I'm pretty sure this isn't what you are talking about. can you give me an example please. I searched and cant find anything or i missed it. thanks very much for your help Inevo.lnevo wrote:Better. But your if statements are wrong. You can't have hour()>=18,01 like that..you'd have to do hour() && minute() comparison...
if (hour()>=10 && minute()<01) && hour()<12)
if (hour()>=10) && hour()<12)
That will run from 10:00-11:59
The reason I was using minutes in there is because I only want NutrientTransportMode to run for 10 minutes at a time.
Re: multiple wave pattern
Use like this then:
I think this would do 10:00 to 10:10 and 11:00 to 11:10
Is it what you wanted?
Code: Select all
if (hour()>=10) && hour()<12 && minute()<=10)
Is it what you wanted?
Roberto.
Re: multiple wave pattern
Just a heads up too....
NTM is a mode that takes about 2.5 hours to complete.
The first 45min, it is nothing more than short pulses.
So, 10 minutes of NTM is not going to give you any more than short pulses
NTM is a mode that takes about 2.5 hours to complete.
The first 45min, it is nothing more than short pulses.
So, 10 minutes of NTM is not going to give you any more than short pulses
Roberto.
Re: multiple wave pattern
rimai wrote:Just a heads up too....
NTM is a mode that takes about 2.5 hours to complete.
The first 45min, it is nothing more than short pulses.
So, 10 minutes of NTM is not going to give you any more than short pulses
I didn't know that lol.....I'll change it then
Re: multiple wave pattern
Ok so heres what Ive got. I added Port 8 to the feed mode aswell so the jebao will shut down during feedings.
#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 = Port8Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port6Bit | Port7Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = 0;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit | Port3Bit;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Ports that are always on
ReefAngel.Relay.On( Port6 );
ReefAngel.Relay.On( Port7 );
ReefAngel.Relay.On( Port8 );
////// Place additional initialization code below here
ReefAngel.Relay.DelayedOn( Port6,5 );
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.ActinicLights( Port1 );
ReefAngel.DayLights( Port2 );
ReefAngel.DayLights( Port3 );
ReefAngel.MoonLights( Port4 );
ReefAngel.StandardHeater( Port5 );
////// Place your custom code below here
////// Place your custom code above here
if (hour()>=10 && hour()<16)
ReefAngel.PWM.SetDaylight( ReefCrestMode(50,20,true) ); // ReefCrest at 50% +/- 20% on sync mode
else if (hour()>=16 && hour()<19)
ReefAngel.PWM.SetDaylight( NutrientTransportMode(30,60,5000,true) );
else if (hour()>=19 && hour()<22)
ReefAngel.PWM.SetDaylight( SineMode(20,45,30,true) );
else if (hour()>=22 && hour()<10)
ReefAngel.PWM.SetDaylight( LongPulseMode(15,35,120,true) );
// This should always be the last line
ReefAngel.Portal( "saltygxp" );
ReefAngel.ShowInterface();
}
#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 = Port8Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port6Bit | Port7Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = 0;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit | Port3Bit;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Ports that are always on
ReefAngel.Relay.On( Port6 );
ReefAngel.Relay.On( Port7 );
ReefAngel.Relay.On( Port8 );
////// Place additional initialization code below here
ReefAngel.Relay.DelayedOn( Port6,5 );
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.ActinicLights( Port1 );
ReefAngel.DayLights( Port2 );
ReefAngel.DayLights( Port3 );
ReefAngel.MoonLights( Port4 );
ReefAngel.StandardHeater( Port5 );
////// Place your custom code below here
////// Place your custom code above here
if (hour()>=10 && hour()<16)
ReefAngel.PWM.SetDaylight( ReefCrestMode(50,20,true) ); // ReefCrest at 50% +/- 20% on sync mode
else if (hour()>=16 && hour()<19)
ReefAngel.PWM.SetDaylight( NutrientTransportMode(30,60,5000,true) );
else if (hour()>=19 && hour()<22)
ReefAngel.PWM.SetDaylight( SineMode(20,45,30,true) );
else if (hour()>=22 && hour()<10)
ReefAngel.PWM.SetDaylight( LongPulseMode(15,35,120,true) );
// This should always be the last line
ReefAngel.Portal( "saltygxp" );
ReefAngel.ShowInterface();
}
Re: multiple wave pattern
This one wont' ever work...
else if (hour()>=22 && hour()<10)
You can't have the hour be greater than 22 AND less than 10... Change the && to || for an OR.
else if (hour()>=22 && hour()<10)
You can't have the hour be greater than 22 AND less than 10... Change the && to || for an OR.
Re: multiple wave pattern
Your other option instead of changing the statement is to just remove it so that your last IF test is just an else... this way it becomes the default if none of your other tests qualify.
Re: multiple wave pattern
lnevo wrote:Your other option instead of changing the statement is to just remove it so that your last IF test is just an else... this way it becomes the default if none of your other tests qualify.
so like this?
void loop()
{
ReefAngel.ActinicLights( Port1 );
ReefAngel.DayLights( Port2 );
ReefAngel.DayLights( Port3 );
ReefAngel.MoonLights( Port4 );
ReefAngel.StandardHeater( Port5 );
////// Place your custom code below here
////// Place your custom code above here
if (hour()>=10 && hour()<16)
ReefAngel.PWM.SetDaylight( ReefCrestMode(50,20,true) ); // ReefCrest at 50% +/- 20% on sync mode
else if (hour()>=16 && hour()<19)
ReefAngel.PWM.SetDaylight( NutrientTransportMode(30,60,5000,true) );
else if (hour()>=19 && hour()<22)
ReefAngel.PWM.SetDaylight( SineMode(20,45,30,true) );
else
ReefAngel.PWM.SetDaylight( LongPulseMode(15,35,120,true) );
// This should always be the last line
ReefAngel.Portal( "saltygxp" );
ReefAngel.ShowInterface();
}
Re: multiple wave pattern
I can't thank you enough for all your help and fast reply's thanks so much.lnevo wrote:Looks good!!!
Re: multiple wave pattern
Thanks for this thread it opened up A little more what I need to know to do what I need to do with my jebaos. Can you break down what exactly the code you wrote is doing at what times so I can get a better idea of what to do in my situation thanks.
For night mode can I just add a constant mode with speed low for lights off hours?
For night mode can I just add a constant mode with speed low for lights off hours?
My other hobby has 450rwhp and eats tires instead of mysis!
Re: multiple wave pattern
// this will allow reefcrest to run from 10-4dapg8gt wrote:Thanks for this thread it opened up A little more what I need to know to do what I need to do with my jebaos. Can you break down what exactly the code you wrote is doing at what times so I can get a better idea of what to do in my situation thanks.
For night mode can I just add a constant mode with speed low for lights off hours?
if (hour()>=10 && hour()<16)
ReefAngel.PWM.SetDaylight( ReefCrestMode(50,20,true) ); // ReefCrest at 50% +/- 20% on sync mode
// here it's going to run NTP from 4-7 it takes two hrs to complet NTP
else if (hour()>=16 && hour()<19)
ReefAngel.PWM.SetDaylight( NutrientTransportMode(30,60,5000,true) );
// it will run Sine for the last 3hr of my lighting period
else if (hour()>=19 && hour()<22)
ReefAngel.PWM.SetDaylight( SineMode(20,45,30,true) );
// here it will run a lower sine mode until the lights turn back on. There is no time need because I used Else
ReefAngel.PWM.SetDaylight(SineMode(15,30,120,true) );