Page 1 of 1
PWMSlope Behavior
Posted: Mon Aug 01, 2011 4:58 pm
by icecool2
I'm having some issues with the PWMSlope function. If you enter into the function inside of the time window for making a change, the function doesn't seem to work. For example, if I restart my controller at 6:00p and it is set to fade out from 5:00p to 7:00p, the PWMSlope function only returns the top value rather than the current value it should be at based on the time.
Maybe I'm having a strange problem... Here's my code:
Code: Select all
ReefAngel.PWM.SetActinic(PWMSlope(11,0,20,0,100,70,120,ReefAngel.PWM.GetActinicValue()));
Re: PWMSlope Behavior
Posted: Mon Aug 01, 2011 5:14 pm
by rimai
The PWMSlope function does not work with inverted values.
The parameters you are using is for a slope from 11:00 to 20:00 going from 100% to 70% within 120 minutes.
Is this what you had in mind? Inverted slope?
If this was not what you wanted, here is the correct way of using the slope function:
Code: Select all
ReefAngel.PWM.SetActinic(PWMSlope(11,0,20,0,70,100,120,ReefAngel.PWM.GetActinicValue()));
Re: PWMSlope Behavior
Posted: Mon Aug 01, 2011 5:18 pm
by icecool2
That could explain the problem. My LEDs run inverted to the default values. 100 = off, 0 = on.
Re: PWMSlope Behavior
Posted: Mon Aug 01, 2011 5:20 pm
by rimai
Try this:
Code: Select all
ReefAngel.PWM.SetActinic(100-PWMSlope(11,0,20,0,0,30,120,ReefAngel.PWM.GetActinicValue()));
Let me know if this works for you.
Re: PWMSlope Behavior
Posted: Tue Aug 02, 2011 6:49 am
by icecool2
I need to spend some more time looking at this, but I'm seeing a strange behavior with that. One iteration of the loop returns the correct value, a second iteration of the loop returns only the slope value and then that repeats.
For example:
Actinic: 97
Actinic: 3
Actinic: 97
Actinic: 3
I'm pretty sure I wiped out everything that could be overriding the SetActinic call, but I will need to double check that again.
Re: PWMSlope Behavior
Posted: Tue Aug 02, 2011 8:54 am
by rimai
Hum...
I remember now.
You are correct.
You have to create a new variable to hold value, otherwise the GetActinicValue will keep doing that.
This is what you need:
Above the setup() section:
In the loop() section:
Code: Select all
BuckPuckActinic=PWMSlope(11,0,20,0,0,30,120,BuckPuckActinic);
ReefAngel.PWM.SetActinic(100-BuckPuckActinic);
Buckpucks use the same PWM values... 100=off and 0=on
I made this code for nanotrevor, who uses buckpucks and needed inverted values too:
Code: Select all
// Autogenerated file by RAGen (v1.0.4.92), (06/03/2011 21:13)
// RA_060311_2113.pde
//
// This version designed for v0.8.5 Beta 12 or later
/* The following features are enabled for this PDE File:
#define DisplayImages
#define DateTimeSetup
#define VersionMenu
#define ATOSetup
#define DirectTempSensor
#define DisplayLEDPWM
#define SingleATOSetup
#define StandardLightSetup
*/
#include <ReefAngel_Colors.h>
#include <ReefAngel_CustomColors.h>
#include <ReefAngel_Features.h>
#include <ReefAngel_Globals.h>
#include <ReefAngel_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <ReefAngel_EEPROM.h>
#include <ReefAngel_NokiaLCD.h>
#include <ReefAngel_ATO.h>
#include <ReefAngel_Joystick.h>
#include <ReefAngel_LED.h>
#include <ReefAngel_TempSensor.h>
#include <ReefAngel_Relay.h>
#include <ReefAngel_PWM.h>
#include <ReefAngel_Timer.h>
#include <ReefAngel_Memory.h>
#include <ReefAngel.h>
byte BuckPuckActinic=0;
byte BuckPuckDaylight=0;
void setup()
{
ReefAngel.Init(); //Initialize controller
ReefAngel.FeedingModePorts = B00000001; //turns off return pump
ReefAngel.WaterChangePorts = B01110001; //turns off return pump, heater, fan/chiller and ATO
ReefAngel.OverheatShutoffPorts = B00101110; //turns off lights and heater
ReefAngel.LightsOnPorts = B00001110; //turns on lights
// Ports that are always on
ReefAngel.Relay.On(Port1);
ReefAngel.Relay.On(Port8);
}
void loop()
{
ReefAngel.ShowInterface();
if (hour(now())<12)
BuckPuckActinic=PWMSlope(7,0,9,0,0,60,60,BuckPuckActinic); //actinic leds ramp up from 0% at 7:30am to 60% at 8:30am and ramp down from 6:00pm to 7:00pm back to 0%
else
BuckPuckActinic=PWMSlope(19,0,20,0,0,60,60,BuckPuckActinic); //actinic leds ramp up from 0% at 7:30am to 60% at 8:30am and ramp down from 6:00pm to 7:00pm back to 0%
BuckPuckDaylight=PWMSlope(8,30,18,0,0,60,60,BuckPuckDaylight); //daylight leds ramp up from 0% at 8:30am to 50% at 9:30am and ramp down from 5:00pm to 6:0pm back to 0%
ReefAngel.PWM.SetActinic(100-BuckPuckActinic); // invert value for buckpucks
ReefAngel.PWM.SetDaylight(100-BuckPuckDaylight); // invert value for buckpucks
// Specific functions
ReefAngel.StandardLights(Port2);
ReefAngel.StandardLights(Port3);
ReefAngel.StandardLights(Port4);
ReefAngel.StandardFan(Port5);
ReefAngel.StandardHeater(Port6);
ReefAngel.SingleATOHigh(Port7);
}
Re: PWMSlope Behavior
Posted: Tue Aug 02, 2011 9:26 am
by icecool2
I'll give that a shot this evening and report back.
Re: PWMSlope Behavior
Posted: Tue Aug 02, 2011 2:24 pm
by NanoTrevor
hey ice, that should set you up, i run pucks also and roberto gave me the inverted code and they work perfect. only issue is that the values displayed will be inverted, if you have code at like 70% the display will read 30%, what binder said i could do is go into the reefangel_nokia cpp and towards the bottom put the 100- in front on the display pwm line stuff
looks like this;
DrawText(DPColor,DefaultBGColor,x+60,y+10,"DP:");
DrawSingleMonitor(100-DaylightPWMValue, DPColor, x+78, y+10,1);
DrawText(APColor,DefaultBGColor,x+60,y+20,"AP:");
DrawSingleMonitor(100-ActinicPWMValue, APColor, x+78, y+20,1);
Re: PWMSlope Behavior
Posted: Wed Aug 03, 2011 7:43 am
by icecool2
Thanks. That code did work.
Trevor, thanks for the tip! I actually didn't realize those values were on the front panel
Re: PWMSlope Behavior
Posted: Thu Aug 04, 2011 8:00 am
by NirvanaandTool
Hmm. Bookmarking this when I actually get brave enough to wire my Buckpucks into my RA.
Did you guys just run Ref into + on the RA and - off the LED to - on the RA like in the Wiring guide for the Puck?
Re: PWMSlope Behavior
Posted: Thu Aug 04, 2011 8:08 am
by rimai
nanotrevor is having a hard time with pucks.
In my opinion, the way the pucks were designed is wrong, but that's just me. They may think the same thing of my controller design.
The issue he's having is exactly because of the - from RA connecting to LED string directly. The LED string is a high side of the driver and creates disturbunces and noise that is carried to the RA, causing it to lock-up or present weird behaviors.
I'm working with him on trying to isolate the 2 sides with opto-isolators, which should take care of his noise problem.
Re: PWMSlope Behavior
Posted: Fri Aug 05, 2011 1:26 pm
by icecool2
Well, you can mark Recom drivers as compatible with your design. I do have some isolation built into my PCB, but nothing unusual that you wouldn't expect any novice to design in.
Re: PWMSlope Behavior
Posted: Fri Aug 05, 2011 3:41 pm
by NirvanaandTool
rimai wrote:nanotrevor is having a hard time with pucks.
In my opinion, the way the pucks were designed is wrong, but that's just me. They may think the same thing of my controller design.
The issue he's having is exactly because of the - from RA connecting to LED string directly. The LED string is a high side of the driver and creates disturbunces and noise that is carried to the RA, causing it to lock-up or present weird behaviors.
I'm working with him on trying to isolate the 2 sides with opto-isolators, which should take care of his noise problem.
Hmm gotcha. Would it be better to build that circuit they describe on the wiring diagram in order to have them run in a non-inverted state?
Re: PWMSlope Behavior
Posted: Sat Aug 06, 2011 5:39 pm
by rimai
I don't think that would solve the issue. The biggest problem is connecting the LED- to RA ground.
Re: PWMSlope Behavior
Posted: Sat Aug 06, 2011 8:48 pm
by NanoTrevor
rimai wrote:I don't think that would solve the issue. The biggest problem is connecting the LED- to RA ground.
if its wired with a transistor there is no - led connection. i tried it, i have the parts but didn't have any luck, i wired the other way cause it was quick and worked with the code inversion...but this would prob solve all probs to wire this way
Re: PWMSlope Behavior
Posted: Sun Aug 07, 2011 8:24 am
by rimai
The picutre above would never work the way it is.
The signal LO/HI needs a ground reference, which isn't represented in the design.
Re: PWMSlope Behavior
Posted: Sun Aug 07, 2011 9:07 am
by NanoTrevor
rimai wrote:The picutre above would never work the way it is.
The signal LO/HI needs a ground reference, which isn't represented in the design.
hmm, prob why it didn't work for me, i thought i wired it wrong somehow.
Re: PWMSlope Behavior
Posted: Sun Aug 07, 2011 9:22 am
by rimai
icecool2 wrote:Well, you can mark Recom drivers as compatible with your design. I do have some isolation built into my PCB, but nothing unusual that you wouldn't expect any novice to design in.
Can you post your schematics?
I'm interested to know how you connected the RA GND to your drivers.
I'm starting to think I originally led nanotrevor into the wrong path
Re: PWMSlope Behavior
Posted: Sun Aug 07, 2011 12:34 pm
by NanoTrevor
rimai wrote:icecool2 wrote:Well, you can mark Recom drivers as compatible with your design. I do have some isolation built into my PCB, but nothing unusual that you wouldn't expect any novice to design in.
Can you post your schematics?
I'm interested to know how you connected the RA GND to your drivers.
I'm starting to think I originally led nanotrevor into the wrong path
Re: PWMSlope Behavior
Posted: Sun Aug 07, 2011 6:00 pm
by rimai
Sorry Trevor...
I've been reading lots of places that people just have these problems with the buckpucks. Not just you.
The solution always seems to be optoisolation, like we've been working on.
But, there was a couple of places where they mention connecting the Vin- to ground, instead of LED- to ground.
I don't know if that would make any difference on the whole issue, but it would be worth trying.
Re: PWMSlope Behavior
Posted: Sun Aug 07, 2011 7:10 pm
by NanoTrevor
rimai wrote:Sorry Trevor...
I've been reading lots of places that people just have these problems with the buckpucks. Not just you.
The solution always seems to be optoisolation, like we've been working on.
But, there was a couple of places where they mention connecting the Vin- to ground, instead of LED- to ground.
I don't know if that would make any difference on the whole issue, but it would be worth trying.
i actually tried that on another arduino based controller i had tried and it didn't work connecting to vin - instead of led -
Re: PWMSlope Behavior
Posted: Mon Aug 08, 2011 5:00 pm
by icecool2
Sorry, I don't have a schematic handy. I have a current limiting resistor on the signal line from the RA to the driver. On the driver side, I have the digital ground separated from the analog ground and joined with a small bridge. There is also a weak pull up on the driver as well. I have the GND from the RA run to the digital ground of the drivers. The analog grounds are connected on the AC side between the RA and the power supplies for my drivers.
Re: PWMSlope Behavior
Posted: Wed Aug 17, 2011 8:08 am
by NirvanaandTool
Yikes. Sounds like problems all over.
Maybe I'll skip trying to get the Buckpucks to run off the PWM and get some RA moonlights instead.