Basic 2 channel PWM setup

New members questions
Post Reply
gaberosenfield
Posts: 89
Joined: Thu Mar 08, 2012 5:11 pm
Location: Redwood City, California

Basic 2 channel PWM setup

Post by gaberosenfield »

I apologize for posting this noob question in advance, but I simply cannot find an understandable explanation anywhere. I want to set up PWM dimming for my DIY LEDs. I have 2 PWM dimmable meanwell drivers, one for blues and one fore whites. All I want is an explanation of how to set up PWM dimming so that I have sunrise/sunset effects. It seems so easy with RAGEN, but I get errors and don't know how to fix them. Here's what I have from RAGEN:

Code: Select all

// Autogenerated file by RAGen (v1.2.1.158), (04/28/2012 21:03)
// RA_042812_2103.pde
//
// This version designed for v0.8.5 Beta 17 or later

/* The following features are enabled for this File: 
#define DisplayImages
#define DateTimeSetup
#define VersionMenu
#define DirectTempSensor
#define DisplayLEDPWM
#define SaveRelayState
#define SIMPLE_MENU
*/


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


void setup()
{
    ReefAngel.Init();  //Initialize controller

    // Ports that are always on
    ReefAngel.Relay.On(Port5);
}

void loop()
{
    // Specific functions
    ReefAngel.StandardLights(Port1);
    ReefAngel.StandardLights(Port2);
    ReefAngel.StandardLights(Port3);
    ReefAngel.StandardLights(Port4);
    ReefAngel.StandardHeater(Port6);
    ReefAngel.DosingPump1(Port7);
    ReefAngel.DosingPump2(Port8);

    ReefAngel.PWM.SetActinic(PWMSlope(
        InternalMemory.StdLightsOnHour_read(),
        InternalMemory.StdLightsOnMinute_read(),
        InternalMemory.StdLightsOffHour_read(),
        InternalMemory.StdLightsOffMinute_read(),
        InternalMemory.PWMSlopeStartA_read(),
        InternalMemory.PWMSlopeEndA_read(),
        InternalMemory.PWMSlopeDurationA_read(),
        ReefAngel.PWM.GetActinicValue()
        ));
    ReefAngel.PWM.SetDaylight(PWMSlope(
        InternalMemory.StdLightsOnHour_read(),
        InternalMemory.StdLightsOnMinute_read(),
        InternalMemory.StdLightsOffHour_read(),
        InternalMemory.StdLightsOffMinute_read(),
        InternalMemory.PWMSlopeStartD_read(),
        InternalMemory.PWMSlopeEndD_read(),
        InternalMemory.PWMSlopeDurationD_read(),
        ReefAngel.PWM.GetDaylightValue()
        ));

    ReefAngel.ShowInterface();
}
Its pretty intuitive that I put the On hours and minutes in each of their respective places, and after looking at the PWMSlope example file I understand what arguments go in the other places as well (I assume that nothing goes in the GetDaylightVlaue() argument). But when I try to compile this I get all kinds of crazy errors saying that none of my files or directories exist, despite the fact that the libraries folder is exactly where the error message says it is and the files are in that directory... What happened and what should I do to fix this?
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Basic 2 channel PWM setup

Post by binder »

The code looks good for the 0.8.5.X version of the libraries.

What version of the libraries do you have installed on your computer? If you are using the newest libraries and the newest ReefAngel Installer, then this code will not work because of the changes to the libraries.

Could you please post the first grouping of the errors that Arduino displays? That will be helpful in determining what is going on.
gaberosenfield
Posts: 89
Joined: Thu Mar 08, 2012 5:11 pm
Location: Redwood City, California

Re: Basic 2 channel PWM setup

Post by gaberosenfield »

Ok, I think I fixed the issue. I had a mismatched version of the libraries and the controller software/RAGEN. I uninstalled everything and re-installed everything and now the errors are gone and I believe everything is working. Sorry to junk up the forum with this thread!
gaberosenfield
Posts: 89
Joined: Thu Mar 08, 2012 5:11 pm
Location: Redwood City, California

Re: Basic 2 channel PWM setup

Post by gaberosenfield »

I think I spoke too soon. Now I get the following when I try to update my controller's internal memory:

Code: Select all

Binary sketch size: 5,584 bytes (of a 32,256 byte maximum)
C:\Program Files\Reef Angel Controller\hardware/tools/avr/bin/avrdude -CC:\Program Files\Reef Angel Controller\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -carduino -P\\.\COM1 -b115200 -D -V -Uflash:w:C:\DOCUME~1\SPINAL~1\LOCALS~1\Temp\build8691695433584287442.tmp\Memory_042912_1955.cpp.hex:i 

avrdude: Version 6.0, compiled on Apr  6 2012 at 19:29:19
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\Program Files\Reef Angel Controller\hardware/tools/avr/etc/avrdude.conf"

         Using Port                    : \\.\COM1
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
Rebooting Reef Angel Controller
avrdude: Send: 0 [30]   [20] 
avrdude: Send: 0 [30]   [20] 
avrdude: Send: 0 [30]   [20] 
avrdude: Recv: 
avrdude: stk500_getsync(): not in sync: resp=0x64

avrdude done.  Thank you.

And my internal memory is not updated. I think the problem is that the arduino window (whatever you're supposed to call the program in which you can code) will not give me the option to use COM3. I can only use COM1 or COM4. How can I fix this?
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Basic 2 channel PWM setup

Post by rimai »

Try COM4
Roberto.
gaberosenfield
Posts: 89
Joined: Thu Mar 08, 2012 5:11 pm
Location: Redwood City, California

Re: Basic 2 channel PWM setup

Post by gaberosenfield »

I tryed both COM1 and COM4
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Basic 2 channel PWM setup

Post by rimai »

Which version Reef Angel Installer did you install??
Did you follow the steps of pluging the USB cable at the right time?
The order of those steps is very important or you may miss one important setting when windows install the driver for the USB cable.
Roberto.
gaberosenfield
Posts: 89
Joined: Thu Mar 08, 2012 5:11 pm
Location: Redwood City, California

Re: Basic 2 channel PWM setup

Post by gaberosenfield »

Figured it out. I had some various outdated drivers that I fixed and all is well again. Sorry for the second false alarm in a row. I'm becoming the boy who cried wolf.
Post Reply