PWMParabola( )

Related to the development libraries, released by Curt Binder
Post Reply
Sebyte

PWMParabola( )

Post by Sebyte »

Am I correct in thinking that PWMParabola( ) is only available to the PWM expansion module?

If so, is there any way of providing a parabola style of control to the two PWM channels on the main relay box?

If not how do you direct the function to control them.

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

Re: PWMParabola( )

Post by rimai »

Open Arduino
File->Sketchbook->ExampleCodes->PWMParabolaExampleCode
Roberto.
Sebyte

Re: PWMParabola( )

Post by Sebyte »

Alread dId that but did not get the result I was expecting.

Both channels worked at the same level,even though different start and end times were set in the pwmparabola() for actinic and daylight.

Will take another look.

Thanks
Sebyte

Re: PWMParabola( )

Post by Sebyte »

Roberto

I looked again at the example and rebuilt my code from scratch. I still had the same problem, that Port 7 and Port 8 come on at the same time. When Port 8 should be 1 hour after port 7.

This means that the Daylight LED's come on at the same time as the Royal Blues and sit at 5% for one hour then start to ramp up. I don't want them on at all during that hour and want Port8 off so that the MeanWell driver is not powered up. I proved Port8 was live by pulling the driver plug from the socket.

If you can please take a look at the code and see where I am wrong.

Code: Select all

 // Autogenerated file by RAGen (v1.2.2.171), (04/05/2012 08:19)
// RA_033112_0819.ino
//
// This version designed for v0.9.0 or later

/* The following features are enabled for this File: 
 #define DisplayLEDPWM
 #define wifi
 #define WDT
 #define CUSTOM_MENU
 #define CUSTOM_MENU_ENTRIES 5
 */


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

#include <InternalEEPROM.h>

/*
Ports assignment:

Port8 - Daylight fixture - "http://www.reefangel.com/Support.Relay-function-StandardLights.ashx"
Port7 - Actinic fixture
*/

////// Place global variable code below here



////// Place global variable code above here

#include <avr/pgmspace.h>
prog_char menu0_label[] PROGMEM = "Feeding";
prog_char menu1_label[] PROGMEM = "Water Change";
prog_char menu2_label[] PROGMEM = "ATO Clear";
prog_char menu3_label[] PROGMEM = "Overheat Clear";
prog_char menu4_label[] PROGMEM = "PH Calibration";
PROGMEM const char *menu_items[] = {
  menu0_label, menu1_label, menu2_label, menu3_label, menu4_label  };

void MenuEntry1()
{
  ReefAngel.FeedingModeStart();

}
void MenuEntry2()
{
  ReefAngel.WaterChangeModeStart();

}
void MenuEntry3()
{
  ReefAngel.ATOClear();
  ReefAngel.DisplayMenuEntry("Clear ATO Timeout");
}
void MenuEntry4()
{
  ReefAngel.OverheatClear();
  ReefAngel.DisplayMenuEntry("Clear Overheat");
}
void MenuEntry5()
{
  ReefAngel.SetupCalibratePH();
  ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;

}


