Page 1 of 1

pwm slope

Posted: Tue Feb 21, 2012 9:33 pm
by Govertical19
I wanna setup times and % for leds I do not have the pwm module so i was womdering
so can anyone tell me if this code would work?




Sent from Yahoo! Mail on

// Autogenerated file by RAGen (v1.2.0.152), (02/19/2012 20:15)
// RA_021912_2015.ino
//
// This version designed for v0.9.0 or later

/* The following features are enabled for this File:
#define VersionMenu
#define DisplayLEDPWM
#define wifi
#define WDT
#define SIMPLE_MENU
*/


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


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

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

void loop()
{
    // Specific functions
    ReefAngel.SingleATOLow(Port1);
    ReefAngel.DosingPump2(Port3);
    ReefAngel.DosingPump1(Port4);
    ReefAngel.MHLights(Port5);
    ReefAngel.MHLights(Port6);
    ReefAngel.StandardHeater(Port7);
    ReefAngel.Portal("Govertical19");

    //Setup the sunrise slopes for actinic and daylight LEDs ReefAngel.PWM.SetActinic(PWMSlope(11,00,13,30,15,85)); //PWM slopes starts a 15% at 11:00 a.m and ends 85% at 1:00pm ReefAngel.PWM.SetDaylight(PWMSlope(12,00,13,30,15,75)); //PWM slopes starts a 15% at 1:30pm and ends 75% at 1:30pm

//Setup the sunset slopes for actinic and daylight LEDs ReefAngel.PWM.SetDaylight(PWMSlope(20,30,22,00,75,0)); //PWM slopes starts a 75% at 8:30pm and ends 0% at 10:00pm int moonPhase = (int)MoonlightPWM;

ReefAngel.PWM.SetActinic(PWMSlope(20,30,23,00,85,15)); //PWM slopes starts a 85% at 8:30pm and ends 15% at 11:00pm

    ReefAngel.ShowInterface();
}

Re: pwm slope

Posted: Wed Feb 22, 2012 5:40 am
by binder
You would need to have #define DisplayLEDPWM inside your features file. Otherwise it will not include the PWM section.

Secondly, if you have multiple PWM.SetActinic or SetDaylight function calls, it will override the previous one. Your PWMSlope function is setup incorrectly. The start time will simulate the "sunrise" for you over the duration and the stop time will simulate the "sunset" for you over your duration.

The simplest way for you to do this would have been to have chosen for RAGen to add PWMSlope for you. Then you would have been able to to just have this:

Code: Select all

ReefAngel.PWM.ActinicPWMSlope();
ReefAngel.PWM.DaylightPWMSlope();
Then you would just set in Internal Memory the On / Off times for the StandardLights to tell PWM what on/off times to use. And then set the PWM Duration, Actinic & Daylight Start & End percentages. So you can shift the times and values around over wifi. Otherwise, like you were doing would have them hard coded and you would not be able to change them without uploading new code.

Or if you just want your existing code fixed, you have to make some changes:

Code: Select all

//Setup the sunrise slopes for actinic and daylight LEDs 
//PWM slopes 
// goes from 15% to 85% (and back down)
// starts at 11:00 and ends at 13:00
// starts at 21:00 and ends at 23:00
// has a 120 minute duration for sunrise & sunset
ReefAngel.PWM.SetActinic(PWMSlope(11,00,23,00,15,85, 120, ReefAngel.PWM.GetActinicValue() ));

//PWM slopes
// goes from 15% to 75% (and back down)
// starts at 12:00 and ends at 13:30
// starts at 20:30 and ends at 22:00
// has a 90 minute duration for sunrise & sunset
ReefAngel.PWM.SetDaylight(PWMSlope(12,00,22,00,15,75, 90, ReefAngel.PWM.GetDaylightValue() )); 
Your PWMSlope function was missing 2 variables. So your code would not have compiled at all due to the missing define (mentioned above) and incomplete PWMSlope function.

Re: pwm slope

Posted: Wed Feb 22, 2012 8:37 am
by Govertical19
binder wrote:Then you would just set in Internal Memory the On / Off times for the StandardLights to tell PWM what on/off times to use. And then set the PWM Duration, Actinic & Daylight Start & End percentages. So you can shift the times and values around over wifi. Otherwise, like you were doing would have them hard coded and you would not be able to change them without uploading new code.
Would this mean it would use the relay ports for standardlights? Because I wanted to use them for a second tank white and blues. Unless I use the metal halide ports and just do not set the standardlights to a port on the relay. Would that work until I get another relay box? I would like the definitely use the WiFi capability!

I understand how you coded it now, I thought you would have to different lines one telling lights to turn on and one to turn off, but I understand.

I am trying to read up on the code I just have so little time in the day to sit and read up on it.. I will get there sooner or later..

Thanks For the help!

Re: pwm slope

Posted: Wed Feb 22, 2012 9:00 am
by rimai
No, you can still keep the drivers plugged into the wall.
In which case, you will want to return 0 on the last parameter.

Code: Select all

ReefAngel.PWM.SetActinic(PWMSlope(11,0,23,0,15,85,120,0));
ReefAngel.PWM.SetDaylight(PWMSlope(12,0,22,0,15,75,90,0)); 

Re: pwm slope

Posted: Wed Feb 22, 2012 10:05 pm
by Govertical19
You guys are the best it is working! Next is WIFI WOOHOO

Thanks