ReefAngel.StandardLights(Port7) not working

Related to the development libraries, released by Curt Binder
Post Reply
Sebyte

ReefAngel.StandardLights(Port7) not working

Post by Sebyte »

Hi

I am testing various options and I am having problems with ReefAngel.StandardLights(Port7) & ReefAngel.MHLights(Port8)

My understanding was that the on/off times set in memory would control ports assigned to that function. Both ports are on all the time and not responding to the settings in memory.

My PDE is:-

Code: Select all

// Autogenerated file by RAGen (v1.1.0.126), (11/13/2011 09:49)
// RA_111311_0949.pde
//
// This version designed for v0.8.5 Beta 17 or later

/* The following features are enabled for this PDE File: 
 #define DisplayImages
 #define WavemakerSetup
 #define OverheatSetup
 #define DateTimeSetup
 #define VersionMenu
 #define ATOSetup
 #define MetalHalideSetup
 #define DirectTempSensor
 #define DisplayLEDPWM
 #define wifi
 #define SingleATOSetup
 #define StandardLightSetup
 #define SaveRelayState
 #define WDT
 #define ENABLE_ATO_LOGGING
 #define ENABLE_EXCEED_FLAGS
 */


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

#include <avr/pgmspace.h>
// Labels for the web banner
prog_char id_label[] PROGMEM = "sebyte";
prog_char probe1_label[] PROGMEM = "Water";
prog_char probe2_label[] PROGMEM = "Room";
prog_char probe3_label[] PROGMEM = "Not%20Used";
prog_char relay1_label[] PROGMEM = "Skimmer";
prog_char relay2_label[] PROGMEM = "ATO";
prog_char relay3_label[] PROGMEM = "Heater";
prog_char relay4_label[] PROGMEM = "Chiller";
prog_char relay5_label[] PROGMEM = "Wave%20Maker";
prog_char relay6_label[] PROGMEM = "Pumps";
prog_char relay7_label[] PROGMEM = "Actinics";
prog_char relay8_label[] PROGMEM = "Daylight";
PROGMEM const char *webbanner_items[] = {
  id_label, probe1_label, probe2_label, probe3_label, relay1_label, relay2_label,
  relay3_label, relay4_label, relay5_label, relay6_label, relay7_label, relay8_label};


