How hard is this gonna be?

Do you have a question on how to do something.
Ask in here.
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: How hard is this gonna be?

Post by binder »

Fourseventeen wrote: I cant for the life of me figure out how to do ANYTHING outside of the main menu. I see I need to install some drivers for the TTL...I tried that and cant even figure that out. I know the basics with computers but this stuff all seems to have me baffled. So as of now I havent even hooked up the RA to my computer. And speaking of hooking it up...does the RA need to be connected to the power strip and into the wall to be able to be programmed on my computer? If so im screwed! The junction box is screwed into the back wall of my cabinet and it will be a PITA to pull it out and put it back in each time I want to program anything.
Start off slow.

First thing first, did you install the Reef Angel Installer? http://www.reefangel.com/Download.ashx
Towards the bottom, it's called "Arduino - Reef Angel Installer (Windows)" (http://www.reefangel.com/files/ReefAngelInstaller.exe)
If you have not, I would suggest installing this first. It walks you through getting your computer prepared for communicating with the RA. It even handles installing the drivers for you and tests that you actually did things properly. It's very good and really simple for anybody to use.

You have to have power to your RA in order to program it. So you will have the power cord plugged into the relay box and then the cable from the relay box to the RA head unit. Then there will be a USB cable connected to your RA and then to your computer. That cable is how you update the RA with the code. I think you should be able to get a USB extension cable to help connect your RA to your computer.
I will say that once you get the basic functionality created for your controller, you won't really need to reprogram it.
and my final issue (so far) is with the ATO. If I manually trigger it by pulling the float down to simulate low water levels the relay kicks on as it should. as soon as I let the float go to float up it turns off as I think it should. I havent even tried the high switch yet because when I try to pull the LOW float down again...it wont turn the switch back on. Is there a lock out to prevent it from going on X amount of times in X amount of time? If I reset the unit and then pull the float down...the ATO switch gets turned on again.
I would suggest reading this post: http://forum.reefangel.com/viewtopic.php?f=7&t=240
It discusses how the ATO switches work.

Let's start with those first. I'll let others comment on the other comments that you have.

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

Re: How hard is this gonna be?

Post by rimai »

Fourseventeen wrote:Next issue I am encountering...when the lighting is 30 mins from shutting down my lights start flickering like crazy...lightning storm like crazy!!! whites keep flicking on and off and dim to bright, its wild! it does that for about 10 mins or so before the lights all shut down. what the heck is going on??? Also if I unplug my RA head unit to do a reboot my lights all kick on 100%...is that normal? the relays are open if the unit is disconnected from the power strip?
The flickering is a limitation of the Meanwell drivers and not RA.
http://www.meanwell.com/search/eln-60/eln-60-spec.pdf
If you look at the datasheet, this happens right about 15%, where the signal fluctuates from 0% to 15% and any very slight change on the signal will cause it to go either 0% or 15%, which causes the effect you perceive as flickering.
Not all drivers present this behavior though. I've handled drivers that didn't do it and some that did. I don't know if they were from different batches or what made them not present this behavior.
What I recommend is using a minimum for the slope of 15% or higher. Since you dialed it down to 800mA, it will be slightly higher, probably close to 20% in your case.
But you can't change the start percentage of the slope on the preloaded code.
You will need to play around to see what is the minimum it will take without flickering.
Our of curiosity, does the actinic channel also present the same behavior?
Roberto.
Fourseventeen
Posts: 26
Joined: Wed Oct 19, 2011 11:48 am
Location: Phoenix, AZ

Re: How hard is this gonna be?

Post by Fourseventeen »

Roberto...The actinics I did not notice doing this. They MAY have but I dont think so. The daylights doing it were so overwhelming. It literally looks like a crazy disco party in there with the whites flashing on and off. The actinics driver output is turned down to 800-850ma. The daylights output I just turned down a little less than quarter of a turn...since they are ok running at max I didnt measure, I just went for what looked good. Somehow or another I need to get rid of that flickering though...when that happened all of my fish darting around and went into hiding...and I dont blame them. So if I am reading right and from what I would already assume...the only way to change this the correct way is to get into the programing of the RA?

