Introduction: Solar Tracking Device Using Msp430

HI everyone.here i am showing my solar tracking project for solar panel. The two LDRs are connected to both edges of the solar panel.so it can able to follow sun direction from east side sunrise to until west side sun set. this project find more light intensity area so it help the solar panel to produce maximum power. the two LDRs analog signal are converted into digital signal in MSP430G2231. the converted values are compared continuously in MSP430G2231 and correspondingly which LDR value is higher that side solar panel will turn. let us see the circuit diagram and programming code for this project.

Step 1: Circuit Diagram

here is the circuit diagram of the project. in the circuit diagram you can see that there is 10 k potentiometer . they are used to adjust and calibrate the ldr value . adjust two pods until the both ldr value get equal. for that connect the circuit and program the ic then do adjust it.

Step 2: Coding :

i did the coding for this project using code composer studio software. here i present the coding for msp430g2231.

#include "msp430.h"

#define ADC_CHANNELS 2

unsigned int samples[ADC_CHANNELS];

#define LED1 BIT4

#define LED2 BIT6

#define SENSOR_LEFT BIT0

#define SENSOR_GND BIT2

#define SENSOR_RIGHT BIT1

#define SENSOR_GND1 BIT3

#define RED_LED LED1

#define GRN_LED LED2

void ConfigureAdc(void){

ADC10CTL1 = INCH_1 | ADC10DIV_0 | CONSEQ_3 | SHS_0;

ADC10CTL0 = SREF_0 | ADC10SHT_2 | MSC | ADC10ON | ADC10IE;

ADC10AE0 =SENSOR_LEFT + SENSOR_RIGHT ;

ADC10DTC1 = ADC_CHANNELS;

}

void main(void) {

WDTCTL = WDTPW | WDTHOLD;

BCSCTL1 = CALBC1_1MHZ;

DCOCTL = CALDCO_1MHZ;

BCSCTL2 &= ~(DIVS_3);

P1DIR = 0; /* set as inputs */

P1SEL = 0; /* set as digital I/Os */

P1OUT = 0; /* set resistors as pull-downs */

P1REN = 0xFF; /* enable pull-down resistors */

P2DIR = 0; /* set as inputs */

P2SEL = 0; /* set as digital I/Os */

P2OUT = 0; /* set resistors as pull-downs */

P2REN = 0xFF; /* enable pull-down resistors */

P1REN &= ~(LED1 | LED2); /* disable pull-up/downs */

P1DIR |= (LED1 | LED2); /* configure as oututs */

P1REN &= ~(SENSOR_GND |SENSOR_GND1); /* disable pull-up/down */

P1OUT &= ~(SENSOR_GND|SENSOR_GND); /* SENSOR_GND should be at GND */

P1DIR |= (SENSOR_GND |SENSOR_GND1); /* SENSOR_GND must be an output */

P1REN |= (SENSOR_LEFT|SENSOR_RIGHT); /* enable pull-up on SENSOR */

P1IN |= (SENSOR_LEFT|SENSOR_RIGHT); /* set resistor as pull-up */

ConfigureAdc();

__enable_interrupt();

while (1) {

__delay_cycles(1000);

ADC10CTL0 &= ~ENC;

while (ADC10CTL1 & BUSY);

ADC10SA = (unsigned int)samples;

ADC10CTL0 |= ENC + ADC10SC;

__bis_SR_register(CPUOFF + GIE);

if (samples[0] < samples[1]) {

P1OUT |=RED_LED;

P1OUT &= ~(GRN_LED);

} else if (samples[0] == samples[1]) {

P1OUT &= ~(RED_LED);

P1OUT &= ~(GRN_LED);

} else {

P1OUT |= GRN_LED;

P1OUT &= ~(RED_LED);

}

}

}

#pragma vector=ADC10_VECTOR

__interrupt void ADC10_ISR (void){

__bic_SR_register_on_exit(CPUOFF);

}

thank you for watching

Comments

author
Cheeme (author)2016-12-29

Sir we wish to use this code for tiva tm4c123gh6m microcontroler
Sir plz tell us can we use the above code for our roject

author
psndalipo (author)2016-01-27

Nice project i was trying to do somwthing similar, but i am struggling witnh reading and convrting the values can u help me?

author
Jennislav (author)2015-04-20

This is wonder full project

author
vigneshraja (author)Jennislav2015-04-20

Thank you

author
prashantj1 (author)2015-01-16

sir i want to do this project can u tell me if the code will run or not.........or which other

microcontroller can be used..

author
vigneshraja (author)prashantj12015-01-17

yes above given code will work on msp430 launchpad.it will work on microcontroller msp430g2231, msp430g2553.

author

can we use the same code for msp430g2553

author

donno :P

author
akram faridi (author)2015-02-19

I have been trying to run this code but the compiler is showing a lot of errors. Could you help me rectify it?

author
vigneshraja (author)akram faridi2015-02-23

yes. tell me what are the errors compiler shows and what msp430 ic you are using either msp430g2231 or something else. And make sure you are using code composer studio software.

author
akram faridi (author)vigneshraja2015-03-20

i am using MSP 430G2553 IN20 , its exactly the same launchpad you have used. I will post the errors i am getting in a day. And i am using CCS v6

author

alright great no errors; i am trying to make it dual axis ...... i will post the code here could you check and tell me if its right?
Could you even tell me by how many degrees is the panel going to rotate basing on the illumination?

author
prashantj1 (author)2015-03-04

can u plz tell me about the degree of rotation by which the panel rotates after comparing the ldr values

author
prashantj1 (author)2015-03-04

can u plz tell me about the degree of rotation by which the panel rotates after comparing the ldr values

author
ayush.rocking (author)2014-08-13

good idea
but practically it wont work
ldr sensors are not that sensitive
when use them at 11am or 3 pm they will give the same value in open area .

author
pcusack1 (author)2014-07-14

Very cool project.

author
vigneshraja (author)pcusack12014-07-14

thank u friend

author
Hassanul_ (author)2014-07-13

I was looking for this. Glad I found it!! Good job

author
vigneshraja (author)Hassanul_2014-07-13

thank u friend