MSP430

Connecting MSP430 and Stellaris Launchpad through NRF24L01

Last few weeks I have been working with RF modules to establish a wireless communication link between two systems. But most of the times my efforts were a failure. I had an MSP430 Launchpad, Stellaris Launchpad and two NRF24L01 modules. In order to check whether those wireless modules are working I had to setup a wireless communication link. I thought it would be easier for me if I used the available Stellaris and MSP launchpads for this task.

DSC04719

I started threads and followed some more on 430h and Stellaris forum.

http://forum.43oh.com/

http://forum.stellarisiti.com/

(more…)

MSP430: Temperature stabilizer

It has been a while since I played with the MSP430G2 evaluation board. Recently one of my friends wanted me to build a temperature stabilizer for one of his projects. The requirement was to stabilize a water container at 50 Centigrades. I decided to use the MSP430 as it has the basic components needed for it. In this post I will be talking about the code I used in the MSP430.

I used MSP430G2553 micro controller to do all the processing,
I used LM35 temperature sensor to measure the temperature.

The application was straight forward. I had to connect the LM35 IC through the ADC of the MSP430 and process the signal.

Schematic:

Following is the connection diagram.

 060420131317

Logic:

Following is a state diagram of the problem.

060420131316

LM35:

According to the datasheet of the LM35 it works within 4V and 30V supply voltages. Since the MSP430 works at 3.3V I used a 9V battery to power up the LM35 IC. But the ground should be shared with the launchpad for this to work properly. It gives 10mV/C as the output in a linear scale.

Code:

The coding was done using the TIs code composer studio.

#include <MSP430.h>

/*
* main.c
*/

unsigned int value = 0;
unsigned int upperT = 180;
unsigned int lowerT = 160;

//The function to configure the ADC
void configureAdc(){
ADC10CTL0 = SREF_1 + ADC10SHT_0 + ADC10ON + ADC10IE + REFON;
ADC10CTL1 = INCH_5 + ADC10DIV_3;
ADC10AE0 |= BIT5;
}

// ADC10 interrupt service routine
#pragma vector=ADC10_VECTOR;

__interrupt void ADC10_ISR (void)
{
__bic_SR_register_on_exit(CPUOFF); // Return to active mode
}

int main(void) {
short flag = 1; //relay on
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer

BCSCTL1 = CALBC1_1MHZ; //Clock calibration
DCOCTL = CALDCO_1MHZ;
BCSCTL2 &= ~(DIVS_3);

P1DIR |= BIT0 + BIT6; //GPIO selection
P1SEL |= BIT5;

P1OUT &= ~(BIT0 + BIT6); //LEDx off

configureAdc();
__enable_interrupt();

P1OUT |= BIT6; //LED1 ON

while(1){
__delay_cycles(2000000); //delay 2sec
ADC10CTL0 |= ENC + ADC10SC; //Enable conversion
__bis_SR_register(CPUOFF + GIE); //Low power mode with enabled interrupts
value = ADC10MEM; //ADC conversion

if(flag == 1){ //When relay is on
if (value>=upperT){ //Wait until T = 53C
P1OUT &= ~(BIT0 + BIT6);
P1OUT |= BIT0;
flag = 0; //relay off //Turn off the relay
}
}
else if(flag==0){ //When relay is off
if (value<=lowerT){ //Wait until T = 47C
P1OUT &= ~(BIT0 + BIT6);
P1OUT |= BIT6;
flag = 1; //relay on //Turn on the relay
}

}

}

return 0;
}

MSP430: Hello World

When you want to learn a programming language the first step you do is writing the hello world application. It’s the same scenario in any other new technological application. It’s always better to have a simple approach to understand some of the basic features of the product.

Hello world application of the MSP430, just same as anygeneral microcontrollers is the blinking of a single LED. In the Launchpad we can see three LEDs and one is of course for power. Here we will try to blink the red LED connected to the pin indexed as P1.0.

These inbuilt LEDs are very important when it comes to debugging and hardware. In a microcontroller we execute codes. It’s in-fact the firmware. The easiest way to determine whether some portion of the system is working is powering up an LED. It is mentioned that the green LED is connected to the pin P1.6.

All these pin positions are available in the User Guide of the Launchpad and the User Guide is available freely in the TI web site.

http://www.ti.com/lit/ug/slau318c/slau318c.pdf
(more…)