Coding Pwm module.

Do you have a question on how to do something.
Ask in here.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Coding Pwm module.

Post by rimai »

I may have screwed up the numbers. They should've represented the time for cloud (C) and ligthtning(L)
Roberto.
abhi_123
Posts: 216
Joined: Tue Mar 20, 2012 8:34 am

Re: Coding Pwm module.

Post by abhi_123 »

56:31 may be 2 days 8 hours 31 min? just a wild guess.
Image
abhi_123
Posts: 216
Joined: Tue Mar 20, 2012 8:34 am

Re: Coding Pwm module.

Post by abhi_123 »

now my moonlight which was fixed on actinic is hanging. on portal it is showing 0% but my moonlight is shining brightly.
Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Coding Pwm module.

Post by rimai »

What does the controller show on AP?
Roberto.
abhi_123
Posts: 216
Joined: Tue Mar 20, 2012 8:34 am

Re: Coding Pwm module.

Post by abhi_123 »

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

Re: Coding Pwm module.

Post by rimai »

Can I see the code?
Roberto.
abhi_123
Posts: 216
Joined: Tue Mar 20, 2012 8:34 am

Re: Coding Pwm module.

Post by abhi_123 »

// Autogenerated file by RAGen (v1.2.2.171), (05/04/2012 21:21)
// RA_050412_2121.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
#define PWMEXPANSION
*/


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

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


////// Place global variable code above here
byte SeasonsVar[]={
  0,0,0,0,0,0};
int LastNumMins=0;

