Go Down

Topic: New sun tracker idea? (Read 6 times) previous topic - next topic

Perfo

LDR's would need assistance to ensure they dont end up facing the wrong way if some plonker stood infront of it. :)

CrashingDutchman

http://hackaday.com/2010/05/24/sun-tracking-solar-panel/

mowcius

Quote
LDR's would need assistance to ensure they dont end up facing the wrong way if some plonker stood infront of it.

Yeah, it was just a simple idea.

You could easily have 12 months or maybe 52 weeks programmed instead of every day as it does not change that much over a week.

Mowcius

SunTracking

Good afternoon:

We write in this forum to share our experience technological developments automatic solar tracking systems in Spain.

The solar tracking system is operating in more than 600 sun trackers along 30 large solar power plants.

If you are developing a prototype sun tracker, or have problems with the tracking control system may present SunTracking will solve the problem.

Inquiries at our website:

http://www.suntracking.es

And please contact us with any questions.

Yours sincerely

SunTracking

mowcius


breaksbassbleeps

Blimey. I didn't expect this many replies..

BroHogan: I would love to make one which calculates the suns position in realtime. It's just the equation needed is too complex for me to put into Arduino code.
There are a few Excel spreadsheets knocking about which show each step in the calculation though. Is there anyone out there who's be able to turn that into code?

Thanks everyone for reading the post.

mowcius

Quote
Blimey. I didn't expect this many replies..

The joys of this forum :)
I have to say that I have grown to expect this kind of response from other forums now, forgetting how much better this one is that others that I know of.

If you have an excel spreadsheet then I would be happy to take a look.

Mowcius


breaksbassbleeps

Hi Mowcius.

Here's a link to the excel spreadsheet I was talking about earlier..
http://www.precisionsundials.com/sunpositioncalculator.xls

mowcius

And which part do you want as a code?

Mowcius

breaksbassbleeps

Hi Mowcius.

Sorry for the long delay. Why does work always get in the way of the fun stuff in life  :-/

Well what I was thinking is that the start time and GPS co-ords are entered into the code and uploaded. In effect I'm looking to get the Azimuth angle and the Elevation angle out the other end which can be sent directly to the servos which move the solar panels.
Servos would only really work on a small setup and I'd like to end up using a stepper motor driven system.
Hope my ramblings make sense.
Thanks.  :)

mowcius

#25
Jun 28, 2010, 09:24 pm Last Edit: Jun 29, 2010, 11:05 am by mowcius Reason: 1
Ok, sorry for my delay now :P

I had a look at that spreadsheet and it is horrendously complicated to try to convert into arduino code.
However I found some code that should work:

SunPos.cpp
Code: [Select]
#include "sunpos.h"
#include <math.h>

void sunpos(cTime udtTime,cLocation udtLocation, cSunCoordinates *udtSunCoordinates)
{
     // Main variables
     float dElapsedJulianDays;
     float dDecimalHours;
     float dEclipticLongitude;
     float dEclipticObliquity;
     float dRightAscension;
     float dDeclination;

     // Auxiliary variables
     float dY;
     float dX;

     // Calculate difference in days between the current Julian Day
     // and JD 2451545.0, which is noon 1 January 2000 Universal Time
     {
           float dJulianDate;
           long int liAux1;
           long int liAux2;
           // Calculate time of the day in UT decimal hours
           dDecimalHours = udtTime.dHours + (udtTime.dMinutes
                 + udtTime.dSeconds / 60.0 ) / 60.0;
           // Calculate current Julian Day
           liAux1 =(udtTime.iMonth-14)/12;
           liAux2=(1461*(udtTime.iYear + 4800 + liAux1))/4 + (367*(udtTime.iMonth
                 - 2-12*liAux1))/12- (3*((udtTime.iYear + 4900
           + liAux1)/100))/4+udtTime.iDay-32075;
           dJulianDate=(float)(liAux2)-0.5+dDecimalHours/24.0;
           // Calculate difference between current Julian Day and JD 2451545.0
           dElapsedJulianDays = dJulianDate-2451545.0;
     }

     // Calculate ecliptic coordinates (ecliptic longitude and obliquity of the
     // ecliptic in radians but without limiting the angle to be less than 2*Pi
     // (i.e., the result may be greater than 2*Pi)
     {
           float dMeanLongitude;
           float dMeanAnomaly;
           float dOmega;
           dOmega=2.1429-0.0010394594*dElapsedJulianDays;
           dMeanLongitude = 4.8950630+ 0.017202791698*dElapsedJulianDays; // Radians
           dMeanAnomaly = 6.2400600+ 0.0172019699*dElapsedJulianDays;
           dEclipticLongitude = dMeanLongitude + 0.03341607*sin( dMeanAnomaly )
                 + 0.00034894*sin( 2*dMeanAnomaly )-0.0001134
                 -0.0000203*sin(dOmega);
           dEclipticObliquity = 0.4090928 - 6.2140e-9*dElapsedJulianDays
                 +0.0000396*cos(dOmega);
     }

     // Calculate celestial coordinates ( right ascension and declination ) in radians
     // but without limiting the angle to be less than 2*Pi (i.e., the result may be
     // greater than 2*Pi)
     {
           float dSin_EclipticLongitude;
           dSin_EclipticLongitude= sin( dEclipticLongitude );
           dY = cos( dEclipticObliquity ) * dSin_EclipticLongitude;
           dX = cos( dEclipticLongitude );
           dRightAscension = atan2( dY,dX );
           if( dRightAscension < 0.0 ) dRightAscension = dRightAscension + twopi;
           dDeclination = asin( sin( dEclipticObliquity )*dSin_EclipticLongitude );
     }

     // Calculate local coordinates ( azimuth and zenith angle ) in degrees
     {
           float dGreenwichMeanSiderealTime;
           float dLocalMeanSiderealTime;
           float dLatitudeInRadians;
           float dHourAngle;
           float dCos_Latitude;
           float dSin_Latitude;
           float dCos_HourAngle;
           float dParallax;
           dGreenwichMeanSiderealTime = 6.6974243242 +
                 0.0657098283*dElapsedJulianDays
                 + dDecimalHours;
           dLocalMeanSiderealTime = (dGreenwichMeanSiderealTime*15
                 + udtLocation.dLongitude)*rad;
           dHourAngle = dLocalMeanSiderealTime - dRightAscension;
           dLatitudeInRadians = udtLocation.dLatitude*rad;
           dCos_Latitude = cos( dLatitudeInRadians );
           dSin_Latitude = sin( dLatitudeInRadians );
           dCos_HourAngle= cos( dHourAngle );
           udtSunCoordinates->dZenithAngle = (acos( dCos_Latitude*dCos_HourAngle
                 *cos(dDeclination) + sin( dDeclination )*dSin_Latitude));
           dY = -sin( dHourAngle );
           dX = tan( dDeclination )*dCos_Latitude - dSin_Latitude*dCos_HourAngle;
           udtSunCoordinates->dAzimuth = atan2( dY, dX );
           if ( udtSunCoordinates->dAzimuth < 0.0 )
                 udtSunCoordinates->dAzimuth = udtSunCoordinates->dAzimuth + twopi;
           udtSunCoordinates->dAzimuth = udtSunCoordinates->dAzimuth/rad;
           // Parallax Correction
           dParallax=(dEarthMeanRadius/dAstronomicalUnit)
                 *sin(udtSunCoordinates->dZenithAngle);
           udtSunCoordinates->dZenithAngle=(udtSunCoordinates->dZenithAngle
                 + dParallax)/rad;
     }
}

