Page 4 of 5
Re: My Jebao "Else" mode
Posted: Thu Mar 27, 2014 5:38 pm
by howaboutme
Thank you!
I'm a bit confused as to where to put the code or if it replaces anything. I used the portal to create the initial code. It is below and I put the code you suggested in where I think you said it goes. But I get the feeling that I am suppose to replace the DCPump lines. With this code below, it also gave me an error " 'else mode' not declared in this scope." Does this go back to question #1, do I call this mode? If so, where?
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 <Humidity.h>
#include <DCPump.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
ReefAngel.Use2014Screen(); // Let's use 2014 Screen
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = Port1Bit | Port5Bit | Port6Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port5Bit | Port6Bit | Port7Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port3Bit | Port4Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port7Bit;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Feeeding and Water Change mode speed
ReefAngel.DCPump.FeedingSpeed=0;
ReefAngel.DCPump.WaterChangeSpeed=0;
// Ports that are always on
ReefAngel.Relay.On( Port2 );
ReefAngel.Relay.On( Port5 );
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.DayLights( Port3 );
ReefAngel.ActinicLights( Port4 );
ReefAngel.StandardHeater( Port7 );
ReefAngel.DCPump.UseMemory = true;
ReefAngel.DCPump.DaylightChannel = None;
ReefAngel.DCPump.ActinicChannel = Sync;
ReefAngel.PWM.SetActinic( ElseMode(37,7,true)); // ElseMode on sync mode, 37 +/- 7%
////// Place your custom code below here
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "howaboutme" );
ReefAngel.ShowInterface();
}
Thank you in advance.
Re: My Jebao "Else" mode
Posted: Thu Mar 27, 2014 7:22 pm
by cosmith71
Add the elsemode code to the very end of your code (after the last '}' ) and try it out. It's not built in to the libraries so you'll have to put it in yourself. If this doesn't work we may have to take out the DCPump stuff.
Here it is.
Code: Select all
byte ElseMode( byte MidPoint, byte Offset, boolean WaveSync )
{
// Static's only initialize the first time they are called
static unsigned long LastChange=millis(); // Set the inital time that the last change occurred
static int Delay = random( 500, 3000); // Set the initial delay
static int NewSpeed = MidPoint; // Set the initial speed
static int AntiSpeed = MidPoint; // Set the initial anti sync speed
if ((millis()-LastChange) > Delay) // Check if the delay has elapsed
{
Delay=random(500,5000); // If so, come up with a new delay
int ChangeUp = random(Offset); // Amount to go up or down
if (random(100)<50) // 50/50 chance of speed going up or going down
{
NewSpeed = MidPoint - ChangeUp;
AntiSpeed = MidPoint + ChangeUp;
}
else
{
NewSpeed = MidPoint + ChangeUp;
AntiSpeed = MidPoint - ChangeUp;
}
LastChange=millis(); // Reset the time of the last change
}
if (WaveSync)
{
return NewSpeed;
}
else
{
return AntiSpeed;
}
}
Re: My Jebao "Else" mode
Posted: Thu Mar 27, 2014 7:45 pm
by lnevo
Look at Sacohens thread. I wrote him a routine to do random functions each day and else mode is included. You will see how we disable the portal and use the custom mode. It also has night mode and post feeding mode defined.
Re: My Jebao "Else" mode
Posted: Fri Mar 28, 2014 7:24 am
by howaboutme
Thanks Cosmith for confirming that the Else mode is not in the libraries. Now I understand I have to define it by adding that code.
I am trying to go through Sacohen's code, almost as complex as Lee's
...Some questions:
1. What's the significance of his code being above the void loop and in a group with the other "DcPump" code as opposed to mine, which is below (or is it within?) the void loop?
Sacohen's code:
Code: Select all
ReefAngel.DCPump.ActinicChannel=Sync; // Now you're pump will be affected by the portal settings.
ReefAngel.DCPump.DaylightChannel=AntiSync; // Now you're pump will be affected by the portal settings.
My code:
Code: Select all
ReefAngel.DCPump.UseMemory = true;
ReefAngel.DCPump.DaylightChannel = None;
ReefAngel.DCPump.ActinicChannel = Sync;
ReefAngel.PWM.SetActinic( ElseMode(37,7,true)); // ElseMode on sync mode, 37 +/- 7%
2. Do I have this code in the right place?
Code: Select all
ReefAngel.PWM.SetActinic( ElseMode(37,7,true)); // ElseMode on sync mode, 37 +/- 7%
3. Does this mean that I can adjust in the portal? Which would only affect the modes that are not else mode since else mode is hard coded? (Follow up question below)
4. Does this code in Sacohen's code mean that when he sets his mode to "custom", it goes into the random mode that you (Lee) helped create? Does it also mean that Sacohen is able to switch to other modes (Reefcrest, constant, etc) in the portal if he so chooses? He won't because he has all of the modes already programed but could be helpful if I only want else mode but occasionally want to switch via portal to something else.
Code: Select all
Add random mode if we set to Mode to Custom in portal
static int rmode;
Thank you all.
Re: My Jebao "Else" mode
Posted: Fri Mar 28, 2014 7:39 am
by cosmith71
I am trying to go through Sacohen's code, almost as complex as Lee's
I think Lee had his paws on some of that code.
Post your code (all of it). That will help a lot.
--Colin
Re: My Jebao "Else" mode
Posted: Fri Mar 28, 2014 8:06 am
by howaboutme
Code is posted above. If you take out your
Code: Select all
ReefAngel.PWM.SetActinic( ElseMode(37,7,true)); // ElseMode on sync mode, 37 +/- 7%
, that will be the base code that was generated from the wizard of which I am starting from. Thanks.
Re: My Jebao "Else" mode
Posted: Fri Mar 28, 2014 3:07 pm
by lnevo
When ReefAngel.DCPump.UseMemory is true it will set the pumps automatically based on the memory settings that you save from the portal.
The reason you see those lines in setup() is because they are defining the behavior of those pumps sync/antisync/none.
What we did for Sacohen is when you pick Custom from the portal the code disables UseMemory and then we can manually set the mode on the channels. In your case you would then use the line you have above.
I'll try and post a sample you can use this weekend sometime.
Lee
Re: My Jebao "Else" mode
Posted: Fri Mar 28, 2014 6:16 pm
by howaboutme
Thanks Lee. I really appreciate it. I hate feeling lost but I am trying.
I played with the code a bit, mostly just copy pasting and seeing what would happen. The only difference for the 2 codes below is the location of
Code: Select all
ReefAngel.PWM.SetActinic( ElseMode(37,7,true)); // ElseMode on sync mode, 37 +/- 7%
Option 1:
In the void loop
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 <Humidity.h>
#include <DCPump.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
ReefAngel.Use2014Screen(); // Let's use 2014 Screen
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = Port1Bit | Port5Bit | Port6Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port5Bit | Port6Bit | Port7Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port3Bit | Port4Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port7Bit;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Feeeding and Water Change mode speed
ReefAngel.DCPump.FeedingSpeed=0;
ReefAngel.DCPump.WaterChangeSpeed=0;
// Ports that are always on
ReefAngel.Relay.On( Port2 );
ReefAngel.Relay.On( Port5 );
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.DayLights( Port3 );
ReefAngel.ActinicLights( Port4 );
ReefAngel.StandardHeater( Port7 );
ReefAngel.DCPump.UseMemory = true;
ReefAngel.DCPump.DaylightChannel = None;
ReefAngel.DCPump.ActinicChannel = Sync;
ReefAngel.PWM.SetActinic( ElseMode(37,7,true)); // ElseMode on sync mode, 37 +/- 7%
////// Place your custom code below here
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "howaboutme" );
ReefAngel.ShowInterface();
}
byte ElseMode( byte MidPoint, byte Offset, boolean WaveSync )
{
// Static's only initialize the first time they are called
static unsigned long LastChange=millis(); // Set the inital time that the last change occurred
static int Delay = random( 500, 3000); // Set the initial delay
static int NewSpeed = MidPoint; // Set the initial speed
static int AntiSpeed = MidPoint; // Set the initial anti sync speed
if ((millis()-LastChange) > Delay) // Check if the delay has elapsed
{
Delay=random(500,5000); // If so, come up with a new delay
int ChangeUp = random(Offset); // Amount to go up or down
if (random(100)<50) // 50/50 chance of speed going up or going down
{
NewSpeed = MidPoint - ChangeUp;
AntiSpeed = MidPoint + ChangeUp;
}
else
{
NewSpeed = MidPoint + ChangeUp;
AntiSpeed = MidPoint - ChangeUp;
}
LastChange=millis(); // Reset the time of the last change
}
if (WaveSync)
{
return NewSpeed;
}
else
{
return AntiSpeed;
}
}
Option 2:
In the setup
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 <Humidity.h>
#include <DCPump.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
ReefAngel.Use2014Screen(); // Let's use 2014 Screen
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = Port1Bit | Port5Bit | Port6Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port5Bit | Port6Bit | Port7Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port3Bit | Port4Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port7Bit;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Feeeding and Water Change mode speed
ReefAngel.DCPump.FeedingSpeed=0;
ReefAngel.DCPump.WaterChangeSpeed=0;
ReefAngel.PWM.SetActinic( ElseMode(37,7,true)); // ElseMode on sync mode, 37 +/- 7%
// Ports that are always on
ReefAngel.Relay.On( Port2 );
ReefAngel.Relay.On( Port5 );
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.DayLights( Port3 );
ReefAngel.ActinicLights( Port4 );
ReefAngel.StandardHeater( Port7 );
ReefAngel.DCPump.UseMemory = true;
ReefAngel.DCPump.DaylightChannel = None;
ReefAngel.DCPump.ActinicChannel = Sync;
////// Place your custom code below here
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "howaboutme" );
ReefAngel.ShowInterface();
}
byte ElseMode( byte MidPoint, byte Offset, boolean WaveSync )
{
// Static's only initialize the first time they are called
static unsigned long LastChange=millis(); // Set the inital time that the last change occurred
static int Delay = random( 500, 3000); // Set the initial delay
static int NewSpeed = MidPoint; // Set the initial speed
static int AntiSpeed = MidPoint; // Set the initial anti sync speed
if ((millis()-LastChange) > Delay) // Check if the delay has elapsed
{
Delay=random(500,5000); // If so, come up with a new delay
int ChangeUp = random(Offset); // Amount to go up or down
if (random(100)<50) // 50/50 chance of speed going up or going down
{
NewSpeed = MidPoint - ChangeUp;
AntiSpeed = MidPoint + ChangeUp;
}
else
{
NewSpeed = MidPoint + ChangeUp;
AntiSpeed = MidPoint - ChangeUp;
}
LastChange=millis(); // Reset the time of the last change
}
if (WaveSync)
{
return NewSpeed;
}
else
{
return AntiSpeed;
}
}
Both compiled and uploaded but it did not change the settings in the pump. It was still at the constant mode I have set it at.
Thanks again.
Re: My Jebao "Else" mode
Posted: Sat Mar 29, 2014 1:59 pm
by lnevo
This *should* work.
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 <Humidity.h>
#include <DCPump.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
ReefAngel.Use2014Screen(); // Let's use 2014 Screen
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = Port1Bit | Port5Bit | Port6Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port5Bit | Port6Bit | Port7Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port3Bit | Port4Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port7Bit;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Feeeding and Water Change mode speed
ReefAngel.DCPump.FeedingSpeed=0;
ReefAngel.DCPump.WaterChangeSpeed=0;
// Ports that are always on
ReefAngel.Relay.On( Port2 );
ReefAngel.Relay.On( Port5 );
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.DayLights( Port3 );
ReefAngel.ActinicLights( Port4 );
ReefAngel.StandardHeater( Port7 );
ReefAngel.DCPump.UseMemory = true;
ReefAngel.DCPump.DaylightChannel = None;
ReefAngel.DCPump.ActinicChannel = Sync;
////// Place your custom code below here
if (ReefAngel.DCPump.Mode==Custom) {
ReefAngel.PWM.SetActinic( ElseMode(ReefAngel.DCPump.Speed,ReefAngel.DCPump.Duration,true)); // ElseMode on sync mode, 37 +/- 7%
}
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "howaboutme" );
ReefAngel.ShowInterface();
}
byte ElseMode( byte MidPoint, byte Offset, boolean WaveSync )
{
// Static's only initialize the first time they are called
static unsigned long LastChange=millis(); // Set the inital time that the last change occurred
static int Delay = random( 500, 3000); // Set the initial delay
static int NewSpeed = MidPoint; // Set the initial speed
static int AntiSpeed = MidPoint; // Set the initial anti sync speed
if ((millis()-LastChange) > Delay) // Check if the delay has elapsed
{
Delay=random(500,5000); // If so, come up with a new delay
int ChangeUp = random(Offset); // Amount to go up or down
if (random(100)<50) // 50/50 chance of speed going up or going down
{
NewSpeed = MidPoint - ChangeUp;
AntiSpeed = MidPoint + ChangeUp;
}
else
{
NewSpeed = MidPoint + ChangeUp;
AntiSpeed = MidPoint - ChangeUp;
}
LastChange=millis(); // Reset the time of the last change
}
if (WaveSync)
{
return NewSpeed;
}
else
{
return AntiSpeed;
}
}
I took out the 37 and 7 from the ElseMode. It should respect the portal settings for Speed/Duration. We can change this behavior or you can replace it with hard coded values. You will need to elect Custom now in the portal and it should use Else mode now.
Re: My Jebao "Else" mode
Posted: Sat Mar 29, 2014 2:02 pm
by lnevo
Also... you don't want to put "running" code in the setup() function. This is stuff that is only set on boot time and nothing in setup() is run constantly. loop() is where things will happen on a regular basis. You should keep non-portal code unless specified in between the custom code comments in the loop function.
There are times where you will need to declare a global variable or add things in the setup, but we'll usually specify in that case. Once again, there is a designated area for global variables and "initialization code" labeled in the wizard generated code.
Re: My Jebao "Else" mode
Posted: Sat Mar 29, 2014 5:48 pm
by howaboutme
Lee, thank you!
So I uploaded the code. I "think" it's working. I'm trying to base whether or not its working by looking at the impeller but I guess my settings are so close together, it all looks the same.....a few questions.
You said you took out the 37 and 7 from the Else mode but I see it in the custom code section. You also said that I can define the speed in the portal, does that override the 37? The 7 is the percentage up and down for speed and since there isn't an option in the portal for setting that, is the 7 a constant and the variable would be the 37? I do understand that duration is overlooked because its not relevant for this mode.
and also just so I understand, if i want to hard code it what would need to happen and does that mean I will not be able to switch to other modes via the portal?
I really appreciate your time!
Re: My Jebao "Else" mode
Posted: Sat Mar 29, 2014 6:59 pm
by howaboutme
Another thing that's strange..I changed this code:
Code: Select all
if (ReefAngel.DCPump.Mode==Custom) {
ReefAngel.PWM.SetActinic( ElseMode(ReefAngel.DCPump.Speed,ReefAngel.DCPump.Duration,true)); // ElseMode on sync mode, 37 +/- 7%
To this:
Code: Select all
if (ReefAngel.DCPump.Mode==Custom) {
ReefAngel.PWM.SetActinic( ElseMode(ReefAngel.DCPump.Speed,ReefAngel.DCPump.Duration,true)); // ElseMode on sync mode, 35 +/- 5%
Because I want to start out slow and tweak as needed upwards. I assume that 35 means the median speed and 5 is the swing so the pump should run anywhere between 30 and 40% power? If this assumption is correct, then why does my actinic settings show it below 30% as well as above 40% as part of the else mode cycle? Shouldn't it be no lower than 30 and no higher than 40? I don't see anything else in the code that would overrule my assumption. The only thing I can think of is if the "duration" in the portal is making it this way (it's currently defaulted to 10)? But from past posts, I thought duration was ignored in else mode. Thoughts?
Thanks again.
Re: My Jebao "Else" mode
Posted: Sat Mar 29, 2014 7:02 pm
by lnevo
The 37 and 7 you see there are the comments left behind. I reused duration for the 7. So you can adjust it if you like. The best way to compare is go from constant mode to custom and see what happens.
Re: My Jebao "Else" mode
Posted: Sat Mar 29, 2014 7:10 pm
by howaboutme
Ah ok..so that line is just FYI.
So if I set my speed via the portal to 35. What will my speed variation be? That's what I am confused about. I want to know the low and high.
thank you.
Re: My Jebao "Else" mode
Posted: Sat Mar 29, 2014 7:38 pm
by lnevo
The duration will be the +/-
If you don't want it to be you can change it back to 7
Re: My Jebao
Posted: Sun Mar 30, 2014 5:02 am
by howaboutme
lnevo wrote:The duration will be the +/-
If you don't want it to be you can change it back to 7
So now I am even more confused.
If that line above is commented out (after "///") and the controller doesn't recognize it as code, how does changing the +/- do anything?
For this purposes, let's say I want the pump to fluctuate from 30% to 40% in else mode. What would I do to the code or portal settings?
Thanks for being patient.
Re: My Jebao "Else" mode
Posted: Sun Mar 30, 2014 5:30 am
by lnevo
35 for speed
5 for duration
I am reusing the duration field...double purpose
Re: My Jebao "Else" mode
Posted: Sun Mar 30, 2014 6:03 am
by howaboutme
Ah, I see it now.
This is the key part that sets that, right?
Code: Select all
ReefAngel.PWM.SetActinic( ElseMode(ReefAngel.DCPump.Speed,ReefAngel.DCPump.Duration,true))
The "true" means portal set?
Also..of interest..the pump went all night between 25 and 45 and the pump did not stop. Maybe the lowest setting CAN go below 30% consistently?
Re: My Jebao "Else" mode
Posted: Sun Mar 30, 2014 6:19 am
by lnevo
No the true defines sync or anti-sync
The ReefAngel.DCPump.Speed and ReefAngel.DCPump.Duration are the key. They are getting their values from internal memory because i did not disable ReefAngel.DCPump.UseMemory.
Those memory locations are set via the portal.
This is the exact reason why its easier to troubleshoot hard coded vs memory
Re: My Jebao "Else" mode
Posted: Sun Mar 30, 2014 9:50 am
by howaboutme
Ah...got it!
Really thank you. I am going to try to take a stab at putting a timer on the mode..will post a new thread for help shortly..haha.
Re: My Jebao "Else" mode
Posted: Sat Jun 07, 2014 9:06 pm
by iratefrizz
OK I just got my jebao wp-25 and my jebao cable and want to conrol it with the RA. I like the else mode. except its too strong for my tank i think. just kinda blows my feathers all over.
SO what I want to do is have this else mode on during the day 0600-2000 = 45% +/- 15
and else mode at night 2000 - 0600 = 35% +/- 5%
I have reefbreeders LEDs and they have their own controller so i do not have the lights on a schedule so i am not sure which dimming switch to plug the jebao into. or if it matters.
I have port 5 as my extra power head on during the day
and port 6 is where I will plug my jebao into.
here is my wizard drafted code.
I have not added in the else mode code yet cause i dont completely understand how the actinic / daylight section works or the schedule I want.
Thank you in advance
EDIT: I found some other threads with schedules in them and got them working. however I uploaded my code but both my dimming channels are at 0% right now even though it should be on else mode.
ideas?
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 <Humidity.h>
#include <DCPump.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
ReefAngel.Use2014Screen(); // Let's use 2014 Screen
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = Port1Bit | Port3Bit | Port5Bit | Port6Bit | Port7Bit | Port8Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port3Bit | Port7Bit | Port8Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port4Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port4Bit;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Set the Overheat temperature setting
InternalMemory.OverheatTemp_write( 869 );
// Feeeding and Water Change mode speed
ReefAngel.DCPump.FeedingSpeed=0;
ReefAngel.DCPump.WaterChangeSpeed=0;
// Ports that are always on
ReefAngel.Relay.On( Port1 );
ReefAngel.Relay.On( Port2 );
ReefAngel.Relay.On( Port6 );
ReefAngel.Relay.On( Port7 );
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.StandardHeater( Port3,771,775 );
ReefAngel.StandardLights( Port4,20,0,8,0 );
ReefAngel.Relay.Set( Port5, !ReefAngel.Relay.Status( Port4 ) );
ReefAngel.StandardFan( Port8,775,780 );
ReefAngel.DCPump.UseMemory = true;
ReefAngel.DCPump.SetMode( ShortPulse,40,30 );
ReefAngel.DCPump.DaylightChannel = None;
ReefAngel.DCPump.ActinicChannel = Sync;
////// Place your custom code below here
if (ReefAngel.DCPump.Mode==Custom)
{
if ( (now()%SECS_PER_DAY >= 28800) || (now()%SECS_PER_DAY<= 72000) ) //0800-2000
{
ReefAngel.PWM.SetActinic( ElseMode(45,15,true)); //
}
else if ( (now()%SECS_PER_DAY >= 72000) && (now()%SECS_PER_DAY<= 28800) )
{
ReefAngel.PWM.SetActinic( ElseMode(35,5,true)); // Else on sync mode, 36 +/- 6%
}
}
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "iratefrizz" );
ReefAngel.ShowInterface();
}
byte ElseMode( byte MidPoint, byte Offset, boolean WaveSync )
{
// Static's only initialize the first time they are called
static unsigned long LastChange=millis(); // Set the inital time that the last change occurred
static int Delay = random( 500, 3000); // Set the initial delay
static int NewSpeed = MidPoint; // Set the initial speed
static int AntiSpeed = MidPoint; // Set the initial anti sync speed
if ((millis()-LastChange) > Delay) // Check if the delay has elapsed
{
Delay=random(500,5000); // If so, come up with a new delay
int ChangeUp = random(Offset); // Amount to go up or down
if (random(100)<50) // 50/50 chance of speed going up or going down
{
NewSpeed = MidPoint - ChangeUp;
AntiSpeed = MidPoint + ChangeUp;
}
else
{
NewSpeed = MidPoint + ChangeUp;
AntiSpeed = MidPoint - ChangeUp;
}
LastChange=millis(); // Reset the time of the last change
}
if (WaveSync)
{
return NewSpeed;
}
else
{
return AntiSpeed;
}
}
Re: My Jebao "Else" mode
Posted: Sun Jun 08, 2014 6:03 am
by howaboutme
iratefrizz wrote:OK I just got my jebao wp-25 and my jebao cable and want to conrol it with the RA. I like the else mode. except its too strong for my tank i think. just kinda blows my feathers all over.
SO what I want to do is have this else mode on during the day 0600-2000 = 45% +/- 15
and else mode at night 2000 - 0600 = 35% +/- 5%
I have reefbreeders LEDs and they have their own controller so i do not have the lights on a schedule so i am not sure which dimming switch to plug the jebao into. or if it matters.
I have port 5 as my extra power head on during the day
and port 6 is where I will plug my jebao into.
here is my wizard drafted code.
I have not added in the else mode code yet cause i dont completely understand how the actinic / daylight section works or the schedule I want.
Thank you in advance
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 <Humidity.h>
#include <DCPump.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
ReefAngel.Use2014Screen(); // Let's use 2014 Screen
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = Port1Bit | Port3Bit | Port7Bit | Port6Bit | Port7Bit | Port8Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port3Bit | Port7Bit | Port8Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port4Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port4Bit | Port2Bit;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Set the Overheat temperature setting
InternalMemory.OverheatTemp_write( 869 );
// Feeeding and Water Change mode speed
ReefAngel.DCPump.FeedingSpeed=0;
ReefAngel.DCPump.WaterChangeSpeed=0;
// Ports that are always on
ReefAngel.Relay.On( Port1 );
ReefAngel.Relay.On( Port2 );
ReefAngel.Relay.On( Port6 );
ReefAngel.Relay.On( Port7 );
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.StandardHeater( Port3,771,775 );
ReefAngel.StandardLights( Port4,20,0,8,0 );
ReefAngel.StandardLights( Port5,8,0,20,0 );
ReefAngel.StandardFan( Port8,775,780 );
ReefAngel.DCPump.UseMemory = false;
ReefAngel.DCPump.SetMode( ShortPulse,50,10 );
ReefAngel.DCPump.DaylightChannel = Sync;
ReefAngel.DCPump.ActinicChannel = None;
////// Place your custom code below here
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "iratefrizz" );
ReefAngel.ShowInterface();
}
You don't have to plug your jebao into any of the outlets in the relay at all so you can save those for better use. Just plugging them into either the daylight (which is what your code says) or actinic is enough to control them. I have mine in the actinic just because it's where I plugged it in initially.
This may help you w/ the scheduling and the speed:
http://forum.reefangel.com/viewtopic.ph ... 5&start=30
See the complete code in my signature for reference too.
Re: My Jebao "Else" mode
Posted: Mon Jun 09, 2014 3:47 am
by iratefrizz
Jack,
Thank you for the reply. that is actually the thread that I pulled my jebao code from
should have given credit but I forgot. I might have missed something. but that is the code that Lee had posted for you towards the end... but with my time of day and using else mode isntead of steady.
I didn't think it needed to be plugged into the box but idk what else to plug in there lol. i have lights fuge light heater fan extra powerhead skimmer and return pump
Re: My Jebao "Else" mode
Posted: Mon Jun 09, 2014 5:22 am
by howaboutme
I see a couple of issues (and maybe Lee or Roberto can chime in).
First, I think you need to eliminate this line:
Code: Select all
ReefAngel.DCPump.SetMode( ShortPulse,40,30 );
You're giving the controller conflicting information. You want else mode, not short pulse.
Second, (this is the one I am not 100% sure on) is to have 2 different settings in else mode, you need to hard code it in. I only have 1 setting when in else mode so I can control that pump settings via the portal. I don't believe you can with your situation. This also means you can't control your else mode pumps via portal on the fly (which I assume is okay). You need to change this:
Code: Select all
ReefAngel.DCPump.UseMemory = true;
This this:
Code: Select all
ReefAngel.DCPump.UseMemory = false;
Changing that means that the controller will take the speed given to it via the code and not from the portal.
And eliminate this:
Code: Select all
if (ReefAngel.DCPump.Mode==Custom)
Lee/Roberto or anyone else, is there a better way to do what he wants w/o eliminating control via portal for other pump settings? Hopefully we can get some experts to chime in as I am far from one.
Re: My Jebao "Else" mode
Posted: Mon Jun 09, 2014 8:27 am
by cosmith71
I'm actually waaaay behind on this stuff. I took down the tank I had set up for Jaebo control and haven't implemented it on my new tank. It's on my list to do as soon as I can get an expansion hub, dimming module, and some Jaebo cables.
Try this. It completely eliminates portal control of the pumps but should do what you want.
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 <Humidity.h>
#include <DCPump.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
ReefAngel.Use2014Screen(); // Let's use 2014 Screen
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = Port1Bit | Port3Bit | Port5Bit | Port6Bit | Port7Bit | Port8Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port3Bit | Port7Bit | Port8Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port4Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port4Bit;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Set the Overheat temperature setting
InternalMemory.OverheatTemp_write( 869 );
// Feeeding and Water Change mode speed
ReefAngel.DCPump.FeedingSpeed=0;
ReefAngel.DCPump.WaterChangeSpeed=0;
// Ports that are always on
ReefAngel.Relay.On( Port1 );
ReefAngel.Relay.On( Port2 );
ReefAngel.Relay.On( Port6 );
ReefAngel.Relay.On( Port7 );
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.StandardHeater( Port3,771,775 );
ReefAngel.StandardLights( Port4,20,0,8,0 );
ReefAngel.Relay.Set( Port5, !ReefAngel.Relay.Status( Port4 ) );
ReefAngel.StandardFan( Port8,775,780 );
////// Place your custom code below here
if (hour() >= 8 && hour() < 20)
{
ReefAngel.PWM.SetActinic( ElseMode(45,15,true));
}
else
{
ReefAngel.PWM.SetActinic( ElseMode(35,5,true));
}
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "iratefrizz" );
ReefAngel.ShowInterface();
}
byte ElseMode( byte MidPoint, byte Offset, boolean WaveSync )
{
// Static's only initialize the first time they are called
static unsigned long LastChange=millis(); // Set the inital time that the last change occurred
static int Delay = random( 500, 3000); // Set the initial delay
static int NewSpeed = MidPoint; // Set the initial speed
static int AntiSpeed = MidPoint; // Set the initial anti sync speed
if ((millis()-LastChange) > Delay) // Check if the delay has elapsed
{
Delay=random(500,5000); // If so, come up with a new delay
int ChangeUp = random(Offset); // Amount to go up or down
if (random(100)<50) // 50/50 chance of speed going up or going down
{
NewSpeed = MidPoint - ChangeUp;
AntiSpeed = MidPoint + ChangeUp;
}
else
{
NewSpeed = MidPoint + ChangeUp;
AntiSpeed = MidPoint - ChangeUp;
}
LastChange=millis(); // Reset the time of the last change
}
if (WaveSync)
{
return NewSpeed;
}
else
{
return AntiSpeed;
}
}
Re: My Jebao "Else" mode
Posted: Mon Jun 09, 2014 12:48 pm
by lnevo
I'm not sure I follow the questions... sorry this is a long thread.
The code I gave Jack should have been good. It allows portal to work and have the custom else mode. Can you please elaborate and point me to the code and the issue.
Thanks,
Lee
Re: My Jebao "Else" mode
Posted: Mon Jun 09, 2014 1:32 pm
by howaboutme
Lee the issue I see is that he wants 2 different speed settings based on 2 time frame's in else mode. Cosmith's code I think will work but it will prevent him from using the portal to change pump wave patterns.
Re: My Jebao "Else" mode
Posted: Mon Jun 09, 2014 3:18 pm
by lnevo
That shouldnt be an issue if he uses your base code... Just need another time based if block inside the if CUSTOM mode.
Can you point me to the code again that was initially presented? Sorry for the lazy mode...
Re: My Jebao "Else" mode
Posted: Mon Jun 09, 2014 3:19 pm
by lnevo
That shouldnt be an issue if he uses your base code... Just need another time based if block inside the if CUSTOM mode.
Can you point me to the code again that was initially presented? Sorry for the lazy mode...
Re: My Jebao "Else" mode
Posted: Mon Jun 09, 2014 5:27 pm
by howaboutme
I believe this is his code:
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 <Humidity.h>
#include <DCPump.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
ReefAngel.Use2014Screen(); // Let's use 2014 Screen
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = Port1Bit | Port3Bit | Port7Bit | Port6Bit | Port7Bit | Port8Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port3Bit | Port7Bit | Port8Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port4Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port4Bit | Port2Bit;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Set the Overheat temperature setting
InternalMemory.OverheatTemp_write( 869 );
// Feeeding and Water Change mode speed
ReefAngel.DCPump.FeedingSpeed=0;
ReefAngel.DCPump.WaterChangeSpeed=0;
// Ports that are always on
ReefAngel.Relay.On( Port1 );
ReefAngel.Relay.On( Port2 );
ReefAngel.Relay.On( Port6 );
ReefAngel.Relay.On( Port7 );
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.StandardHeater( Port3,771,775 );
ReefAngel.StandardLights( Port4,20,0,8,0 );
ReefAngel.StandardLights( Port5,8,0,20,0 );
ReefAngel.StandardFan( Port8,775,780 );
ReefAngel.DCPump.UseMemory = false;
ReefAngel.DCPump.SetMode( ShortPulse,50,10 );
ReefAngel.DCPump.DaylightChannel = Sync;
ReefAngel.DCPump.ActinicChannel = None;
////// Place your custom code below here
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "iratefrizz" );
ReefAngel.ShowInterface();
}
I think this is leftover from the wizard probably and should be deleted:
Code: Select all
ReefAngel.DCPump.SetMode( ShortPulse,40,30 );
Maybe the above was the only issue?