Issue getting 2nd Relay to work.

Expansion modules and attachments
Post Reply
vonjankmon
Posts: 17
Joined: Tue Jan 08, 2013 6:43 am

Issue getting 2nd Relay to work.

Post by vonjankmon »

So trying to getting a 2nd Relay expansion working (so three including the initial one) and it just is not functioning for me.

I set the dip switches to on|off|off, which should be correct for a second relay expansion, I have the new code uploaded and on the portal and my Android app they show up but they do not turn on and are not controllable.

I just verified all of the dip switches and I verified that it could work by setting the dip switches to off|off|off and making it think it was my 1st expansion. It copied the function of the first expansion at that point fine so the hardware is good, I just must be missing something on the software end of things.

Copy of my code below, not sure what I am missing though, hopefully someone can help out.

Code: Select all

#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 <PH.h>
#include <WaterLevel.h>
#include <ReefAngel.h>

////// Place global variable code below here


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


void setup()
{
    // This must be the first line
    ReefAngel.Init();  //Initialize controller
    ReefAngel.AddStandardMenu();  // Add Standard Menu

    //// Ports toggled in Feeding Mode
    // Turns off Skimmer(Port2), Small Koralia (Port4), and Large Koralia (Port6)
    ReefAngel.FeedingModePorts = Port2Bit | Port4Bit | Port6Bit;
    // Turns off GFO/Carbon Reactor during feeding
    ReefAngel.FeedingModePortsE[0] = Port6Bit | Port5Bit;
    //// Ports toggled in Water Change Mode
    // Turns off Skimmer (Port2) and Return Pump (Port7)
    ReefAngel.WaterChangePorts = Port2Bit | Port7Bit;
    // Turns off Heater (Port[0]1), Heater (Port[0]2, Reactor Pump (Port[0]6), and ATO (Port[0]8)
    ReefAngel.WaterChangePortsE[0] = Port1Bit | Port2Bit | Port6Bit | Port8Bit;
    
    //// Ports turned off when Overheat temperature exceeded
    // To Turn Off: Frag Tank Light (Port1), Dosing Alk (Port3), Dosing Calcium (Port4), Large Koralia (Port6)
    ReefAngel.OverheatShutoffPorts = Port1Bit | Port3Bit | Port4Bit | Port6Bit;
    // To Turn Off: Heater (Port[0]1), and Heater (Port[0]2)
    ReefAngel.OverheatShutoffPortsE[0] = Port1Bit | Port2Bit;
    
    //// Use T1 probe as temperature and overheat functions
    // This is the Probe in the Display Tank, Probe 2 is for the Room, and Probe 3 is in the Frag Tank
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;


    // Ports that are always on
    
    //Empty
    ReefAngel.Relay.On( Box2_Port7 );
    //Empty
    ReefAngel.Relay.On( Box2_Port8 );
    
    // Skimmer
    ReefAngel.Relay.On( Port2 );
    //Frag Tank Pump
    ReefAngel.Relay.On( Port3 );
    //Small Korilia
    ReefAngel.Relay.On( Port4 );
    //Return Pump to DT
    ReefAngel.Relay.On( Port7 );      
    //Power to 3rd Relay
    ReefAngel.Relay.On( Port8 );
    //Small Koralia near Vortech
    ReefAngel.Relay.On( Box1_Port5 );
    //GFO and Carbon Reactor
    ReefAngel.Relay.On( Box1_Port6 );
    //Vortech
    ReefAngel.Relay.On( Box1_Port7 );
    //ATO Plug
    ReefAngel.Relay.On( Box1_Port8 );
    //Ground
    ReefAngel.Relay.On( Box2_Port1 );
    //Frag Tank Koralia Pumps
    ReefAngel.Relay.On( Box2_Port6 );
    ////// Place additional initialization code below here
    

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

void loop()
{
    // Frag Tank Lights
    ReefAngel.DayLights( Port1 );
    // Alk Dosing
    ReefAngel.DosingPumpRepeat1( Box1_Port3 );
    //Calcium Dosing
    ReefAngel.DosingPumpRepeat2( Box1_Port4 );
    //Large Korilia
    ReefAngel.WavemakerRandom( Port6,10,20 );
    //Heater
    ReefAngel.StandardHeater( Box1_Port1 );
    //Heater
    ReefAngel.StandardHeater( Box1_Port2 );
    //LED Light 1400mA
    ReefAngel.StandardLights( Box2_Port2,6,0,21,0 );
    //LED Light 1400mA
    ReefAngel.StandardLights( Box2_Port3,6,0,21,0 );
    //LED Light 700mA  
    ReefAngel.StandardLights( Box2_Port4,6,0,21,0 );
    //LED Light 700mA
    ReefAngel.StandardLights( Box2_Port5,6,0,21,0 );
    //PWM Daylight Dimming  
    ReefAngel.PWM.DaylightPWMSlope();
    //PWM Actinic Dimming  
    ReefAngel.PWM.ActinicPWMSlope();
    
    ReefAngel.RF.UseMemory = true;
    
    ////// Place your custom code below here
    
    if ( ( (hour()==9) && (minute()==30) ) ||  ( (hour()==19) && (minute() ==30) ) )
    {ReefAngel.FeedingModeStart(); 
    ReefAngel.Relay.Set(Port5,now()%60<4);}
    else
    {ReefAngel.Relay.Off(Port5);}
    

    ////// Place your custom code above here

    // This should always be the last line
    ReefAngel.Portal( "vonjankmon" );
    ReefAngel.ShowInterface();
}

void DrawCustomMain()
{
    int x,y;
    char text[10];
    // Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
    ReefAngel.LCD.DrawMonitor( 15, 62, ReefAngel.Params,
    ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
    ReefAngel.LCD.DrawMonitor( 15, 62, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
    pingSerial();

    // Main Relay Box
    byte TempRelay = ReefAngel.Relay.RelayData;
    TempRelay &= ReefAngel.Relay.RelayMaskOff;
    TempRelay |= ReefAngel.Relay.RelayMaskOn;
    ReefAngel.LCD.DrawOutletBox( 12, 93, TempRelay );
    pingSerial();

    // Relay Expansion
    TempRelay = ReefAngel.Relay.RelayDataE[0];
    TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
    TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
    ReefAngel.LCD.DrawOutletBox( 12, 107, TempRelay );
    pingSerial();

    // Date and Time
    ReefAngel.LCD.DrawDate( 6, 122 );
    pingSerial();
}

void DrawCustomGraph()
{
    ReefAngel.LCD.DrawGraph( 5, 5 );
}
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Issue getting 2nd Relay to work.

Post by rimai »

Just to be sure of the dip switch setting, can you post the results of the I2CScanner code?
http://forum.reefangel.com/viewtopic.php?p=29914#p29914
Roberto.
vonjankmon
Posts: 17
Joined: Tue Jan 08, 2013 6:43 am

Re: Issue getting 2nd Relay to work.

Post by vonjankmon »

Here we go:

I2CScanner ready!
starting scanning of I2C bus from 1 to 128...
addr: 1 addr: 2 addr: 3 addr: 4
addr: 5 addr: 6 addr: 7 addr: 8
addr: 9 addr: A addr: B addr: C
addr: D addr: E addr: F addr: 10 found!
addr: 11 addr: 12 addr: 13 addr: 14
addr: 15 addr: 16 addr: 17 addr: 18
addr: 19 addr: 1A addr: 1B addr: 1C
addr: 1D addr: 1E addr: 1F addr: 20 found!
addr: 21 addr: 22 addr: 23 addr: 24
addr: 25 addr: 26 addr: 27 addr: 28
addr: 29 addr: 2A addr: 2B addr: 2C
addr: 2D addr: 2E addr: 2F addr: 30
addr: 31 addr: 32 addr: 33 addr: 34
addr: 35 addr: 36 addr: 37 addr: 38 found!
addr: 39 addr: 3A addr: 3B addr: 3C
addr: 3D addr: 3E addr: 3F addr: 40
addr: 41 addr: 42 addr: 43 addr: 44
addr: 45 addr: 46 addr: 47 addr: 48
addr: 49 addr: 4A addr: 4B addr: 4C
addr: 4D addr: 4E addr: 4F addr: 50 found!
addr: 51 addr: 52 addr: 53 addr: 54 found!
addr: 55 addr: 56 addr: 57 addr: 58
addr: 59 addr: 5A addr: 5B addr: 5C
addr: 5D addr: 5E addr: 5F addr: 60
addr: 61 addr: 62 addr: 63 addr: 64
addr: 65 addr: 66 addr: 67 addr: 68 found!
addr: 69 addr: 6A addr: 6B addr: 6C
addr: 6D addr: 6E addr: 6F addr: 70
addr: 71 addr: 72 addr: 73 addr: 74
addr: 75 addr: 76 addr: 77 addr: 78
addr: 79 addr: 7A addr: 7B addr: 7C
addr: 7D addr: 7E addr: 7F addr: 80

done
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Issue getting 2nd Relay to work.

Post by rimai »

address 38 is the 1st relay box.
The 2nd relay box would have to be shown as address 39
Roberto.
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: Issue getting 2nd Relay to work.

Post by rossbryant1956 »

check your dip switches. make sure you notice pin one is denoted by the 1 on the motherboard, not the 1 on the switchbox itself. Same mistake I made. Thx
Roscoe's Reefs - Starting Over Again:

Building new 29g Nano after landlord went berserk over my 4 75 gallon tanks, Multiple RA's, Water mixing stations, etc. Your help welcomed in remembering all I've forgotten.
vonjankmon
Posts: 17
Joined: Tue Jan 08, 2013 6:43 am

Re: Issue getting 2nd Relay to work.

Post by vonjankmon »

Thanks Rossbryant1956 that was the issue. I had the dip switches set according to the switch box, not the circuit board and they are reversed. Set them according to the circuit board and working like a charm now.
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: Issue getting 2nd Relay to work.

Post by rossbryant1956 »

glad I could help!!
Roscoe's Reefs - Starting Over Again:

Building new 29g Nano after landlord went berserk over my 4 75 gallon tanks, Multiple RA's, Water mixing stations, etc. Your help welcomed in remembering all I've forgotten.
Post Reply