Curt...
Thanks for the links. The ATO topic I have read but it doesnt give me any clue as to if the ATO switches have a time out (other then how long it stays on for) or should I say a recycle time that it takes to reset. I have set the ATO time out for 20 seconds. However my issue is that the ATO I cant even get to turn on. After powering up the RA I can get the float to trigger by pushing it below water level (I have enough water in the tank so it wont trigger on its own). So after I trigger it, I would assume it would then reset so if the water level drops again it will activate again...but it doesnt. I waited overnight now and tried it again and it wont turn on UNLESS I reboot the RA.

As far as connecting this thing to the computer....it is mounted and all my wires are ran nicely through looming and all zip tied up...took me a good hour to run all the wires. So I guess I need to pull them all out to get the RA box out. My tank is a good 80 feet away from my computer. Ill get that part worked out though. I think the hard part is going to be to code the functions, rename/number the ports so that im not seeing 0-7 on the screen but 1-8 on the plugs, if its possible...get rid of the graph on the display and make it so the PH and temps show larger, get my lights to ramp up and down properly and get my wavemaker to shut down one of the pumps at night. I know once i get all the bugs out of the way I am going to love this RA set up.
Tank 1-34G RSM reef tank. Rapidled DIY premium 24 kit, Reef Angel, (2) Hydor Evolution 550's, Hydor slim skim, JBJ chiller. Tank 2- Ocanic BC14, nanocustoms ballasts, hydor nano, saphire skimmer.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: How hard is this gonna be?

Post by rimai »

Yes, when you get into programming your RA, you can set the minimum PWM to 15% and you won't have that issue anymore.
Is the ATO float switches mounted so the are opposite to each other? One pointing up and one pointing down? This is how they have to be to work with the preloaded code.
If you want it to work with just one float like you are expecting and describing, you can do so by choosing SingleATO when you generate code with RAGen.
The numbers on the screen are set from 1-8 the same way as the plugs by default once you program the RA with code generated from RAGen.
The only way to make larger numbers and get rid of the graph is using custom screen, which will also require you to move away from the preloaded code.
So, it does look like the code from RAGen is the way to go for you.
Roberto.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: How hard is this gonna be?

Post by rimai »

Roberto.
Fourseventeen
Posts: 26
Joined: Wed Oct 19, 2011 11:48 am
Location: Phoenix, AZ

Re: How hard is this gonna be?

Post by Fourseventeen »

I am using both floats as you desribe. low switch with wires aiming up and high switch with wires aiming down (and then back up out of the tank obviously). I am not sure what the deal is with the ATO but I need to get that figured out today at some point.

RAGen is a MUST for me without a doubt. Guess I plan to spend some time today trying to get that started too...but I am real worried I am going to screw something up and then not have anything working
Tank 1-34G RSM reef tank. Rapidled DIY premium 24 kit, Reef Angel, (2) Hydor Evolution 550's, Hydor slim skim, JBJ chiller. Tank 2- Ocanic BC14, nanocustoms ballasts, hydor nano, saphire skimmer.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: How hard is this gonna be?

Post by rimai »

Let me explain then how the ATO on the preloaded code works.
The low switch is what turns the port on and high switch is what turns the port off.
Water level has to travel from when low switch is activated all the way up to when the high level switch is activated within the timeout period, 20s in your case.
It seems to me that 20 is not enough, unless you have a realy strong pump or your float switches are mounted in two levels so the difference between low and high is packed together.
If the 20s expires, the RA will disable the feature and generates and alert.
It disables because it could be that you have something that is altering the level of water and you don't want RA to start pumping RO water indefinetely or it could be that your container is dry and you don't want the pump to be running dry.
When an alert is triggered, the red led status will turn on.
To re-enable the ATO feature and clear the alert flag, you have to go to menu "View Log" if you are using the pre-loaded code. That will clear all alerts and turn the red status led off.
Roberto.
Fourseventeen
Posts: 26
Joined: Wed Oct 19, 2011 11:48 am
Location: Phoenix, AZ

Re: How hard is this gonna be?

Post by Fourseventeen »

