This program uses the "PSA" solar positioning algorithm calculating the sun position, based on longitude, latitude, and time zone. Then Mbed chip controls the two digital servos to rotate the solar panel to the correct azimuth and zenith angle.

Dependencies:   4DGL-uLCD-SE AX12 NetServices mbed spxml

Fork of AX12-HelloWorld by Chris Styles

Committer:
conantina
Date:
Mon Apr 25 17:28:13 2016 +0000
Revision:
2:2a3493799f03
n

Who changed what in which revision?

UserRevisionLine numberNew contents of line
conantina 2:2a3493799f03 1 /*
conantina 2:2a3493799f03 2 Helios.h - Library for calculating the solar
conantina 2:2a3493799f03 3 position.
conantina 2:2a3493799f03 4 Copyright (c) 2011 Hannes Hassler. All right reserved.
conantina 2:2a3493799f03 5
conantina 2:2a3493799f03 6 This library is free software; you can redistribute it and/or
conantina 2:2a3493799f03 7 modify it under the terms of the GNU Lesser General Public
conantina 2:2a3493799f03 8 License as published by the Free Software Foundation; either
conantina 2:2a3493799f03 9 version 2.1 of the License, or (at your option) any later version.
conantina 2:2a3493799f03 10
conantina 2:2a3493799f03 11 This library is distributed in the hope that it will be useful,
conantina 2:2a3493799f03 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
conantina 2:2a3493799f03 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
conantina 2:2a3493799f03 14 Lesser General Public License for more details.
conantina 2:2a3493799f03 15
conantina 2:2a3493799f03 16 You should have received a copy of the GNU Lesser General Public
conantina 2:2a3493799f03 17 License along with this library; if not, write to the Free Software
conantina 2:2a3493799f03 18 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
conantina 2:2a3493799f03 19 */
conantina 2:2a3493799f03 20 #ifndef Helios_h
conantina 2:2a3493799f03 21 #define Helios_h
conantina 2:2a3493799f03 22
conantina 2:2a3493799f03 23
conantina 2:2a3493799f03 24 #include <math.h>
conantina 2:2a3493799f03 25
conantina 2:2a3493799f03 26 // Declaration of some constants
conantina 2:2a3493799f03 27 #define pi 3.14159265358979323846
conantina 2:2a3493799f03 28 #define twopi (2*pi)
conantina 2:2a3493799f03 29 #define rad (pi/180)
conantina 2:2a3493799f03 30 #define dEarthMeanRadius 6371.01 // In km
conantina 2:2a3493799f03 31 #define dAstronomicalUnit 149597890 // In km
conantina 2:2a3493799f03 32
conantina 2:2a3493799f03 33
conantina 2:2a3493799f03 34 class Helios
conantina 2:2a3493799f03 35 {
conantina 2:2a3493799f03 36 public:
conantina 2:2a3493799f03 37 Helios();
conantina 2:2a3493799f03 38 void calcSunPos(
conantina 2:2a3493799f03 39 int iYear,
conantina 2:2a3493799f03 40 int iMonth,
conantina 2:2a3493799f03 41 int iDay,
conantina 2:2a3493799f03 42 double dHours,
conantina 2:2a3493799f03 43 double dMinutes,
conantina 2:2a3493799f03 44 double dSeconds,
conantina 2:2a3493799f03 45 double dLongitude,
conantina 2:2a3493799f03 46 double dLatitude);
conantina 2:2a3493799f03 47
conantina 2:2a3493799f03 48 // Main variables
conantina 2:2a3493799f03 49 double dElapsedJulianDays;
conantina 2:2a3493799f03 50 double dDecimalHours;
conantina 2:2a3493799f03 51 double dEclipticLongitude;
conantina 2:2a3493799f03 52 double dEclipticObliquity;
conantina 2:2a3493799f03 53 double dRightAscension;
conantina 2:2a3493799f03 54 double dDeclination;
conantina 2:2a3493799f03 55
conantina 2:2a3493799f03 56 // Auxiliary variables
conantina 2:2a3493799f03 57 double dSin_EclipticLongitude;
conantina 2:2a3493799f03 58
conantina 2:2a3493799f03 59
conantina 2:2a3493799f03 60 double dMeanLongitude;
conantina 2:2a3493799f03 61 double dMeanAnomaly;
conantina 2:2a3493799f03 62 double dOmega;
conantina 2:2a3493799f03 63
conantina 2:2a3493799f03 64 double dGreenwichMeanSiderealTime;
conantina 2:2a3493799f03 65 double dLocalMeanSiderealTime;
conantina 2:2a3493799f03 66 double dLongitude;
conantina 2:2a3493799f03 67 double dLatitudeInRadians;
conantina 2:2a3493799f03 68 double dHourAngle;
conantina 2:2a3493799f03 69 double dCos_Latitude;
conantina 2:2a3493799f03 70 double dSin_Latitude;
conantina 2:2a3493799f03 71 double dCos_HourAngle;
conantina 2:2a3493799f03 72 double dParallax;
conantina 2:2a3493799f03 73 double dAzimuth;
conantina 2:2a3493799f03 74 double dZenithAngle;
conantina 2:2a3493799f03 75 double dElevation;
conantina 2:2a3493799f03 76
conantina 2:2a3493799f03 77
conantina 2:2a3493799f03 78
conantina 2:2a3493799f03 79 };
conantina 2:2a3493799f03 80
conantina 2:2a3493799f03 81
conantina 2:2a3493799f03 82
conantina 2:2a3493799f03 83
conantina 2:2a3493799f03 84 #endif