New System

New members questions
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: New System

Post by rimai »

Try this:

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 <AI.h>
#include <RF.h>
#include <IO.h>
#include <ORP.h>
#include <Salinity.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
  ReefAngel.WaterChangePorts= Port1Bit | Port2Bit | Port3Bit | Port5Bit | Port6Bit;

  // Ports that are always on
  ReefAngel.Relay.On(Port1);
  ReefAngel.Relay.On(Port2);
  ReefAngel.Relay.On(Port3);
  ReefAngel.Relay.On(Port4);
  ////// Place additional initialization code below here


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

void loop()
{
  // Specific functions that use Internal Memory values
  ReefAngel.Wavemaker(Port5,60);
  ReefAngel.Wavemaker(Port6,120);
  ReefAngel.StandardHeater(Port7,757,763);
//  ReefAngel.StandardLights(Port8,17,0,13,0);
  ReefAngel.WaterLevelATO(Port8,60,70,75); // 60 seconds timeout, turn on at 70% and turn off at 75%
  ReefAngel.PWM.SetDaylight( MoonPhase() );
  ReefAngel.PWM.SetActinic( MoonPhase() );
  ////// Place your custom code below here


    ////// Place your custom code above here

    // This should always be the last line
  ReefAngel.ShowInterface();
}


void DrawCustomMain()
{
  int x,y;
  char text[10];
  // Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
  ReefAngel.LCD.DrawMonitor( 15, 14, ReefAngel.Params,
  ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
  ReefAngel.LCD.DrawMonitor( 15, 14, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
  pingSerial();

  // Salinity
  ReefAngel.LCD.DrawText( COLOR_DARKKHAKI,DefaultBGColor,15,54, "SAL:" );
  ReefAngel.LCD.DrawText( COLOR_DARKKHAKI,DefaultBGColor,39,54, ReefAngel.Params.Salinity );
  pingSerial();

  // Water Level
  ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,75,75, "WL:" );
  ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,99,75, ReefAngel.WaterLevel.GetLevel() );
  pingSerial();

  // Main Relay Box
  byte TempRelay = ReefAngel.Relay.RelayData;
  TempRelay &= ReefAngel.Relay.RelayMaskOff;
  TempRelay |= ReefAngel.Relay.RelayMaskOn;
  ReefAngel.LCD.DrawOutletBox( 12, 95, TempRelay );
  pingSerial();

  // Date and Time
  ReefAngel.LCD.DrawDate( 6, 122 );
  pingSerial();
}

void DrawCustomGraph()
{
}

Roberto.
smcglaughn
Posts: 67
Joined: Tue Sep 18, 2012 8:00 pm
Location: Spruce Pine Alabama

Re: New System

Post by smcglaughn »

When I verified this code it said "class reefangelclass has no memeber named waterlevelATO


#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 <AI.h>
#include <RF.h>
#include <IO.h>
#include <ORP.h>
#include <Salinity.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
  ReefAngel.WaterChangePorts= Port1Bit | Port2Bit | Port3Bit | Port5Bit | Port6Bit;

  // Ports that are always on
  ReefAngel.Relay.On(Port1);
  ReefAngel.Relay.On(Port2);
  ReefAngel.Relay.On(Port3);
  ReefAngel.Relay.On(Port4);
  ////// Place additional initialization code below here


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

void loop()
{
  // Specific functions that use Internal Memory values
  ReefAngel.Wavemaker(Port5,60);
  ReefAngel.Wavemaker(Port6,120);
  ReefAngel.StandardHeater(Port7,757,763);
//  ReefAngel.StandardLights(Port8,17,0,13,0);
  ReefAngel.WaterLevelATO(Port8,60,70,75); // 60 seconds timeout, turn on at 70% and turn off at 75%
  ReefAngel.PWM.SetDaylight( MoonPhase() );
  ReefAngel.PWM.SetActinic( MoonPhase() );
  ////// Place your custom code below here


    ////// Place your custom code above here

    // This should always be the last line
  ReefAngel.ShowInterface();
}


void DrawCustomMain()
{
  int x,y;
  char text[10];
  // Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
  ReefAngel.LCD.DrawMonitor( 15, 14, ReefAngel.Params,
  ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
  ReefAngel.LCD.DrawMonitor( 15, 14, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
  pingSerial();

  // Salinity
  ReefAngel.LCD.DrawText( COLOR_DARKKHAKI,DefaultBGColor,15,54, "SAL:" );
  ReefAngel.LCD.DrawText( COLOR_DARKKHAKI,DefaultBGColor,39,54, ReefAngel.Params.Salinity );
  pingSerial();

  // Water Level
  ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,75,75, "WL:" );
  ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,99,75, ReefAngel.WaterLevel.GetLevel() );
  pingSerial();

  // Main Relay Box
  byte TempRelay = ReefAngel.Relay.RelayData;
  TempRelay &= ReefAngel.Relay.RelayMaskOff;
  TempRelay |= ReefAngel.Relay.RelayMaskOn;
  ReefAngel.LCD.DrawOutletBox( 12, 95, TempRelay );
  pingSerial();

  // Date and Time
  ReefAngel.LCD.DrawDate( 6, 122 );
  pingSerial();
}

