Jump to content
43oh

Recommended Posts

Here is a Relay boosterpack that I'm planning on using for a couple of things.  

post-1690-0-29255200-1365951121_thumb.jpg

 

There are a couple of units available on Tindie.

 

First - I built a wireless fireworks launcher last year for the 4th of july using the Anaren booster.  Unfortunately the range was much too short - so I'm hoping to use a pair of NRF24L01's.  The relays work great to trigger nichrome wire.

Second - I'm helping a co-worker out with a home-automation project.  The relays work great as a dry-contact.  

 

One of the reasons why I went with creating a booster was to make sure the traces were nice and large - in case I needed it to run something beefy.  Most relay boards I've found online have fairly thin traces.  I used all available space (top and bottom) to make mine as large as possible.  If you take a look at the pictures of the board - you'll see the large planes for NO/NC and COM for the relays.  I haven't tested yet - but based on a PCB trace width calculator - they should be able to take several amps.  Might be good for solenoids or really beefy motors.

 

post-1690-0-52375700-1365955262_thumb.jpg

 

Some additional info:

  • Relays are numbered on the board - Relay 1 is in the upper-left.  
  • NO and NC are labeled next to the screw terminals - the center is common.
  • Power for triggering the relays is provided via a two-pin header at the bottom of the board.  For testing, I've been using a 9v battery.  
  • Latch and Enable pins are selectable via a set of small jumpers on the back.  The testing code I've provided are set for Enable - 2.2 and Latch - 2.3.  2.2 through 2.5 are available for selection for either feature.
  • The board doesn't use opto-isolators - so only DC should be used.

 

BOM - Parts are all Tayda

SOIC 595 Shift Register (1)

ULN2003AD SOIC Darlington Array (1)

~1K Pull-up Resistor (1)

1N4006 Rectifier diode or similar (4) - These serve as protection diodes

Relays (4) - I used 6v relays - but the footprint fits plenty of other types of mini relays

3 Position, 3.5mm terminal block (4)

 

 

Eagle files are attached.  

 

Here is a sample program for CCS.  Pushing button 1 

#include <msp430.h> 

/*
 * main.c
 */

#define CS_595 BIT3 //P2
#define ENABLE BIT2 //P2
#define SCL_PIN BIT5 //CLK
#define SDA_PIN BIT7  //Data to 595's
#define DISABLE_SR P2DIR |= ENABLE; P2OUT |= ENABLE
#define ENABLE_SR P2DIR &= ~ENABLE; P2OUT &= ~ENABLE
#define SR_DESELECT P2OUT &= ~CS_595 //Select shift register
#define SR_SELECT P2OUT |= CS_595 //Deselect shift register
#define BUTTON	BIT3

#define RELAY_1 BIT1
#define RELAY_2	BIT2
#define RELAY_3 BIT3
#define RELAY_4 BIT4

#define TEST_DELAY 5000000

//Function prototypes
void initSPI();
void write(char relays);



int main(void) {
    WDTCTL = WDTPW | WDTHOLD;	// Stop watchdog timer

    //configuration from GRACE
    BCSCTL2 = SELM_0 + DIVM_0 + DIVS_0;
    if (CALBC1_16MHZ != 0xFF) {
           /* Adjust this accordingly to your VCC rise time */
           __delay_cycles(100000);

           /* Follow recommended flow. First, clear all DCOx and MODx bits. Then
            * apply new RSELx values. Finally, apply new DCOx and MODx bit values.
            */
           DCOCTL = 0x00;
           BCSCTL1 = CALBC1_16MHZ;     /* Set DCO to 16MHz */
           DCOCTL = CALDCO_16MHZ;
       }
    BCSCTL1 |= XT2OFF + DIVA_0;
    BCSCTL3 = XT2S_0 + LFXT1S_2 + XCAP_1;
    //INTERRUPT ON 1.3 - Pull up resistor enabled
    P1IE |= BUTTON;
    P1IFG |= BUTTON;
    P1REN |= BUTTON;
    P1OUT |= BUTTON;
    P1IFG &= ~BUTTON;
    P1DIR |= BIT0|BIT6;
    P1OUT &= ~(BIT0|BIT6);

    _bis_SR_register(GIE);

	initSPI();
	ENABLE_SR;
	LPM0; //sleep until button press
	while(1)
	{
		P1OUT |= BIT0|BIT6;
		write(RELAY_1|RELAY_2|RELAY_3|RELAY_4);//all on
		_delay_cycles(8000000); //half second
		P1OUT ^= BIT0;
		write(RELAY_2|RELAY_3|RELAY_4);//turn off 1
		_delay_cycles(8000000); //half second
		P1OUT ^= BIT0;
		P1OUT ^= BIT6;
		write(RELAY_3|RELAY_4);//turn off 2
		_delay_cycles(8000000); //half second
		P1OUT ^= BIT0;
		P1OUT ^= BIT6;
		write(RELAY_4); //turn off 3
		_delay_cycles(8000000); //half second
		write(0x00);//turn off all
		P1OUT &= ~(BIT0|BIT6); //turn off all LEDs
		LPM0;
	}

}

