Liebe Leute
Möchte euch den Script nicht vorenthalten. Habe für Arduino Source Code gefunden, der Azimut und Elevation berechnet anhand der Zeit und Ort. Habe das heute mal schnell nach PHP übertragen, flux in meine Steuerung aufgenommen und es scheint zu funktionieren.
Bemerkung: Beispiel Aufruf am Ende des Codes.
Bemerkung: Azimut starten im Norden bei 0 Grad.
Bemerkung: Längen- und Breitengrad für euren Ort kann man überall im Internet raussuchen.
Code ist nicht schön aufbereitet etc…
Nicht ausgiebig getestet und daher alles ohne Gewähr.
! Eigentlich sollte eine solche Funktion gleich in den Kern von IP Symcon übernommen werden, denn bei Beschattungssteuerungen kommt dieses Thema immer wieder auf. :rolleyes:
Bis dann und Gruss
Adrian
<?
//function calcSunPos( int iYear,int iMonth,int iDay,double dHours, double dMinutes,double dSeconds, double dLongitude, double dLatitude)
function calcSunPos( $iYear, $iMonth, $iDay, $dHours, $dMinutes, $dSeconds, $dLongitude, $dLatitude)
{
$pi = 3.14159265358979323846;
$twopi = (2*$pi);
$rad = ($pi/180);
$dEarthMeanRadius = 6371.01; // In km
$dAstronomicalUnit = 149597890; // In km
// Calculate difference in days between the current Julian Day
// and JD 2451545.0, which is noon 1 January 2000 Universal Time
// Calculate time of the day in UT decimal hours
$dDecimalHours = floatval($dHours) + (floatval($dMinutes) + floatval($dSeconds) / 60.0 ) / 60.0;
// Calculate current Julian Day
$iYfrom2000 = $iYear;//expects now as YY ;
$iA= (14 - ($iMonth)) / 12;
$iM= ($iMonth) + 12 * $iA -3;
$liAux3=(153 * $iM + 2)/5;
$liAux4= 365 * ($iYfrom2000 - $iA);
$liAux5= ( $iYfrom2000 - $iA)/4;
$dElapsedJulianDays= floatval(($iDay + $liAux3 + $liAux4 + $liAux5 + 59)+ -0.5 + $dDecimalHours/24.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)
$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)
$dSin_EclipticLongitude = sin( $dEclipticLongitude );
$dY1 = cos( $dEclipticObliquity ) * $dSin_EclipticLongitude;
$dX1 = cos( $dEclipticLongitude );
$dRightAscension = atan2( $dY1,$dX1 );
if( $dRightAscension < 0.0 ) $dRightAscension = $dRightAscension + $twopi;
$dDeclination = asin( sin( $dEclipticObliquity )* $dSin_EclipticLongitude );
// Calculate local coordinates ( azimuth and zenith angle ) in degrees
$dGreenwichMeanSiderealTime = 6.6974243242 + 0.0657098283 * $dElapsedJulianDays + $dDecimalHours;
$dLocalMeanSiderealTime = ($dGreenwichMeanSiderealTime*15 + $dLongitude)* $rad;
$dHourAngle = $dLocalMeanSiderealTime - $dRightAscension;
$dLatitudeInRadians = $dLatitude * $rad;
$dCos_Latitude = cos( $dLatitudeInRadians );
$dSin_Latitude = sin( $dLatitudeInRadians );
$dCos_HourAngle= cos( $dHourAngle );
$dZenithAngle = (acos( $dCos_Latitude * $dCos_HourAngle * cos($dDeclination) + sin( $dDeclination )* $dSin_Latitude));
$dY = -sin( $dHourAngle );
$dX = tan( $dDeclination )* $dCos_Latitude - $dSin_Latitude * $dCos_HourAngle;
$dAzimuth = atan2( $dY, $dX );
if ( $dAzimuth < 0.0 )
$dAzimuth = $dAzimuth + $twopi;
$dAzimuth = $dAzimuth / $rad;
// Parallax Correction
$dParallax = ($dEarthMeanRadius / $dAstronomicalUnit) * sin( $dZenithAngle);
$dZenithAngle = ($dZenithAngle + $dParallax) / $rad;
$dElevation = 90 - $dZenithAngle;
// IP Symcon -> Create and take your own variables
// Save Azimuth and Elevation as Float values
SetValueFloat(43090 /*[Allgemein\Sonnenstand_Berechnung\azimut]*/, $dAzimuth);
SetValueFloat(13746 /*[Allgemein\Sonnenstand_Berechnung\elevation]*/, $dElevation);
// Save Azimuth and Elevation as Integer values
SetValueInteger(26719 /*[Allgemein\Sonnenstand_Berechnung\azimut_int]*/,intval($dAzimuth));
SetValueInteger(26905 /*[Allgemein\Sonnenstand_Berechnung\elevation_int]*/,intval($dElevation));
}
// Coordinates format is the pair of latitude and longitude, with sign minus (-) for the direction south latitude and west longitude separate by comma simbol (,), here some example:
// 52.5163 , 13.3779
// 40.7682 , -73.9816
// -22.9708 , -43.1830
//function calcSunPos( $iYear, $iMonth, $iDay, $dHours, $dMinutes, $dSeconds, $dLongitude, $dLatitude)
//example -> calcSunPos( 2011, 8, 6, 11, 40, 0, 8.2545691, 47.3460627);
calcSunPos( gmdate("y"), gmdate("m"), gmdate("d"), gmdate("H"), gmdate("i"), 0, 8.2545691, 47.3460627); // location Switzerland - Buttwil
?>