void setup()
{
  // This must be the first line
  ReefAngel.Init();  //Initialize controller
  // Initialize the custom menu
  ReefAngel.InitMenu(pgm_read_word(&(menu_items[0])),SIZE(menu_items));

  // Ports toggled in Feeding Mode
  ReefAngel.FeedingModePorts = Port6Bit;
  // Ports toggled in Water Change Mode
  ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port5Bit | Port6Bit;
  // Ports toggled when Lights On / Off menu entry selected
  ReefAngel.LightsOnPorts = Port7Bit | Port8Bit;

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



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

void loop()
{
  // Specific functions that use Internal Memory values
  
  // ReefAngel.SingleATOLow(Port2); // commented out 27/11/11 advice of rimai re ATO shutdown like overheat
  
  ReefAngel.StandardHeater(Port3);
  ReefAngel.StandardFan(Port4);
  ReefAngel.Wavemaker1(Port5);
  ReefAngel.StandardLights(Port7);
  ReefAngel.StandardLights(Port8);

  
  ////// Place your custom code below here

  // Activate Watch Dog Timer at 6am and 6pm

  if ((now()%86400)==21600) delay(1000);

  if ((now()%86400)==43200) delay(1000);

  // ATO available 6 times per day - 00:00 to 01:00, 04:00 to 05:00, 08:00 to 09:00, 12:00 to 13:00, 16:00 to 17:00, 20:00 to 21:00,


  if (hour() % 4 == 0 && ReefAngel.LowATO.IsActive()) //Rev made 19/11/11
  {

    ReefAngel.Relay.On(Port2);
  }
  else
  { 
    ReefAngel.Relay.Off(Port2);
  }


  // Kalk Reactor available 6 times per day - 01:30 to 2:00, 05:30 to 06:00, 09:30 to 10:00, 
  // 13:30 to 14:00, 17:30 to 18:00, 21:30 to 2:00.

  if (hour() % 4 == 1 && minute()>30) 
  {
    pinMode(highATOPin,OUTPUT);
    digitalWrite(highATOPin,HIGH); // Turn on Solid State Relay
  }
  else
  {
    pinMode(highATOPin,OUTPUT);
    digitalWrite(highATOPin,LOW); // Turn off Solid State Relay
  } 


  // Wavemaker not available 9 pm to 10 am

  if ( (hour() >= 20) || (hour() <= 9) ) 
  {

    ReefAngel.Relay.Off(Port5);

  }

  //********************************************************************************************************************************
   //LED SETUP
     
  ReefAngel.StandardLights(Port7,9,0,22,0); // Actinic LED Lights on at 9:00am and off at 10:00pm
  ReefAngel.StandardLights(Port8,10,0,21,0); // Daylight LED Lights on at 10:00am and off at 9:00pm


  // PWMParabola(byte startHour, byte startMinute, byte endHour, byte endMinute, byte startPWM, byte endPWM, byte oldValue)
  // startHour - Hour of the start the slope
  // startMinute - Minute of the start the slope
  // endHour - Hour of the end of the slope
  // endMinute - Minute of the end slope
  // startPWM - Beginning PWM value
  // endPWM - Ending PWM value
  // oldValue - Should be the startPWM value or the existing/current PWM value (ReefAngel.PWM.GetActinicValue() or GetDaylightValue())

  ReefAngel.PWM.SetActinic(PWMParabola(9,0,22,0,5,100,5)); 
  // Actinic PWM % starts raising from 5% to 100%  and back down to 5% from 9:00am to 10:00pm forming a parabola.
  ReefAngel.PWM.SetDaylight(PWMParabola(10,0,21,0,5,100,5)); 
  // Daylight PWM % starts raising from 5% to 100%  and back down to 5% from 10:00am to 9:00pm forming a parabola.

  /*
  
  If you get a compile error similar to this:
  'class ReefAngelClass' has no member named 'PWM'
  Please make sure that you enabled Display LED PWM on your features file.
  
  Open RAGen and make sure you have Display LED PWM checked under the Features tab.

  Or, you can manually edit the file.
  The file is located at "Documents\Arduino\libraries\ReefAngel_Features.h" file and has to include this line in it:
  #define DisplayLEDPWM
  
  */  
   

//*********************************************************************************************************************************
  ReefAngel.Portal("sebyte", "xxxx");  // invoke Portal

    ////// Place your custom code above here
  // This sends all the data to the portal
  // Do not add any custom code that changes any relay status after this line
  // The only code after this line should be the ShowInterface function


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

// End of void loop()

Many thanks

PS: You may notice that the date stamp on my banner below is wrong. It appears to be ahead of time :?
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: PWMParabola( )

Post by rimai »

Roberto.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: PWMParabola( )

Post by rimai »

I'll look into the parabola function
Roberto.
Sebyte

Re: PWMParabola( )

Post by Sebyte »

:oops: Ok about -7 = GMT.

Thanks.
Sebyte

Re: PWMParabola( )

Post by Sebyte »

I'll look into the parabola function
When I set the start to 0% instead of 5% everything worked as expected. My drivers kick in at 3%.

Strange :?
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: PWMParabola( )

Post by rimai »

Seriously?
Those meanwell with multi signal start at 3%?
How dim is it?
Can it be used as moonlight?
Let me look at the code right now.
Roberto.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: PWMParabola( )

Post by rimai »

I just loaded the example code and modified to what you had in the code above:

Code: Select all

  ReefAngel.PWM.SetActinic(PWMParabola(9,0,22,0,5,100,5)); 
  ReefAngel.PWM.SetDaylight(PWMParabola(10,0,21,0,5,100,5)); 
At 9:24am, I had AP: 13% and DP: 5%
At 11:00am, I had AP: 48% and DP: 31%
At 3:01pm, I had AP: 99% and DP: 99%
At 8:16pm, I had AP: 43% and DP: 24%
Seemed to be working fine.
So, I went and loaded with this, since you said that start 0% was giving problems:

Code: Select all

  ReefAngel.PWM.SetActinic(PWMParabola(9,0,22,0,0,100,0)); 
  ReefAngel.PWM.SetDaylight(PWMParabola(10,0,21,0,0,100,0)); 
At 9:24am, I had AP: 8% and DP: 0%
At 11:00am, I had AP: 45% and DP: 27%
At 3:01pm, I had AP: 99% and DP: 99%
At 8:16pm, I had AP: 40% and DP: 20%
Seemed to be working fine too.
So, I went ahead and loaded your code.
At 9:24am, I had AP: 13% and DP: 5%
At 11:00am, I had AP: 48% and DP: 31%
At 3:01pm, I had AP: 99% and DP: 99%
At 8:16pm, I had AP: 43% and DP: 24%

So, I'm not so sure why it wasn't working right... :?
Roberto.
Sebyte

Re: PWMParabola( )

Post by Sebyte »

I don't know either, but were ok now :D
Sebyte

Re: PWMParabola( )

Post by Sebyte »

Roberto
Seriously?
Those meanwell with multi signal start at 3%?
How dim is it?
Can it be used as moonlight?
Let me look at the code right now.
Initially I thought it was at 5% that they came on. That is why I set the start to 5%. But this morning playing around I set the start to 0% and watched as they ramped up. After 10 minutes the royal blues started, and the RA controller showed the actinic channel at 3%.

I have two Meanwell LPF-60D-48, one for 10000K, the other for Royal blue. Each driver has 28 LED's in series/parallel circuit. When the blues kick in you have a deep blue light which makes the corals pop! It is a fraction brighter than my 8 x 1watt moonlights. I guess I could run them during the night but as I already have moonlights which I am happy with, I think I will stick as I am. :P
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: PWMParabola( )

Post by rimai »

Nice!!
It's very good info to know. Thanks :)
Roberto.
Post Reply