Newbie

Do you have a question on how to do something.
Ask in here.
Post Reply
pepsiman
Posts: 11
Joined: Sat Feb 11, 2012 3:06 pm

Newbie

Post by pepsiman »

Hi,

So I was able to finally upload code from the RAGen successfully to my RA. However, I am having difficulty with setting up my AI Sol Blue...

I get an error that says 'class ReefAngelClass' has no member named 'AI'. Any thoughts?

Attached is my code..

Thanks
Attachments
my pde.rtf
(1.81 KiB) Downloaded 198 times
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Newbie

Post by binder »

What version of the libraries are you using? the AI support was added in to 0.8.5.19.
You should update your libraries to the latest:
http://forum.reefangel.com/viewtopic.php?f=8&t=2

If you are running 0.8.5.19, make sure you have this in your ReefAngel_Features.h file:

Code: Select all

#define AI_LED
That will enable the AI support.
pepsiman
Posts: 11
Joined: Sat Feb 11, 2012 3:06 pm

Re: Newbie

Post by pepsiman »

Hi,

I have the updated libraries -

When I open the Features.h file, its two paragraphs with a space inbetween - I added it but it still gives me an error...anyother suggestions?
pepsiman
Posts: 11
Joined: Sat Feb 11, 2012 3:06 pm

Re: Newbie

Post by pepsiman »

Hi Roberto - I've sent you an email...
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Newbie

Post by rimai »

If there was only 2 lines, you are opening the wrong file.
The ReefAngel_Features.h file is located at "Documents\Arduino\libraries\ReefAngel_Features"
Just copy and paste this:

Code: Select all

#ifndef __REEFANGEL_FEATURES_H__
#define __REEFANGEL_FEATURES_H__


#define DisplayImages
#define VersionMenu
#define wifi
#define SIMPLE_MENU
#define AI_LED


#endif  // __REEFANGEL_FEATURES_H__
Try this code to start and then we can work on getting it more customized:

Code: Select all

//Autogenerated file by RAGen (v1.1.0.126), (02/11/2012 16:45)
// RA_021112_1645.pde
//
// This version designed for v0.8.5 Beta 17 or later

/* The following features are enabled for this PDE File: 
#define DisplayImages
#define DateTimeSetup
#define DisplayLEDPWM
#define wifi
#define SaveRelayState
#define SIMPLE_MENU
#define ENABLE_ATO_LOGGING
#define AI_LED
*/


#include <ReefAngel_Features.h>
#include <ReefAngel_Globals.h>
#include <ReefAngel_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <ReefAngel_EEPROM.h>
#include <ReefAngel_NokiaLCD.h>
#include <ReefAngel_ATO.h>
#include <ReefAngel_Joystick.h>
#include <ReefAngel_LED.h>
#include <ReefAngel_TempSensor.h>
#include <ReefAngel_Relay.h>
#include <ReefAngel_PWM.h>
#include <ReefAngel_Timer.h>
#include <ReefAngel_Memory.h>
#include <ReefAngel_AI.h>
#include <ReefAngel.h>


void setup()
{
    ReefAngel.Init();  //Initialize controller
    ReefAngel.AI.SetPort(highATOPin);
    // Ports that are always on
    ReefAngel.Relay.On(Port4);
    ReefAngel.Relay.On(Port6);
    ReefAngel.Relay.On(Port7);
    ReefAngel.Relay.On(Port8);
}

void loop()
{
    // Specific functions
    ReefAngel.AI.SetChannel(White,0);
    ReefAngel.AI.SetChannel(Blue,4);
    ReefAngel.AI.SetChannel(RoyalBlue,4);
    ReefAngel.StandardATO(Port1);
    ReefAngel.StandardLights(Port2);
    ReefAngel.StandardHeater(Port3);
    ReefAngel.Wavemaker1(Port5);
    ReefAngel.ShowInterface();
}
Roberto.
pepsiman
Posts: 11
Joined: Sat Feb 11, 2012 3:06 pm

