We all know during summer heat is more intense because sun rays are perpendicular to the earth surface and hence the solar energy is concentrated over a small region.
· This can be applied to solar cell as well viz. the power output from a solar cell is directly proportional to sine of angle between the cell surface and light rays.
· So it’s clear that the power output from a solar cell will be maximum when it is facing the sun i.e. the angle between its surface and sun rays is 900.
· Thus the setup by which the above objective is achieved is known as solar tracker.
· Solar trackers are continually being employed in practice to get max efficiency.
· In this solar tracker project we will design a simplest single axis solar tracker and its concept can be expanded to make a full fledged dual axis solar tracker.
· We are making single axis for sake of simplicity and better understanding.
Components:
Freeduino board (Atmega 328)
Features:
Microcontroller |
ATmega328 |
Operating Voltage |
5V |
Input Voltage (recommended) |
7-12V |
Input Voltage (limits) |
6-20V |
Digital I/O Pins |
14 (of which 6 provide PWM output) |
Analog Input Pins |
6 |
DC Current per I/O Pin |
40 mA |
DC Current for 3.3V Pin |
50 mA |
Flash Memory |
32 KB (ATmega328) of which 0.5 KB used by bootloader |
SRAM |
2 KB (ATmega328) |
EEPROM |
1 KB (ATmega328) |
Clock Speed |
16 MHz |
Servo, Sensor & Interfaces
Servo:
Servo is most widely used actuator in project like robotic arms, Rc plane, self balancer, multirotors, etc.
· It uses a feedback mechanism to maintain its shaft position with minimum error.
The servo motor has three wires unlike normal PMDC motors which have two wires.
· Among those 3 wires, 2 wires provide power supply to the motor and one is used to send signals to the motor for required shaft positions.
These signals are PWM signal of varying duty cycle and frequency of 50Hz (analog servos) or 400-500Hz (digital servos).
· Analog servos are cheaper and consume less power and Digital servos provide relatively high torque and speed and are normally used as Helicopter Tail servo.
· Servo shaft is rotated by an angle depending on the ON-Time and Off-time of the pulse.
On time |
Off time |
Angle |
1 ms |
19 ms |
00 |
1.5 ms |
18.5 ms |
900 |
2 ms |
18 ms |
1800 |
· In this project I have used 9 gm Tower pro analog servo.
Sensor:
{C}· There are varieties of optical sensors available in market like Photo-resistors, photo-transistors, Photodiode and solar cells.
· Among these the most suitable for these project in terms of cost, availability and interfacing is photo-resistor also called as LDR (Light Dependent Resistor).
{C} LDR is a passive transducer hence we will use potential divider circuit to obtain corresponding voltage value from the resistance of LDR.
· LDRs resistance is inversely proportional to the intensity of light falling on it i.e. Higher the intensity or brightness of light the Lower the resistance and vice versa.
Interfaces:
Input(ADC):
· Arduino has an inbuilt 10-bit Analog to Digital converter(ADC), hence it can provide Digital values from 0-1023.(since 2^10=1024)
· We can also set the ADC reference voltage in arduino, but here we’ll let it use default value.
· LDR’s has two pins, and to get voltage value from it we use potential divider circuit.
· In potential divider we get Vout corresponding to resistance of LDR which in turn is a function of Light falling on LDR.
· The higher the intensity of light, lower the LDR resistance and hence lower the Output voltage (Vout)
· And lower the light intensity, higher the LDR resistance and hence higher the Vout.
· You can swap Rtop and LDR in above circuit to get inverse voltage and LDR resistance relationship.
Output(PWM):
· Arduino has a 8-bit PWM generator, so we can get up to 256 distinct PWM signal
· To drive a servo we need to get a PWM signal from the board, this is usually accomplished using timer function of the microcontroller but arduino makes it very easy.
· Arduino provides a servo library in which we have to only assign servo angle (0-1800) and the servo rotates by that angle, all the PWM calculations are handled by the servo library and we get a neat PWM signal according to the desired angle.
In our program we will set an initial angle for servo arm and then increment it or decrement it according to our output from LDR.
Circuit Connections
CIRCUIT Connections:
Circuit Connections are shown in the Circuit Diagram Tab.
Structural details:
You can make your own design, below are the self explanatory images of the one I made.
I just hot glued every part and it was ready within 20 minutes.
The material I used was light weight Depron (Ad board).
You can very well use cardboard or thermocol, ply etc but remember that bottom platform should be strong enough to hold everything and top platform (movable) should not be very heavy.
Figure: Top view
Figure: TOP
Figure : sideview
I directly connected the top platform to servo horn using hot glue.
Figure : side
Tracker Platform Details
Figure : platform details
We need a separator between the LDRs I call it shadower because it will cast shadow on appropriate LDR when solar tracker is not facing the sun.
And we actually compare the LDR value to an average value to see whether that LDR is receiving sun light or whether it is in SHADOW.
Figure : Platform Top
It worked better in Tubelight but under sun the LDRs were receiving light reflected from white surface so I painted the area near LDR to prevent any reflected light entering LDRs.
Figure: Platform bottom
In order that the tracker platform will move efficiently we have to attach shaft to its bottom and allow the shaft to rotate in some predefined hole.
Here 1 shaft is nothing but servo shaft itself and other shaft is the 14-16 Gauge copper wire bent in L shape.
One half is glued to the surface and other half is elevated so it can be inserted in the hole in bottom platform.
Figure : platform shaft
I also hot glued the potential divider circuit below the platform.
Under that glue mess are the 10K resistors connected to LDRs and both the circuit are using same power supply.
Orange and Yellow wire coming out from the mess is the Vout Pins from both LDRs, these wires will be connected to analog pins of Arduino.
Servo Motor Placement
Figure 9: hole for shaft
Figure 10: bottom platform
Just attach the servo using screws or make the space a bit smaller so servo fits tightly.
Figure 11
Figure: 12
Micro servos have enough torque but still if you platform is too heavy then you can use bigger servo.
Figure : Pins
After connecting pins to the arduino board if you are getting opposite response of tracker then just swap orange and yellow wires connected to arduino analog pin 0 and 1.
Program Description
Program Description:
{C}{· There is more than one approach to make a right code for solar tracker for almost same setup.
{· I went through various codes and they all used almost same method i.e. they compared both LDRs value with each other and the one getting lower light was determined.
{C· However in our program code we will just see which LDR is in shadow.
For eg: If light source is right w.r.t. to the platform then Right LDR will receive maximum light and left LDR will be in shadow. So we’ll use If statement to see which LDR is in shadow and rotate our platform in opposite direction so that it’s again facing the source. In above example, the platform will be rotated in right direction.
{C· Arduino program has two parts namely Setup part and Loop part.
· Setup part is executed only once and loop part is executed again and again.
{C· So first we will calibrate the sensors for light and dark values.
{C}{· Since calibration is required to be done only once we will put the calibration code in the setup part.
{C}{· I actually made two versions: one was manual calibration and other was automatic, I am sharing the
Automatic one.
}· Void_Setup
1. Initialize our servo and write 90 to it. (When I say write ‘xyz’ it means turning servo shaft to xyz degrees.)
when shaft turns to 90 degrees then immediately attach the movable platform to servo and platform should be perfect horizontal and facing the light source, now during tracking the platform can move +/-900 on both sides.(give enough delay so that you get enough time to attach your platform and orient your setup to face the light)
2. Then write 750 to your servo, the platform will turn through -150 from normal: at this point the values of both sensors should be read and saved in two separate variables. (Say x1 & y1)
when platform is 150 from normal (or 750 from horizontal) then sensor 1 is in shadow and other one is receiving maximum light.
3. Then write 1050 to your servo, now the servo will go +150 from normal and sensor 2 is in shadow and 1st one is receiving max light. Again the values are sampled and saved in another set of variables.(say x2 &y2)
4. Now the variables x1, x2 & y1, y2 will hold values of light and shadow for both sensors but we are only interested in the midpoint or average, so we’ll calculate average and store it in another set of variables.
X=(x1+x2)/2.
Y=(y1+y2)/2.
5. X and Y will be global variables i.e. they will be initialized before void_setup part and can be used in both setup and loop part.
{C}· Void_Loop
1. Here we will read the sensors.
2.Then compare the values with average value.
3.If value read from a sensor is greater than the average value then it means that sensor is in shadow and we will increment servo angles until the value being read becomes less than average value.
4.Same goes for other sensor, if it is in shadow then we’ll decrement the servo angles until sensor value becomes less than average value. Remember there are two average values for two sensors, we can’t use one value for both sensor.
5.Finally write the corrected angle values to servo.
You’ll get more clear idea after reading the program code, I have added enough comments in the code.
Video
Video for Solar Tracker
Project Source Code
###
/* Program for solar tracker*/
#include <Servo.h> // including servo library
Servo Sajids_Servo; // defining a servo named Sajids_servo
int angle=90; // initial value on servo angle
float Left_Sensor_AVG=0; // variable to store average value (Global variable)
float Right_Sensor_AVG=0; /*we will be requiring these variables in setup as well as loop part so we're declaring it here.*/
// the setup routine runs once when you press reset
void setup()
{
Sajids_Servo.attach(9); //declaring the pin at which servo is attached
Sajids_Servo.write(90); //initially writing 90 to servo
delay(2000); //hold at 90 degrees, give enough delay as required
/*Auto callibration part*/
Sajids_Servo.write(75); //turn shaft to 75 degrees
delay(1000); /*give delay so that you read value after the platform reaches the desired position*/
int left_1=analogRead(A0); //read left and right sensor values
int right_1=analogRead(A1);
delay(1000); // again delay
Sajids_Servo.write(105); // now write 105 i.e. turn shaft to 105 degrees
delay(1000); // same reason for delay
int left_2=analogRead(A0); //2nd set of value
int right_2=analogRead(A1);
delay(1000);
Left_Sensor_AVG= (left_1+left_2)/2; //calculate average and store it in global variable
Right_Sensor_AVG= (right_1+right_2)/2;
}
// the loop routine runs over and over again forever:
void loop()
{
int Left_LDR = analogRead(A0); // read the input on analog pins.
int Right_LDR = analogRead(A1);
if(Left_LDR > Left_Sensor_AVG) /*if left LDR's value is greater than average then it is in shadow.*/
{
angle=angle+1; /*increment servo angle, this angle will be written at the end of if statement*/
if (angle>=180) //don't let angle value go beyond 180
{
angle=180; //because servo can go max to 180 degrees.
}
}
else if(Right_LDR > Right_Sensor_AVG) /* if left sensor is in light then program will compare right sensor value*/
{
angle=angle-1; // decrement servo angle if right sensor is in shadow.
if (angle<=0)
{
angle=0; // again, don't let servo angle go below 0 degrees
}
}
Sajids_Servo.write(angle); // write the corrected angle to servos
delay(10); /*delay in between writes for stability, don't set it too low, coz at 5ms I was getting oscillations, 10 was just perfect for me.*/
}
###
Circuit Diagrams
Filed Under: Electronic Projects
Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.