Well, noone replied on that last issue, but somehow it fixed itself. Maybe the controller just needed to be reset or something because when I booted it up again last night, the MHLights functions were working perfectly for the expansion relay box ports. Yay!
OK, I'm getting closer to getting my code finalized. Here's my Internal Memory File:
Code: Select all
// Autogenerated file by RAGen (v1.2.1.158), (02/19/2012 15:48)
// Memory_021912_1548.ino
//
// This file sets the default values to the Internal Memory
//
#include <ReefAngel_Features.h>
#include <Globals.h>
#include <Time.h>
#include <OneWire.h>
#include <RA_NokiaLCD.h>
#include <avr/pgmspace.h>
#include <InternalEEPROM.h>
#include <Wire.h>
#include <Memory.h>
RA_NokiaLCD e;
void setup()
{
e.Init();
e.Clear(COLOR_WHITE,0,0,132,132);
e.BacklightOn();
InternalMemory.MHOnHour_write(9);
InternalMemory.MHOnMinute_write(55);
InternalMemory.MHOffHour_write(20);
InternalMemory.MHOffMinute_write(30);
InternalMemory.MHDelay_write(5);
InternalMemory.StdLightsOnHour_write(8);
InternalMemory.StdLightsOnMinute_write(0);
InternalMemory.StdLightsOffHour_write(22);
InternalMemory.StdLightsOffMinute_write(0);
InternalMemory.DP1OnHour_write(20);
InternalMemory.DP1OnMinute_write(0);
InternalMemory.DP2OnHour_write(22);
InternalMemory.DP2OnMinute_write(30);
InternalMemory.DP1Timer_write(0);
InternalMemory.DP2Timer_write(0);
InternalMemory.DP1RepeatInterval_write(60);
InternalMemory.DP2RepeatInterval_write(60);
InternalMemory.ATOTimeout_write(60);
InternalMemory.ATOHighTimeout_write(60);
InternalMemory.ATOHourInterval_write(0);
InternalMemory.ATOHighHourInterval_write(0);
InternalMemory.FeedingTimer_write(900);
InternalMemory.LCDTimer_write(600);
InternalMemory.LEDPWMActinic_write(50);
InternalMemory.LEDPWMDaylight_write(50);
InternalMemory.WM1Timer_write(0);
InternalMemory.WM2Timer_write(354);
InternalMemory.HeaterTempOn_write(780);
InternalMemory.HeaterTempOff_write(791);
InternalMemory.ChillerTempOn_write(810);
InternalMemory.ChillerTempOff_write(785);
InternalMemory.OverheatTemp_write(1500);
InternalMemory.PHMax_write(840);
InternalMemory.PHMin_write(550);
InternalMemory.SalMax_write(2550);
InternalMemory.RFMode_write(Constant);
InternalMemory.RFSpeed_write(140);
InternalMemory.RFDuration_write(8);
InternalMemory.RFDuration_write(8);
InternalMemory.PWMSlopeStartD_write(10);
InternalMemory.PWMSlopeEndD_write(128);
InternalMemory.PWMSlopeDurationD_write(60);
InternalMemory.PWMSlopeStartA_write(10);
InternalMemory.PWMSlopeEndA_write(128);
InternalMemory.PWMSlopeDurationA_write(60);
InternalMemory.IMCheck_write(0x5241494D);
}
void loop()
{
// display success screen
e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*2, "Internal Memory Set");
e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*4, "Now load your");
e.DrawText(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*5, " RA code file");
delay(5000);
}
Here's my latest .ino file:
Code: Select all
// Autogenerated file by RAGen (v1.2.1.158), (02/21/2012 22:03)
// RA_022112_2203.ino
//
// This version designed for v0.9.0 or later
/* The following features are enabled for this File:
#define DirectTempSensor
#define DisplayLEDPWM
#define wifi
#define SaveRelayState
#define RelayExp
#define InstalledRelayExpansionModules 1
#define CUSTOM_MENU
#define CUSTOM_MENU_ENTRIES 1
#define PWMEXPANSION
#define CUSTOM_MAIN
#define RFEXPANSION
*/
#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 <ReefAngel.h>
//**************************************************************************************************************
//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
//*************************************************************************************************************
boolean ForceCloud=false;
prog_char menu0_label[] PROGMEM = "Feeding Mode";
prog_char menu1_label[] PROGMEM = "Water Change Mode";
prog_char menu2_label[] PROGMEM = "Force Cloud";
prog_char menu3_label[] PROGMEM = "Clear ATO Timeout";
PROGMEM const char *menu_items[] = {
menu0_label, menu1_label, menu2_label, menu3_label};
void MenuEntry1()
{
ReefAngel.FeedingModeStart();
}
void MenuEntry2()
{
ReefAngel.WaterChangeModeStart();
}
void MenuEntry3()
{
ForceCloud=true;
ReefAngel.DisplayedMenu=RETURN_MAIN_MODE;
}
void MenuEntry4()
{
ReefAngel.ATOClear();
ReefAngel.DisplayedMenu=RETURN_MAIN_MODE;
}
#include <avr/pgmspace.h>
void DrawCustomMain()
{
//Draw Top Banner
ReefAngel.LCD.DrawText(COLOR_BLACK, COLOR_SKYBLUE, 9, 2, " George's 75G Reef ");
//Draw Date & Time
ReefAngel.LCD.DrawDate(6, 123);
pingSerial();
#if defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor(15, 30, ReefAngel.Params,
ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue());
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor(15, 30, ReefAngel.Params);
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
pingSerial();
// Display Main Relay Box
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox(13, 97, TempRelay);
pingSerial();
// Display Expansion Relay Box 1
TempRelay = ReefAngel.Relay.RelayDataE[0];
TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
ReefAngel.LCD.DrawOutletBox(13, 109, TempRelay);
pingSerial();
}
void DrawCustomGraph()
{
}
void setup()
{
ReefAngel.Init(); //Initialize controller
ReefAngel.InitMenu(pgm_read_word(&(menu_items[0])),SIZE(menu_items));
ReefAngel.FeedingModePorts = B10000001;
ReefAngel.WaterChangePorts = B11100001;
ReefAngel.OverheatShutoffPortsE[0] = B00001111;
ReefAngel.LightsOnPortsE[0] = B00001111;
// Ports that are always on
ReefAngel.Relay.On(Port1);
ReefAngel.Relay.On(Port3);
ReefAngel.Relay.On(Port5);
ReefAngel.Relay.On(Port6);
ReefAngel.Relay.On(Port7);
ReefAngel.Relay.On(Port8);
ReefAngel.Relay.On(Box1_Port7);
ReefAngel.Relay.On(Box1_Port8);
}
void loop()
{
// Specific functions
ReefAngel.StandardHeater(Port2);
ReefAngel.StandardLights(Box1_Port1); //Left Blue LEDs
ReefAngel.StandardLights(Box1_Port2); //Right Blue LEDs
ReefAngel.MHLights(Box1_Port3); //Left White LEDs
ReefAngel.MHLights(Box1_Port4); //Right White LEDs
ReefAngel.MoonLights(Box1_Port5); //Left Moonlight
ReefAngel.MoonLights(Box1_Port6); //Right Moonlight
ReefAngel.MoonLights(Port4); //Fuge light on when main lights are out
ReefAngel.PWM.ActinicPWMSlope();
ReefAngel.PWM.DaylightPWMSlope();
ReefAngel.Portal("TanksNStuff");
//*********************************************************************************************************************************
//Start of PWM Expansion Code for Slope
PWMChannel[LEDPWM0]=PWMSlope(8,0,22,00,9,50,60,PWMChannel[LEDPWM0]);
PWMChannel[LEDPWM1]=PWMSlope(8,0,22,00,10,50,60,PWMChannel[LEDPWM1]);
PWMChannel[LEDPWM2]=PWMSlope(10,0,20,30,9,50,75,PWMChannel[LEDPWM2]);
PWMChannel[LEDPWM3]=PWMSlope(10,0,20,30,10,50,75,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
//PWMChannel[LEDPWM1]=PWMSlope(15,0,21,30,15,45,90,PWMChannel[LEDPWM1]);
// In the example above, we are starting the slope at 3:00pm with 15% and going up to 45% within 90 minutes, which would be 4:30pm.
// Then it would stay at 45% from 4:30 to 90 minutes prior to 9:30pm, which would be 8:00pm.
// Then from 8:00pm, it would start sloping down from 45% all the way back to 15% within 90 minutes, which would be 9:30pm.
//CheckCloud();
ReefAngel.PWM.Expansion(LEDPWM0,int(2.55*PWMChannel[LEDPWM0]));
ReefAngel.PWM.Expansion(LEDPWM1,int(2.55*PWMChannel[LEDPWM1]));
ReefAngel.PWM.Expansion(LEDPWM2,int(2.55*PWMChannel[LEDPWM2]));
ReefAngel.PWM.Expansion(LEDPWM3,int(2.55*PWMChannel[LEDPWM3]));
//End of PWM Expansion Code for Slope
//*********************************************************************************************************************************
ReefAngel.ShowInterface();
}
As you can see, I copy/pasted from some stuff I found on these forums to get the basic functions I needed, then tweaked them to match my setup.
I was able to test 1 of my LED lights with the modified PWM module (Roberto made one Analog for me) and that seemed to work fine with my code above. I did a test run with the PWM slope to make it ramp up quickly for each channel... just to see it brighten in real time as if time were going by faster. Worked great! After the test, I changed the slope back to what I have in the .ino above. I also temporarily changed the On Hour and On Minutes for standard and MH Light ports to match my test PWM slope times via WiFi and the Android App... and that worked like a champ too! As with the the other test, I then reset those internal memory settings back to what my internal memory file above shows.
I didn't try both LED's (and therefore didn't test the other 2 PWM channels) but I'm pretty confident that they will all work based on what I saw with the tests. Roberto, I want to do a few more tests before sending my old PWM module back to you if you don't mind but everything looks great so far. Should be going back to you by monday. **NOTE TO SELF** I still need to check if 1% - 9% signal turns lights on instead of needing 10% signal (now that I have modified analog signal for PWM module).
Now, some issues I'm having that keep this topic's thread open....running out of code space and I need more functions.
1. If you noticed, there's a menu item for "Force Cloud", along with some variables needed for that function. However, when I added the code I found to make that function happen, it made my file too big. Looks like I'm going to have to remove that from the menu and remove the variables associated with it.
2. As with the cloud function, I don't think there's any way I'll be able to have any storm functions either.
3. When I was about passing out at my computer, I tried to add some code for the RF Module (that I just got yesterday too). Do I need to do anything other than enable it in RAGen? I see there are memory seetings I can change in the Android App, but since my controller isn't live on my tank yet I didn't set my MP40 to slave to test any of them. I'm hoping I don't need any other code for this as that would take up more space I don't have.
4. I still need to add lines in the code to set FEED MODE (I want 2 automatic runs during the day for 15 minutes each, and then use the Android App to enter that mode when I feed manually. I'm guessing this should be a few simple IF/ELSE lines but I'm running out of room fast.
5. Not sure about my moonlights. I think they came on when both Standard and MH lights were off, so I probably don't need to do much else for them. I did assign them to the appropriate relay ports in my code, so is that enough to have them come on automatically? I don't see any moonlight memory settings in the Android App, so I'm guessing they operate opposite the MH/Standard ON/OFF times? I still may want to select a specified OFF time for moonlights though, and that will need to fit in regardless.
6. Not really a file size issue, but something that I need help with. Is there any way to change the PWMChannel slope settings via WiFi (via Android App or Client) so that I don't have to re-upload code when I want to adjust the settings? I know Curt said it's on the todo list for the Android App. Can I even just do it on my PC via the WiFi default page or something? If/when this gets added to Android App, it may save me a few lines of code that I used assigning the PWMChannel labels, etc.
7. I know this is on the todo list for Curt too, but it would really be helpful to see/change status of the expansion relay box ports on Android.
Even though that's a lot of questions, I think I made great progress last night. Unfortunately, I'm sure I'll have more to resolve after trying to tackle more of the above tonight.