void setup()
{
  ReefAngel.Init();  //Initialize controller
  // Initialize and start the web banner timer
  ReefAngel.LoadWebBanner(pgm_read_word(&(webbanner_items[0])), SIZE(webbanner_items));
  ReefAngel.Timer[4].SetInterval(180);  // set interval to 180 seconds
  ReefAngel.Timer[4].Start();

  ReefAngel.FeedingModePorts = B00111001;
  ReefAngel.WaterChangePorts = B00111111;
  ReefAngel.OverheatShutoffPorts = B11000001;
  ReefAngel.LightsOnPorts = B11000000;

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

void loop()
{
  // Specific functions
  ReefAngel.SingleATOLow(Port2);
  ReefAngel.StandardHeater(Port3);
  ReefAngel.StandardFan(Port4);
  ReefAngel.Wavemaker1(Port5);
  ReefAngel.StandardLights(Port7);
  ReefAngel.MHLights(Port8);
  
  // Turn lights off if water temperature reaches 85f

if (ReefAngel.Params.Temp1>850) ReefAngel.Relay.Off(Port7);

else ReefAngel.Relay.On(Port7);

if (ReefAngel.Params.Temp1>850) ReefAngel.Relay.Off(Port8);

else ReefAngel.Relay.On(Port8); 

// ATO available 6 times per day

if (hour() % 4 == 0) {
  ReefAngel.SingleATOLow(Port2); 
}
else {
  ReefAngel.Relay.Off(Port2);
}

    // Web Banner stuff
  if(ReefAngel.Timer[4].IsTriggered())
  {
    ReefAngel.Timer[4].Start();
    ReefAngel.WebBanner();
  }

  ReefAngel.ShowInterface();
}

My lights are on all the time. I have even tried using the long version to override the memory setting.

Here is the memory file in use at present:-

Code: Select all

// Autogenerated file by RAGen (v1.1.0.126), (11/13/2011 09:50)
// Memory_111311_0950.pde
//
// This file sets the default values to the Internal Memory
//


#include <ReefAngel_Features.h>
#include <ReefAngel_Globals.h>
#include <Time.h>
#include <OneWire.h>
#include <Phillips6610LCDInv.h>
#include <avr/pgmspace.h>
#include <ReefAngel_EEPROM.h>


Phillips6610LCDInv e;

void setup()
{
    e.lcd_init();
    e.lcd_clear(COLOR_WHITE,0,0,132,132);
    e.lcd_BacklightOn();

    InternalMemory.MHOnHour_write(10);
    InternalMemory.MHOnMinute_write(0);
    InternalMemory.MHOffHour_write(20);
    InternalMemory.MHOffMinute_write(0);
    InternalMemory.MHDelay_write(0);
    InternalMemory.StdLightsOnHour_write(9);
    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(10);
    InternalMemory.DP2Timer_write(10);
    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(10);
    InternalMemory.WM2Timer_write(354);
    InternalMemory.HeaterTempOn_write(780);
    InternalMemory.HeaterTempOff_write(790);
    InternalMemory.ChillerTempOn_write(805);
    InternalMemory.ChillerTempOff_write(795);
    InternalMemory.OverheatTemp_write(850);
    InternalMemory.PHMax_write(840);
    InternalMemory.PHMin_write(550);
}

void loop()
{
    // display the values
    char buf[128];
    sprintf(buf, "MH %2d:%02d-%2d:%02d,%d", InternalMemory.MHOnHour_read(), InternalMemory.MHOnMinute_read(),
                                         InternalMemory.MHOffHour_read(), InternalMemory.MHOffMinute_read(),
                                         InternalMemory.MHDelay_read());
    e.lcd_draw_text(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW, buf);
    sprintf(buf, "Std %2d:%02d-%2d:%02d", InternalMemory.StdLightsOnHour_read(), InternalMemory.StdLightsOnMinute_read(),
                                          InternalMemory.StdLightsOffHour_read(), InternalMemory.StdLightsOffMinute_read());
    e.lcd_draw_text(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*2, buf);
    sprintf(buf, "LED A: %d%% D: %d%%", InternalMemory.LEDPWMActinic_read(), InternalMemory.LEDPWMDaylight_read());
    e.lcd_draw_text(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*3, buf);
    sprintf(buf, "WM1: %ds", InternalMemory.WM1Timer_read());
    e.lcd_draw_text(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*4, buf);
    sprintf(buf, "WM2: %ds", InternalMemory.WM2Timer_read());
    e.lcd_draw_text(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*5, buf);
    sprintf(buf, "F: %ds", InternalMemory.FeedingTimer_read());
    e.lcd_draw_text(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*6, buf);
    sprintf(buf, "S: %ds", InternalMemory.LCDTimer_read());
    e.lcd_draw_text(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*7, buf);
    sprintf(buf, "H On: %d -> %d", InternalMemory.HeaterTempOn_read(), InternalMemory.HeaterTempOff_read());
    e.lcd_draw_text(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*9, buf);
    sprintf(buf, "C On: %d -> %d", InternalMemory.ChillerTempOn_read(), InternalMemory.ChillerTempOff_read());
    e.lcd_draw_text(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*10, buf);
    sprintf(buf, "PH %d - %d", InternalMemory.PHMax_read(), InternalMemory.PHMin_read());
    e.lcd_draw_text(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*11, buf);

    delay(10000);
    e.lcd_clear(COLOR_WHITE,0,0,132,132);

    sprintf(buf, "OH: %dF", InternalMemory.OverheatTemp_read());
    e.lcd_draw_text(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW, buf);
    sprintf(buf, "ATO L: %ds (%dh)", InternalMemory.ATOTimeout_read(), InternalMemory.ATOHourInterval_read());
    e.lcd_draw_text(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*2, buf);
    sprintf(buf, "ATO H: %ds (%dh)", InternalMemory.ATOHighTimeout_read(), InternalMemory.ATOHighHourInterval_read());
    e.lcd_draw_text(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*3, buf);

    sprintf(buf, "DP1: %2d:%02d", InternalMemory.DP1OnHour_read(), InternalMemory.DP1OnMinute_read());
    e.lcd_draw_text(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*5, buf);
    sprintf(buf, "     %ds", InternalMemory.DP1Timer_read());
    e.lcd_draw_text(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*6, buf);
    sprintf(buf, "DP2: %2d:%02d", InternalMemory.DP2OnHour_read(), InternalMemory.DP2OnMinute_read());
    e.lcd_draw_text(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*7, buf);
    sprintf(buf, "     %ds", InternalMemory.DP2Timer_read());
    e.lcd_draw_text(COLOR_BLACK, COLOR_WHITE, MENU_START_COL, MENU_START_ROW*8, buf);

    delay(10000);
    e.lcd_clear(COLOR_WHITE,0,0,132,132);
}
I am using v0.8.5.19 library's, What am I doing wrong? :?

Thanks
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: ReefAngel.StandardLights(Port7) not working

Post by binder »

The problem is you are overriding the functions.

this code:

Code: Select all

  // Turn lights off if water temperature reaches 85f

if (ReefAngel.Params.Temp1>850) ReefAngel.Relay.Off(Port7);

else ReefAngel.Relay.On(Port7);

if (ReefAngel.Params.Temp1>850) ReefAngel.Relay.Off(Port8);

else ReefAngel.Relay.On(Port8); 
should not be there.

You are telling the controller to ALWAYS turn on the ports when the temp is below 850 (85.0). The functions are not able to do their job.

The overheat shutting off is handled automatically when the overheat temp is reached. This line tells what ports to shutoff when you exceed the overheat temp:

Code: Select all

  ReefAngel.OverheatShutoffPorts = B11000001;
Based on this, you are turning off ports 1, 7, & 8 when your temp gets too high, which sounds like what you want.
You have the correct value in your memory to shut the ports off above 85.

If you remove the code segment I mentioned, you should work just fine.

curt
Sebyte

Re: ReefAngel.StandardLights(Port7) not working

Post by Sebyte »

I agree that that code should not be there and I can see how it is overriding the functions, but without it the overheat set in memory at 85f does not shut off the ports assigned.

So the I guess the next question is why is the overheat temperature set in memory not calling the function

ReefAngel.OverheatShutoffPorts = B11000001;
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: ReefAngel.StandardLights(Port7) not working

Post by binder »

Sebyte wrote: So the I guess the next question is why is the overheat temperature set in memory not calling the function

ReefAngel.OverheatShutoffPorts = B11000001;
It actually is working as it is designed. The overheat temperature defaults to monitoring the second temp probe. In your case, it would be the lights and not the tank water. To change what probe is monitored, you need to add another line to your setup function.

This functionality was added in to 0.8.5.17, as you can see here: http://forum.reefangel.com/viewtopic.php?f=7&t=310

The code you need to monitor the first probe is this. It needs to be added to your setup() AFTER the ReefAngel.Init(); function.

Code: Select all

void setup()
{
  ReefAngel.Init();
  ReefAngel.OverheatTempProbe = &ReefAngel.Params.Temp1;
  // ... of setup here
}
Now this should work like planned for you.

curt
Sebyte

Re: ReefAngel.StandardLights(Port7) not working

Post by Sebyte »

Thank you Curt,

I did not think about which temp probe was the initiator! All works ok now.

I am working on small sections of code at a time and testing each part before adding it to the master code PDE. That way I hope I will end up with a working model at the end, if there is ever an end :lol:

In another post you helped me with setting my ATO to be available 6 time per day. I use a Kalk reactor and need to have that run thirty minutes after the ATO stops being available, and to run for 30 minutes.

I do not have a spare relay port at this time, and I was going to put the stirrer on a digital time switch. But I was wondering if I could set the ATO Hi port to give me a 100% PWM output at the predetermined times. I can build a circuit that would use a 5v solid state relay to switch the 115v stirrer pump. Does this sound doable, and if so any suggestions?

I have an observation and this is not a criticism, as a new user, I am finding it difficult to find and remember where all of the version notes are (re above on changing temp sensor). Would it be possible if all the version notes were placed in one location and not in a topic area that can be posted into as they seem to me to get lost. Or maybe there is such a place and I have not yet found it :roll:

Reef Angel is a great device and the help you and Roberto provide is second to none, and I have worked in IT management and support for over 30 years.

Keep up the good work.
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: ReefAngel.StandardLights(Port7) not working

Post by binder »

Sebyte wrote: In another post you helped me with setting my ATO to be available 6 time per day. I use a Kalk reactor and need to have that run thirty minutes after the ATO stops being available, and to run for 30 minutes.

I do not have a spare relay port at this time, and I was going to put the stirrer on a digital time switch. But I was wondering if I could set the ATO Hi port to give me a 100% PWM output at the predetermined times. I can build a circuit that would use a 5v solid state relay to switch the 115v stirrer pump. Does this sound doable, and if so any suggestions?
It does sound doable. I know others have used ATO ports for PWM signal. If you aren't using the builtin PWM ports, you could use those. I'm pretty sure we could figure a way to set the PWM port to 100% after the ATO stops. It might take some effort to make sure the logic is correct, but does sound like it is possible. Roberto most likely has more input for this.
Sebyte wrote: I have an observation and this is not a criticism, as a new user, I am finding it difficult to find and remember where all of the version notes are (re above on changing temp sensor). Would it be possible if all the version notes were placed in one location and not in a topic area that can be posted into as they seem to me to get lost. Or maybe there is such a place and I have not yet found it :roll:
That's a great suggestion. I've tried to keep track of this a few times, but ended up failing at it because I never spent the time to figure out how to automate it. I can generate my changelog from my git repository. I think what I'm going to do is start a thread and keep it sticky for my development libraries and have it be a changelog for the libraries.

curt
Sebyte

Re: ReefAngel.StandardLights(Port7) not working

Post by Sebyte »

Great, I have found out how to make the ATO Hi output 5v, but I cannot figure out how to get the Port to be on for the time periods needed. The circuit is fairly basic and electronic relays easy to get. Hopefully Roberto can advise on the code. Eventualy I will get an expansion box, but at the moment I am saving up to convert my lighting over to LED.

Your suggestion on having a sticky for version info would help. The alternative would be to dump the text from your postings onto the web server and have a page of links. This is time consuming, who is the webmaster? I could offer my time and web skills to maintain the updates if that would help.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: ReefAngel.StandardLights(Port7) not working

Post by rimai »

Yes, you can use a SSR controlled by ATO High.
Very easy.
Place this anywhere after ReefAngel.Init() in the setup() funtion:

Code: Select all

pinMode(highATOPin,OUTPUT);
The use this to turn the SSR on/off:

Code: Select all

digitalWrite(highATOPin,HIGH) // Turn on SSR
digitalWrite(highATOPin,LOW) // Turn off SSR
Roberto.
Sebyte

Re: ReefAngel.StandardLights(Port7) not working

Post by Sebyte »

Thanks for that Roberto, but I have already worked that one out. What I need is to be able to have the ATO Hi port on for six half hour periods per day. I am using the following code to run my ATO, and need the Kalk reactor to come on half an hour after the ATO port becomes unavailable, and to run for thirty minutes, then turn off.

void loop()
{
// ATO available 6 times per day
if (hour() % 4 == 0) {
SingleATO(Port1);
}
else {
ReefAngel.Relay.Off(Port1);
}

}



I gues I could hard code in the time for the event six times but that is not very elegant.

ANy suggestions would be welcome.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: ReefAngel.StandardLights(Port7) not working

Post by rimai »

So, right now Port1 is available for ATO every 6 hours at 0,4,8,12,16 and 20.
And you want to turn the SSR on for 30minutes prior to those hours and turn off when Port 1 is available for ATO.
So it would be on at 3:30, 7:30, 11:30, 15:30, 19:30 and 23:30, off at 0,4,8,12,16 and 20.
Is this correct?
Roberto.
Sebyte

Re: ReefAngel.StandardLights(Port7) not working

Post by Sebyte »

No, I need to turn it on 30 minutes after the ATO available period is over. That would be:-

01:30 to 2:00, 05:30 to 06:00, 09:30 to 10:00, 13:30 to 14:00, 17:30 to 18:00, 21:30 to 220:00.

That will leave two hours for the Kalk to settle before I pump RO/DI water through the reactor and in to the tank as required by the ATO.

I know that this is a bit out of the ordinary, and if I had a spare relay port it would be straight forward. I plan to get a second relay box, but my next major purchase will be replacing my T5's with LED's. In the mean time I can use the PWM 5v max output from ATO Hi to switch an electronic relay and control the Kalk mixer in the reactor.

I hope this makes things clearer.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: ReefAngel.StandardLights(Port7) not working

Post by rimai »

Let's try this:

Code: Select all

  if (hour() % 4 == 1 && minute()>30)
  {
    digitalWrite(highATOPin,HIGH) // Turn on SSR
  }
  else
  {
    digitalWrite(highATOPin,LOW) // Turn on SSR
  }
Roberto.
Sebyte

Re: ReefAngel.StandardLights(Port7) not working

Post by Sebyte »

Thanks for the code Roberto. Unfortunately it did not work. The time section was correct and produced the correct on/off time. I was not sure of the syntax for a 'AND' function when I was trying to code this myself. I have now had a look at the Arduino site and found their reference section, that will help me lots in the future.

I played around and found that this code worked and gave me the output on ATO Hi.

Code: Select all

// Kalk Reactor available 6 times per day - 01:30 to 2:00, 05:30 to 06:00, 09:30 to 10:00, 13:30 to 14:00, 17:30 to 18:00, 21:30 to 220:00.

  if (hour() % 4 == 1 && minute()>30) 
  {
    pinMode(highATOPin,OUTPUT);
    digitalWrite(highATOPin,HIGH); // Turn on Solid State Relay
  }
  else
  {
    pinMode(highATOPin,OUTPUT);
    digitalWrite(highATOPin,LOW); // Turn off Solid State Relay
  } 
All I needed to add was, pinMode(highATOPin,OUTPUT)

Again thanks for your help.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: ReefAngel.StandardLights(Port7) not working

Post by rimai »

Awesome :mrgreen:
Roberto.
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: ReefAngel.StandardLights(Port7) not working

Post by binder »

Sebyte wrote: I have an observation and this is not a criticism, as a new user, I am finding it difficult to find and remember where all of the version notes are (re above on changing temp sensor). Would it be possible if all the version notes were placed in one location and not in a topic area that can be posted into as they seem to me to get lost. Or maybe there is such a place and I have not yet found it :roll:
As per your request, here's a complete changelog of my branch of code. It's rather long but it's a complete list of all the changes that I've made (all my commit notes). I've made the topic Sticky and locked so nobody can post to it thus keeping it "clutter free". :)

http://forum.reefangel.com/viewtopic.php?f=7&t=448

curt
Sebyte

Re: ReefAngel.StandardLights(Port7) not working

Post by Sebyte »

Just the job Curt!

I did make a similar comment to Roberto. I gues he must have some database because he often answers questions with a one line answere like-

http://forum.reefangel.com/viewtopic.ph ... date#p1809

That is a long string to type out and he must cut and paste from a listing. If so it would be the basis for a wiki?

Thanks again,
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: ReefAngel.StandardLights(Port7) not working

Post by rimai »

Yes, I do cut and paste.
But actually, all I did was search for the words "wifi" and "date"
If you look at the link I gave you, both words will be highlighted :)
Roberto.
Sebyte

Re: ReefAngel.StandardLights(Port7) not working

Post by Sebyte »

Point taken Roberto :P

My concern is that there is so much info in the forum that newbies, (with or without a programming background), will find the forum search facility limited. Basically because everyone uses different terminology to describe their issue/problem/tip/ etc. etc.

Also as time goes on the amount of info/knowledge will increase exponentially. In the past before I retired I managed IT support teams, and this was a major issue, specially when a new support person joined a team. The only way we could deal with it was to create knowledge bases for the use of the team, and made a subset available top our client base. I acknowledge that this takes time and is labour intensive (that's why I had staff :lol: )

Might I suggest that as a start there are a number of excellent "how to" posts, such as your Sunrise and Sunset effect with your PWM Expansion Module", that could be collated together as Locked Stickies in a new section of the forum perhaps called Reference Library.

If you need a resource to do this I am willing to have a look at it, but would need access rights etc. If you would like to take this further then please PM.

I believe strongly in the RA system as a leading edge product. Also as a past executive member of the Marine Society of Toronto I am promoting RA at every opportunity, and I am slowly getting members who were looking at off the shelf controllers interested in RA, evangelism!

Regards
Post Reply