Stack Shields & Have fun : Two relay shield

In the news recently, we released a second shield for the DEVCC platform. We named it the DUO (Two) relay shield, but it has a bit more to it that that. The shield also contains a MIKROBUS slot, which I will have a look at later.

For now, I am test driving the new shield as the relays open up a number of possibilities that normal transistorized switching does not allow. Familiar with relays; you will know that the relay principle is a low voltage switching a much high voltage. In this case the HKE relay is switching at 5VDC, but the coil will switch 220VAC @ 16 AMPs.

Basic I / O Need to know

The Two Relay Shield shares space with a Mikro Bus slot and if you have worked with these guys before, you will know that 12 I/O lines get consumed. As a result you can run out of I/O quite quickly especially if you want versatility on your board and the MikroBus slot is wired in to accommodate all possible clicks available – as is the case here. What I mean is that, if for example your board intends to only ever use the I2C bus to connect to specific click boards, there would be no need to make all the connections. In this case, however all connections have been made so virtually any (current and future) click boards can be accommodated.

The Two relay shield has two connections namely RB0 and RB1. They are permanently tracked.

The Two relay shield is compatible with the DEVCC V18, DEVCC V28 and DEVCC V40. You can get around the NC for the DEVCC V20 with wire jumpers.

Shown below is a code sample which demonstrates two ways of switching the relays. With the code sample, the relays can be switched on one by one or a 4 BIT binary value is written to the PINS RB0 & RB1 – counting up in binary.

On my work bench, raw and in the flesh a DEVCC V18 with the Two relay shield stacked. I have wired up two leds very simply for easy of use.

On my desk_TwoRelays

 

Basic Step through

  1.  Startup is called to initialize the device, configuring RB0 and RB1 as outputs, all else inputs
  2. All analog inputs off, all pins as inputs
  3. void main calls
    1. Counter: a for each routine that counts up to four writing the value to PORT B
    2. OneByOne: A sequential routine that switches the relays on and then off with an interval of 1/2 second.
/*

(c) 2015,  ZarDynamix
Sample code to test Two relay shield with PIC16F1847

*/

void Startup(){

     TRISB = 0xFF;

     TRISB = 0x00;
     PORTB = 0b11111100;
     
     ANSELB = 0x0;
     ANSELA = 0x0;
}

void Counter(){

     int i;

     for(i = 0 ; i <= 3; i++)
     {
         PORTB = i;
         Delay_ms(500);
     }

}

void OnebyOne(){
 
 PORTB.B0 = 1;
 Delay_ms(500);

 PORTB.B1 = 1;
 Delay_ms(500);

  PORTB.B0 = 0;
  Delay_ms(500);

  PORTB.B1 = 0;
  Delay_ms(500);
}

void main() {

     Startup();
     
     while(1){

              Counter();
              
              //OneByOne();
     }
}

 Resources

Note: The example project was written using mikroC Pro Ver 6.6.2. The project is contained within a zip file.

Code project for Mikroc:  TESTV18

Wrap Up

The Two Relay shield is an awesome addition to the DEVCC Shield Line Up and offers the possibility of switching high current loads or just something usual. Have Fun!

Our usual disclaimer applies ie: Use at your discretion, work safely and at your own risk. We accept no liability.

[E]