Go Down

Topic: Tracker Solar (Read 707 times) previous topic - next topic

pc5_costa

Hello!

Does anyone have code for the solar tracker project (consisting of 4 SWDS, which will rotate the servo motor in order to capture more light)??

rogerClark

Let me Google that for you.

"solar tracker arduino"

Oh yes. Here it is.

http://www.instructables.com/id/Arduino-Solar-Tracker/?ALLSTEPS

Well, that wasn't so hard was it ;-)

And here is the code

Code: [Select]
/* this code is written by geobruce
for more info check my site http://xprobe.net
*/
#include <Servo.h> // include Servo library

Servo horizontal; // horizontal servo
int servoh = 90; // stand horizontal servo

Servo vertical; // vertical servo
int servov = 90; // stand vertical servo

// LDR pin connections
// name = analogpin;
int ldrlt = 0; //LDR top left
int ldrrt = 1; //LDR top rigt
int ldrld = 2; //LDR down left
int ldrrd = 3; //ldr down rigt

void setup()
{
  Serial.begin(9600);
// servo connections
// name.attacht(pin);
  horizontal.attach(9);
  vertical.attach(10);
}

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 rigt

  int dtime = analogRead(4)/20; // read potentiometers
int tol = analogRead(5)/4;

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

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 > 180)
{
servov = 180;
}
}
else if (avt < avd)
{
servov= --servov;
if (servov < 0)
{
servov = 0;
}
}
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 < 0)
{
servoh = 0;
}
}
else if (avl < avr)
{
servoh = ++servoh;
if (servoh > 180)
{
servoh = 180;
}
}
else if (avl == avr)
{
// nothing
}
horizontal.write(servoh);
}
delay(dtime);
}

dave-in-nj

well, since you asked for 4 swds and I have no idea what that means, I can offer you a couple places.

I checked out SWDS  http://swds.org/  but could not find any information about solar tracking.
" unique habitat for birds, bugs and other little creature...."

for what I know about solar tracking...first Dwyane over at Redrok invented the application of using 4 LED's as the sensors.  it has been copied many times, so I would start there.

that site offers a non-arduino solution as it uses  the sensors to move the motor.
the problem is that without the smarts, it has a few areas that it cannot handle. such as it will not follow with clouds and does not have either a night return or a flat setting to eliminate the effects of wind.

the guy is brilliant, but not great on web page design.

the other place is the guy who is brilliant with arduino code for the same application.  not sure if he uses 4swds though.

http://www.cerebralmeltdown.com/

this is a calculated postioner that uses your location on the planet, the alignment of the sun along with the rotation of the earth and will point the array at the sun.  it does not use feedback so if your alignment is off, your tracking is off.

both are very viable technologies and the blending of the two would make a great final project.  heck, you might be able to install one at SWDS !







Robin2

... and there have been several Threads on the same subject in the last few months. Some even have a similar title.

...R

PeterH


both are very viable technologies and the blending of the two would make a great final project.  heck, you might be able to install one at SWDS !


Having a tracker based purely on realtime brightness feedback strikes me as a very crude approach, but using it to refine a cumulative estimate of lat/long and season to configure a polar aligned tracker seems very elegant.
I only provide help via the forum - please do not contact me for private consultancy.

Go Up