code for dual axis solar tracker with arduino

Hi every one
i want to to do a project "solar tracker" and here's a discription of my solar tracker :
i use a dual axis solar tracker with spa algorith and two stepper motor driven by 2 ULN2803a and RTC ds1307, i looked on the web and find a code to track the sun by elevation angle and azimth from a member in the arduino's forum called Mowcius http://forum.arduino.cc/index.php?topic=22670.20;wap2 but there's no commands for the stepper motors and the RTC ds1307.
so anyone know how to integrated a code for the ds and stepper motors would appreciate it
and thanks in advance :-*

void loop() {
 // Get the UTC date and time.  Set your DS1307 to UTC.
 Year = DS1307.year();
 Month = DS1307.month();
 Day = DS1307.day();
 Hours = DS1307.hour();
 Minutes = DS1307.minute();

 //Run sun position calculations
 sunPos();
 
 // Run the stepper motors to point at ElevationAngle and Azimuth.  How you do that depends on
// the geometry of your hardware and where the motors are currently pointing.  Since you occasionally lose
// power you should have switches to indicate a HOME position for which you know the azimuth and elevation.

delay(60000); // Wait a minute since the time only changes once a minute.
}

If the purpose is to keep a solar panel facing the sun stepper motors are a bad idea as they use too much energy.

...R

Robin2:
If the purpose is to keep a solar panel facing the sun stepper motors are a bad idea as they use too much energy.

...R

what you suggest fop replacing the stepper motors ?

Hi,
How big is the array?

Tom..... :slight_smile:

How well balanced is the array and how much wind might it have to work in?

You could build something so fine and light that a mini-motor can turn it and lose the whole rig to a 10mph gust or a hard rain. Design your rig with real world use in mind.

Whatever motive device you use, make your code let the motion stop at “close enough” and it won’t waste energy “tuning” the position.
With solar cells you can let it go at least 5 degrees, the cosine of 5 degrees is .9962+. Cosine of 15 degrees is over .9659+. The array doesn’t have to move so often and only in one direction.

It might do to use a big windup motor and use a solenoid to hold or release the catchment for on/off control.

If your gymbal is designed right, you can set the vertical axis once a day and be right enough.

You want to track by pre-determined data. Have you thought about using sensors to follow the sun? Sunlight comes in for practical purposes in parallel (not diverging) rays. If you glued a soda can to a board and pointed the soda can directly at the sun it would cast no shadow on the board. If you ring the base of the soda can with maybe 4 light detectors, you can know from the shadow when the can is not pointing at the sun. Wait for the shadow to cover one side and then move till the shadow covers the opposite and wait again. Just make sure the program can tell when clouds are over when most/all the sensors read shadow and don’t have it move immediately over unexpected data.

lamineoriska:
what you suggest fop replacing the stepper motors ?

A DC motor with a worm drive has the virtue that it is powerful and can’t be driven by the load so it will hold position without any power. A motor driving a screwed rod is another good option.

For a larger solar panel a used car screen-wiper motor might be a good choice.

From a programming point of view all you need is to detect that the sun has moved on and move the motor a little to catch up. If the “little” is not enough, just repeat it. If it is slightly too much, just leave things alone and the sun will catch up.

…R

GoForSmoke:
If your gymbal is designed right, you can set the vertical axis once a day and be right enough.

Even once every week or two would be enough.

Robin2:
From a programming point of view all you need is to detect that the sun has moved on and move the motor a little to catch up. If the "little" is not enough, just repeat it. If it is slightly too much, just leave things alone and the sun will catch up.

So what happens after sunset?

If it were up to me, I'd just use a clock and move the motor maybe once every 20 or 30 minutes during the day.

odometer:
Even once every week or two would be enough.

So right!

The sun track moves through 46 degrees in 6 months, one change a month would mean at most 7.7 degrees 'off'. Cosine 8 degrees is .9903, only 1% loss. Set the panel midway and you get half the loss.

So what happens after sunset?

All the sensors see dark for long enough (hours?), move the panel to start position.

odometer:
So what happens after sunset?

Write two or three lines of code to make it go back to the East (assuming you are in the Northern hemisphere).

In fact if the sensors are bi-directional (so it moves a little bit towards the brightest point) it should sort itself out at sunrise without any special code.

...R

The sun rises in the east everywhere on the planet. (Except if you're close enough to the pole in winter, where it may not rise at all.)

I would like to ask Smoky how the windup motor is reset for the next day. Waterwheel winds up a weight at night?

MorganS:
The sun rises in the east everywhere on the planet.

You are quite right. I was confusing East with "Left" - but then I have to say I am facing South - which just makes things nonsensical.... doh.

I will edit my Post.

...R

Robin2:
From a programming point of view all you need is to detect that the sun has moved on and move the motor a little to catch up. If the "little" is not enough, just repeat it. If it is slightly too much, just leave things alone and the sun will catch up.
...R

GoForSmoke:
All the sensors see dark for long enough (hours?), move the panel to start position.

Robin2:
Write two or three lines of code to make it go back to the East (assuming you are in the Northern hemisphere).

In fact if the sensors are bi-directional (so it moves a little bit towards the brightest point) it should sort itself out at sunrise without any special code.
...R

Hi,
Sorry guys, what sensors, the OP is using a timing algorythm, he has not mentioned sensors.
I could get on my soapbox about the over complexity of this method compared to light sensing, but I won't.
Tom.... :slight_smile:

TomGeorge:
Hi,
How big is the array?

Tom..... :slight_smile:

It's not big just a cell 10*10mm

I want to use the algorithms to track the sun not with the sensors (LDR) and i need to make commands to the stepper motors with the results of azimuth and altitude angles from the program i mention it above at the link

Is there a gearbox between the stepper motor and the solar panel?
If so what is the gear ratio?

How many steps does your stepper motor take per revolution?

We need this information to be able to calculate how many steps of the motor correspond to one degree of rotation of the array.

MorganS:
The sun rises in the east everywhere on the planet. (Except if you're close enough to the pole in winter, where it may not rise at all.)

I would like to ask Smoky how the windup motor is reset for the next day. Waterwheel winds up a weight at night?

Human power. It's an old secret that people who have done manual labor know about.

johnwasser:

void loop() {

// Get the UTC date and time.  Set your DS1307 to UTC.
Year = DS1307.year();
Month = DS1307.month();
Day = DS1307.day();
Hours = DS1307.hour();
Minutes = DS1307.minute();

//Run sun position calculations
sunPos();

// Run the stepper motors to point at ElevationAngle and Azimuth.  How you do that depends on
// the geometry of your hardware and where the motors are currently pointing.  Since you occasionally lose
// power you should have switches to indicate a HOME position for which you know the azimuth and elevation.

delay(60000); // Wait a minute since the time only changes once a minute.
}

I appreciate your help i'll try it when i solve the problem with my ds1307 it's never change, displaying the same time and date

Robin2:
If the purpose is to keep a solar panel facing the sun stepper motors are a bad idea as they use too much energy.

...R

I already purchase the steppers motors and i should work with it
but the steppers will not work all the day long
they will work for couple times to drive the panel and face the sun about once/30 min