//Set up USCI_B for SPI
void initSPI()
{
	P1DIR |= SCL_PIN|SDA_PIN;
	P2DIR |= CS_595;
	SR_DESELECT;

	P1SEL |= SCL_PIN + SDA_PIN;
	P1SEL2 |= SCL_PIN + SDA_PIN;

	UCB0CTL0 |= UCCKPH + UCMSB + UCMST + UCSYNC; // 3-pin, 8-bit SPI master
	UCB0CTL1 |= UCSSEL_2; // SMCLK
	UCB0BR0 |= 0x01; // div/1
	UCB0BR1 = 0;
	UCB0CTL1 &= ~UCSWRST; // Initialize
	_delay_cycles(5000);
}

/*
 * Outputs relay settings to booster
 */
void write(char relays) {
	SR_SELECT;

	UCB0TXBUF = relays; //this will end up on the second shift register
	while (!(IFG2 & UCB0TXIFG)); //wait for send to complete
	SR_DESELECT;
}

// Port 1 interrupt service routine
#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{
  //P1OUT ^= 0x01;                            // P1.0 = toggle
  P1IFG &= ~BUTTON;
  LPM0_EXIT;
}

RelayBP_Eagle.zip

Link to post
Share on other sites

I like, but those clearings don't seem enough to run 230V through the relay. Can you past the schematic and PCB as PNG too?

Definitely not - it's only meant for DC.  If I'd planned on AC - I would have added opto-isolators as well. It would have required a larger board and my planned applications were DC-only.  I didn't want to fry a board if I put a couple of amps through it lighting a firework.

 

I've attached the schematic and images of the top and bottom of the board from gerbv.  

post-1690-0-17915500-1366032896_thumb.png

post-1690-0-54603800-1366032916_thumb.png

post-1690-0-07506500-1366032924_thumb.png

Link to post
Share on other sites

Optos are kind of redundant if you're using relays already. Ofcourse the backcurrent from the relay coils can still fry your launchpad. I was wondering what that curious thing in the middle of the bottom of the board was, but your schematic has curious things as well ;-) What's connected to P2.0/3/4/5? Unless you plan on adding much more relays the current pin cost doesn't weigh up to directly driving the ULN, which would greatly simplify code, what's your line of thinking in this place?

Oh now I see, you can choose which lines to use as latch and enable, enabling you to "configure" multiple (up to two?) of these boards using solder jumers.

Link to post
Share on other sites

 

Ofcourse the backcurrent from the relay coils can still fry your launchpad.

I believe that's part of why people use Optos, although I thought it had something to do with the AC interfering causing signal issues as well.  The diodes should prevent the relays from causing problems under most circumstances from what I read - http://electronicsclub.info/relays.htm#protect

 

 

Oh now I see, you can choose which lines to use as latch and enable, enabling you to "configure" multiple (up to two?) of these boards using solder jumers.

Right - I'm planning on using this with one of the NRF wireless boards - plus possibly some extra peripherals - just trying to conserve pins.  Felt like a bit of a waste to use an 8 pin expander and a 7 pin darlington array.  Probably should have broken out the extra pins.  The solder jumpers are the smallest I've ever used (a custom part I created) - but they're honestly extremely easy to use.  I've used 0805 pads - but they always take a 0 ohm resistor or a big blob of solder.  

Link to post
Share on other sites

I thought optos are used for galvavic isolation. Mostly for purposes of either level shifting or high voltage separation. Since your darlington array is taking care of level shifting and the relays are already galvanic isolated, it should be perfectly safe to drive 230V AC with it. That is, given the clearance of the switch part of the relays to the inductor part is sufficient for these purposes (which would be 2.1mm for UL iirc).

Link to post
Share on other sites

I thought optos are used for galvavic isolation. Mostly for purposes of either level shifting or high voltage separation. Since your darlington array is taking care of level shifting and the relays are already galvanic isolated, it should be perfectly safe to drive 230V AC with it. That is, given the clearance of the switch part of the relays to the inductor part is sufficient for these purposes (which would be 2.1mm for UL iirc).

I've got a ground plane and some signals running over relays 3 & 4, and the board is 1.6mm thick - so that's definitely not enough - not to mention isolation on the rest of the board.  

Link to post
Share on other sites

Speaking of which - I bought some pogo pins on eBay that fit nicely into female headers (used a v1.4 LP).  I was able to test the boards without soldering on headers.

I'll have to do a post on it soon.  I'll be using the pogo pins to program the ultrasonic backpack I sent off to OSHPark.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...