Coding Pwm module.
Coding Pwm module.
Hello Everyone.
which code should i use to make my pwm module to work.
i will be using 4 led drivers & two fans with parabola instead of slope with random cloud & lightning effect + moonlight phase on actinic channel on relay box.
which code should i use to make my pwm module to work.
i will be using 4 led drivers & two fans with parabola instead of slope with random cloud & lightning effect + moonlight phase on actinic channel on relay box.
Re: Coding Pwm module.
I vote for one thing at a time.
1st step is getting the base code from RAGen. Do you have that?
1st step is getting the base code from RAGen. Do you have that?
Roberto.
Re: Coding Pwm module.
here we gorimai wrote:I vote for one thing at a time.
1st step is getting the base code from RAGen. Do you have that?
// 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
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);
////// 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.StandardLights(Port3);
ReefAngel.Wavemaker1(Port5);
ReefAngel.Wavemaker2(Port6);
ReefAngel.StandardHeater(Port8);
// PWMSlope based on Internal Memory values for Standard Lights
ReefAngel.PWM.ActinicPWMSlope();
ReefAngel.PWM.DaylightPWMSlope();
////// Place your custom code below here
////// 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();
}
Re: Coding Pwm module.
Ok, first thing we want to do is add the moonlight.
Replace this:
With this:
Replace this:
Code: Select all
ReefAngel.PWM.ActinicPWMSlope();
Code: Select all
ReefAngel.PWM.SetActinic(MoonPhase());
Roberto.
Re: Coding Pwm module.
Then, remove the daylight channel you are not using:
Code: Select all
ReefAngel.PWM.DaylightPWMSlope();
Roberto.
Re: Coding Pwm module.
And add the code for the parabolas. Make sure to add them in the designated area for your custom code:
Code: Select all
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));
Roberto.
Re: Coding Pwm module.
Here is what i had uploaded. pwm expansion channel rating is still zero.// 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
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);
////// 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.StandardLights(Port3);
ReefAngel.Wavemaker1(Port5);
ReefAngel.Wavemaker2(Port6);
ReefAngel.StandardHeater(Port8);
// PWMSlope based on Internal Memory values for Standard Lights
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));
////// 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();
}
Re: Coding Pwm module.
So, we don't know if it is working, right?
I guess you will need to wait until tomorrow to test?
I guess you will need to wait until tomorrow to test?
Roberto.
Re: Coding Pwm module.
I hate waiting for the sun to rise!
Seems like that's all I do lately!
Have fun-

Seems like that's all I do lately!
Have fun-
Re: Coding Pwm module.
An update. Pwm expansion module is working fine but have some issue with actinic moonphase it is still on 59% although it is 9:30am here with sun shinning high.
Re: Coding Pwm module.
Replace this:
With this:
Code: Select all
ReefAngel.PWM.SetActinic(MoonPhase());
Code: Select all
if (ReefAngel.Relay.Status(Port2)) ReefAngel.PWM.SetActinic(0); else ReefAngel.PWM.SetActinic(MoonPhase());
Roberto.
Re: Coding Pwm module.
Alright. My standard light are assigned on relay 3 so i have to make it 3 instead of 2?
After that now comes the fan portion. I like to install pwm fans on channel 4& 5 to control the temp of my heat sink & tank respectively.
After that now comes the fan portion. I like to install pwm fans on channel 4& 5 to control the temp of my heat sink & tank respectively.
Re: Coding Pwm module.
For Fan, use this:
You can change the temperatures and % on the map function.
I thought I had already posted this for you...
Code: Select all
byte Fan1Speed;
Fan1Speed=map(ReefAngel.Params.Temp[1],772,800,30,100); // Calculate Fan 1 speed
Fan1Speed=constrain(Fan1Speed,0,100);
ReefAngel.PWM.SetChannel(4,Fan1Speed);
byte Fan2Speed;
Fan2Speed=map(ReefAngel.Params.Temp[1],772,800,30,100); // Calculate Fan 2 speed
Fan2Speed=constrain(Fan2Speed,0,100);
ReefAngel.PWM.SetChannel(5,Fan2Speed);
I thought I had already posted this for you...

Roberto.
Re: Coding Pwm module.
Sorry Roberto i missed that post that's why i asked again.
All my code is working great. Now i want to add lightning , cloud & thunderstorm effect to my lights.
All my code is working great. Now i want to add lightning , cloud & thunderstorm effect to my lights.
Re: Coding Pwm module.
That's getting pretty close to full.
I don't think we'll be able to fit.
I don't think we'll be able to fit.
Roberto.
Re: Coding Pwm module.
any modification in my existing code is possible to include the desired function?
Re: Coding Pwm module.
If we hard code some of the settings and use a custom screen and custom menu, we will be able to squeeze it.
This would mean that you will loose the pH calibration on the menu and the graph on the main screen.
The other alternative is to modify the code in your PWM module itself and shift all the code for your lights to the module.
Take a look at these threads:
http://forum.reefangel.com/viewtopic.php?f=11&t=535
http://forum.reefangel.com/viewtopic.php?f=11&t=1069
http://forum.reefangel.com/viewtopic.php?f=11&t=923
This would mean that you will loose the pH calibration on the menu and the graph on the main screen.
The other alternative is to modify the code in your PWM module itself and shift all the code for your lights to the module.
Take a look at these threads:
http://forum.reefangel.com/viewtopic.php?f=11&t=535
http://forum.reefangel.com/viewtopic.php?f=11&t=1069
http://forum.reefangel.com/viewtopic.php?f=11&t=923
Roberto.
Re: Coding Pwm module.
this is what i have to include in my code to shift light setting to my module?
//Start of PWM Expansion Code Header
// This is just how we are going to reference the PWM expansion ports within the code.
// You can change the labels if you would like, just as long as they are changed all throughout the code too.
#define LEDPWM0 0
#define LEDPWM1 1
#define LEDPWM2 2
#define LEDPWM3 3
#define LEDPWM4 4
#define LEDPWM5 5
// Initial values to all 6 channels at startup. They will always be 0.
byte PWMChannel[]={
0,0,0,0,0,0};
//End of PWM Expansion Code Header
//*********************************************************************************************************************************
//Start of PWM Expansion Code Header
// This is just how we are going to reference the PWM expansion ports within the code.
// You can change the labels if you would like, just as long as they are changed all throughout the code too.
#define LEDPWM0 0
#define LEDPWM1 1
#define LEDPWM2 2
#define LEDPWM3 3
#define LEDPWM4 4
#define LEDPWM5 5
// Initial values to all 6 channels at startup. They will always be 0.
byte PWMChannel[]={
0,0,0,0,0,0};
//End of PWM Expansion Code Header
//*********************************************************************************************************************************