Controller freezing and trouble compiling sketch

New members questions
Post Reply
reefer gladness
Posts: 29
Joined: Sat Jun 09, 2012 11:18 pm

Controller freezing and trouble compiling sketch

Post by reefer gladness »

About 2 days ago my controller unit froze up, screen blank, red status light blinking and no response to input from the joystick. It resets properly when power cycled and returns to normal function. It's happened a couple more times in the past few days.

I have the RA Plus unit and it's been running without issue for quite awhile. No recent changes were made to the hardware or code.

My computer was upgraded recently though and I copied the Reef Angel folder over to the drive. I wanted to try uploading my code again to see if that helped but now I get a wall of - 'xxxxx' was not declared in this scope messages. The first being 'ReefAngel' was not declared in this scope.

Hoping you can help. It's been smooth sailing for quite awhile now. The Arduino software is v1.01 and I have the Board option set to Reef Angel Plus Controller.

Edit: the Wi-Fi unit lost connection also. I unplugged it for now. Feed mode works okay but water change does not for some reason.

Here's my code:

Code: Select all

// Autogenerated file by RAGen (v1.2.2.171), (07/19/2012 20:00)
// RA_071912_2000.ino
//
// This version designed for v0.9.0 or later

/* The following features are enabled for this File: 
#define DisplayImages
#define DateTimeSetup
#define DosingPumpSetup
#define VersionMenu
#define DirectTempSensor
#define DisplayLEDPWM
#define wifi
#define StandardLightSetup
#define SaveRelayState
#define RelayExp
#define InstalledRelayExpansionModules 1
#define WDT
#define PWMEXPANSION
#define IOEXPANSION
#define CUSTOM_MAIN
#define RFEXPANSION
#define FONT_8x16
#define NUMBERS_8x16
*/


#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 <IO.h>
#include <ReefAngel.h>
#include <avr/wdt.h>

////// Place global variable code below here
// Globals Needed for Params on Custom Main
byte x,y;
char text[10];
int v;

// Globals Needed for RF Mode on Custom Main
       byte vtechmode;
       boolean bFeeding=false;

//------------------------------------------------------ End of Global Variables --------------------------------------------------
//*********************************************************************************************************************************

////// Place global variable code above here

//---------------------------------------------Custom Main for PWM Expansion Module------------------------------------------------


void DrawCustomMain()
{
        //Top Banner
        ReefAngel.LCD.DrawText(COLOR_BLACK, COLOR_SKYBLUE, 9, 2, "Sean's 58G Money Pit"); 
        
        // Display T2 Header Text
        ReefAngel.LCD.DrawText(COLOR_ROYALBLUE,255,8,14,"Tank");
  
        // Display the T2 Temp Value
        char text[7];
        ConvertNumToString(text, ReefAngel.Params.Temp[T2_PROBE], 10);
        ReefAngel.LCD.Clear(255, 4, 21, 37, 37);
        ReefAngel.LCD.DrawLargeText(COLOR_ROYALBLUE, 255, 4, 24, text, Num8x16);
        pingSerial();

        // Display the T1 Header Text
        ReefAngel.LCD.DrawText(COLOR_CRIMSON,255,52,14,"Room");
  
        // Display the T1 Temp Value
        ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
        ReefAngel.LCD.Clear(255, 52, 21, 75, 37);
        ReefAngel.LCD.DrawLargeText(COLOR_CRIMSON, 255, 52, 24, text, Num8x16);
        pingSerial();

        // Display pH Header Text
        ReefAngel.LCD.DrawText(COLOR_INDIGO,255,108,14,"pH");
  
        // Display pH Value
        ConvertNumToString(text, ReefAngel.Params.PH, 100);
        ReefAngel.LCD.Clear(255, 94, 21, 106, 37);
        ReefAngel.LCD.DrawLargeText(COLOR_INDIGO, 255, 94, 24, text, Num8x16);
        pingSerial();
        
        // Display Vortech MP10wES Mode Header Text
        ReefAngel.LCD.Clear(DefaultFGColor,5,39,127,39);
        ReefAngel.LCD.DrawText(0,255,18,42,"EcoSmart Vortech");

        // Display EcoSmart Mode Value 
        ReefAngel.LCD.Clear(255, 1, 49, 128, 64);
        if (vtechmode == 0) ReefAngel.LCD.DrawLargeText(COLOR_LIMEGREEN,255,35,50,"Constant");
        else if(vtechmode == 1) ReefAngel.LCD.DrawLargeText(COLOR_GOLD,255,42,50,"Lagoon");
        else if (vtechmode == 2) ReefAngel.LCD.DrawLargeText(COLOR_GOLD,255,25,50,"Reef Crest");
        else if (vtechmode == 3) ReefAngel.LCD.DrawLargeText(COLOR_CORNFLOWERBLUE,255,22,50,"Short Pulse");
        else if (vtechmode == 4) ReefAngel.LCD.DrawLargeText(COLOR_PINK,255,25,50,"Long Pulse");
        else if (vtechmode == 5) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,8,50,"Nutrient Trnsp.");
        else if (vtechmode == 6) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,23,50,"Tidal Swell");
        else if (vtechmode == 9) ReefAngel.LCD.DrawLargeText(COLOR_WHITE,0,45,50,"Night");

        // Display PMW Expansion Channel Headers and % Values
        ReefAngel.LCD.Clear(DefaultFGColor,5,65,127,65);
        ReefAngel.LCD.DrawText(COLOR_DARKGOLDENROD,DefaultBGColor,31,68,"LED Dimming");
        x=15;
        y=78;
        for (int a=0;a<4;a++)
        {
          if (a>1) x=75;
          if (a==2) y=78;
          ReefAngel.LCD.DrawText(COLOR_DARKGOLDENROD,DefaultBGColor,x,y,"Ch :");
          ReefAngel.LCD.DrawText(COLOR_DARKGOLDENROD,DefaultBGColor,x+12,y,a);
          ConvertNumToString(text, ReefAngel.PWM.GetChannelValue(a), 1);
          strcat(text," ");
          ReefAngel.LCD.DrawText(COLOR_DARKGOLDENROD,DefaultBGColor,x+24,y,text);
          y+=10;
        }
        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();
        
        //Draw Date & Time
        ReefAngel.LCD.DrawDate(6, 123);
        pingSerial();
}