void setup()
{
    // This must be the first line
    ReefAngel.Init(); //Initialize controller

    // Ports that are always on
    ReefAngel.Relay.On(Port4);
    ReefAngel.Relay.On(Port7);
    ReefAngel.Relay.On(Port3);
    ////// Place additional initialization code below here
    

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

void loop()
{
    // Specific functions that use Internal Memory values
    ReefAngel.SingleATOLow(Port1);
    ReefAngel.StandardLights(Port2);
    ReefAngel.WavemakerToggle(Port5, Port6, 60);
    ReefAngel.StandardHeater(Port8);

    // PWMSlope based on Internal Memory values for Standard Lights
    if (ReefAngel.Relay.Status(Port2)) ReefAngel.PWM.SetActinic(0); else ReefAngel.PWM.SetActinic(MoonPhase());
    ////// Place your custom code below here
    ReefAngel.PWM.SetChannel(0,PWMParabola(9,0,20,0,0,100,0));
    ReefAngel.PWM.SetChannel(1,PWMParabola(9,0,20,0,0,100,0));
    ReefAngel.PWM.SetChannel(2,PWMParabola(9,0,20,0,0,100,0));
    ReefAngel.PWM.SetChannel(3,PWMParabola(9,0,20,0,0,100,0));
    byte Fan1Speed;
    Fan1Speed=map(ReefAngel.Params.Temp[1],722,950,30,100); // Calculate Fan 1 speed
    Fan1Speed=constrain(Fan1Speed,0,100);
    ReefAngel.PWM.SetChannel(4,Fan1Speed);

    byte Fan2Speed;
    Fan2Speed=map(ReefAngel.Params.Temp[2],722,950,30,100); // Calculate Fan 2 speed
    Fan2Speed=constrain(Fan2Speed,0,100);
    ReefAngel.PWM.SetChannel(5,Fan2Speed);
    
      Wire.requestFrom(8,6);
  for (int a=0;a<6;a++)
  {
    if (Wire.available()) SeasonsVar[a]=Wire.read();
  }
  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 (SeasonsVar[4])
    {
      int x=0;
      if (SeasonsVar[0]>=10) x=11; else x=17;
      ReefAngel.LCD.DrawText(0,255,x,120,SeasonsVar[0]);
      if (SeasonsVar[1]>=10) x=29; else x=35;
      ReefAngel.LCD.DrawText(0,255,x,120,SeasonsVar[1]);
    }
    if (SeasonsVar[5])
    {
      int x=0;
      if (SeasonsVar[3]>=10) x=51; else x=57;
      ReefAngel.LCD.DrawText(0,255,x,120,SeasonsVar[3]);
      if (SeasonsVar[4]>=10) x=69; else x=75;
      ReefAngel.LCD.DrawText(0,255,x,120,SeasonsVar[4]);
    }
  }   
 

    ////// 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
    ReefAngel.Portal("abhi_123","");

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

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

Re: Coding Pwm module.

Post by rimai »

What happens if you reboot the controller?
Did it start after you added the last code?
Roberto.
abhi_123
Posts: 216
Joined: Tue Mar 20, 2012 8:34 am

Re: Coding Pwm module.

Post by abhi_123 »

the light is running continously even after unplugging the power cable when i again put the power its start.
Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Coding Pwm module.

Post by rimai »

I think I created a bug on the previous libraries release.
Can you use the update utility and upload your code again?
Roberto.
abhi_123
Posts: 216
Joined: Tue Mar 20, 2012 8:34 am

Re: Coding Pwm module.

Post by abhi_123 »

how to use it.
Image
abhi_123
Posts: 216
Joined: Tue Mar 20, 2012 8:34 am

Re: Coding Pwm module.

Post by abhi_123 »

I updated my utility to 0.9.9. will upload the code & update here.
Image
abhi_123
Posts: 216
Joined: Tue Mar 20, 2012 8:34 am

Re: Coding Pwm module.

Post by abhi_123 »

loaded the code & its working fine for now.
Image
abhi_123
Posts: 216
Joined: Tue Mar 20, 2012 8:34 am

Re: Coding Pwm module.

Post by abhi_123 »

The code is working fine for now. I want to add sunrise sunset effect as per season variance. So longer days during summer & shorter during winter.
Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Coding Pwm module.

Post by rimai »

Are you getting the cloud and lightning effects?
Roberto.
abhi_123
Posts: 216
Joined: Tue Mar 20, 2012 8:34 am

Re: Coding Pwm module.

Post by abhi_123 »

Yep. So far not bad.
Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Coding Pwm module.

Post by rimai »

Cool.
Now, take a look at this thread:
http://forum.reefangel.com/viewtopic.php?f=12&t=667
Roberto.
abhi_123
Posts: 216
Joined: Tue Mar 20, 2012 8:34 am

Re: Coding Pwm module.

Post by abhi_123 »

my led started flashing like crazy dont know wat went wrong.
Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Coding Pwm module.

Post by rimai »

Was there anything added or removed?
Did you change or update code?
Roberto.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Coding Pwm module.

Post by rimai »

Roberto.
abhi_123
Posts: 216
Joined: Tue Mar 20, 2012 8:34 am

Re: Coding Pwm module.

Post by abhi_123 »

That ok but the prob is that i am not overridding the current. i am using aquastyle led which are connected in 2 parallel strings of 12 led each. the maximum forward voltage is 3.6 for each making 43.2 for a string whereas the voltage range for the driver is 28.8 to 48v.

here is the link for the specification of driver i am using.http://www.meanwell.com/search/LPF-60D/default.htm
Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Coding Pwm module.

Post by rimai »

So, it was working before with another driver, but it doesn't on this one?
Has it ever worked on this driver?
Did you test the driver?
Roberto.
abhi_123
Posts: 216
Joined: Tue Mar 20, 2012 8:34 am

Re: Coding Pwm module.

Post by abhi_123 »

Well i am just going to buy one 10VDC Adaptor to look whether it works with that or not. i think with 10 V they will lit up at 100%
Image
abhi_123
Posts: 216
Joined: Tue Mar 20, 2012 8:34 am

Re: Coding Pwm module.

Post by abhi_123 »

Update.

Output voltage of my driver is 49.5v & output for the dimming cable is 10v. my pwm channel output is also as per value shown on portal. dont know where i am messing up :(
Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Coding Pwm module.

Post by rimai »

Does it stop flashing if you disconnect the drivers from RA?
What happens when you use a AA battery or a 9V battery instead of RA?
Roberto.
abhi_123
Posts: 216
Joined: Tue Mar 20, 2012 8:34 am

Re: Coding Pwm module.

Post by abhi_123 »

when i am using AA battery for single led it is running fine. havnt checked the leds without RA.
Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Coding Pwm module.

Post by rimai »

What I meant was use the AA battery as dimming signal for the drivers.
Roberto.
abhi_123
Posts: 216
Joined: Tue Mar 20, 2012 8:34 am

Re: Coding Pwm module.

Post by abhi_123 »

got it. Will be using 9 volt battery & update here.
Last edited by abhi_123 on Mon Jun 04, 2012 11:45 pm, edited 1 time in total.
Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Coding Pwm module.

Post by rimai »

1.5V should give you 15%.
On LPF driver, it should be above the threshold.
I head they go all the way down to 3%
Roberto.
abhi_123
Posts: 216
Joined: Tue Mar 20, 2012 8:34 am

Re: Coding Pwm module.

Post by abhi_123 »

dimming is ok. the prob is with the voltage or current coz of that they are blinking. any idea how to correct it?
Image
Post Reply