void DrawCustomGraph()
{
}
smcglaughn
Posts: 67
Joined: Tue Sep 18, 2012 8:00 pm
Location: Spruce Pine Alabama

Re: New System

Post by smcglaughn »

I had a light in outlet 8 before. could that be the problem?
Piper
Posts: 298
Joined: Fri Jul 20, 2012 7:13 am
Location: Oakley, CA

Re: New System

Post by Piper »

What version of the libs do you have? Go to Tools -> Reef Angel Libraries Version. Sounds like you might need to update to the latest libs, 1.0.3.

~Charlie
smcglaughn
Posts: 67
Joined: Tue Sep 18, 2012 8:00 pm
Location: Spruce Pine Alabama

Re: New System

Post by smcglaughn »

The head unit shows version 1.0.2
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

New System

Post by lnevo »

http://forum.reefangel.com/viewtopic.php?p=15603#p15603

Or make sure your arduino has updated the libraries to latest version...

The feature was added between 1.0.2 and 1.0.3
smcglaughn
Posts: 67
Joined: Tue Sep 18, 2012 8:00 pm
Location: Spruce Pine Alabama

Re: New System

Post by smcglaughn »

How do I do that?
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: New System

Post by rimai »

Didn't your Arduino ask you to update libraries?
Roberto.
smcglaughn
Posts: 67
Joined: Tue Sep 18, 2012 8:00 pm
Location: Spruce Pine Alabama

Re: New System

Post by smcglaughn »

No sir it didnt.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: New System

Post by rimai »

It should have asked you. If it didn't, you will need to uninstall the RA installer, download it from the website and install again.
Roberto.
smcglaughn
Posts: 67
Joined: Tue Sep 18, 2012 8:00 pm
Location: Spruce Pine Alabama

Re: New System

Post by smcglaughn »

I did as suggested and it worked.
The additions appear to be working.
Thanks for your help!
smcglaughn
Posts: 67
Joined: Tue Sep 18, 2012 8:00 pm
Location: Spruce Pine Alabama

Re: New System

Post by smcglaughn »

Well I was to quick . The moonlights stay on all the time. I calibrated the salinity probe, but on the main screen it shows "SAL 239"
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: New System

Post by rimai »

That's how we coded your moonlights. Do you have a specific time you want them on?
Make sure the calibration happens at the same temperature as your tank.
1 degree difference and your calibration is off.
Roberto.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

New System

Post by lnevo »

When do you want your moonlights on?

Do you want it to ramp up to the
Moonphase % ? how long of a ramp up/down? or a parabola effect with the moonphase % as a peak? Or just on/off?
smcglaughn
Posts: 67
Joined: Tue Sep 18, 2012 8:00 pm
Location: Spruce Pine Alabama

Re: New System

Post by smcglaughn »

I have the calibration solution bottle floating in the tank. I will retry but 240 is a long way from 35?
I would like the moonlights to have a parabola effect with the moon phase. To simulate natural moonlight.
Also my ATO pump seems like it is running to much. It turns on about every minute or two for a fraction of a second. It seems that it has a very small water level range that it is operating in. It isn't overflowing my tank.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

New System

Post by lnevo »

Still need to know times you want moonlight on..

The waterlevelato line controls the ato pump...the numbers are 70 and 75 represent the on/off times...you can make it longer by changing those numbers further apart...but then you will have a larger swing in salinity...on/off more frequently for shorter time is good..

Your other option is to adjust the flow on your ato pump...if you have that capability to slow it down...
smcglaughn
Posts: 67
Joined: Tue Sep 18, 2012 8:00 pm
Location: Spruce Pine Alabama

Re: New System

Post by smcglaughn »

Moonlights on at 10 PM off at 6 AM
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

New System

Post by lnevo »

I'll let roberto answer on the code because doing the parabola over night requires a helper function not in the library...

Sorry to make it more confusing...

If you just want it on and off for change the setdaylight/setactinitic functions to this instead

If ( (hour()>=22) || (hour()<6) ) {
ReefAngel.PWM.SetDaylight( MoonPhase() );
ReefAngel.PWM.SetActinic( MoonPhase() );
}
smcglaughn
Posts: 67
Joined: Tue Sep 18, 2012 8:00 pm
Location: Spruce Pine Alabama

Re: New System