Re: Newbie

Post by pepsiman »

Hi Roberto - I got it to work perfectly...thanks so much for your help!! now my corals won't be burnt.
I have been fiddling around with the PMW Slope function, but I am a bit confused...

what do the values in ReefAngel.AI.SetChannel(White,PWMSlope(9,0,22,0,0,30,240,0)) mean?

I plugged it into the code (replacing ReefAngel.AI.SetChannel(White,4)) and it was uploaded successfully and the white light turned off - from surfing the forums, this is what my impression is:

For the White Light, at 9,00 AM from 22:00, go from 0% to 30% over 240 min? I can't figure out what the last zero means?

In any case, could you write me a snippet that does the following (or at least get me started):

(W,B,RB)

12:00 PM - 12:45 PM (1,0,4) to (5,8,8) over 20 min
12:45 PM - 13:00 (5,8,8) to (8,10,10) over 10 min
13:00 - 17:00 (8,10,10) to (15,10,10) over 240 min
17:00-19:00 (15,10,10) to (20, 10,10) over 10 min
19:00 - 23:00 (20,10,10) to (15,10,10) over 120 min
23:00 - 00:45 (15,10,10) to (2,8,8) over 10 min
00:45 -01:30 (2,8,8) to (1,0,4) over 5 min
01:30 - 12:00 PM (1,0,4)


in chart form:

..................W B RB Ramp (min)
12:00 PM ...5 8 8 20
12:45 PM ...8 10 10 10
13:00.........15 10 10 240
17:00.........20 10 10 10
19:00.........15 10 10 120
23:00..........5 10 10 20
00:45..........2 8 8 10
01:30 (AM)..0 0 4 5

Thanks Roberto - after this I've fully customized the RA to my needs.....(well until I get wifi :D) thanks!!
pepsiman
Posts: 11
Joined: Sat Feb 11, 2012 3:06 pm

Re: Newbie

Post by pepsiman »

Any one? I've been able to use the code in the first post from this thread (http://forum.reefangel.com/viewtopic.ph ... ping#p3354) but want to know how i can use the PMW Slope function for my needs above....

Thanks
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Newbie

Post by rimai »

