Jumat, 26 Oktober 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