void DrawCustomGraph() // Not Used
{
}

//------------------------------------------------------ End Custom Main ----------------------------------------------------------
//*********************************************************************************************************************************
//-------------------------------------------------------- Begin Setup ------------------------------------------------------------

void setup()
{
    // This must be the first line
    ReefAngel.Init(); //Initialize controller
    //Ports that are always on
    ReefAngel.Relay.On(Box0_Port4);
    ReefAngel.Relay.On(Box0_Port5);
    ReefAngel.Relay.On(Box1_Port2);
    ReefAngel.Relay.On(Box1_Port4);
    ReefAngel.Relay.On(Box1_Port5);
    ReefAngel.Relay.On(Box1_Port6);
    ReefAngel.Relay.On(Box1_Port7);
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = Port4Bit | Port5Bit | Port7Bit | Port8Bit;
    ReefAngel.FeedingModePortsE[0] = Port1Bit | Port2Bit | Port4Bit;
    // Ports toggled in Water Change Mode
     ReefAngel.WaterChangePorts = Port4Bit | Port5Bit | Port7Bit | Port8Bit;
     ReefAngel.WaterChangePortsE[0] = Port1Bit | Port2Bit | Port4Bit;
     // define T2 probe as temp probe
     ReefAngel.TempProbe = T2_PROBE;

    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = 0;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = Port1Bit | Port2Bit | Port3Bit ;
}
//---------------------------------------------------------- End Setup ------------------------------------------------------------
//*********************************************************************************************************************************
//--------------------------------------------------------- Begin Loop ------------------------------------------------------------


