ReefCrest for Tunze

Do you have a question on how to do something.
Ask in here.
Post Reply
jayclaire
Posts: 24
Joined: Tue Jan 29, 2013 11:15 am

ReefCrest for Tunze

Post by jayclaire »

Hi,

Can u please help me code my pair of Tunzes to run on ReefCrest mode anti-sync?

Thanks,
~JaY
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: ReefCrest for Tunze

Post by rimai »

Roberto.
VSpeck
Posts: 13
Joined: Thu Dec 20, 2012 12:35 am

Re: ReefCrest for Tunze

Post by VSpeck »

i saw that topic and used the code and i like it but how do i set the min speed at 30 as you arent supposed to go under that on the tunzes. I would like the max at 80 and the min at 30
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

ReefCrest for Tunze

Post by lnevo »

Th range in that code is +/- 20 so if you set the speed at 55, you'll have a range of 75-35. If you want to increase the range to 25 which would give you 30-80, you'll need to change the s-20,s+20 line to 25's
VSpeck
Posts: 13
Joined: Thu Dec 20, 2012 12:35 am

ReefCrest for Tunze

Post by VSpeck »

lnevo wrote:Th range in that code is +/- 20 so if you set the speed at 55, you'll have a range of 75-35. If you want to increase the range to 25 which would give you 30-80, you'll need to change the s-20,s+20 line to 25's
Awesome I figured it was something simple like that. I'm still trying to get a grasp on all the coding but with the help of the board my coding is working great for me.
jayclaire
Posts: 24
Joined: Tue Jan 29, 2013 11:15 am

Re: ReefCrest for Tunze

Post by jayclaire »


Will the code work for 2 tunzes anyti-sync mode?

byte ReefCrestMode(byte s)
{
static unsigned long lastmillis=millis();
static int newspeed=s;
if ((millis()-lastmillis) > 5000)
{
int delta;
delta=random(20);
if (delta<10) newspeed--; else newspeed++;
newspeed=constrain(newspeed,s-20,s+20);
newspeed=constrain(newspeed,0,100);
lastmillis=millis();
}
return newspeed;
}
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: ReefCrest for Tunze

Post by rimai »

No :(
But we recode it to do :)
Roberto.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: ReefCrest for Tunze

Post by rimai »

Try this:

Code: Select all

byte ReefCrestMode(byte s, boolean sync)
{
  static unsigned long lastmillis=millis();
  static int newspeed=s;
  if ((millis()-lastmillis) > 5000)
  {
    int delta;
    delta=random(20);
    if (delta<10) newspeed--; else newspeed++;
    newspeed=constrain(newspeed,s-20,s+20);
    newspeed=constrain(newspeed,0,100);
    lastmillis=millis();
  }  
  if (sync)
    return newspeed;
  else
    return s-(newspeed-s);
}
Roberto.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

ReefCrest for Tunze

Post by lnevo »

Roberto making my day twice in a row!!!
jayclaire
Posts: 24
Joined: Tue Jan 29, 2013 11:15 am

Re: ReefCrest for Tunze

Post by jayclaire »

Will do - Thanks once again Roberto.
VSpeck
Posts: 13
Joined: Thu Dec 20, 2012 12:35 am

ReefCrest for Tunze

Post by VSpeck »

Awesome I was wondering this as well.
jayclaire
Posts: 24
Joined: Tue Jan 29, 2013 11:15 am

Re: ReefCrest for Tunze

Post by jayclaire »

Here's my current code - Where should I put the new code?
#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;
ReefAngel.FeedingModePortsE[0] = 0;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port8Bit;
ReefAngel.WaterChangePortsE[0] = Port7Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = 0;
ReefAngel.LightsOnPortsE[0] = 0;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port2Bit | Port7Bit;
ReefAngel.OverheatShutoffPortsE[0] = Port7Bit;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;


// Ports that are always on
ReefAngel.Relay.On( Port2 );
ReefAngel.Relay.On( Port8 );

////// Place additional initialization code below here


////// Place additional initialization code above here
}

void loop()
{
ReefAngel.StandardATO( Port1 );
ReefAngel.MoonLights( Port3 );
ReefAngel.Wavemaker1( Port5 );
ReefAngel.Wavemaker1( Port6 );
ReefAngel.StandardHeater( Port7 );
ReefAngel.DayLights( Box1_Port1 );
ReefAngel.ActinicLights( Box1_Port2 );
ReefAngel.DayLights( Box1_Port3 );
ReefAngel.ActinicLights( Box1_Port4 );
ReefAngel.DayLights( Box1_Port5 );
ReefAngel.ActinicLights( Box1_Port6 );
ReefAngel.StandardHeater( Box1_Port7 );
////// Place your custom code below here

if (hour()>14)
{
ReefAngel.PWM.SetDaylight (now()%(2*60*60)<(1*60*60)?80:35);
ReefAngel.PWM.SetActinic (now()%(2*60*60)<(1*60*60)?35:90);
}
else
{
ReefAngel.PWM.SetDaylight (45);
ReefAngel.PWM.SetActinic (45);
}

if (ReefAngel.DisplayedMenu==FEEDING_MODE)
{
ReefAngel.PWM.SetActinic(30);
ReefAngel.PWM.SetDaylight(30);
}
////// Place your custom code above here

// This should always be the last line
ReefAngel.AddWifi();
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 );
}
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: ReefCrest for Tunze

Post by rimai »

All the way at the end after the last }
Roberto.
Post Reply