ok view log....that cleared up the hang up so the ATO kicks on again. Ill have to work on the timing so that I have the time expire before it will get to high but not to short so that it doesnt allow the high flow to kick the pump off on its own. I think I got that part handled.

The wife is watching a movie so I just stole her laptop....and yes shes going to be pissed! but oh well. Its much easier then trying to take all the stuff out of the tank stand lol. So I am about to load all the stuff onto this computer and see what I can do. im REAL nervous over here.
Tank 1-34G RSM reef tank. Rapidled DIY premium 24 kit, Reef Angel, (2) Hydor Evolution 550's, Hydor slim skim, JBJ chiller. Tank 2- Ocanic BC14, nanocustoms ballasts, hydor nano, saphire skimmer.
Fourseventeen
Posts: 26
Joined: Wed Oct 19, 2011 11:48 am
Location: Phoenix, AZ

Re: How hard is this gonna be?

Post by Fourseventeen »

K got the RA software installed and the RA connected to the computer. It appears to be communicating (com3). I dont see anywhere though where I can open the current codes to just modify them.

for the led lighting to turn on at 10am at 15% intensity and ramp up to 100% and then at the end of the day ramp down to 15% before shutting off at 10pm. If I could put in random cloud cover that would be even cooler! maybe a few times a day dim the daylights to simulate this? But I wont be upset if I cant get the cloud cover part done.

For the wavemaker I want them to alternate at 30 seconds during the day (one off, one on...or even random) and then have pump 2 shut off at 10pm to calm things down and turn back on at 10am and go back to alternating again.

If I could get those 2 things working I would be a happy camper. Now if I can get rid of the graph and make the text larger so I can easily view temps, time, pumps that are on and PH and name the sockets and ditch the 0-7 and make that right I would be even more stoked! Another thing I would like to do is change up the sockets as well so that 7 or 8 works my fans. I would plug the fans into the daylight outlet BUT its a transformer plug so it wont fit anywhere but on the end of the outlet. right now my fans are in socket 8 but they dont ever shut off I would like them to stay on only when my LEDS are on.
Tank 1-34G RSM reef tank. Rapidled DIY premium 24 kit, Reef Angel, (2) Hydor Evolution 550's, Hydor slim skim, JBJ chiller. Tank 2- Ocanic BC14, nanocustoms ballasts, hydor nano, saphire skimmer.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: How hard is this gonna be?

Post by rimai »

Ok, let's start small :)
Try generating the code with RAGen with the things you have plugged in on the relay box.
Copy and paste the code, so I can see what you have.
Roberto.
Fourseventeen
Posts: 26
Joined: Wed Oct 19, 2011 11:48 am
Location: Phoenix, AZ

Re: How hard is this gonna be?

Post by Fourseventeen »

I dont even know how to start generating any codes. I have read and read so much i cant see straight lol.
I have RAGen open and I have Arduino open and have looked at the drop down menus in each and cant sem to figure out where to start. guess I will go back to the tutorials again and read some more.

I need a teacher lol
Tank 1-34G RSM reef tank. Rapidled DIY premium 24 kit, Reef Angel, (2) Hydor Evolution 550's, Hydor slim skim, JBJ chiller. Tank 2- Ocanic BC14, nanocustoms ballasts, hydor nano, saphire skimmer.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: How hard is this gonna be?

Post by rimai »

Open RAGen
Select PDE tab
Click in each port and choose what you want on the right side
That's it :)
Once you go through all 8 ports, click generate
Roberto.
Fourseventeen
Posts: 26
Joined: Wed Oct 19, 2011 11:48 am
Location: Phoenix, AZ

Re: How hard is this gonna be?

Post by Fourseventeen »

oh ok yeah I seen how to do that but that doesnt give me the options to ramp anything up or down or create a starting intensity of the LEDS or change the timing curve of the pumps for wavemaking function.