Post by smcglaughn »

I did the calibration of the salinity probe again. Temps were the same. The head unit still shows SAL 260
Ill just wait on the moon lights. I would like a natural cycle.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

New System

Post by lnevo »

Lol

Good...cause I forgot a paren.,,
smcglaughn
Posts: 67
Joined: Tue Sep 18, 2012 8:00 pm
Location: Spruce Pine Alabama

Re: New System

Post by smcglaughn »

What about the salinity probe?
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: New System

Post by rimai »

What do you get when you finish calibration and the probe is still inside the solution?
Roberto.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: New System

Post by rimai »

260 is really 26.0
It's a display bug that doesn't draw the decimal point.
Roberto.
smcglaughn
Posts: 67
Joined: Tue Sep 18, 2012 8:00 pm
Location: Spruce Pine Alabama

Re: New System

Post by smcglaughn »

Thats fine. Ill revisit later. It showed 350. I used the calibration fluid on my refractometer and it was way off. What about my moonlights
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: New System

Post by rimai »

Parabola won't cross over to next day :(
Maybe we can steal the code from another user :twisted:
http://forum.reefangel.com/viewtopic.php?f=2&t=2386

This is the code we need to adapt:

Code: Select all

byte TunzeSineWave(boolean isleftpump, byte minspeed, byte maxspeed, int period_sec) {
  double x,y;

  x=double(now()%(period_sec));
  x/=period_sec;
  x*=2.0*PI;
  if (!isleftpump) 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(maxspeed-minspeed);
  y+=double(minspeed); 
  
  y+=0.5; // for proper rounding
  
  // y is now between minspeed and maxspeed, constrain for safety  
  return constrain(byte(y),30,100); 
}
Are you good with math? :)
The idea is to create a sine wave that will cycle through with a total phase of 16 hours.
This will create the first half phase of 8 hrs, which is what you want, right?
Then we can just offset it by 79200 seconds, which represents 22 hours of the day and make the cycle start at 10pm.
Does it make sense?
Roberto.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: New System

Post by lnevo »

An easier route if you don't mind making some compromise.... Moonrise/Set isn't so much like Sunrise / Set, so if you use the slope, here's the PWMSlopeOvernight function and how you would use it...

ReefAngel.PWM.SetDaylight(PWMSlopeOvernight(22,0,6,0,0,MoonPhase(),30,0));
ReefAngel.PWM.SetActinic(PWMSlopeOvernight(22,0,6,0,0,MoonPhase(),30,0));

byte PWMSlopeOvernight(byte startHour, byte startMinute, byte endHour, byte
endMinute, byte startPWM, byte endPWM, byte Duration, byte oldValue)
{

unsigned long Start = previousMidnight(now())+((unsigned long)NumMins(startHour, startMinute)*60);
if (hour()<startHour) Start-=86400;
unsigned long StartD = Start + (Duration*60);
unsigned long End = nextMidnight(now())+((unsigned long)NumMins(endHour, endMinute)*60);
if (hour()<startHour) End-=86400;
unsigned long StopD = End - (Duration*60);
if ( now() >= Start && now() <= StartD )
return constrain(map(now(), Start, StartD, startPWM, endPWM),startPWM,
endPWM);
else if ( now() >= StopD && now() <= End )
{
byte v = constrain(map(now(), StopD, End, startPWM, endPWM),startPWM,
endPWM);
return endPWM-v+startPWM;
}
else if ( now() > StartD && now() < StopD )
return endPWM;

// lastly return the existing value
return oldValue;
}
smcglaughn
Posts: 67
Joined: Tue Sep 18, 2012 8:00 pm
Location: Spruce Pine Alabama

Re: New System

Post by smcglaughn »

Where do I put this code? Im good with either one. I would like it to be variable. It doesnt have to be perfect.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: New System

Post by lnevo »

put this part

ReefAngel.PWM.SetDaylight(PWMSlopeOvernight(22,0,6,0,0,MoonPhase(),30,0));
ReefAngel.PWM.SetActinic(PWMSlopeOvernight(22,0,6,0,0,MoonPhase(),30,0));

where you had the ReefAngel.PWM.SetDaylight/SetActinic functions...

put the rest at the bottom after the last } in your code.

The 30 toward the end of those lines btw is a 30 minute ramp up/down. If you want it longer you can change that to 60 or 90 or whatever minutes you want....
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: New System

Post by rimai »

Hey lnevo, just curious to know if you've been using the overnight function.
How's it working out?
I wanted to confirm that it works so I can put it in the libraries.
Roberto.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: New System

Post by lnevo »

Good question... I haven't been up between 3 and 5 am to check on it... but according to the status chart... it looks like it is working..

http://forum.reefangel.com/status/chart ... ilter=pwma
Post Reply