• Announcements

    • bluehash

      Forum Upgrade   03/11/2017

      Hello Everyone, Thanks for being patient while the forums were being fixed and upgraded. Please see details and report issues in this thread. Thanks!

Search the Community

Showing results for tags 'relay'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • News
    • Announcements
    • Suggestions
    • New users say Hi!
  • Spotlight!
    • Sponsor Spotlight
    • Sponsor Giveaways
  • Energia
    • Energia - MSP
    • Energia - TivaC/CC3XXX
    • Energia - C2000
    • Energia Libraries
  • MSP Technical Forums
    • General
    • Compilers and IDEs
    • Development Kits
    • Programmers and Debuggers
    • Code vault
    • Projects
    • Booster Packs
    • Energia
  • Tiva-C, Hercules, CCXXXX ARM Technical Forums
    • General
    • SensorTag
    • Tiva-C, Hercules, CC3XXX Launchpad Booster Packs
    • Code Vault
    • Projects
    • Compilers and IDEs
    • Development Kits and Custom Boards
  • Beagle ARM Cortex A8 Technical Forums
    • General
    • Code Snippets and Scripts
    • Cases, Capes and Plugin Boards
    • Projects
  • General Electronics Forum
    • General Electronics
    • Other Microcontrollers
  • Connect
    • Embedded Systems/Test Equipment Deals
    • Buy, Trade and Sell
    • The 43oh Store
    • Community Projects
    • Fireside Chat
  • C2000 Technical Forums
    • General
    • Development Kits
    • Code Vault
    • Projects
    • BoosterPacks

Calendars

  • Community Calendar

