Pages: [1] 2   Go Down
Author Topic: Tracker Solar  (Read 485 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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)??
Logged

Melbourne. Australia
Offline Offline
God Member
*****
Karma: 23
Posts: 733
Freelance software and hardware development based in Melbourne Australia
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
/* 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);
}
Logged

Offline Offline
God Member
*****
Karma: 28
Posts: 889
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 !






Logged

UK
Offline Offline
Tesla Member
***
Karma: 101
Posts: 6306
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

...R
Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12568
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

the code works correctly?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

sent me this code for a solar tracker, but it does to me, does not work!
someone could help me

* sketch_jun14a.ino (1.68 KB - downloaded 14 times.)
Logged

Offline Offline
Full Member
***
Karma: 7
Posts: 139
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That 1.68k file is small.
If it does not work then you are better off starting from a clean page.
Write down your specification of what yours must do, should do, may do, could do, and then write small programs at first to test each part of that.

By the way, in your writeup you might get nil marks if you don't spell it as the Oxford Dictionary does.
Logged

Oregon, USA
Offline Offline
Edison Member
*
Karma: 65
Posts: 2125
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you want help from this forum, read this and follow directions before posting: http://forum.arduino.cc/index.php/topic,148850.0.html
Logged

"It seems to run on some form of electricity"

UK
Offline Offline
Tesla Member
***
Karma: 101
Posts: 6306
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Their have been several Threads about solar trackers in recent months. Google will help you find them.

...R
Logged

UK
Offline Offline
Tesla Member
***
Karma: 101
Posts: 6306
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you take the trouble to search for previous Threads about solar tracking you should quickly find that all you need is 4 Light Dependent Resistors and 20 or 30 lines of code.

if you are prepared to adjust the tilt manually once a month you only need 2 LDRs.

...R
Logged

Victoria, Australia
Offline Offline
Edison Member
*
Karma: 46
Posts: 1390
Electronics Engineer/Industrial Control
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,  at the top of this page is a window that says "search the Arduino Forum", I suggest you use it by inputting

solar tracker

The forum is littered with this subject, it has been done so many times before.

Tom........ smiley
Logged

Everything runs on smoke, let the smoke out, it stops running......VK3DMK

Lincoln, England
Offline Offline
Full Member
***
Karma: 8
Posts: 183
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Have you build your hardware?
With the following features that are required by the sketch:

   4 light dependent resistors resistors, connected to analogue inputs 0, 1, 2, 3
   2 potentiometers, connected to analogue inputs 4 & 5
   2 servos connected to digital pins 9 & 10
Logged

Lincoln, England
Offline Offline
Full Member
***
Karma: 8
Posts: 183
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You say that the sketch doesn't work, but you don't say in what way.

Does the servo move in the wrong direction?
Does the servo move too far?
Do the servos go backwards and forwards trying to find the best position?

Just saying it doesn't work isn't very helpful to anyone prepared to give you assistance.
Logged

Offline Offline
God Member
*****
Karma: 28
Posts: 889
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

sent me this code for a solar tracker, but it does to me, does not work!
someone could help me

you need to get the schematic for that sketch and also make sure the servo's you are using are working with the signals being sent.

Logged

Pages: [1] 2   Go Up
Jump to: