Friday, 26 October 2012

Solar Tracking System Using ATmega16

Introduction

Extracting useable electricity from the sun was made possible by the discovery of the photoelectric mechanism and subsequent development of the solar cell – a semi conductive material that converts visible light into a direct current. By using solar arrays, a series of solar cells electrically connected, a DC voltage is generated which can be physically used on a load. Solar arrays or panels are being used increasingly in remote areas where placement of electricity lines is not economically viable.

Light gathering is dependent on the angle of incidence of the light source providing power (i.e. the sun) to the solar cell’s surface, and the closer to perpendicular, the greater the power.

Day sunlight will have an angle of incidence close to 90°in the morning and the evening. At such an angle, the light gathering ability of the cell is essentially zero, resulting in no output. As the day progresses to midday, the angle of incidence approaches 0°, causing a steady increase in power until at the point where the light incident on the panel is completely perpendicular, and maximum power is achieved.

From this background, we see the need to maintain the maximum power output from the panel by maintaining an angle of incidence as close to 0° as possible. By tilting the solar panel to continuously face the sun, this can be achieved. This process of sensing and following the position of the sun is known as Solar Tracking.

The Sensing Element And Signal Processing

Many different methods have been proposed and used to track the position of the sun. The simplest of all uses use two LDR– a Light Dependent Resistor separated by a small plate to act as a shield to sunlight, as shown in the next figures.  




The stable position is when the two LDRs having the same light intensity (position A).When morning arrives, The left LDR is turned on(small resistance approximately shorted), causing a signal to turn the motor continuously counterclockwise until the two LDRs having the same light intensity again(position B). As the day slowly progresses (position C) is reached shortly, turning on the LDRs. The motor turns clockwise, and the cycle continues until the end of the day, or until the minimum detectable light level is reached.



The above figures show that when the sun at the right to the solar panel LDR2 has small value resistance and the other LDR has no light (large resistance) and a software in the micro-controller translate this to signals to control the stepper motor to rotate the panel to the left. 

Circuit description

The two LDRs are connected to a bridge and the output of the bridge is connected to a comparator (the analog comparator of the microcontroller is used).

When LDR1 has higher light intensity than LDR2 then the resistance of LDR1 is smaller than that of  LDR2 then voltage at AIN0 is higher than that of AIN1 and the output of comaparator is high.

When LDR2 has higher light intensity than LDR1 then the resistance of LDR1 is larger than that of  LDR2 then voltage at AIN0 is smaller than that of AIN1 and the output of comparator is low.

Then the output of the comparator is used in the UC program to control the stepper motor RV1 variable resistor is used to balance the bridge when the two LDRs having the same light intensities (due to the mismatch between the two LDRs).

The minimum light detectable circuit

It's a circuit used to detect the condition when there is no sunlight to turn off the tracking system
It uses a summing op. amp. Circuit it's output is given by :
Where 1.23V is the internal bandgap reference used by the analog comparator in the UC.
By calculating the value of V(AIN0) and V(AIN1) at sunset and adjusting RV2 the output of the comparator can be used to turn on or turn off the solar tracking system.

Microcontroller program for sun tracking system

// declaration of variables
#include <mega16.h>
#include <delay.h>
char temp ;
unsigned char seq[4]={0x10,0x40,0x20,0x80};
int i= 0;

// check the sum out
      ADCSRA.7=0;   // disable ADC
      SFIOR |= 0x08;   // enable MUX
      ADMUX |= 0x02; ADMUX &= 0xFA;    // selecting PA2
      ACSR.6=1; // select band gap reference
            
      if (ACSR.5==1)       //  no sunlight
        {
        PORTC.3=0;             // disable sun tracking system
        }
      else                      // there is sunlight
        {
        SFIOR &=0xF7; // disable the MUX
        ACSR.6=0;      // disable the band gap ref.
        PORTC.3=1; // enable H-bridge
        if (ACSR.5==1)       //  rotate counter clockwise
        {
        while (ACSR.5==1)
        {
        temp =PIND;
        temp &=0x0F;
        temp |= seq[i];
        PORTD = temp;
        delay_ms(100);
        i=(i+1)%4;
        }
        PORTD &=0x0F;          // stop the motor
        }
        else
        {
        while (ACSR.5==0)     //  rotate clockwise
        {
        i=(i+3)%4;
        temp =PIND;
        temp &=0x0F;
        temp |= seq[i];
        PORTD = temp;
        delay_ms(100);
        }
        PORTD &=0x0F;        // stop the motor
        }
        }


Some notes on the program

  • The sequence of the stepper motor is stored in a temporary variable (temp) because we use only 4 pins of PORTD and may be another outputs or inputs connected to the other pins of PORTD so it's first stored in a temporary variable so that it's not changed when changing the sequence of the stepper motor.
  • The piece of program if written in while (1) (endless loop) the motor will not stop in a certain position as always the output of the comparator will give one of the two states (high or low), so it's better to execute this program once every 20 or 30 minutes according to the motion of the sun path.

YOU CAN DOWNLOAD THE SIMULATION AND THE PROJECT HERE
Download Here
YOU CAN DOWNLOAD THIS TUTORIAL IN PDF HERE
Download Here

Do you like this post? Please link back to this article by copying one of the codes below.

URL: HTML link code: BB (forum) link code:

12 comments:

  1. the stepper is rotating continuously irrespective of the inputs to atmega 32,, even if i deleted the input wires to atmega 32,,the motor is rotating !!
    but it is supposed to rotate in steps based on ldr values know ??

    ReplyDelete
  2. you need to make a delay between the sequences sent to stepper but i dont know how motor rotates without input??!!!!!!!!!!!

    ReplyDelete
    Replies
    1. but it is rotating when i edited the simulation file provided.
      also the motor is rotating even when the both LDR's are given equal intensities !!
      could u please help me with this !

      Delete
    2. when LDR give the same voltage the motor will rotate as the analog comparator will give 0 or 1 even when analog inputs are equal(practically they will never be equal) so it's better to run this program once every 30 min or something like that (see second point in note)

      Delete
    3. i think this tracker is not that efficient. if you use 30 mins delay after every step .
      using ADC might give more accurate system.

      Delete
  3. This tracker won't track the optimum point(point where maximum amount of light falls on the panel). By keeping 30 mins delay after every step, the tracker only rotates a STEP in the direction of high light intensity, but not till the optimum point is attained.

    ReplyDelete
  4. sir,
    i am trying to make this project using one LDR only. i am thinking that if i get the the max. intensity of the LDR then according to this max. intensity i will compare another s/g which will come after few minute or few seconds delay.If the difference is greater then the max. intensity,then move the motor in both the directions. In which direction diff. will increase,i will leave that particular direction and will move the motor in opposite direction till again i get max. intensity.
    So plzz sir tell me that my approch is right or not.....if right then help me to develop such type of system.
    ramsahay27@gmail.com
    ## "if we are together then we will make a difference" ##
    thanks a lot

    ReplyDelete
    Replies
    1. you are right it can be made. but you will need to make a little bit difficult programming. any help you want you can send me at : arduino.lover@gmail.com

      Delete
  5. Sir,
    Can solar tracking using Arduino, if you can program into what?
    thanks...

    ReplyDelete
  6. Thanks for sharing this precious information. I like your concern in the post which is very useful for me.
    I like your information which is very useful for me. Thanks.


    embedded systems training in chandigarh



    ReplyDelete


  7. I found your blog quite interesting and the concern in the blog is really impressive.I always prefer to read the quality content and this thing I found in your post. Thanks for sharing.

    pic microcontroller training in chandigarh


    ReplyDelete