void loop()
{
    // Specific functions that use Internal Memory values
    ReefAngel.StandardLights(Box0_Port1,11,0,22,0);
    ReefAngel.StandardLights(Box0_Port2,23,0,10,0);
    ReefAngel.StandardLights(Box0_Port3,10,0,23,0);
    ReefAngel.StandardLights(Box1_Port8,10,0,23,30);
    ReefAngel.StandardFan(Box0_Port6, 773,777);
    ReefAngel.StandardFan(Box0_Port7, 775,790);
    ReefAngel.StandardHeater(Box0_Port8,768,771);
    ReefAngel.DosingPumpRepeat(Box1_Port3,0,360,600);
    ReefAngel.DosingPumpRepeat(Box1_Port1,0,60,90);
    ReefAngel.Relay.DelayedOn(Box0_Port4,30 );
    ReefAngel.Relay.DelayedOn(Box1_Port4,30 );
    
    ////// Place your custom code below here
    ReefAngel.PWM.SetChannel(0,PWMSlope(11,0,22,0,12,30,60,10));
    ReefAngel.PWM.SetChannel(1,PWMSlope(10,0,23,0,12,45,60,10));
    ReefAngel.PWM.SetChannel(2,PWMSlope(10,0,23,0,12,45,60,10));
    ReefAngel.PWM.SetChannel(3,PWMSlope(10,0,23,0,12,45,60,10));

    ////// Place your custom code above here
    // This sends all the data to the portal
    // Do not add any custom code that changes any relay status after this line
    // The only code after this line should be the ShowInterface function
    ReefAngel.Portal("reefer gladness", "xxxxxxxx");

    // This should always be the last line
    ReefAngel.ShowInterface();
    //------------------------------------------------- End PWM Expansion Code for Slope ----------------------------------------------

//------------------------------------------------ Start Time-of-Day Based Functions ----------------------------------------------
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ These are the mode numbers for the RF Expansion Module for reference ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //#define Constant 0
    //#define Random1 1 // Lagoonal
    //#define Random2 2 // Reef Crest
    //#define ShortWave 3
    //#define LongWave 4
    //#define Smart_NTM 5 // Nutrient Transport Mode
    //#define Smart_TSM 6 // Tidal Swell Mode
    //#define Feeding_Start 7
    //#define Feeding_Stop 8
    //#define Night 9
    //#define Slave_Start 97
    //#define Slave_Stop 98
    //#define None 99
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

//-------------------------------------------------------- Start RF Nightmode Control ---------------------------------------------    

  if (hour()>=23 || hour()<10) // Defining "Nightmode" hours for VorTech = between 11 PM and 10 AM
    {
      ReefAngel.RF.UseMemory=false;
      ReefAngel.RF.SetMode(Night,15,0);
      vtechmode = 9;
    }
  else
    {
      if (vtechmode==9) ReefAngel.RF.SetMode(Feeding_Stop,0,0); //Temp fix for coming out of Night mode
      ReefAngel.RF.UseMemory=true;
      vtechmode = InternalMemory.RFMode_read();
    } 
//---------------------------------------------------------- End RF Nightmode Control ---------------------------------------------
//------------------------------------------------------ End Time-of-Day Based Functions ------------------------------------------
}
//--------------------------------------------------------------- End Loop --------------------------------------------------------
//*********************************************************************************************************************************
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: Controller freezing and trouble compiling sketch

Post by lnevo »

If your getting errors like that it sounds like the libraries are not installed properly. Try to remove and reinstall.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Controller freezing and trouble compiling sketch

Post by rimai »

I'd recommend you uninstalling the previous installer and installing the newest RA installer from the download page.
Roberto.
reefer gladness
Posts: 29
Joined: Sat Jun 09, 2012 11:18 pm

Re: Controller freezing and trouble compiling sketch

Post by reefer gladness »

Many thanks, we have progress. Re-installing the Reef Angel software on my computer got my sketch compiling correctly again.

I can't get the Wi-Fi unit to authenticate though. Nothing has changed on my network, tried using the Wi-Fi utility software to configure it again but no success. It's associated but not authenticated with a slow blinking blue and slow blinking green light.

For now I'm going to observe the controller unit for a day or two without the Wi-Fi attached to make sure it's not freezing any more.
reefer gladness
Posts: 29
Joined: Sat Jun 09, 2012 11:18 pm

Re: Controller freezing and trouble compiling sketch

Post by reefer gladness »

Well that didn't take long, the controller is frozen again. I have a dead screen, solid red and solid green light and no response from the joystick again. Is it the board?
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Controller freezing and trouble compiling sketch

Post by rimai »

Do you have expansion modules?
Roberto.
reefer gladness
Posts: 29
Joined: Sat Jun 09, 2012 11:18 pm

Re: Controller freezing and trouble compiling sketch

Post by reefer gladness »

Yes, 1 expansion module, PWM dimming module, RF module for vortech and the Wi-Fi expansion. All the modules, etc. are mounted inside a separate cabinet so they're well protected.

I had left the Wi-Fi expansion plugged in after the last test and that's when the controller froze. It's working fine again now without the Wi-Fi attached. Gonna try to reset the Wi-Fi back to factory settings tomorrow and try again to authenticate it with my network.
User avatar
cosmith71
Posts: 1432
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Controller freezing and trouble compiling sketch

Post by cosmith71 »

This sounds a lot like the RF noise problem I was having.

--Colin
Post Reply