that part you just mentioned seems simple enough but it doesnt appear to give me the options to change things around and rename the ports?
Tank 1-34G RSM reef tank. Rapidled DIY premium 24 kit, Reef Angel, (2) Hydor Evolution 550's, Hydor slim skim, JBJ chiller. Tank 2- Ocanic BC14, nanocustoms ballasts, hydor nano, saphire skimmer.
Fourseventeen
Posts: 26
Joined: Wed Oct 19, 2011 11:48 am
Location: Phoenix, AZ

Re: How hard is this gonna be?

Post by Fourseventeen »

// Autogenerated file by RAGen (v1.1.0.126), (10/22/2011 15:14)
// RA_102211_1514.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 VersionMenu
#define DirectTempSensor
#define DisplayLEDPWM
#define wifi
#define SIMPLE_MENU
*/


#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.h>


void setup()
{
ReefAngel.Init(); //Initialize controller

ReefAngel.LightsOnPorts = B01010110;

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

void loop()
{
// Specific functions
ReefAngel.StandardATO(Port1);
ReefAngel.StandardLights(Port2);
ReefAngel.MHLights(Port3);
ReefAngel.Wavemaker1(Port4);
ReefAngel.Wavemaker2(Port5);
ReefAngel.StandardFan(Port7);

ReefAngel.ShowInterface();
}
Tank 1-34G RSM reef tank. Rapidled DIY premium 24 kit, Reef Angel, (2) Hydor Evolution 550's, Hydor slim skim, JBJ chiller. Tank 2- Ocanic BC14, nanocustoms ballasts, hydor nano, saphire skimmer.
Fourseventeen
Posts: 26
Joined: Wed Oct 19, 2011 11:48 am
Location: Phoenix, AZ

Re: How hard is this gonna be?

Post by Fourseventeen »

ok so that should make it so port 7 is my fan which should go on with my lights? and it should make it so wavemaker 2 only goes on when my lights are on as well?

Now what do I do? lol
Tank 1-34G RSM reef tank. Rapidled DIY premium 24 kit, Reef Angel, (2) Hydor Evolution 550's, Hydor slim skim, JBJ chiller. Tank 2- Ocanic BC14, nanocustoms ballasts, hydor nano, saphire skimmer.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: How hard is this gonna be?

Post by rimai »

Good. that's a start.
Remeber, we have to go doing baby steps.
If you tackle everything at once, everything goes wrong and you won't be able to find out what it is.
Let's read what you generated to make sure that's what you have plugged in the relay box.
Port1 - ATO pump
Port2 - Lights
Port3 - Lights
Port4 - WM Pump 1
Port5 - WM Pump 2
Port 6 - always on, no matter. Will not turn off for anything
Port 7 - Fan
Port 8 - always on, no matter. Will not turn off for anything

Is this correct?
Here is the first thing I'd recommend: Put your fan on port 4 and move wm pumps to port 5 and 6. These ports have special dampening components to help minimize the spikes generated by pumps.
On RAGen, there is a section for Ports toggled during modes.
Make sure to select which port you would like turned off for feeding and water change.
Roberto.
Fourseventeen
Posts: 26
Joined: Wed Oct 19, 2011 11:48 am
Location: Phoenix, AZ

Re: How hard is this gonna be?

Post by Fourseventeen »

I need to run the fan on 7 or 8 because the plug wont fit any other place...its a block style plug for 12V.

yes I made it so port 6 and 8 are always on. The WM ports I just left them where they came set up...i didnt change those at all.

port one is ATO
port 2 is my moonlight
port 3 is nothing
port 4 is nothing at the moment
port 5 is WM
port 6 is WM
port 7 is nothing at the moment
port 8 is my fans currently
this is are port #s according to the power supply box not the display. the display as we discussed befoe are reading one number less then actual. which also throws me off all the time.
Tank 1-34G RSM reef tank. Rapidled DIY premium 24 kit, Reef Angel, (2) Hydor Evolution 550's, Hydor slim skim, JBJ chiller. Tank 2- Ocanic BC14, nanocustoms ballasts, hydor nano, saphire skimmer.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: How hard is this gonna be?

Post by rimai »

Will you want to stop the WM pumps on feeding and/or water change mode?
Roberto.
Fourseventeen
Posts: 26
Joined: Wed Oct 19, 2011 11:48 am
Location: Phoenix, AZ

Re: How hard is this gonna be?

Post by Fourseventeen »

Yes I want to shut off the WM for feeding but not water changes
Tank 1-34G RSM reef tank. Rapidled DIY premium 24 kit, Reef Angel, (2) Hydor Evolution 550's, Hydor slim skim, JBJ chiller. Tank 2- Ocanic BC14, nanocustoms ballasts, hydor nano, saphire skimmer.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: How hard is this gonna be?

Post by rimai »

So, your code should be something like this then:

Code: Select all

#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.h>


void setup()
{
ReefAngel.Init(); //Initialize controller
ReefAngel.FeedingModePorts = B00110000;
}

void loop()
{
// Specific functions
ReefAngel.StandardATO(Port1);
ReefAngel.Wavemaker1(Port5);
ReefAngel.Wavemaker2(Port6);  
ReefAngel.StandardLights(Port8);

ReefAngel.ShowInterface();
}
Port1 - ATO
Port5 - WM
Port6 - WM
Port8 - Fan that follows the same schedule as lights
Roberto.
Fourseventeen
Posts: 26
Joined: Wed Oct 19, 2011 11:48 am
Location: Phoenix, AZ

Re: How hard is this gonna be?

Post by Fourseventeen »

I so what do the other ports not mentioned do? I need a port for moon lights too
Tank 1-34G RSM reef tank. Rapidled DIY premium 24 kit, Reef Angel, (2) Hydor Evolution 550's, Hydor slim skim, JBJ chiller. Tank 2- Ocanic BC14, nanocustoms ballasts, hydor nano, saphire skimmer.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: How hard is this gonna be?

Post by rimai »

You said port 3,4 and 7 have nothing.
So, we are not touching them for now.
The moonlight, I'm just going to have it go on when Port 8 is off and vice-versa.
Is it how you want or you prefer having specific time on/off for them?
Roberto.
Fourseventeen
Posts: 26
Joined: Wed Oct 19, 2011 11:48 am
Location: Phoenix, AZ

Re: How hard is this gonna be?

Post by Fourseventeen »

Yeah the moonlights On when day lights off
Tank 1-34G RSM reef tank. Rapidled DIY premium 24 kit, Reef Angel, (2) Hydor Evolution 550's, Hydor slim skim, JBJ chiller. Tank 2- Ocanic BC14, nanocustoms ballasts, hydor nano, saphire skimmer.
Fourseventeen
Posts: 26
Joined: Wed Oct 19, 2011 11:48 am
Location: Phoenix, AZ

Re: How hard is this gonna be?

Post by Fourseventeen »

k i am trying to load that code you gave me and I keep getting an error saying problem uploading to board??
Tank 1-34G RSM reef tank. Rapidled DIY premium 24 kit, Reef Angel, (2) Hydor Evolution 550's, Hydor slim skim, JBJ chiller. Tank 2- Ocanic BC14, nanocustoms ballasts, hydor nano, saphire skimmer.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: How hard is this gonna be?

Post by rimai »

Can you post the error you are getting?
Roberto.
Fourseventeen
Posts: 26
Joined: Wed Oct 19, 2011 11:48 am
Location: Phoenix, AZ

Re: How hard is this gonna be?

Post by Fourseventeen »

I wish I could. I tried to copy/paste and it wont let me. its in the black box with orange writing. I see a line that says not in sync, another that says protocal error. but its a lot of stuff. it goes on like its loading to the boad, the controller resets and then i get the error.

I watched the youtube video about uploading the internal memory times. this is something i didnt do...am I suppose to do this or is this something in the codes you gave me to copy/paste? or something i dont need to do?
Tank 1-34G RSM reef tank. Rapidled DIY premium 24 kit, Reef Angel, (2) Hydor Evolution 550's, Hydor slim skim, JBJ chiller. Tank 2- Ocanic BC14, nanocustoms ballasts, hydor nano, saphire skimmer.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: How hard is this gonna be?

Post by rimai »

Can you check on menu Tools->Board and make sure that you have "Reef Angel Controller w/ optiboot" selected?
Roberto.
Fourseventeen
Posts: 26
Joined: Wed Oct 19, 2011 11:48 am
Location: Phoenix, AZ

Re: How hard is this gonna be?

Post by Fourseventeen »

that is correct. that is what it shows selected.
Tank 1-34G RSM reef tank. Rapidled DIY premium 24 kit, Reef Angel, (2) Hydor Evolution 550's, Hydor slim skim, JBJ chiller. Tank 2- Ocanic BC14, nanocustoms ballasts, hydor nano, saphire skimmer.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: How hard is this gonna be?

Post by rimai »

Here is the code:

Code: Select all

#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.h>

#define MinimumPWM  17

byte ActinicPWMValue=0;
byte DaylightPWMValue=0;

void setup()
{
  ReefAngel.Init(); //Initialize controller
  ReefAngel.FeedingModePorts = B00110000;
  ReefAngel.WaterChangePorts = B00000000;
  ReefAngel.OverheatShutoffPorts = B00000000;
  ReefAngel.LightsOnPorts = B10000000;
  ReefAngel.Relay.On(Port5);
  ReefAngel.Timer[1].SetInterval(InternalMemory.WM1Timer_read());
  ReefAngel.Timer[1].Start();
}

void loop()
{
  // Specific functions
  ReefAngel.StandardATO(Port1);
  ReefAngel.StandardLights(Port8);

// PWM and Moonlight
  if (bitRead(ReefAngel.Relay.RelayData,Port8-1))
  {
    ActinicPWMValue=PWMSlope(InternalMemory.StdLightsOnHour_read(),InternalMemory.StdLightsOnMinute_read(),InternalMemory.StdLightsOffHour_read(),InternalMemory.StdLightsOffMinute_read(),MinimumPWM,InternalMemory.LEDPWMActinic_read(),60,0);
    DaylightPWMValue=PWMSlope(InternalMemory.StdLightsOnHour_read(),InternalMemory.StdLightsOnMinute_read(),InternalMemory.StdLightsOffHour_read(),InternalMemory.StdLightsOffMinute_read(),MinimumPWM,InternalMemory.LEDPWMDaylight_read(),60,0);
    ReefAngel.Relay.Off(Port2);
  }
  else
  {
    ActinicPWMValue=0;
    DaylightPWMValue=0;
    ReefAngel.Relay.On(Port2);
  }
// Cloud and lightining
  CheckCloud();
  ReefAngel.PWM.SetActinic(ActinicPWMValue);
  ReefAngel.PWM.SetDaylight(DaylightPWMValue);

  // Wavemaker Code
  if ( ReefAngel.Timer[1].IsTriggered() )
  {
    ReefAngel.Timer[1].Start();
    ReefAngel.Relay.Toggle(Port5);
    ReefAngel.Relay.Toggle(Port6);
  }
  ReefAngel.ShowInterface();
}


//*********************************************************************************************************************************
// Random Cloud/Thunderstorm effects function
void CheckCloud()
{

  // ------------------------------------------------------------
  // Change the values below to customize your cloud/storm effect

  // Frequency in days based on the day of the month - number 2 means every 2 days, for example (day 2,4,6 etc)
  // For testing purposes, you can use 1 and cause the cloud to occur everyday
#define Clouds_Every_X_Days 1 

  // Percentage chance of a cloud happening today
  // For testing purposes, you can use 100 and cause the cloud to have 100% chance of happening
#define Cloud_Chance_per_Day 100

  // Minimum number of minutes for cloud duration.  Don't use max duration of less than 6
#define Min_Cloud_Duration 7

  // Maximum number of minutes for the cloud duration. Don't use max duration of more than 255
#define Max_Cloud_Duration 15

  // Minimum number of clouds that can happen per day
#define Min_Clouds_per_Day 3

  // Maximum number of clouds that can happen per day
#define Max_Clouds_per_Day 5

  // Only start the cloud effect after this setting
  // In this example, start could after 11:30am
#define Start_Cloud_After NumMins(11,30)

  // Always end the cloud effect before this setting
  // In this example, end could before 8:00pm
#define End_Cloud_Before NumMins(18,30)

  // Percentage chance of a lightning happen for every cloud
  // For testing purposes, you can use 100 and cause the lightning to have 100% chance of happening
#define Lightning_Change_per_Cloud 100

  // Note: Make sure to choose correct values that will work within your PWMSLope settings.
  // For example, in our case, we could have a max of 5 clouds per day and they could last for 50 minutes.
  // Which could mean 250 minutes of clouds. We need to make sure the PWMSlope can accomodate 250 minutes of effects or unforseen resul could happen.
    // Also, make sure that you can fit double those minutes between Start_Cloud_After and End_Cloud_Before.
  // In our example, we have 510 minutes between Start_Cloud_After and End_Cloud_Before, so double the 250 minutes (or 500 minutes) can fit in that 510 minutes window.
    // It's a tight fit, but it did.

    //#define printdebug // Uncomment this for debug print on Serial Monitor window
  #define forcecloudcalculation // Uncomment this to force the cloud calculation to happen in the boot process. 


  // Change the values above to customize your cloud/storm effect
  // ------------------------------------------------------------
  // Do not change anything below here

  static byte cloudchance=255;
  static byte cloudduration=0;
  static int cloudstart=0;
  static byte numclouds=0;
  static byte lightningchance=0;
  static byte cloudindex=0;
  static byte lightningstatus=0;
  static int LastNumMins=0;
  // Every day at midnight, we check for chance of cloud happening today
  if (hour()==0 && minute()==0 && second()==0) cloudchance=255;

#ifdef forcecloudcalculation
    if (cloudchance==255)
#else
    if (hour()==0 && minute()==0 && second()==1 && cloudchance==255) 
#endif
    {
      //Pick a random number between 0 and 99
      cloudchance=random(100); 
      // if picked number is greater than Cloud_Chance_per_Day, we will not have clouds today
      if (cloudchance>Cloud_Chance_per_Day) cloudchance=0;
      // Check if today is day for clouds. 
      if ((day()%Clouds_Every_X_Days)!=0) cloudchance=0; 
      // If we have cloud today
      if (cloudchance)
      {
        // pick a random number for number of clouds between Min_Clouds_per_Day and Max_Clouds_per_Day
        numclouds=random(Min_Clouds_per_Day,Max_Clouds_per_Day);
        // pick the time that the first cloud will start
        // the range is calculated between Start_Cloud_After and the even distribuition of clouds on this day. 
        cloudstart=random(Start_Cloud_After,Start_Cloud_After+((End_Cloud_Before-Start_Cloud_After)/(numclouds*2)));
        // pick a random number for the cloud duration of first cloud.
        cloudduration=random(Min_Cloud_Duration,Max_Cloud_Duration);
        //Pick a random number between 0 and 99
        lightningchance=random(100);
        // if picked number is greater than Lightning_Change_per_Cloud, we will not have lightning today
        if (lightningchance>Lightning_Change_per_Cloud) lightningchance=0;
      }
    }
  // Now that we have all the parameters for the cloud, let's create the effect

  if (cloudchance)
  {
    //is it time for cloud yet?
    if (NumMins(hour(),minute())>=cloudstart && NumMins(hour(),minute())<(cloudstart+cloudduration))
    {
      DaylightPWMValue=ReversePWMSlope(cloudstart,cloudstart+cloudduration,DaylightPWMValue,0,180);
      if (lightningchance && (NumMins(hour(),minute())==(cloudstart+(cloudduration/2))) && second()<5) 
      {
        if (random(100)<20) lightningstatus=1; 
        else lightningstatus=0;
        if (lightningstatus)
        {
          DaylightPWMValue=100; 
          ActinicPWMValue=100;
        }
        else 
        {
          DaylightPWMValue=0;
          ActinicPWMValue=0;
        }
        delay(1);
      }
    }
    if (NumMins(hour(),minute())>(cloudstart+cloudduration))
    {
      cloudindex++;
      if (cloudindex < numclouds)
      {
        cloudstart=random(Start_Cloud_After+(((End_Cloud_Before-Start_Cloud_After)/(numclouds*2))*cloudindex*2),(Start_Cloud_After+(((End_Cloud_Before-Start_Cloud_After)/(numclouds*2))*cloudindex*2))+((End_Cloud_Before-Start_Cloud_After)/(numclouds*2)));
        // pick a random number for the cloud duration of first cloud.
        cloudduration=random(Min_Cloud_Duration,Max_Cloud_Duration);
        //Pick a random number between 0 and 99
        lightningchance=random(100);
        // if picked number is greater than Lightning_Change_per_Cloud, we will not have lightning today
        if (lightningchance>Lightning_Change_per_Cloud) lightningchance=0;
      }
    }
  }
  
  if (LastNumMins!=NumMins(hour(),minute()))
  {
    LastNumMins=NumMins(hour(),minute());
    ReefAngel.LCD.Clear(255,0,120,132,132);
    ReefAngel.LCD.DrawText(0,255,5,120,"C");
    ReefAngel.LCD.DrawText(0,255,11,120,"00:00");
    ReefAngel.LCD.DrawText(0,255,45,120,"L");
    ReefAngel.LCD.DrawText(0,255,51,120,"00:00");
    if (cloudchance && (NumMins(hour(),minute())<cloudstart))
    {
      int x=0;
      if ((cloudstart/60)>=10) x=11; else x=17;
      ReefAngel.LCD.DrawText(0,255,x,120,(cloudstart/60));
      if ((cloudstart%60)>=10) x=29; else x=35;
      ReefAngel.LCD.DrawText(0,255,x,120,(cloudstart%60));
    }
    ReefAngel.LCD.DrawText(0,255,90,120,cloudduration);
    if (lightningchance) 
    {
      int x=0;
      if (((cloudstart+(cloudduration/2))/60)>=10) x=51; else x=57;
      ReefAngel.LCD.DrawText(0,255,x,120,((cloudstart+(cloudduration/2))/60));
      if (((cloudstart+(cloudduration/2))%60)>=10) x=69; else x=75;
      ReefAngel.LCD.DrawText(0,255,x,120,((cloudstart+(cloudduration/2))%60));
    }
  }   
}

byte ReversePWMSlope(long cstart,long cend,byte PWMStart,byte PWMEnd, byte clength)
{
  long n=elapsedSecsToday(now());
  cstart*=60;
  cend*=60;
  if (n<cstart) return PWMStart;
  if (n>=cstart && n<=(cstart+clength)) return map(n,cstart,cstart+clength,PWMStart,PWMEnd);
  if (n>(cstart+clength) && n<(cend-clength)) return PWMEnd;
  if (n>=(cend-clength) && n<=cend) return map(n,cend-clength,cend,PWMEnd,PWMStart);
  if (n>cend) return PWMStart;
}
And the Feature file

Code: Select all

// AutoGenerated file by RAGen (v1.1.0.124), (10/22/2011 19:43)

/*
 * Copyright 2010-11 Curt Binder
 *
 * Licensed under the Apache License, Version 2.0 (the "License")
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


#ifndef __REEFANGEL_FEATURES_H__
#define __REEFANGEL_FEATURES_H__


#define DateTimeSetup
#define VersionMenu
#define ATOSetup
#define DisplayLEDPWM
#define StandardLightSetup
#define WavemakerSetup
#define WDT


#endif  // __REEFANGEL_FEATURES_H__
Roberto.
Fourseventeen
Posts: 26
Joined: Wed Oct 19, 2011 11:48 am
Location: Phoenix, AZ

Re: How hard is this gonna be?

Post by Fourseventeen »

Roberto....YOU ARE THE MAN!!!!! Talk about a real stand up guy! He just spent a good amount of time helping me out and has got me up and running.

If anyone is reading this who is thinking about buying a Reef Angel and is having doubts, Just go buy this thing!!! The man behind the product is top notch! His customer service skills cant be beat!!!!
Tank 1-34G RSM reef tank. Rapidled DIY premium 24 kit, Reef Angel, (2) Hydor Evolution 550's, Hydor slim skim, JBJ chiller. Tank 2- Ocanic BC14, nanocustoms ballasts, hydor nano, saphire skimmer.
Post Reply