Page 1 of 1
smoothing out led dimming
Posted: Wed Nov 04, 2015 4:37 pm
by Ademster
is there a way to smoooth out the dimming?
I have the pwm expansion running ldd drivers.
you can see the steps as it dims, Id like to smooth it out so it slowly drops down like the sun rather step down... is this possible?
Re: smoothing out led dimming
Posted: Wed Nov 04, 2015 7:14 pm
by lnevo
As long as its not a really old dimming expansion you should be able to use the new highres dimming that gives us 4096 steps instead of 256. Can you post your code? When was the last time you updated your libraries and ra?
smoothing out led dimming
Posted: Wed Nov 04, 2015 7:15 pm
by lnevo
Even with the older module you'll actually get 256 steps rather than 100, which is still a big increase
Re: smoothing out led dimming
Posted: Thu Nov 05, 2015 6:13 am
by Ademster
this is whats in there now, but will be changing it soon eliminated the dc pump as it doesnt work, stuck on constant 30% never changed.
and adding delay to when certain channels start coming on for sun rise effect.
I built a new 180gal 48x30x30 tank and large sump with new equipment. so codes needs to be redone.
Code: Select all
#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 <InternalEEPROM.h>
#include <RA_Colors.h>
#include <RA_CustomColors.h>
#include <Salinity.h>
#include <RF.h>
#include <IO.h>
#include <AI.h>
#include <PH.h>
#include <WaterLevel.h>
#include <Humidity.h>
#include <DCPump.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
ReefAngel.Use2014Screen(); // Let's use 2014 Screen
ReefAngel.AddSalinityExpansion(); // Salinity Expansion Module
ReefAngel.AddMultiChannelWaterLevelExpansion(); // Water Level Expansion Module
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = Port1Bit | Port2Bit | Port4Bit | Port6Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port4Bit | Port6Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = 0;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port3Bit;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
ReefAngel.UseFlexiblePhCalibration();
ReefAngel.DCPump.FeedingSpeed=30;
ReefAngel.DCPump.WaterChangeSpeed=0;
ReefAngel.DCPump.ActinicChannel=Sync; // Now you're pump will be affected by the portal settings.
// Ports that are always on
ReefAngel.Relay.On( Port1 );
ReefAngel.Relay.On( Port6 );
ReefAngel.Relay.On( Port7 );
ReefAngel.Relay.On( Box1_Port1 );
ReefAngel.Relay.On( Box1_Port2 );
ReefAngel.Relay.On( Box1_Port3 );
ReefAngel.Relay.On( Box1_Port4 );
ReefAngel.Relay.On( Box1_Port5 );
ReefAngel.Relay.On( Box1_Port6 );
ReefAngel.Relay.On( Box1_Port7 );
ReefAngel.Relay.On( Box1_Port3 );
////// Place additional initialization code below here
//Use PH Flexible Calibration
ReefAngel.UseFlexiblePhCalibration();
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.Relay.DelayedOn( Port2 );
ReefAngel.StandardHeater( Port3 );
ReefAngel.Wavemaker1( Port5 );
ReefAngel.DayLights( Port8 );
ReefAngel.PWM.Channel0PWMSlope();
ReefAngel.PWM.Channel1PWMSlope();
ReefAngel.PWM.Channel2PWMSlope();
ReefAngel.PWM.Channel3PWMSlope();
ReefAngel.PWM.Channel4PWMSlope();
////// Place your custom code below here
// Add random mode if we set to Mode to Custom in portal
static int rmode;
static boolean changeMode=true;
// These are the modes we can cycle through. You can add more and even repeat...
byte modes[] = { ReefCrest, Lagoon, Constant, TidalSwell, ShortPulse, LongPulse, Else, Gyre };
if (now()%SECS_PER_DAY==0 || changeMode==true) { // Change at midnight or if controller rebooted
rmode=random(100)%sizeof(modes); // Change the mode once per day to pick from our array
changeMode=false;
}
// Set timer when in feeding mode
static unsigned long feeding;
if (ReefAngel.DisplayedMenu==FEEDING_MODE) feeding=now();
if (now()-feeding<3600) {
// Continue NTM for the 60 minutes
ReefAngel.DCPump.UseMemory=false;
ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
ReefAngel.DCPump.Mode=NutrientTransport;
} else if (now()%SECS_PER_DAY<43200 || now()%SECS_PER_DAY>=79200) { // 12pm / 10pm
// Night mode (go to 30%)
ReefAngel.DCPump.UseMemory=false;
ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
ReefAngel.DCPump.Mode=Constant;
ReefAngel.DCPump.Speed=30;
} else if (InternalMemory.DCPumpMode_read()==11) {
// Custom Mode and nothing else going on
ReefAngel.DCPump.UseMemory=false;
ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
ReefAngel.DCPump.Mode=modes[rmode]; // Put the mode to the random mode :)
ReefAngel.DCPump.Speed=InternalMemory.DCPumpSpeed_read(); // Set speed from portal
} else {
ReefAngel.DCPump.UseMemory=true; // Will reset all values from memory
}
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "ademster" );
ReefAngel.ShowInterface();
}
Re: smoothing out led dimming
Posted: Thu Nov 05, 2015 6:41 am
by lnevo
Good news. The code you are using will support the high resolution dimming. You just need to make sure you're on the latest libraries and re-upload. You should get either double or ~400x resolution.
Re: smoothing out led dimming
Posted: Sat Nov 07, 2015 6:51 am
by Ademster
so simply updating the libs and uploading the new code will give me the better resolution on dimming?
Re: smoothing out led dimming
Posted: Sat Nov 07, 2015 3:20 pm
by lnevo
It should. It was added into the last release and should be transparent based on your code.
Re: smoothing out led dimming
Posted: Sun Nov 08, 2015 8:29 pm
by rimai
I think he will need a code change.
Re: smoothing out led dimming
Posted: Sun Nov 08, 2015 8:48 pm
by lnevo
Why? He'a using ReefAngel.PWM.ChannelXSlope() those functions call the HighRes functions behind the scenes. What code would need to change?
Re: smoothing out led dimming
Posted: Sun Nov 08, 2015 8:52 pm
by rimai
It calls the high res behind the scenes, but the resolution is still 0-100 steps, which gets upscaled, I think.
He would need to use the raw numbers 0-4096 to be able to take advantage of the high resolution.
Re: smoothing out led dimming
Posted: Sun Nov 08, 2015 8:59 pm
by lnevo
I'm pretty sure thats not the case.
Re: smoothing out led dimming
Posted: Mon Nov 09, 2015 5:37 am
by lnevo
Here's the function. It's callng HighRes slope and doing a SetChannelRaw. I think he's good....
Code: Select all
void RA_PWMClass::ChannelPWMSlope(byte Channel, byte Start, byte End, byte Duration)
{
SetChannelRaw(Channel,PWMSlopeHighRes(
InternalMemory.StdLightsOnHour_read(),
InternalMemory.StdLightsOnMinute_read(),
InternalMemory.StdLightsOffHour_read(),
InternalMemory.StdLightsOffMinute_read(),
Start,
End,
Duration,
ExpansionChannel[Channel]
));
}
Re: smoothing out led dimming
Posted: Mon Nov 09, 2015 10:23 am
by rimai
I think you are right.
Looking at the code now, it looks like it would work.