Ether10 and Relay8 shields

The EtherTen combines an Uno-equivalent Arduino-compatible board and Wiznet-based Ethernet support, along with a microSD card slot and Power-over-Ethernet support. [Product page]
Post Reply
charlesjudd
Posts: 3
Joined: Tue Feb 07, 2017 11:13 pm

Ether10 and Relay8 shields

Post by charlesjudd » Tue May 02, 2017 8:41 am

Hello,
I have 2 x Relay8 shields. I have this working 100% on an Arduino Uno board.
In serial monitor;
Press A to select Relay8 shieldA (0x20)
Then press 1-8 to toggle relay on/off.
Press B to select Relay8 shieldB (0x21)
Then press 1-8 to toggle relay on/off
Both Relay8 shields have been configured for R2 headers by soldering the pads on the back of the board. This was the key to getting the Relay8 Shields working with Arduino Uno.

The problem comes when I mount the Relay8 Shields onto a Freetronics EtherTen.
The program seems to hang after trying to initialise the Relay8 Shields.

I suspect the issue is the existence of pullup resistors built into the Ether10, and pullup resistors built into the Relay8 Shields (?) can you please confirm this assumption?

You will see in the example sketch below that I have tried to disable EtherTen Ethernet, and SD interface to rule out these as being the problem.

I would like to retain automatic MAC address assignment of the Ether10 (i.e.: Leave the pull up resistors on Ether10).
Can I disable the pullup resistors on the Relay8 shields? and, will this solve my problem of the sketch hanging when running on the Ether10 with 2 x Relay8 shields connected? How do I disable the pullup resistors on the Relay8 Shields please?

here is the sketch I have 100% working with Arduino Uno, and not working with EtherTen.

// *** BEGIN EXAMPLE SKETCH - works on uno*** //
#include "Wire.h"

#define I2C_ADDR_RELAY8_SHIELD_A 0x20 // 0x20 is the address with all jumpers removed
#define I2C_ADDR_RELAY8_SHIELD_B 0x21 // 0x21 jumper added to A0

byte shield1BankA = 0; // Current status of all outputs on first shield, one bit per output
byte shield2BankA = 0; // Current status of all outputs on second shield, one bit per output

byte relayPort=B0;
byte RelayShield; //stores which shield is currently being operated on.

void setup()
{
Serial.begin( 38400 );
Serial.println("RELAY8 testing");

Serial.println("Disable SD Card");
// disable SD card
pinMode(4, OUTPUT);
digitalWrite(4, HIGH);

Serial.println("Disable Etherent");
// disable Ethernet chip
pinMode(10, OUTPUT);
digitalWrite(10, HIGH);

//Serial.println("inside Void Setup");
debug_messages();
Wire.begin(); // Wake up I2C bus
Serial.println("Initialise Relay8 Shield A");
initialiseShield(I2C_ADDR_RELAY8_SHIELD_A);
sendRawValueToLatch1(0); // If we don't do this, channel 6 turns on! I don't know why
Serial.println("Initialise Relay8 Shield B");
initialiseShield(I2C_ADDR_RELAY8_SHIELD_B);
sendRawValueToLatch2(0); // If we don't do this, channel 6 turns on! I don't know why

Serial.println("Ready. Type A for shield 1 (0x20) or B for Shield 2 (0x21)");
Serial.println("Ready. Type 0 to turn off relays, 1 - 8 to activate a relay.");
}