Found 5 results

  1. Hi, I am trying to operate a 3V relay (from OMRON) using MSP430G2553. The relay is a SPDT one, with 6 PINs. I am not quite sure how to wire a6 PIN relay (I have some experience with 5 PIN SPDT relay), and I cannot find much information in the internet. I was also told that, for driving a 3V relay, I would not require transistor + diode combination. For your information, the relay has a rated coil current of 50 mA. Can anyone help me on understanding the wiring structure of the relay? How to interface it with MSP430? Also, is it true that, I can operate the 3V relay without separate transistor + diode combination? I do not have much experience in microcontroller, particularly in MSP430 platform. Any suggestion is welcome. Thank you in advance for your support.
  2. Hi 43oh! It seemed like there was some interest in my solid state relay board, so I figured I'd post up the design files. Because of liability reasons (being high voltage and what not) I can't produce this, but your welcome to get some boards made and solder them yourself. Be warned, soldering the heat-sinks to the board is VERY DIFFICULT! You'll need a board pre-heater, hot air, and some good flux. Schematic: triac_board.pdf Design package (in EAGLE 6.5): triac_board.zip Cheers!
  3. This is very much in progress, and there's nothing fancy about it, but I wanted to share with you what I'm working on at the moment since I'm back into the 430 again after a while in arm/linux land. Only the relay stuff is implemented for now and the master is currently just a test which advances the relay selections by push of the s2 button. Criticism, ideas and insults welcome I would like to do various slave firmwares for sensors, etc and I will be incoprorating also a BBB controller at some point. Code shamefully stolen/modified from TI examples. Master.c //****************************************************************************** // MSP430G2x31 - I2C Automation Controller/Sensor, Master // // Description: This is the test firmware for the I2C master controller. It // currently advances, by action of s2 on the launchpad (falling edge of P1.3), // the control word from 0x00 through 0x1111 were each bit is the relay to be // (0) opened or (1) closed. It will be updated to reflect the desired control // protocol shortly. // //****************************************************************************** #include <msp430g2231.h> char MST_Data = 0; // Variable for transmitted data char SLV_Addr = 0x90; // Address is 0x48 << 1 bit + 0 for Write int I2C_State = 0; // State variable void main(void) { volatile unsigned int i; // Use volatile to prevent removal WDTCTL = WDTPW + WDTHOLD; // Stop watchdog if (CALBC1_1MHZ ==0xFF || CALDCO_1MHZ == 0xFF) { while(1); // If calibration constants erased do not load, trap CPU!! } BCSCTL1 = CALBC1_1MHZ; // Set DCO DCOCTL = CALDCO_1MHZ; P1OUT = 0xC0; // P1.6 & P1.7 Pullups, others to 0 P1OUT |= BIT3; P1REN |= 0xC0; // P1.3, P1.6 & P1.7 Pullups P1REN |= BIT3; P1DIR = 0xFF; P1DIR &= ~BIT3; // Unused pins as outputs. s2 as input. P1IE |= BIT3; // Enable P1 interrupt for P1.3 P2OUT = 0; P2DIR = 0xFF; USICTL0 = USIPE6+USIPE7+USIMST+USISWRST; // Port & USI mode setup USICTL1 = USII2C+USIIE; // Enable I2C mode & USI interrupt USICKCTL = USIDIV_3+USISSEL_2+USICKPL; // Setup USI clocks: SCL = SMCLK/8 (~125kHz) USICNT |= USIIFGCC; // Disable automatic clear control USICTL0 &= ~USISWRST; // Enable USI USICTL1 &= ~USIIFG; // Clear pending flag P1IFG &= ~BIT3; // Clear p1.3 interrupt flag. _EINT(); while(1) { USICTL1 |= USIIFG; // Set flag and start communication LPM0; // CPU off, await USI interrupt _NOP(); // Used for IAR for (i = 0; i < 5000; i++); // Dummy delay between communication cycles } } /****************************************************** // Port1 isr ******************************************************/ #pragma vector=PORT1_VECTOR __interrupt void Port_1(void) { USICTL1 &= ~USIIE; // Disable I2C interrupt until we finish. P1IE &= ~BIT3; // Clear own interrupt until we finish if(MST_Data < 15) { MST_Data++; // Increment Master data } else { MST_Data = 0; } P1OUT &= ~BIT0; __delay_cycles(1000000); P1OUT |= BIT0; P1IE |= BIT3; // Re-enable own interrupt and clear interrupt flag. P1IFG &= ~BIT3; USICTL1 |= USIIE; // Re-enable I2C interrupt and clear pending flag. USICTL1 &= ~USIIFG; } /****************************************************** // USI isr ******************************************************/ #pragma vector = USI_VECTOR __interrupt void USI_TXRX (void) { switch(I2C_State) { case 0: // Generate Start Condition & send address to slave //P1OUT |= 0x01; // LED on: sequence start USISRL = 0x00; // Generate Start Condition... USICTL0 |= USIGE+USIOE; USICTL0 &= ~USIGE; USISRL = SLV_Addr; // ... and transmit address, R/W = 0 USICNT = (USICNT & 0xE0) + 0x08; // Bit counter = 8, TX Address I2C_State = 2; // Go to next state: receive address (N)Ack break; case 2: // Receive Address Ack/Nack bit USICTL0 &= ~USIOE; // SDA = input USICNT |= 0x01; // Bit counter = 1, receive (N)Ack bit I2C_State = 4; // Go to next state: check (N)Ack break; case 4: // Process Address Ack/Nack & handle data TX USICTL0 |= USIOE; // SDA = output if (USISRL & 0x01) { // If Nack received, send stop USISRL = 0x00; USICNT |= 0x01; // Bit counter = 1, SCL high, SDA low I2C_State = 10; // Go to next state: generate Stop //P1OUT |= 0x01; // Turn on LED: error } else { // Ack received, TX data to slave... USISRL = MST_Data; // Load data byte USICNT |= 0x08; // Bit counter = 8, start TX I2C_State = 6; // Go to next state: receive data (N)Ack //P1OUT &= ~0x01; // Turn off LED } break; case 6: // Receive Data Ack/Nack bit USICTL0 &= ~USIOE; // SDA = input USICNT |= 0x01; // Bit counter = 1, receive (N)Ack bit I2C_State = 8; // Go to next state: check (N)Ack break; case 8: // Process Data Ack/Nack & send Stop USICTL0 |= USIOE; if (USISRL & 0x01) { // If Nack received... //P1OUT |= 0x01; // Turn on LED: error } else { // Ack received //P1OUT &= ~0x01; // Turn off LED } // Send stop... USISRL = 0x00; USICNT |= 0x01; // Bit counter = 1, SCL high, SDA low I2C_State = 10; // Go to next state: generate Stop break; case 10:// Generate Stop Condition USISRL = 0x0FF; // USISRL = 1 to release SDA USICTL0 |= USIGE; // Transparent latch enabled USICTL0 &= ~(USIGE+USIOE);// Latch/SDA output disabled I2C_State = 0; // Reset state machine for next transmission LPM0_EXIT; // Exit active for next transfer break; } USICTL1 &= ~USIIFG; // Clear pending flag } Slave.c //****************************************************************************** // MSP430G2x31 - I2C Automation Controller/Sensor, Slave Node // // Description: This is the firmware for the i2c slave controller // //****************************************************************************** #include <msp430.h> // peripheral selections #define ADC // Define if slave needs ADC10 // Select peripheral type for each pin: // RELAY for relay or other digital output such as MOSFET or other TTL control, // DIGITAL for digtal input such as TTL sensor, switch, etc. // CT for current transformer, // NTC for negative temp. coefficient thermistor, // PTC for positive temp. coefficient thermistor, #define P1_0 RELAY #define P1_1 RELAY #define P1_2 RELAY #define P1_3 RELAY #define P1_4 CT #define P1_5 NTC char ownAddr = 0x90; // Address is 0x48<<1 for R/W int i2cState = 0; // State variable unsigned char RXData=0; void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog if (CALBC1_1MHZ ==0xFF || CALDCO_1MHZ == 0xFF) { while(1); // If calibration constants erased // do not load, trap CPU!! } // Peripherals setup // port setup stuff #if P1_0 == RELAY P1DIR |= BIT0; // set pin to output. #elif P1_0 == THERM P1DIR &= ~BIT0; // set pin to input. ADC10CTL1 |= INCH0; // enable adc chan. 0 #elif P1_0 == CT P1DIR &= ~BIT0; // set pin to input. ADC10CTL1 |= INCH0; // enable adc chan #elif P1_0 == ACLK #elif P1_0 == TA0CLK #endif #if P1_1 == RELAY P1DIR |= BIT1; // set pin to output. #elif P1_1 == THERM P1DIR &= ~BIT1; // set pin to input. ADC10CTL1 |= INCH1; // enable adc chan. #elif P1_1 == CT P1DIR &= ~BIT1; // set pin to input. ADC10CTL1 |= INCH1; // enable adc chan. #elif P1_1 == TA0 #endif #if P1_2 == RELAY P1DIR |= BIT2; // set pin to output. #elif P1_2 == THERM P1DIR &= ~BIT2; // set pin to input. ADC10CTL1 |= INCH2; // enable adc chan. #elif P1_2 == CT P1DIR &= ~BIT2; // set pin to input. ADC10CTL1 |= INCH2; // enable adc chan. #elif P1_2 == TA0 #endif #if P1_3 == RELAY P1DIR |= BIT3; // set pin to output. #elif P1_3 == NTC P1DIR &= ~BIT3; // set pin to input. ADC10CTL1 |= INCH3; // enable adc chan. #elif P1_3 == CT P1DIR &= ~BIT3; // set pin to input. ADC10CTL1 |= INCH3; // enable adc chan. #elif P1_3 == ADC10CLK #elif P1_3 == VREFn #endif #if P1_4 == RELAY P1DIR |= BIT4; // set pin to output. #elif P1_4 == THERM P1DIR &= ~BIT4; // set pin to input. ADC10CTL1 |= INCH4; // enable adc chan. #elif P1_4 == CT P1DIR &= ~BIT4; // set pin to input. ADC10CTL1 |= INCH4; // enable adc chan. #elif P1_4 == SMCLK #elif P1_4 == VREFp #endif #if P1_5 == RELAY P1DIR |= BIT5; // set pin to output. #elif P1_5 == THERM P1DIR &= ~BIT5; // set pin to input. ADC10CTL1 |= INCH5; // enable adc chan. #elif P1_5 == CT P1DIR &= ~BIT5; // set pin to input. ADC10CTL1 |= INCH5; // enable adc chan. #elif P1_5 == SCLK #endif BCSCTL1 = CALBC1_1MHZ; // Set DCO DCOCTL = CALDCO_1MHZ; P1OUT = 0xC0; // P1.6 & P1.7 Pullups P1REN |= 0xC0; // P1.6 & P1.7 Pullups P2OUT = 0; P2DIR = 0xFF; USICTL0 = USIPE6+USIPE7+USISWRST; // Port & USI mode setup USICTL1 = USII2C+USIIE+USISTTIE; // Enable I2C mode & USI interrupts USICKCTL = USICKPL; // Setup clock polarity USICNT |= USIIFGCC; // Disable automatic clear control USICTL0 &= ~USISWRST; // Enable USI USICTL1 &= ~USIIFG; // Clear pending flag _EINT(); #ifdef ADC ADC10CTL0 |= ENC + ADC10SC; #endif while(1) { LPM0; // CPU off, await USI interrupt _NOP(); // Used for IAR } } //****************************************************************************** // USI interrupt service routine //****************************************************************************** #pragma vector = USI_VECTOR __interrupt void USI_TXRX (void) { if (USICTL1 & USISTTIFG) // Start entry? { P1OUT |= 0x01; // LED on: sequence start i2cState = 2; // Enter 1st state on start } switch(i2cState) { case 0: // Idle, should not get here break; case 2: // RX Address USICNT = (USICNT & 0xE0) + 0x08; // Bit counter = 8, RX address USICTL1 &= ~USISTTIFG; // Clear start flag i2cState = 4; // Go to next state: check address break; case 4: // Process Address and send (N)Ack if (USISRL & 0x01) // If read... ownAddr++; // Save R/W bit USICTL0 |= USIOE; // SDA = output if (USISRL == ownAddr) // Address match? { USISRL = 0x00; // Send Ack P1OUT &= ~0x01; // LED off i2cState = 8; // Go to next state: RX data } else { USISRL = 0xFF; // Send NAck P1OUT |= 0x01; // LED on: error i2cState = 6; // Go to next state: prep for next Start } USICNT |= 0x01; // Bit counter = 1, send (N)Ack bit break; case 6: // Prep for Start condition USICTL0 &= ~USIOE; // SDA = input ownAddr = 0x90; // Reset slave address i2cState = 0; // Reset state machine break; case 8: // Receive data byte USICTL0 &= ~USIOE; // SDA = input USICNT |= 0x08; // Bit counter = 8, RX data i2cState = 10; // Go to next state: Test data and (N)Ack break; case 10:// Check Data & TX (N)Ack RXData = USISRL; // Get RX data USICTL0 |= USIOE; // SDA = output P1OUT = 0x0; if(RXData & BIT0) { P1OUT |= BIT1; } if(RXData & BIT1) { P1OUT |= BIT2; } if(RXData & BIT2) { P1OUT |= BIT3; } if(RXData & BIT3) { P1OUT |= BIT4; } USISRL = 0x00; // Send Ack P1OUT &= ~0x01; // LED off /* { USISRL = 0xFF; // Send NAck P1OUT |= 0x01; // LED on: error } */ USICNT |= 0x01; // Bit counter = 1, send (N)Ack bit i2cState = 6; // Go to next state: prep for next Start break; } USICTL1 &= ~USIIFG; // Clear pending flags } And I got lazy and did a fraunchpad version for testing which uses LED 5-8 instead of external relays and the extra voltage level. //****************************************************************************** // MSP430G2x31 - I2C Relay Controller, Fraunchpad Slave // // Description: This is a test version of the slave firmware for conveniently // testing using the Fraunchpad and it's user LEDs 5-8 in place of relays. // //****************************************************************************** #include <msp430.h> unsigned char RXData; int main(void) { WDTCTL = WDTPW + WDTHOLD; // Init SMCLK = MCLk = ACLK = 1MHz CSCTL0_H = 0xA5; CSCTL1 |= DCOFSEL0 + DCOFSEL1; // Set max. DCO setting = 8MHz CSCTL2 = SELA_3 + SELS_3 + SELM_3; // set ACLK = MCLK = DCO CSCTL3 = DIVA_3 + DIVS_3 + DIVM_3; // set all dividers to 1MHz // Configure Pins for I2C P1SEL1 |= BIT6 + BIT7; // Pin init // Configure pins for LEDs 5-8 P3DIR = BIT4+BIT5+BIT6+BIT7; // eUSCI configuration UCB0CTLW0 |= UCSWRST ; //Software reset enabled UCB0CTLW0 |= UCMODE_3 + UCSYNC; //I2C mode, sync mode UCB0I2COA0 = 0x48 + UCOAEN; //own address is 0x48 + enable UCB0CTLW0 &=~UCSWRST; //clear reset register UCB0IE |= UCRXIE0; //receive interrupt enable __bis_SR_register(CPUOFF + GIE); // Enter LPM0 w/ interrupts __no_operation(); } #pragma vector = USCI_B0_VECTOR __interrupt void USCIB0_ISR(void) { switch(__even_in_range(UCB0IV,0x1E)) { case 0x00: break; // Vector 0: No interrupts break; case 0x02: break; // Vector 2: ALIFG break; case 0x04: break; // Vector 4: NACKIFG break; case 0x06: break; // Vector 6: STTIFG break; case 0x08: break; // Vector 8: STPIFG break; case 0x0a: break; // Vector 10: RXIFG3 break; case 0x0c: break; // Vector 14: TXIFG3 break; case 0x0e: break; // Vector 16: RXIFG2 break; case 0x10: break; // Vector 18: TXIFG2 break; case 0x12: break; // Vector 20: RXIFG1 break; case 0x14: break; // Vector 22: TXIFG1 break; case 0x16: RXData = UCB0RXBUF; // Get RX data if(RXData & BIT0) { P3OUT |= BIT4; } else P3OUT &= ~BIT4; if(RXData & BIT1) { P3OUT |= BIT5; } else P3OUT &= ~BIT5; if(RXData & BIT2) { P3OUT |= BIT6; } else P3OUT &= ~BIT6; if(RXData & BIT3) { P3OUT |= BIT7; } else P3OUT &= ~BIT7; break; // Vector 24: RXIFG0 break; case 0x18: break; // Vector 26: TXIFG0 break; case 0x1a: break; // Vector 28: BCNTIFG break; case 0x1c: break; // Vector 30: clock low timeout break; case 0x1e: break; // Vector 32: 9th bit break; default: break; } }
  4. Have some 5V SPDT EM-relay (called "sugar cube" relays), rated for ~240VAC-10Amps. To switch those, I believe I cannot directly connect them to the MSP430 launchpad I/O pins, right ? I need to use a BJT/FET -- mandatorily ? The 4 relays in turn control incandesent lamps. If anyone has a circuit schematic they could share, it would be very helpful. thanks, Jay
  5. Here is a Relay boosterpack that I'm planning on using for a couple of things. 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. 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