Solarni sustav za praćenje izvora svjetlosti (Solar Tracking System)
Prikazana shema predstavlja sustav za automatsko praćenje izvora svjetlosti temeljen na Arduino Uno mikrokontroleru, četiri fotootpornika (LDR) i dva servo motora. Fotootpornici su povezani u naponske djelitelje te neprekidno mjere intenzitet svjetlosti iz različitih smjerova. Arduino uspoređuje očitane vrijednosti sa senzora i određuje smjer najvećeg intenziteta svjetlosti.
Na temelju dobivenih podataka upravlja s dva servo motora koji omogućuju horizontalno i vertikalno zakretanje sustava. Na taj način solarni panel ili drugi objekt može automatski pratiti položaj izvora svjetlosti tijekom dana, čime se povećava učinkovitost iskorištavanja dostupne svjetlosne energije.
Sustav je jednostavan za izradu, energetski učinkovit i pogodan za edukacijske projekte iz područja elektronike, automatike i obnovljivih izvora energije.
Kod za IDE sučelje:
#include <Servo.h> // include Servo library
// 180 horizontal MAX
Servo horizontal; // horizontal servo
int servoh = 180; // 90; // stand horizontal servo
int servohLimitHigh = 175;
int servohLimitLow = 5;
// 65 degrees MAX
Servo vertical; // vertical servo
int servov = 45; // 90; // stand vertical servo
int servovLimitHigh = 60;
int servovLimitLow = 1;
// LDR pin connections
// name = analogpin;
int ldrlt = 0; //LDR top left – BOTTOM LEFT <— BDG
int ldrrt = 1; //LDR top right – BOTTOM RIGHT
int ldrld = 2; //LDR down left – TOP LEFT
int ldrrd = 3; //ldr down rigt – TOP RIGHT
void setup(){
Serial.begin(9600);
horizontal.attach(8);
vertical.attach(9);
horizontal.write(180);
vertical.write(45);
delay(3000);
}
void loop() {
int lt = analogRead(ldrlt); // top left
int rt = analogRead(ldrrt); // top right
int ld = analogRead(ldrld); // down left
int rd = analogRead(ldrrd); // down right
int dtime = 10; int tol = 90; // dtime=diffirence time, tol=toleransi
int avt = (lt + rt) / 2; // average value top
int avd = (ld + rd) / 2; // average value down
int avl = (lt + ld) / 2; // average value left
int avr = (rt + rd) / 2; // average value right
int dvert = avt – avd; // check the diffirence of up and down
int dhoriz = avl – avr;// check the diffirence og left and rigt
Serial.print(avt);
Serial.print(” “);
Serial.print(avd);
Serial.print(” “);
Serial.print(avl);
Serial.print(” “);
Serial.print(avr);
Serial.print(” “);
Serial.print(dtime);
Serial.print(” “);
Serial.print(tol);
Serial.println(” “);
if (-1*tol > dvert || dvert > tol) // check if the diffirence is in the
tolerance else change vertical angle
{
if (avt > avd)
{
servov = ++servov;
if (servov > servovLimitHigh)
{
servov = servovLimitHigh;
}
}
else if (avt < avd)
{
servov= –servov;
if (servov < servovLimitLow)
{
servov = servovLimitLow;
}
}
vertical.write(servov);
}
if (-1*tol > dhoriz || dhoriz > tol) // check if the diffirence is in the
tolerance else change horizontal angle
{
if (avl > avr)
{
servoh = –servoh;
if (servoh < servohLimitLow)
{
servoh = servohLimitLow;
}
}
else if (avl < avr)
{
servoh = ++servoh;
if (servoh > servohLimitHigh)
{ servoh = servohLimitHigh; }
}
else if (avl = avr)
{ delay(5000); }
horizontal.write(servoh);
}
Serial.print(” “);
Serial.print(servoh);
Serial.print(” “);
Serial.print(servov);
Serial.print(” “);
delay(dtime);
}
Tekst koda
// code
#include <Servo.h>
Servo servohori;
int servoh = 0;
int servohLimitHigh = 160;
int servohLimitLow = 20;
Servo servoverti;
int servov =0;
int servovLimitHigh = 160;
int servovLimitLow = 20;
int ldrtopl = A2; //foto otpornik “gore-lijevo”
int ldrtopr = A1; //foto otpornik “gore-desno”
int ldrbotl = A3; // foto otpornik “dolje-lijevo”
int ldrbotr = A0; // foto otpornik “dolje-desno”
void setup () {
servohori.attach(10);
servohori.write(0);
servoverti.attach(9);
servoverti.write(0);
delay(500);
}
void loop()
{
servoh = servohori.read();
servov = servoverti.read();
//capturing analog values of each LDR
int topl = analogRead(ldrtopl);
int topr = analogRead(ldrtopr);
int botl = analogRead(ldrbotl);
int botr = analogRead(ldrbotr);
// calculating average
int avgtop = (topl + topr) / 2; //srednja vrijednost – gore
int avgbot = (botl + botr) / 2; //srednja vrijednost – dolje
int avgleft = (topl + botl) / 2; //srednja vrijednost – lijevo
int avgright = (topr + botr) / 2; //srednja vrijednost – desno
if (avgtop < avgbot)
{
servoverti.write(servov +1);
if (servov > servovLimitHigh)
{
servov = servovLimitHigh;
}
delay(10);
}
else if (avgbot < avgtop)
{
servoverti.write(servov -1);
if (servov < servovLimitLow)
{
servov = servovLimitLow;
}
delay(10);
}
else
{
servoverti.write(servov);
}
if (avgleft > avgright)
{
servohori.write(servoh +1);
if (servoh > servohLimitHigh)
{
servoh = servohLimitHigh;
}
delay(10);
}
else if (avgright > avgleft)
{
servohori.write(servoh -1);
if (servoh < servohLimitLow)
{
servoh = servohLimitLow;
}
delay(10);
}
else
{
servohori.write(servoh);
}
delay(50);
}
