Page 1 of 1

feeding mode code

Posted: Sun Aug 11, 2013 5:30 pm
by rossbryant1956
I am having trouble getting my feeding mode to work again since installing my new relays. Here is a snippet of my code:

Code: Select all

   // Define Relay Ports by Name
    #define DT_LightsOne       1
    #define DT_LightsTwo       2
    #define Unused3            3
    #define Unused4            4
    #define DT_LWM             5
    #define GT_LWM             6
    #define Unused7            7
    #define Unused8            8

    #define Unused11           Box1_Port1
    #define Unused12           Box1_Port2
    #define GT_LightsOne       Box1_Port3
    #define GT_LightsTwo       Box1_Port4
    #define DT_RWM             Box1_Port5
    #define GT_RWM             Box1_Port6
    #define DT_Heat            Box1_Port7
    #define DT_Pump            Box1_Port8
    
    #define RV_Heat            Box2_Port1
    #define RV_Pump            Box2_Port2
    #define GT_Heat            Box2_Port3
    #define Unused24           Box2_Port4
    #define GT_OverFill        Box2_Port5
    #define GT_Fill            Box2_Port6
    #define Skimmer            Box2_Port7
    #define GT_Pump            Box2_Port8

    void setup() {
        ReefAngel.Init();  //Initialize controller
        ReefAngel.InitMenu(pgm_read_word(&(menu_items[0])),SIZE(menu_items)); // Initialize the menu
        ReefAngel.FeedingModePortsE[0] = DT_Pump; // Turn off on Box1 when feeding mode is activated is activated
        ReefAngel.FeedingModePortsE[1] = Skimmer | GT_Pump; // Turn off on Box2 when feeding mode is activated is activated
        ReefAngel.WaterChangePorts = DT_LWM | GT_LWM ; // Turn off when water change mode is activated
        ReefAngel.WaterChangePortsE[0] = DT_RWM | GT_RWM | DT_Heat | DT_Pump; // Turn off on Box1 when water change mode is activated
        ReefAngel.WaterChangePortsE[1] = GT_Heat | GT_Pump | Skimmer | GT_Fill | RV_Heat; // Turn off on Box1 when water change mode is activated
        
The ports that need to be toggled are on relay boxes 1 & 2: box1_port8 and box2_port8. The ports it is switching are: Box2_port1, box2_port3, and box2_port5. I haven't tested the water change mode but it will probably act the same way. Here is the code snippet I call feeding mode with.

Code: Select all

// if the hour is 2p or 8p, minute is 55 and seconds is 0, start the feeding mode
          if ( ((hour() == 14) || (hour() == 20)) &&
          (minute() == 55) &&
          (second() == 0) )
          {
          ReefAngel.FeedingModeStart();
          }   

Re: feeding mode code

Posted: Sun Aug 11, 2013 6:18 pm
by lnevo
So you have three relay boxes or two?

The FeedingModePortsE[0] is the first expansion box. The main relay box is still FeedingModePorts

Re: feeding mode code

Posted: Sun Aug 11, 2013 6:58 pm
by rossbryant1956
I have three, there are no devices on the first relay that need switching. should i do a line like FeedingModePort=0 and then my other lines? For some reason it is getting confused. Thx

Re: feeding mode code

Posted: Mon Aug 12, 2013 4:22 am
by lnevo
Ahh i see the problem.

You dont use the relay port number for that (ie 1-8, 11-18, 21-28)

You need to use Port1Bit and Port2Bit and so forth.

The PortXBit is the same whether its Box1 or Box2 or main relay box.

Re: feeding mode code

Posted: Mon Aug 12, 2013 7:22 pm
by rossbryant1956
thx so much. I'll fix it in the next day or so.