May I ask why I have such a complex waveform?
I'm typing on phone, so can't really code, but you will need to have several if statements.
For every step, you'll need something like this:
if (NumMins(hour(),minute()>720 && NumMins(hour(),minute()<765) ReefAngel.AI.SetChannel(White,PWMSlope(12,0,12,45,0,5,20,0)
Roberto.
wolfador
Posts: 241
Joined: Sun Sep 04, 2011 9:59 am
Location: Pittsburgh, PA

Re: Newbie

Post by wolfador »

Here is my code for my Ai Nano

Code: Select all

  if (hour()>=22 || hour()<9)
  {
    ReefAngel.AI.SetChannel(White,0);
    ReefAngel.AI.SetChannel(Blue,MoonPhase()*0.07);
    ReefAngel.AI.SetChannel(RoyalBlue,MoonPhase()*0.07);
  }
  else
  {
    ReefAngel.AI.SetChannel(White,PWMSlope(9,0,21,0,3,30,200,3));
    ReefAngel.AI.SetChannel(Blue,PWMSlope(9,0,21,0,8,35,240,8));
    ReefAngel.AI.SetChannel(RoyalBlue,PWMSlope(9,0,21,0,8,35,240,8));

  }
This ramps the lights up to 30/35/35 starting at 9am over 200/240/240 minutes. Then they stay at those values, from 1pm until 5pm where they start to ramp down over the same time period (200/240/240), ending at 9pm where they sit at 3/8/8 until 10pm where they switch to lunar mode which is controlled by the MoonPhase(), taking the B/RB to a max of 7% on "full moon"

This has worked well for me the past few months. I have the white ramping faster so when I am home after ~5pm from work I get to see the tank in a crisp blue color which makes the corals pop and they still get the "daylight" that they need while I am away.
John
ReefAngel and ReefAngel-HD developer
If the RA iOS app has helped please consider a donation
Image
pepsiman
Posts: 11
Joined: Sat Feb 11, 2012 3:06 pm

Re: Newbie

Post by pepsiman »

HI Guys,

Thanks for your reply - I'll try your code John...I've been fildding around with my RA and basically have some of the code working below - except im abit confused about the if/else hour line.. right now it says If its between midnight (is 0 the correct number for midnight or is it 24?) or and 12 PM, the lights will be (W1, B0, RB 4), and if its between 12 PM and 1 PM, its gonna be W5,B8,WB8)

What is the code for minutes?
Like suppose I want to say between 12 PM and 12:30 PM? Is it (hour()>=12,30 && hour()<12,30)

Can't seem to figure it out...

Thanks!

Code: Select all

if (hour()>=0 && hour()<12)
    {
  ReefAngel.AI.SetChannel(White,1);
  ReefAngel.AI.SetChannel(Blue,0);
  ReefAngel.AI.SetChannel(RoyalBlue,4);
    }
    else if (hour()>=12 && hour()<13)
    { 
  ReefAngel.AI.SetChannel(White,5);
  ReefAngel.AI.SetChannel(Blue,8);
  ReefAngel.AI.SetChannel(RoyalBlue,8);
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Newbie

Post by rimai »

If you need to do minutes too, it's easier to calculate by the number of minutes from midnight.
The same code I posted above:

Code: Select all

if (NumMins(hour(),minute()>720 && NumMins(hour(),minute()<765) ReefAngel.AI.SetChannel(White,PWMSlope(12,0,12,45,0,5,20,0)
This would check if the number of minutes from midnight is >720 and <765
I jut wanted to inform that the new libraries have a new waveform that could be used.
Instead of using PWMSlope, which slopes up, remains flat and slopes down, you can use the new PWMParabola, which will generate a parabola type of waveform, which seems to be what you are trying to accomplish. Parabola is a much better approximation to the sun path that the slope.
Just an idea.
Roberto.
pepsiman
Posts: 11
Joined: Sat Feb 11, 2012 3:06 pm

Re: Newbie

Post by pepsiman »

Hi Roberto,

Thanks for the help. Im not to clear about the PMWSlope function.
For example, in (White,PWMSlope(12,0,12,45,0,5,20,0)), what does the last 0 mean?

Also, I thought the PMW Slope function allows your to Ramp up to a target value, and leave it that way...but then you're saying that it ramps to a target value, and then back to the original value?

How can I code it such that it will ramp to a target value and stay that way until I give another command?

Thanks
wolfador
Posts: 241
Joined: Sun Sep 04, 2011 9:59 am
Location: Pittsburgh, PA

Re: Newbie

Post by wolfador »

rimai wrote: the new PWMParabola, which will generate a parabola type of waveform, which seems to be what you are trying to accomplish. Parabola is a much better approximation to the sun path that the slope.
Just an idea.
Wait why was I not notified of this? :D
John
ReefAngel and ReefAngel-HD developer
If the RA iOS app has helped please consider a donation
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Newbie

Post by rimai »

The PWM Slope will ramp up and stay there and ramp down.
The last number is the number which you would like to be returned if when the time is outside of the slope schedule.
Roberto.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Newbie

Post by rimai »

wolfador wrote:Wait why was I not notified of this? :D
:(
Check out the new example codes.
Download at http://www.reefangel.com/Download.ashx
Roberto.
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Newbie

Post by binder »

wolfador wrote:
rimai wrote: the new PWMParabola, which will generate a parabola type of waveform, which seems to be what you are trying to accomplish. Parabola is a much better approximation to the sun path that the slope.
Just an idea.
Wait why was I not notified of this? :D
I found out by looking at the libraries as well. :)
Post Reply