Solar Arduino tracker: Unterschied zwischen den Versionen
(22 dazwischenliegende Versionen von 3 Benutzern werden nicht angezeigt) | |||
Zeile 2: | Zeile 2: | ||
=General considerations= | =General considerations= | ||
− | + | For calculating the solar position with a microcontroller (on a fixed geographic place) | |
you have to solve two problems: | you have to solve two problems: | ||
The controller needs a time device (typically a battery buffered chip like in a PC) | The controller needs a time device (typically a battery buffered chip like in a PC) | ||
Zeile 12: | Zeile 12: | ||
==Get the Time== | ==Get the Time== | ||
− | [[Image: | + | [[Image:Arduino_DS1307_FritzingExport.jpg|thumb|timer chip DS1307 with Arduino]] |
To get Greenwich Time (aka UT) I use a DS1307 chip. | To get Greenwich Time (aka UT) I use a DS1307 chip. | ||
Following the description of http://www.glacialwanderer.com/hobbyrobotics/?p=12 | Following the description of http://www.glacialwanderer.com/hobbyrobotics/?p=12 | ||
Zeile 18: | Zeile 18: | ||
4.7K ones are just as fine. | 4.7K ones are just as fine. | ||
I have taken the code from that site and tucked the complexity | I have taken the code from that site and tucked the complexity | ||
− | into an Arduino libary ( | + | into an Arduino libary (DS1307H.h) |
==Calculate Azimuth and Elevation== | ==Calculate Azimuth and Elevation== | ||
− | + | The formulas for exact calculation of solar azimuth and elevation | |
− | + | are very involved. However, for practical | |
purposes like sun tracking of a heliostat there are | purposes like sun tracking of a heliostat there are | ||
simpler ones available. | simpler ones available. | ||
Zeile 30: | Zeile 30: | ||
and you can download it [http://www.psa.es/sdg/sunpos.htm here] as C++ code. | and you can download it [http://www.psa.es/sdg/sunpos.htm here] as C++ code. | ||
There are adaptions neccessary for Arduino, though. | There are adaptions neccessary for Arduino, though. | ||
− | The formulas for calculating the [http://en.wikipedia.org/wiki/Julian_day | + | The formulas for calculating the [http://en.wikipedia.org/wiki/Julian_day Julian Day] |
are not working properly on Arduino due to reduced double precision. | are not working properly on Arduino due to reduced double precision. | ||
Therefore, I have adapted them, expecting only Julians dates starting from 1.Jan. 2000. | Therefore, I have adapted them, expecting only Julians dates starting from 1.Jan. 2000. | ||
These calculations I have put into another library (Helios.h) | These calculations I have put into another library (Helios.h) | ||
+ | |||
+ | Use following program plus libraries for older Arduino IDE (0023 and older): | ||
+ | {{zip|SolarTracker4Arduino.zip|14KB|Version from 09.03.2011}} | ||
+ | |||
+ | For newer Arduino IDE (1.0.1 and later) use instead the following package, | ||
+ | {{zip|SolarTracker4Arduino1.0.1.zip|17KB|Version from 16.01.2015}} | ||
+ | |||
+ | Once you got it running, verify the calculated positions, for instance with | ||
+ | [http://www.sunearthtools.com/dp/tools/pos_sun.php solar position calculator] from | ||
+ | sunearthtools. (Attention: SolarTracker4Arduino does NOT account for daylight saving time (DST), | ||
+ | you have to determine UT (when you set your timer chip) as if there was no DST at all. On the other hand, sunearthtools allow using DST, | ||
+ | and this option is selected by default. | ||
+ | |||
+ | ==SPA Algorithm== | ||
+ | A much more accurate solar algorithm seems to be from Reda, I.; Andreas, A. (2003): | ||
+ | ''Solar Position Algorithm for Solar Radiation Applications. NREL Report No. TP-560-34302, | ||
+ | ''Revised January 2008. The algorithm is supposed to work for the years -2000 to 6000, | ||
+ | ''with uncertainties of +/-0.0003 degrees.'' | ||
+ | In this paper methods have been worked out according to the book from | ||
+ | ''Jean Meeus: Astronomical Algorithms, Willmann-Bell, Richmond 2000 (2nd ed., 2nd printing)'' | ||
+ | a well known text book for astronomic calculations. | ||
+ | The calculations are, however, very extensive; for Arduino I chose the simpler PSA. | ||
+ | Implementations and references for both algorithms I found thanks to the code from | ||
+ | [http://klaus.e175.net/solarpositioning Klaus Brunner]. It was also a valuable help for debugging | ||
+ | the Arduino implementation. | ||
+ | |||
+ | --[[User:Hannes.hassler|Hannes.hassler]] 13:36, 3 March 2011 (CET) |
Aktuelle Version vom 9. März 2015, 14:04 Uhr
German version Sonnenstandsberechner (für sun tracker devices)
General considerations
For calculating the solar position with a microcontroller (on a fixed geographic place) you have to solve two problems: The controller needs a time device (typically a battery buffered chip like in a PC) and it needs a reasonably simple algorithm to calculate solar azimuth and elevation from date, time and geographic position (longitude and latitude). An algorithm which works on a PC might have problems on a microcontroller. For instance, on Arduino you must take into account that double data type has the same precision as float (IEEE 23 bit mantissa)
Get the Time
To get Greenwich Time (aka UT) I use a DS1307 chip. Following the description of http://www.glacialwanderer.com/hobbyrobotics/?p=12 it worked immediately. Did not find any 2.2K resistors, 4.7K ones are just as fine. I have taken the code from that site and tucked the complexity into an Arduino libary (DS1307H.h)
Calculate Azimuth and Elevation
The formulas for exact calculation of solar azimuth and elevation are very involved. However, for practical purposes like sun tracking of a heliostat there are simpler ones available. Widely used formulas for solar tracking are the one from the so called PSA-algorithm. It has been made avaible from Plataforma Solar de Almeria (Spain) and you can download it here as C++ code. There are adaptions neccessary for Arduino, though. The formulas for calculating the Julian Day are not working properly on Arduino due to reduced double precision. Therefore, I have adapted them, expecting only Julians dates starting from 1.Jan. 2000. These calculations I have put into another library (Helios.h)
Use following program plus libraries for older Arduino IDE (0023 and older):
SolarTracker4Arduino.zip (14KB) [info] Version from 09.03.2011 |
For newer Arduino IDE (1.0.1 and later) use instead the following package,
SolarTracker4Arduino1.0.1.zip (17KB) [info] Version from 16.01.2015 |
Once you got it running, verify the calculated positions, for instance with solar position calculator from sunearthtools. (Attention: SolarTracker4Arduino does NOT account for daylight saving time (DST), you have to determine UT (when you set your timer chip) as if there was no DST at all. On the other hand, sunearthtools allow using DST, and this option is selected by default.
SPA Algorithm
A much more accurate solar algorithm seems to be from Reda, I.; Andreas, A. (2003): Solar Position Algorithm for Solar Radiation Applications. NREL Report No. TP-560-34302, Revised January 2008. The algorithm is supposed to work for the years -2000 to 6000, with uncertainties of +/-0.0003 degrees. In this paper methods have been worked out according to the book from Jean Meeus: Astronomical Algorithms, Willmann-Bell, Richmond 2000 (2nd ed., 2nd printing) a well known text book for astronomic calculations. The calculations are, however, very extensive; for Arduino I chose the simpler PSA. Implementations and references for both algorithms I found thanks to the code from Klaus Brunner. It was also a valuable help for debugging the Arduino implementation.
--Hannes.hassler 13:36, 3 March 2011 (CET)