PWM Expansion difficulties

New members questions
Post Reply
c_wick
Posts: 25
Joined: Tue May 22, 2012 2:41 pm

PWM Expansion difficulties

Post by c_wick »

So I've been trying for the past day and half to figure out how to set my LED lights on a dimming schedule. So far all I've been able to do is turn them on and off. I've changed to code during my experiments to have the LED's run at only 30% so that I can visually tell if the code is working....but so far they keep running at full power...my brain is fried from reading posts on the forum and trying to figure this out...any help would be awesome!

Not looking for anything fancy right now...just want a sunrise/sunset effect...

Code: Select all

// Autogenerated file by RAGen (v1.2.2.171), (05/22/2012 14:47)
// RA_052212_1447.ino
//
// This version designed for v0.9.0 or later

//The following features are enabled for this File: 
#define DisplayImages
#define DateTimeSetup
#define VersionMenu
#define DirectTempSensor
#define DisplayLEDPWM
#define SIMPLE_MENU
#define PWMEXPANSION
#define RFEXPANSION
#define IOEXPANSION



#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 <RF.h>
#include <IO.h>
#include <ReefAngel.h>

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

// LEDPWM Channel defines for easy code reading
#define LEDPWM0 0
#define LEDPWM1 1
#define LEDPWM2 2
#define LEDPWM3 3

// Initial values to all 6 channels at startup. They will always be 0.
byte PWMChannel[]={
0,0,0,0,0,0};


////// 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(Port2);
    ReefAngel.Relay.On(Port5);
    ReefAngel.Relay.On(Port6);
    ReefAngel.Relay.On(Port7);
    ReefAngel.Relay.On(Port8);
    ////// Place additional initialization code below here
    
    
    ////// Place additional initialization code above here
}

void loop()
{
       ////// Place your custom code below here
    
//Start of PWM Expansion Code for Slope
    PWMChannel[LEDPWM0]=PWMSlope(11,00,17,00,20,80,60,PWMChannel[LEDPWM0]);
    PWMChannel[LEDPWM1]=PWMSlope(10,00,18,00,20,80,60,PWMChannel[LEDPWM1]);
    PWMChannel[LEDPWM2]=PWMSlope(9,30,18,30,20,80,30,PWMChannel[LEDPWM2]);
    PWMChannel[LEDPWM3]=PWMSlope(10,30,17,30,20,80,30,PWMChannel[LEDPWM3]);
    
    // The lines above are what calculates the slope.
    // You can change the schedule by changing the parameter inside the parenthesis of the PWMSlope() function
    // The are as follow:
    // 1st parameter: hour to start slope
    // 2nd parameter: minute to start slope
    // 3rd parameter: hour to end slope
    // 4th parameter: minute to end slope
    // 5th parameter: % of the PWM signal to start slope
    // 6th parameter: % of the PWM signal to end slope
    // 7th parameter: duration of slope in minutes
    // 8th parameter: always the same as the variable before the PWMSlope() call

    ////// Place your custom code above here

    // This should always be the last line

  ReefAngel.ShowInterface();  
}
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: PWM Expansion difficulties

Post by rimai »

Your code looks just fine to me.
Did you place the jumper on the head unit?
Roberto.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: PWM Expansion difficulties

Post by rimai »

Actually, I'm sorry.
Tired today. I should go rest for a bit....
On 2nd look, the code is actually not doing anything.
Try this:

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 <RF.h>
#include <IO.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(Port2);
    ReefAngel.Relay.On(Port5);
    ReefAngel.Relay.On(Port6);
    ReefAngel.Relay.On(Port7);
    ReefAngel.Relay.On(Port8);
    ////// Place additional initialization code below here
    
    
    ////// Place additional initialization code above here
}

void loop()
{
       ////// Place your custom code below here
    
//Start of PWM Expansion Code for Slope
    ReefAngel.PWM.SetChannel(0,PWMSlope(11,00,17,00,20,80,60,0));
    ReefAngel.PWM.SetChannel(1,PWMSlope(10,00,18,00,20,80,60,0));
    ReefAngel.PWM.SetChannel(2,PWMSlope(9,30,18,30,20,80,30,0));
    ReefAngel.PWM.SetChannel(3,PWMSlope(10,30,17,30,20,80,30,0));
    
    // The lines above are what calculates the slope.
    // You can change the schedule by changing the parameter inside the parenthesis of the PWMSlope() function
    // The are as follow:
    // 1st parameter: hour to start slope
    // 2nd parameter: minute to start slope
    // 3rd parameter: hour to end slope
    // 4th parameter: minute to end slope
    // 5th parameter: % of the PWM signal to start slope
    // 6th parameter: % of the PWM signal to end slope
    // 7th parameter: duration of slope in minutes
    // 8th parameter: always the same as the variable before the PWMSlope() call

    ////// Place your custom code above here

    // This should always be the last line

  ReefAngel.ShowInterface();  
}
Roberto.
c_wick
Posts: 25
Joined: Tue May 22, 2012 2:41 pm

Re: PWM Expansion difficulties

Post by c_wick »

No changes Roberto...lights still pumping full power. Not sure if this matters much, I figured a ground is a ground...but...when wiring the PWM Expansion Module everytime I hooked the 12V Adapter ground wire to the ground on the Module the adapter shorted out. Right now I have all 4 drivers hooked into channel 0,1,2,3 on the Module and the 12V adapter hot wire in the +12VDC spot and all the ground drivers plus the ground from the 12V adapter soldered together, separate from the Module. When I do it this way the lights work...not sure if this is the reason why the lights aren't dimming...what do you think?
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: PWM Expansion difficulties

Post by rimai »

Yes, this is the reason.
You need the ground reference from the module to be the same as everything else and leaving disconnected you create 2 ground references.
But it should not short out when you connect the ground.
Can you descrive what happens when you say it shorts out?
Roberto.
c_wick
Posts: 25
Joined: Tue May 22, 2012 2:41 pm

Re: PWM Expansion difficulties

Post by c_wick »

Ok, after the + wire is hooked on the +12VDC spot on the module as soon as I touch the ground wire to the module the green light on the adapter goes out...figured it was shorting...
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: PWM Expansion difficulties

Post by rimai »

Yeah, that is definitelly not normal behavior.
Does it do the same thing even without the drivers connected?
PM me to send it for repair.
Roberto.
c_wick
Posts: 25
Joined: Tue May 22, 2012 2:41 pm

Re: PWM Expansion difficulties

Post by c_wick »

Thanks Roberto, just got your package in the mail, installed the module, hooked the wiring up...everything works like a champ! Thank you again for all your quick responses and great service!
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: PWM Expansion difficulties

Post by rimai »

Cool. Glad it's working :)
Roberto.
Post Reply