Pages: 1 [2] 3 4   Go Down
Author Topic: New sun tracker idea?  (Read 5752 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 94
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Netherlands
Offline Offline
Sr. Member
****
Karma: 0
Posts: 414
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

North Yorkshire, UK
Offline Offline
Faraday Member
**
Karma: 104
Posts: 5531
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

North Yorkshire, UK
Offline Offline
Faraday Member
**
Karma: 104
Posts: 5531
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

spamming shit
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 15
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

North Yorkshire, UK
Offline Offline
Faraday Member
**
Karma: 104
Posts: 5531
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Blimey. I didn't expect this many replies..
The joys of this forum smiley
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

Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 15
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Mowcius.

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

North Yorkshire, UK
Offline Offline
Faraday Member
**
Karma: 104
Posts: 5531
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

And which part do you want as a code?

Mowcius
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 15
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

North Yorkshire, UK
Offline Offline
Faraday Member
**
Karma: 104
Posts: 5531
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, sorry for my delay now smiley-razz

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:
#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:
#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  >smiley-sad
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
« Last Edit: June 29, 2010, 04:05:15 am by mowcius » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 15
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

North Yorkshire, UK
Offline Offline
Faraday Member
**
Karma: 104
Posts: 5531
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.   >smiley-sad

I will keep trying to sort it though.

Mowcius
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 15
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Gaithersburg, Maryland
Offline Offline
Newbie
*
Karma: 0
Posts: 11
If it ain't broken, don't fix it.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: 1 [2] 3 4   Go Up
Jump to: