setting memory with client/iphone app problem

Do you have a question on how to do something.
Ask in here.
Post Reply
psyrob
Posts: 242
Joined: Thu Sep 01, 2011 8:44 pm

setting memory with client/iphone app problem

Post by psyrob »

Every since I loaded this code below, my lights won't follow the schedule that my client and iphone app have entered...the daylights and actinics are coming on too early and are coming on together, and they are not shutting off at all at night. I am having to mask them on or off to get them to be on and off at the right times.

I used the wizard to generate the initial times, which had the actinics come on an hour before the daylights, then used the client to switch them to actnics on at 11 am and off at 10 pm, and daylights on at 1pm and off at 8:45...any ideas as to why they are not following this schedule?

thanks

Code: Select all

//July 7, 2012, first try with the new 1.0.0 libraries
//Latest, uploaded July 8th, with wavemaker fixes and new screen.  Moonlights NOT coded...

#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 <ORP.h>
#include <AI.h>
#include <ReefAngel.h>

////// Place global variable code below here
time_t WMRTimer=now();
boolean wmdelay=false;
byte wmport=Port5;

////// Place global variable code above here
void DrawCustomMain()
{
  // the graph is drawn/updated when we exit the main menu &
  // when the parameters are saved
  ReefAngel.LCD.DrawDate(6, 120);
  ReefAngel.LCD.DrawLargeText(COLOR_DARKTURQUOISE, COLOR_WHITE, 4, 4 , "ROB'S REEF ANGEL");
  ReefAngel.LCD.Clear(COLOR_MAROON, 1, 13, 132, 13);
  ReefAngel.LCD.Clear(COLOR_MAROON, 10, 37, 119, 37);
  ReefAngel.LCD.Clear(COLOR_MAROON, 10, 75, 119, 75);
  ReefAngel.LCD.Clear(COLOR_MAROON, 10, 59, 119, 59);
  pingSerial();

  ReefAngel.LCD.DrawLargeText(COLOR_GOLDENROD, COLOR_WHITE, 6, 15, "Display");
  ReefAngel.LCD.DrawLargeText(COLOR_GOLDENROD, COLOR_WHITE, 18, 27, "Tank");
  char text[7];
  ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
  pingSerial();
  ReefAngel.LCD.DrawHugeText(COLOR_GOLDENROD, DefaultBGColor, 65, 17, text);
  pingSerial(); 

  ReefAngel.LCD.DrawText(COLOR_RED, COLOR_WHITE,72,39,"Frag:");
  ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T3_PROBE], COLOR_RED, 104, 39, 10);
  ReefAngel.LCD.DrawText(COLOR_DARKORCHID, COLOR_WHITE,72,48,"Room:");
  ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T2_PROBE], T2TempColor, 104, 48, 10);
  //ReefAngel.LCD.DrawText(COLOR_TEAL, COLOR_WHITE, 72, 39,"Moon Phase");
  pingSerial();
  
  ReefAngel.LCD.DrawLargeText(COLOR_MEDIUMSEAGREEN, COLOR_WHITE, 8, 44, "pH:");
  ConvertNumToString(text, ReefAngel.Params.PH, 100);
  ReefAngel.LCD.DrawLargeText(PHColor, DefaultBGColor, 35, 44, text);
  pingSerial();
 

  ReefAngel.LCD.DrawText(DPColor,DefaultBGColor, 5, 64,"WAVE FLOW:");
  if (bitRead(ReefAngel.Relay.RelayData,Port5-1)==1) ReefAngel.LCD.DrawText(APColor,DefaultBGColor, 67, 64,"----->"); //port 5 on
  else if (bitRead(ReefAngel.Relay.RelayData,Port6-1)==1) ReefAngel.LCD.DrawText(APColor,DefaultBGColor, 67, 64,"<-----");  //port 6 on
  else ReefAngel.LCD.DrawText(APColor,DefaultBGColor, 67, 64," 00000 "); //port5 and port 6 off, wavemaker delay: taken away for the
  

  //show the timer for wavemaker
  int t=WMRTimer-now();
  if (t>=0)
    ReefAngel.LCD.Clear(255,105,64,135,74);
  ReefAngel.LCD.DrawText(APColor, COLOR_KHAKI,110,64,t);

  pingSerial();

  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,10,79,"Actinic");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,10,89,"FragLt");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,10,99,"WM RT");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,10,109,"Fan");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,80,79,"Fr/Pump");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,80,89,"DayLts");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,80,99,"WM LFT");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,80,109,"Heater");
  byte TempRelay = ReefAngel.Relay.RelayData;
  TempRelay &= ReefAngel.Relay.RelayMaskOff;
  TempRelay |= ReefAngel.Relay.RelayMaskOn;
  ReefAngel.LCD.DrawCircleOutletBox(60, 81, TempRelay, true);
}

void DrawCustomGraph()
{

}
void setup()
{
  // This must be the first line
  ReefAngel.Init();  //Initialize controller
  ReefAngel.AddStandardMenu();
  // Ports toggled in Feeding Mode
  ReefAngel.FeedingModePorts = Port5Bit | Port6Bit;
  // Ports toggled in Water Change Mode
  ReefAngel.WaterChangePorts = Port5Bit | Port6Bit;
  // Ports toggled when Lights On / Off menu entry selected
  ReefAngel.LightsOnPorts = Port2Bit | Port3Bit | Port4Bit;
  // Ports turned off when Overheat temperature exceeded
  ReefAngel.OverheatShutoffPorts = Port2Bit | Port3Bit | Port4Bit | Port7Bit;
  // Use T1 probe as temperature and overheat functions
  ReefAngel.TempProbe = T1_PROBE;
  ReefAngel.OverheatProbe = T1_PROBE;


  // Ports that are always on

  ////// Place additional initialization code below here


  ////// Place additional initialization code above here
}

void loop()
{
  ReefAngel.DayLights( Port1 );
  ReefAngel.ActinicLights( Port2 );
  ReefAngel.DayLights( Port3 );
  ReefAngel.DayLights( Port4 );
  //ReefAngel.Wavemaker1( Port5 );
  //ReefAngel.Wavemaker1( Port6 );
  ReefAngel.StandardHeater( Port7 );
  ReefAngel.StandardFan( Port8 );
  ReefAngel.PWM.SetDaylight( MoonPhase() );
  ReefAngel.PWM.SetActinic( MoonPhase() );
  ////// Place your custom code below here
  MyWavemakerRandom(Port5,Port6,35,50); // Turn Port5 on/off random cycles that lasts from 35 to 50 secs
  // This should always be the last line
  ReefAngel.Portal( "psyrob" );
  ReefAngel.ShowInterface();
}

void MyWavemakerRandom(byte WMRelay1, byte WMRelay2, int MinWMTimer, int MaxWMTimer)
{
  if (now()>WMRTimer)
  {
    if ((hour() >= 21) || (hour() <= 8)) //from 9p-8a 
    {
      if (wmdelay)
      {
        WMRTimer=now()+60;
        ReefAngel.Relay.Off(WMRelay1);
        ReefAngel.Relay.Off(WMRelay2);
        if (wmport==Port5) wmport=Port6; 
        else wmport=Port5;        
        wmdelay=false;
      }
      else
      {
        WMRTimer=now()+20;
        ReefAngel.Relay.On(wmport);
        wmdelay=true;
      }
    }
    else
    {
      WMRTimer=now()+random(MinWMTimer, MaxWMTimer);
      ReefAngel.Relay.Toggle(WMRelay1);
      ReefAngel.Relay.Set(WMRelay2,!ReefAngel.Relay.Status(WMRelay1)); // Turn Port6 on/off on opposite cycle as Port 5
      // Port 5 and 6 are synchronized.
      // They work in opposing motion of each other at random times.
    }
  }
}
Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: setting memory with client/iphone app problem

Post by rimai »

The iphone doesn't support the ActinicLights() function until we can get John to fix the custom memory location on the iPhone app.
According to the code, you have ports 1,3 and 4 coming on at the same time on the same schedule and they follow the Standard Lights schedule.
How are you setting up 2 different times? Are you using the StandardLights and MHLights schedule?
Roberto.
psyrob
Posts: 242
Joined: Thu Sep 01, 2011 8:44 pm

Re: setting memory with client/iphone app problem

Post by psyrob »

I thought I had set the actinics (port 2) to come on first (I set this on the wizard thru clicking "actinic lights" and setting the times for on and off) then the others (1, 3 and 4) later (clicking "Day Lights" and time time was set automatically ). I used the "CHANGE time" button in the wizard and set the daylights to come on at a certain time, then set the actinics on the same menu for 60 minutes earlier...the "offset for actinics" I set for 60 minutes. Then after uploading, I used the client to try and change this because I wanted a different schedule....
Image
psyrob
Posts: 242
Joined: Thu Sep 01, 2011 8:44 pm

Re: setting memory with client/iphone app problem

Post by psyrob »

BTW, in the wizard, when trying to set up the wavemaker, I couldn't click on "random", only "constant" would work...
Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: setting memory with client/iphone app problem

Post by rimai »

May I ask you to try to use the wizard without changing anything with neither Client nor iPhone?
The Wizard only offers constant if you are going for internal memory settings.
Roberto.
psyrob
Posts: 242
Joined: Thu Sep 01, 2011 8:44 pm

Re: setting memory with client/iphone app problem

Post by psyrob »

OK, I will try
Image
psyrob
Posts: 242
Joined: Thu Sep 01, 2011 8:44 pm

Re: setting memory with client/iphone app problem

Post by psyrob »

I have generated a new schedule with the wizard and I cut and pasted my custom code in there (wavemaker randomness, slowing it down at night, added standard menu). I will let you know if the lights go out the right way tonight. . .
Image
psyrob
Posts: 242
Joined: Thu Sep 01, 2011 8:44 pm

Re: setting memory with client/iphone app problem

Post by psyrob »

the daylights went off at the right time, but the actinics went off at the same time. I had used the wizard and scheduled the actinics to go on and off one hour before and after the daylights
Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: setting memory with client/iphone app problem

Post by rimai »

Did you adjust the actinic offset to 60 minutes for one port and then back to 0 to another port, by any chance?
There is only one actinic offset memory setting.
Can you open Wizard, go to the port 1 and click "Change Time Schedule Settings" and tell me which settings you have?
Those are the settings that are being used. There is only one time schedule and everything will be based on that schedule. If you move to port 2 and click "Change Time Schedule Settings", you will see that they are the same and if you change them and go back to port1, they will be changed too.
If you have different schedules that can't be followed by just using offset, you will need to hard code them.
We have always had only one light schedule and even RAGen only had one.
The 2nd time schedule was called MHLights, which you still can use it, but have to manually add it to your code

Code: Select all

ReefAngel.MHLights (Port2,0);
Roberto.
psyrob
Posts: 242
Joined: Thu Sep 01, 2011 8:44 pm

Re: setting memory with client/iphone app problem

Post by psyrob »

OK, here are my settings under "change time Schedule Settings" on port 1:
"Turn On dayligts at 1:00 pm
Turn off Daylights at 9:00 pm
Delayed start 0
Offset for Actinics 60
Your Actinics will turn on at 12:00 pm and turn off at 10:00 pm
Your moonlights will turn on at 9:00 pm and turn off at 1:00 pm"

This would be fine, but the actinics are not turning on like this says. all lights are going on at 1 pm and off at 9 pm
Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: setting memory with client/iphone app problem

Post by rimai »

What value do you get if you browse the controller http://ipaddress:2000/mb284 ?
Roberto.
psyrob
Posts: 242
Joined: Thu Sep 01, 2011 8:44 pm

Re: setting memory with client/iphone app problem

Post by psyrob »

It says:

"This XML file does not appear to have any style information associated with it. The document tree is shown below
<m284> 30 <m284>"
Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: setting memory with client/iphone app problem

Post by rimai »

I'm testing the code here and port2 turns on accordingly.
Here are the settings I had:
/mb204 = 14 - Turn on Hour
/mb205 = 0 - Turn on Minute
/mb206 = 22 - Turn off Hour
/mb207 = 0 - Turn off Minute
/mb284 = 45 - Actinic Offset

Port 2 was coming on 45 minutes earlier and coming off 45 min later.
You must use v1.0.0 of the libraries though.
Roberto.
psyrob
Posts: 242
Joined: Thu Sep 01, 2011 8:44 pm

Re: setting memory with client/iphone app problem

Post by psyrob »

I am using v1.0.0...I checked with the portal right now, and actinics not on...should have been on at 1:15 PST, with standard lights coming on at 2...it's now 1:26...
Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: setting memory with client/iphone app problem

Post by rimai »

Oh, you said your settings had 30 for actinic offset.
The values above were the ones stored in my internal memory, not yours. Can you do the same thing and pull those numbers from yours, go make sure everything is stored correctly?

Sent from my SPH-D700 using Tapatalk 2
Roberto.
psyrob
Posts: 242
Joined: Thu Sep 01, 2011 8:44 pm

Re: setting memory with client/iphone app problem

Post by psyrob »

I got confused, I thought you had somehow pulled those values off my controller...yes the actinics came on like they should have....I checked the internal memory and the numbers are stored correctly. Is there a list of those values posted somewhere, like all the mb #'s and the memory values they correspond to?

I will check and see if they go off tonight like they are scheduled. I am noticing that I am getting screwy problems that will go away after a day or two, like this one, where the past two days, all the lights went on and off together, but today, the actinics are coming on early like they should...
I'll let you know if this continues, thanks for the help.
Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: setting memory with client/iphone app problem

Post by rimai »

Not posted yet, but all memory locations can be found on globals.h file

Sent from my SPH-D700 using Tapatalk 2
Roberto.
psyrob
Posts: 242
Joined: Thu Sep 01, 2011 8:44 pm

Re: setting memory with client/iphone app problem

Post by psyrob »

Here is what is happening...I generated a new INO with the wizard, and set the actinics to come on and off one hour (60 Minutes) before and after the daylight schedule...I used the change time schedule settings tab to do this, and the screen says "Actinic Turns on at 12:00 pm and turns off at 10:00 pm" I uploaded it to the controller. The actinics are coming on at 12:30 and going off at 9:30, 30 minutes instead of 60. I did the mb284 in the browser and it shows 30, not 60...Do I need to set the actinic offset to 120 to get 60 minutes on either end?
Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: setting memory with client/iphone app problem

Post by rimai »

Are you sure you are using libraries 1.0.0???
What do you get when reading /mb884?
800s was the old memory location table prior to v1.0.0
Because of some issues, it has been relocated to 200s on v1.0.0
Roberto.
psyrob
Posts: 242
Joined: Thu Sep 01, 2011 8:44 pm

Re: setting memory with client/iphone app problem

Post by psyrob »

Yes, arduino says Libraries Version 1.0.0, so does the controller...

I get 30 when I do mb884...
Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: setting memory with client/iphone app problem

Post by rimai »

When you get to the step of uploading internal memory on the wizard, are you skipping or uploading?
Roberto.
psyrob
Posts: 242
Joined: Thu Sep 01, 2011 8:44 pm

Re: setting memory with client/iphone app problem

Post by psyrob »

I generate only, then open in ardurino, cut and paste my custom code then upload the whole thing...
Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: setting memory with client/iphone app problem

Post by rimai »

Oh, that's why then.
When you get to the part of the internal memory, you need to let Arduino upload the internal memory file, instead of skipping it.
Without the internal memory file upload process, your settings that you picked will never be loaded into the memory.
The second step, you can choose to generate only.
If you don't want to upload the internal memory, you can skip, but you would have to manually change them.
For example, the actinic offset, you would use /mb284,60 to set the memory location 284 to 60.
Roberto.
psyrob
Posts: 242
Joined: Thu Sep 01, 2011 8:44 pm

Re: setting memory with client/iphone app problem

Post by psyrob »

OK, that's what I will do...thanks for your patience...
Image
Post Reply