void loop()
{
int command = 0;
if (Serial.available())
{
command = Serial.read();
switch(command)
{
case '0':
Serial.println("All relays OFF");
sendValueToLatch(relayPort); //XOR with self produces 0
break;
case '1':
Serial.println("Flipping relay 1");
sendValueToLatch(B1);
break;
case '2':
Serial.println("Flipping relay 2");
sendValueToLatch(B10);
break;
case '3':
Serial.println("Flipping relay 3");
sendValueToLatch(B100);
break;
case '4' :
Serial.println("Flipping relay 4");
sendValueToLatch(B1000);
break;
case '5':
Serial.println("Flipping relay 5");
sendValueToLatch(B10000);
break;
case '6':
Serial.println("Flipping relay 6");
sendValueToLatch(B100000);
break;
case '7':
Serial.println("Flipping relay 7");
sendValueToLatch(B1000000);
break;
case '8':
Serial.println("Flipping relay 8");
sendValueToLatch(B10000000);
break;
case '9':
Serial.println("Flipping ALL relays");
sendValueToLatch(B11111111);
break;
case 'a':
Serial.println("Relay Shield A selected");
RelayShield = I2C_ADDR_RELAY8_SHIELD_A;
debug_messages();
break;
case 'b':
Serial.println("Relay Shield B selected");
RelayShield = I2C_ADDR_RELAY8_SHIELD_B;
debug_messages();
break;

}
}
}
void sendValueToLatch(int latchValue)
{
Serial.print("sendValueToLatch value ");
Serial.println(latchValue);
relayPort=relayPort^latchValue; //XOR toggles desired port
debug_messages();
Wire.beginTransmission(RelayShield);
Wire.write(0x12); // Select GPIOA
Wire.write(relayPort); // Send value to bank A
Wire.endTransmission();
relayState();
}
void relayState()
{
Serial.println("inside Function RelayState");
for (byte i=0;i<8;i++)
{
Serial.print ("Relay ");
Serial.print (i+1);
if bitRead(relayPort,i) {Serial.println(" is ON");} //bitRead gets status of bit
else {Serial.println(" is OFF");}
}
}

void initialiseShield(int shieldAddress)
{
// Set addressing style
Serial.println("begin Set addressing style");
Wire.beginTransmission(shieldAddress);
Serial.println("Wire.Write 0x12");
Wire.write(0x12);
Serial.println("Wire.Write 0x20");
Wire.write(0x20); // use table 1.4 addressing
Serial.println("Wire.End transmission");
Wire.endTransmission();
Serial.println("End Set addressing style");

// Set I/O bank A to outputs
Serial.println("begin Set I/O bank A to outputs");
Wire.beginTransmission(shieldAddress);
Wire.write(0x00); // IODIRA register
Wire.write(0x00); // Set all of bank A to outputs
Wire.endTransmission();
Serial.println("end Set I/O bank A to outputs");
}
void sendRawValueToLatch1(byte rawValue)
{
Wire.beginTransmission(I2C_ADDR_RELAY8_SHIELD_A);
Wire.write(0x12); // Select GPIOA
Wire.write(rawValue); // Send value to bank A
shield1BankA = rawValue;
Wire.endTransmission();
}
void sendRawValueToLatch2(byte rawValue)
{
Wire.beginTransmission(I2C_ADDR_RELAY8_SHIELD_B);
Wire.write(0x12); // Select GPIOA
Wire.write(rawValue); // Send value to bank A
shield2BankA = rawValue;
Wire.endTransmission();
}

void debug_messages()
{
Serial.print("RelayShield [");
Serial.print(RelayShield);
Serial.print("] RelayPort [");
Serial.print(relayPort);
Serial.println("]");
}

// *** END EXAMPLE SKETCH - works on uno** //


Many thanks,

Charles

charlesjudd
Posts: 3
Joined: Tue Feb 07, 2017 11:13 pm

Re: Ether10 and Relay8 shields

Post by charlesjudd » Tue May 09, 2017 1:41 am

It appears that EtherTen has a unique configuration when compared with an Arduino Uno.

When any of the i2C/PullUp resistors are cut on Relay8 board and/or EtherTen, no power is supplied from EtherTen to the Relay8 shield.
This differs to the Arduino Uno which appears to provide power to the Relay8 shield regardless of i2C pullup status.

Also, when EtherTen and/or Relay8 shield has pullups disabled, supplying power directly on the 5-24volt terminal does not power the Relay8.

incase anyone else tries to use an EtherTen with Relay8 shields. here's what I needed to do to get them working together;

1) Leave i2C pullups enabled on EtherTen (allows setting an Arduino MAC address using the MCP 24AA025E48) - do not solder "isolate sda/scl" pads.

2) Disable pullup resistors on Relay8 Shield/s by cutting the "I2C Pads" on the Relay8 shield/s. These need to be disabled as only one set of pullups can be enabled for all stacked components.
    3) On the back of Relay8 shield, solder pads labeled "POWER INPUT CONNECT TO VIN". This allows the Ether10 to power the Relay8 Shields. If you dont do this step, the Relay8 blue power light will never come on. It also allows the Relay8 Shield to be powered by the 5-24 vold DC terminal block on the Relay8.

    I hope this helps someone!

    Post Reply

    Who is online

    Users browsing this forum: No registered users and 2 guests