SunPos.h
Code: [Select]
#ifndef __SUNPOS_H
#define __SUNPOS_H

#include <WProgram.h>

// Declaration of some constants
#define pi    3.14159265358979323846
#define twopi (2*pi)
#define rad   (pi/180)
#define dEarthMeanRadius     6371.01      // In km
#define dAstronomicalUnit    149597890      // In km

struct cTime
{
     int iYear;
     int iMonth;
     int iDay;
     float dHours;
     float dMinutes;
     float dSeconds;
};

struct cLocation
{
     float dLongitude;
     float dLatitude;
};

struct cSunCoordinates
{
     float dZenithAngle;
     float dAzimuth;
};

void sunpos(cTime udtTime, cLocation udtLocation, cSunCoordinates *udtSunCoordinates);

#endif


Unfortunately when I add them to a sketch and try to compile it I keep getting an error whatever I try and do  >:(
Done some searching and I'm still clueless!

Error:
Quote

C:\DOCUME~1\Mowcius\LOCALS~1\Temp\build1394151963041089549.tmp\core.a(main.cpp.o): In function `main':

C:\Program Files\arduino-0018\hardware\arduino\cores\arduino/main.cpp:7: undefined reference to `setup'

C:\Program Files\arduino-0018\hardware\arduino\cores\arduino/main.cpp:10: undefined reference to `loop'

If anyone has any ideas then speak up!  8-)

Mowcius

breaksbassbleeps

Blimey Mowcius.

Thanks for taking a look anyway. It's really quite mind-bending the calculation needed. I'm still currently designing some basic code to run a simple solar tracker with a table of pre-defined angles. With any luck the code you provided will be able to run the same hardware.
Does anyone know what could be causing the compiling error?

Thanks again Mowcius.  :D

mowcius

Quote
Thanks for taking a look anyway. It's really quite mind-bending the calculation needed.

It is pretty complex. This will be pretty accurate if I can get it working.
If you think this is complex though then you should have seen the other C code I found. It is no doubt more accurate but it takes into account humidity and temperature as well for calculating the refraction through the atmosphere! Much too accurate for a simple sun tracker for solar panel or similar. Unfortunately that is going to require a lot of work if I wanted to run it on an arduino.
Quote
I'm still currently designing some basic code to run a simple solar tracker with a table of pre-defined angles. With any luck the code you provided will be able to run the same hardware.

Well I found some values that I was going to to some code with using a lookup table and an RTC but I would rather have some code that does not require massive changes for different locations. I am thinking of the possibilities of implementing this onto my UGV so that using a magnetic compass module, a GPS and a RTC it will be able to accurately point at the sun. This wouldn't then work on a slope but for the amount of slope it might be on, I don't think it matters much.
Quote
Does anyone know what could be causing the compiling error

Unfortunately I have not had any luck yet with working it out.   >:(

I will keep trying to sort it though.

Mowcius

breaksbassbleeps

Quote
It is pretty complex. This will be pretty accurate if I can get it working


Not wrong there. I've spent most of the morning trying to break down each calculation step with the aid of excel and wikipedia. It's be great to get this working.

Quote
This wouldn't then work on a slope but for the amount of slope it might be on, I don't think it matters much.


Would some kind of inclinometer be able to tell your UGV if it were driving up a slope?

incidently, How fast do you think a standard arduino would be able to carry out the entire calculation?

BreaksBassBleeps

Austin Duff

For an "inclinometer" you could try an IMU. ArduIMU is cheap and easy to implement.

Go Up