PWM code crazy..!?

Share you PDE file with our community
Post Reply
rafamar
Posts: 8
Joined: Wed Feb 15, 2012 1:21 am

PWM code crazy..!?

Post by rafamar »

Hi,
ive upload this in my memory

Code: Select all

// Autogenerated file by RAGen (v1.2.1.158), (03/11/2012 21:13)
// Memory_031112_2113.ino
//
// This file sets the default values to the Internal Memory
//


#include <ReefAngel_Features.h>
#include <Globals.h>
#include <Time.h>
#include <OneWire.h>
#include <RA_NokiaLCD.h>
#include <avr/pgmspace.h>
#include <InternalEEPROM.h>
#include <Wire.h>
#include <Memory.h>


RA_NokiaLCD e;

void setup()
{
    e.Init();
    e.Clear(COLOR_WHITE,0,0,132,132);
    e.BacklightOn();

    InternalMemory.MHOnHour_write(14);
    InternalMemory.MHOnMinute_write(0);
    InternalMemory.MHOffHour_write(0);
    InternalMemory.MHOffMinute_write(0);
    InternalMemory.MHDelay_write(3);
    InternalMemory.StdLightsOnHour_write(2);
    InternalMemory.StdLightsOnMinute_write(0);
    InternalMemory.StdLightsOffHour_write(0);
    InternalMemory.StdLightsOffMinute_write(0);
    InternalMemory.DP1OnHour_write(20);
    InternalMemory.DP1OnMinute_write(0);
    InternalMemory.DP2OnHour_write(22);
    InternalMemory.DP2OnMinute_write(30);
    InternalMemory.DP1Timer_write(10);
    InternalMemory.DP2Timer_write(10);
    InternalMemory.DP1RepeatInterval_write(60);
    InternalMemory.DP2RepeatInterval_write(60);
    InternalMemory.ATOTimeout_write(60);
    InternalMemory.ATOHighTimeout_write(60);
    InternalMemory.ATOHourInterval_write(0);
    InternalMemory.ATOHighHourInterval_write(0);
    InternalMemory.FeedingTimer_write(900);
    InternalMemory.LCDTimer_write(600);
    InternalMemory.LEDPWMActinic_write(100);
    InternalMemory.LEDPWMDaylight_write(100);
    InternalMemory.WM1Timer_write(200);
    InternalMemory.WM2Timer_write(354);
    InternalMemory.HeaterTempOn_write(780);
    InternalMemory.HeaterTempOff_write(791);
    InternalMemory.ChillerTempOn_write(810);
    InternalMemory.ChillerTempOff_write(785);
    InternalMemory.OverheatTemp_write(1500);
    InternalMemory.PHMax_write(840);
    InternalMemory.PHMin_write(550);
    InternalMemory.SalMax_write(2550);
    InternalMemory.RFMode_write(Constant);
    InternalMemory.RFSpeed_write(140);
    InternalMemory.RFDuration_write(8);
    InternalMemory.RFDuration_write(8);
    InternalMemory.PWMSlopeStartD_write(15);
    InternalMemory.PWMSlopeEndD_write(128);
    InternalMemory.PWMSlopeDurationD_write(60);
    InternalMemory.PWMSlopeStartA_write(15);
    InternalMemory.PWMSlopeEndA_write(128);
    InternalMemory.PWMSlopeDurationA_write(60);
    InternalMemory.IMCheck_write(0x5241494D);
}

void loop()
{
    // display success screen
    e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*2, "Internal Memory Set");
    e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*4, "Now load your");
    e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*5, "   RA code file");
    delay(5000);
}
and this sketch

Code: Select all

// Autogenerated file by RAGen (v1.2.1.158), (03/11/2012 21:21)
// RA_031112_2121.ino
//
// This version designed for v0.9.0 or later

/* The following features are enabled for this File: 
#define DisplayLEDPWM
#define wifi
#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
    ReefAngel.SetTemperatureUnit(1);  // set to Celsius Temperature

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

void loop()
{
    // Specific functions
    
    ReefAngel.Relay.DelayedOn(Port3, 2);
    ReefAngel.StandardLights(Port5);
    ReefAngel.StandardLights(Port6);

    ReefAngel.PWM.SetActinic(PWMSlope(14,00,0,30,15,100, 60, ReefAngel.PWM.GetActinicValue() ));
    ReefAngel.PWM.SetDaylight(PWMSlope(14,30,0,00,15,90, 60, ReefAngel.PWM.GetDaylightValue() ));

    ReefAngel.ShowInterface();
    
    
    // accensione pompa dx  grande dalle 15:00 alle 0:00 
    if (((NumMins(hour(),minute()) >= NumMins(15,00)) && (NumMins(hour(),minute()) <= NumMins(23,59))) )ReefAngel.Relay.On(Port7); else ReefAngel.Relay.Off(Port7); 
    // accensione pompa dx piccola dalle 0:00 alle 14:43 e dalle 15:00 alle 21:15 
    if (((NumMins(hour(),minute()) >= NumMins(0,00)) && (NumMins(hour(),minute()) <= NumMins(14,43))) || (NumMins(hour(),minute()) >= NumMins(15,00)) && (NumMins(hour(),minute()) <= NumMins(21,15))) ReefAngel.Relay.On(Port8); else ReefAngel.Relay.Off(Port8);
}
Led will be on 14.00 and off at 0.30 with 60 minutes of slope at 15%.
This morning at 8.00 ive found my light on at 57% instead they would have been off!!
what is the error?

thx and bye
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: PWM code crazy..!?

Post by rimai »

I don't think the PWMSlope function can cross-over to next day.
Can you try to change it to within the same day and let me know if that works?
Roberto.
rafamar
Posts: 8
Joined: Wed Feb 15, 2012 1:21 am

Re: PWM code crazy..!?

Post by rafamar »

rimai wrote:I don't think the PWMSlope function can cross-over to next day.
Can you try to change it to within the same day and let me know if that works?
how and where i ve to change?

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

Re: PWM code crazy..!?

Post by rimai »

Code: Select all

    ReefAngel.PWM.SetActinic(PWMSlope(14,00,0,30,15,100, 60, ReefAngel.PWM.GetActinicValue() ));
    ReefAngel.PWM.SetDaylight(PWMSlope(14,30,0,00,15,90, 60, ReefAngel.PWM.GetDaylightValue() ));
Right now you have it from 2:00pm to 12:30am and 2:30PM and 12:00am.
Change it so it doesn't go over to next day.
Try to end the slop at 11:59pm and let me know if that works.
If I remember correctly, the slope calculation doesn't allow for crossing to next day.
Roberto.
Post Reply