Code:
'++++++++ Sonnenstandberechnung 2012 ++++++++++
'Vorlage: Excel-berechnung
'nachvollziebar auf: http://www.solartopo.com/sonnenumlaufbahn.htm zum überprüfen der zahlen
'$sim
$regfile = "m16def.dat"
$crystal = 16000000
$hwstack = 100
$swstack = 100
$framesize = 70
'$prog &HFF , &HFF , &HD9 , &H00
'Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
' Config Adc = Single , Prescaler = Auto , Reference = Avcc
Ddra = &B11111111
Ddrb = &B11111111
Config Portc.1 = Output
Config Portd.7 = Output
Config Lcd = 16 * 4
Config Lcdpin = Pin , Db4 = Portc.4 , Db5 = Portc.5 , Db6 = Portc.6 , Db7 = Portc.7 , E = Portc.3 , Rs = Portc.2
Initlcd
Cursor Off
Config Dcf77 = Pind.6 , Inverted = 0 , Timer = 1 , Debug = 1 , , Check = 1 , Update = 0 , Gosub = Sectic
Config Date = Dmy , Separator = .
Enable Interrupts
Signal_kontroll_led Alias Portc.1
Dim Neue_sekunde As Bit
Dim Synchron As Bit
Dim Tag_im_jahr As Byte
Dim Diff_zu_utc As Byte
'Dim Pi As Single
'Dim Pi2 As Single
'Dim Pi3 As Single
'Dim K_pi As Single
Dim Tageszahl As Integer
Dim Diff_utc As Single
Dim Sekunde As Single
Dim Minute As Single
Dim Stunde As Single
'---------------------------
Dim S_0 As Single
Dim S_1 As Single
Dim S_2 As Single
Dim S_3 As Single
Dim S_4 As Single
Dim S_5 As Single
Dim S_6 As Single
Dim S_7 As Single
Dim S_8 As Single
'---------------------------
Dim D_0 As Single
Dim D_1 As Single
Dim D_2 As Single
Dim D_3 As Single
Dim D_4 As Single
Dim D_5 As Single
Dim D_6 As Single
Dim D_7 As Single
Dim D_8 As Single
Dim D_9 As Single
Dim D_10 As Single
Dim D_11 As Single
Dim D_12 As Single
Dim D_13 As Single
Dim D_14 As Single
Dim D_15 As Single
Dim D_16 As Single
Dim D_17 As Single
Dim D_18 As Single
Dim D_19 As Single
Dim D_20 As Single
Dim D_21 As Single
Dim D_22 As Single
Dim D_23 As Single
Dim D_24 As Single
Dim D_25 As Single
Dim D_26 As Single
Dim D_27 As Single
Dim D_28 As Single
'--------------------------
Dim Z_0 As Single
Dim Z_1 As Single
Dim Z_2 As Single
Dim Z_3 As Single
Dim Z_4 As Single
Dim Z_5 As Single
Dim Z_6 As Single
Dim Z_7 As Single
Dim Z_8 As Single
Dim Z_9 As Single
Dim Z_10 As Single
Dim Z_11 As Single
Dim Z_12 As Single
Dim Z_13 As Single
Dim Z_14 As Single
Dim Z_15 As Single
Dim Z_16 As Single
'--------------------------
Dim W_0 As Single
Dim W_1 As Single
Dim W_2 As Single
Dim W_3 As Single
Dim W_4 As Single
Dim W_5 As Single
Dim W_6 As Single
Dim W_7 As Single
'--------------------------
Dim H_0 As Single
Dim H_1 As Single
Dim H_2 As Single
Dim H_3 As Single
Dim H_4 As Single
Dim H_5 As Single
Dim H_6 As Single
Dim H_7 As Single
Dim H_8 As Single
Dim H_9 As Single
Dim H_10 As Single
Dim H_11 As Single
Dim H_12 As Single
Dim H_13 As Single
Dim H_14 As Single
'--------------------------
Dim R_0 As Single
Dim R_1 As Single
Dim R_2 As Single
Dim R_3 As Single
Dim R_4 As Single
'-------------------------
Dim Ca_0 As Single
Dim Ca_1 As Single
Dim Ca_2 As Single
Dim Ca_3 As Single
Dim Ca_4 As Single
Dim Ca_5 As Single
Dim Ca_6 As Single
Dim Ca_7 As Single
Dim Ca_8 As Single
Dim Ca_9 As Single
Dim Ca_10 As Single
Dim Ca_11 As Single
Dim Ca_12 As Single
Dim Ca_13 As Single
Dim Ca_14 As Single
'--------------------
Dim Az_0 As Single
Dim Az_1 As Single
Dim Az_2 As Single
Dim Az_3 As Single
Dim Az_4 As Single
Dim Az_5 As Single
Dim Az_6 As Single
Dim Az_7 As Single
Dim Az_8 As Single
Dim Az_9 As Single
Dim Az_10 As Single
Dim Az_11 As Single
Dim Az_12 As Single
Dim Az_13 As Single
Dim Az_14 As Single
Dim Az_15 As Single
Dim Az_16 As Single
Dim Az_17 As Single
Dim Azimut As Single
Dim A As Single
Dim A1 As Single
Dim C As Single
Dim D As Single
'--------------------
'---------------------------Const Deklination---------------------------
Const De_1 = 0.006918
Const De_2 = 0.399912
Const De_3 = 0.070257
Const De_4 = 0.006758
Const De_5 = 0.000907
Const De_6 = 0.002697
Const De_7 = 0.00148
Const De_1_2 = -0.392994
'----------------------------------
'--------------------------Const Zeitgeichung-----------------
Const Zg_1 = 229.18
Const Zg_2 = 0.000075
Const Zg_3 = 0.001868
Const Zg_1_2 = 0.001943
Const Zg_4 = 0.032077
Const Zg_5 = 0.014615
Const Zg_6 = 0.040849
'Const Arcsin = 0.5333333333333333
Const Pi = 3.14159265358
Const Pi2 = 6.2831853071
Const Pi3 = 12.5663706143
Const K_pi = 0.0174532925
'----------------------------------
Const L = 48.11602 'München DC Lat
Const B = 11.57954 'google earth Long
'------------------------
Time$ = "13:18:00"
Date$ = "17.08.12"
'--------------------------
Declare Sub Sonnenaufgang
Declare Sub Sonnenuntergang
Declare Sub Anzeige
'------------------------------------
Deflcdchar 1 , 28 , 20 , 28 , 32 , 32 , 32 , 32 , 32 ' Grad
Cls
Do
'
Tageszahl = Dayofyear()
'Goto Anzeige
'------------------Jahresteil S-S_6---------------------------------
'| /|
'| =(Tageszahl-1+((Stunde+Minute/60)-12)/24)/365 \/ |
'-------------------------------------------------------------------
Minute = _min
Stunde = _hour
S_0 = Stunde
Stunde = Stunde - 1
S_1 = Minute
S_2 = S_0 + S_1
S_3 = S_2 / 60
S_4 = Tageszahl + 1 '- 1
S_5 = S_3 - 12
S_6 = S_5 / 24
S_7 = S_6 + S_4
S_8 = S_7 / 365
'Print S_0 ; " " ; S_1 ; " " ; S_2 ; " " ; S_3 ; " " ; S_4 ; " " ; S_5 ; " " ; S_6 ; " " ; S_7 ; " " ; S_8
'** S_6 ** 0.092579897
'--------------------Deklination D-D_28-------------------------------------------------
'| |
'| =(0,006918-0,399912*COS(Pi2()*S_6)+0,070257*SIN(2*PI()*S_6)-0,006758*COS(2*S_6*PI()) |
'| /|
'| +0,000907*SIN(2*S_6*PI())-0,002697*COS(3*S_6*PI())+0,00148*SIN(3*S_6*PI()))/K_pi \/ |
'---------------------------------------------------------------------------------------
D_0 = Pi2 * S_8
D_1 = Cos(d_0)
D_2 = De_2 * D_1
D_3 = De_1 - D_2
D_4 = Pi2 * S_8
D_5 = Sin(d_4)
D_6 = De_3 * D_5
D_7 = D_3 + D_6
D_8 = 2 * S_8
D_9 = D_8 * Pi
D_10 = Cos(d_9)
D_11 = D_10 * De_4
D_12 = D_7 - D_11
D_13 = 2 * S_8
D_14 = D_13 * Pi
D_15 = Sin(d_14)
D_16 = D_15 * De_5
D_17 = D_16 + D_12
D_18 = 3 * S_8
D_19 = D_18 * Pi
D_20 = Cos(d_19)
D_21 = D_20 * De_6
D_22 = D_17 - D_21
D_23 = 3 * S_8
D_24 = D_23 * Pi
D_25 = Sin(d_24)
D_26 = D_25 * De_7
D_27 = D_26 + D_22
D_28 = D_27 / K_pi
'-------------------------------------------------------------------------------------------------
'------------------Zeitgleichung Z-16----------------------------------------------------------
' |
' =229,18*(0,000075+0,001868*COS(2*PI()*F26)-0,032077*SIN(2*PI()*F26) / |
' -0,014615*COS(2*2*PI()*F26)-0,040849*SIN(2*2*PI()*F26)) |
'Zeitgleichung=-0,171*SIN(0,0337*A1+0,465)-0,1299*SIN(0,01787*A1-0,168) |
'-----------------------------------------------------------------------------------------------------
Z_0 = Pi2 * S_8
Z_1 = Cos(z_0)
Z_2 = Z_1 * Zg_3
Z_3 = Z_2 + Zg_2
Z_4 = Pi2 * S_8
Z_5 = Sin(z_4)
Z_6 = Z_5 * Zg_4
Z_7 = Z_3 - Z_6
Z_8 = Pi3 * S_8
Z_9 = Cos(z_8)
Z_10 = Z_9 * Zg_5
Z_11 = Z_7 - Z_10
Z_12 = Pi3 * S_8
Z_13 = Sin(z_12)
Z_14 = Z_13 * Zg_6
Z_15 = Z_11 - Z_14
Z_16 = Zg_1 * Z_15
'-------------------------------------------------------------
'------------------Stundenwinkel W-7-----------------------------
' /|
' =($B$6*60+$B$7+H25+4*$B$5-60)/4-180 \/ |
'----------------------------------------------------------------
W_0 = Stunde * 60
W_1 = W_0 + Minute
W_2 = W_1 + Z_16
W_3 = 4 * B
W_4 = W_2 + W_3
W_5 = W_4 - 60
W_6 = W_5 / 4
W_7 = W_6 - 180
'Print W_0 ; " " ; W_1 ; " " ; W_2 ; " " ; W_3 ; " " ; W_4 ; " " ; W_5 ; " " ; W_6 ; " " ; W_7
'----------------------------------------------------------------------------
'----------------sin(Sonnenhöhe)-----------------------------------------------
' /|
' =-(SIN($Q$16*$B$4)*J26-SIN($Q$16*G26))/(COS($Q$16*$B$4)*SIN(ARCCOS(J26)))
'------------------------------------------------------------------------------
H_0 = K_pi * L
H_1 = Sin(h_0)
H_2 = K_pi * D_28
H_3 = Sin(h_2)
H_4 = H_1 * H_2
H_5 = K_pi * L
H_6 = Cos(h_5)
H_7 = K_pi * D_28
H_8 = Cos(h_7)
H_9 = K_pi * W_7
H_10 = Cos(h_9)
H_11 = H_1 * H_3
H_12 = H_6 * H_8
H_13 = H_12 * H_10
H_14 = H_4 + H_13
'--------------------------------------------------------------
'-------------------(SONNENHÖHE)---------------------------------
' -3,2 |
' =ARCSIN(J25)/$B$9 ?????? |
'--------------------------------------------------------------------------
R_0 = Asin(h_14)
'R_1 =Acos (r_0)
R_2 = R_0 / K_pi
'R_2 = R_2 + 4.03
R_4 = R_2
'-------------------------------------------------------------------------
'-------------------cos(Azimut)----------------------------------------------
' |
' =-(SIN($B$9*$B$4)*J25-SIN($B$9*G25))/(COS($B$9*$B$4)*SIN(ARCCOS(J25))) ? |
' |
'----------------------------------------------------------------------------
Ca_0 = K_pi * L
Ca_1 = Sin(ca_0)
Ca_2 = Ca_1 * H_14 '***
Ca_3 = K_pi * D_28
Ca_4 = Sin(ca_3)
Ca_5 = Ca_4 - Ca_2 '**********
Ca_6 = Cos(ca_0) '***
Ca_7 = Acos(h_14)
Ca_8 = Sin(ca_7)
Ca_9 = Ca_8 * Ca_6
Ca_10 = Ca_5 / Ca_9
' Print Ca_0 ; " " ; Ca_1 ; " " ; Ca_2 ; " " ; Ca_3 ; " " ; Ca_4 ; " " ; Ca_5 ; " " ; Ca_6 ; " " ; Ca_7 ; " " ; Ca_8 ; " " ; Ca_9 ; " " ; Ca_10
'---------------------------------------------------------------------------------------
'---------------------Azimut---------------------------------------------------------------
' Prüfung: | Dann_Wert | Sonst_Wert ???? |
' =WENN($B$6+$B$7/60<=12+(15-$B$5)/15-H25/60;ARCCOS(L25)/$B$9;360-ARCCOS(L25)/$B$9) |
' | | |
'------------------------------------------------------------------------------------------
Az_0 = Stunde
Az_1 = Minute / 60
Az_3 = Az_0 + Az_1
A = Az_3 'prüfung a
'
Az_4 = 15 - B
Az_5 = Az_4 / 15
Az_6 = Az_5 + 12 '***
Az_7 = Z_16 / 60
Az_8 = Az_6 - Az_7 ' prüfung b
A1 = Az_8
'-----------------------------------------------------------------------------------------------
Az_11 = Acos(ca_10)
Az_12 = Az_11 / K_pi 'ergebnis wahr (Dann_Wert)
C = Az_12
'---------------------------------------------------------------------------------------------
Az_13 = Acos(ca_10)
Az_14 = Az_13 / K_pi
Az_15 = 360 - Az_14 'ergebnis falsch (Sonst_Wert)
D = Az_15
'---------------------------------------------------------------------------------
If Neue_sekunde = 1 Then
Neue_sekunde = 0
Call Anzeige
End If
If A > A1 And Az_15 > 190.0 Then
Call Sonnenuntergang
End If
If A < A1 Then
Call Sonnenaufgang
End If
Signal_kontroll_led = Dcf_status.0
If Dcf_status.2 = 1 Then
Portd.6 = 1
End If
'Print S_4 ; " " ; S_8 ; " " ; D_28 ; " " ; Z_16 ; " " ; W_7 ; " " ; H_14 ; " " ; R_2 ; " " ; Ca_10 ; " " ; Az_12 ; " " ; Az_15
Print A ; " " ; A1 ; " " ; R_2
Loop
End
Sectic:
Neue_sekunde = 1
If _sec = 59 Then Synchron = Dcf_status.2
'
If Synchron = 1 Then
Portd.7 = 1
Else
Portd.7 = 0
End If
Return
'
Sub Anzeige
Locate 1 , 1
Lcd ; "48.11" ; Chr(1) ; " " ; Time$
Locate 2 , 1
Lcd "Zenith :" ; Fusing(r_2 , "##.##") ; Chr(1) ; " "
Locate 3 , 1
Lcd "11.57" ; Chr(1) ; " " ; Date$
If A < A1 Then
Locate 4 , 1
Lcd "Azimut :" ; Fusing(az_12 , "##.##" ) ; Chr(1) ; " "
Else
Locate 4 , 1
Lcd "Azimut :" ; Fusing(az_15 , "##.##" ) ; Chr(1) ; " "
End If
End Sub
'
Sub Sonnenaufgang
Select Case R_2
Case -9.9 To -7.3:
Porta = &B00000000
Portb = &B00000000
Case -7.0 To -6.5:
Porta = &B00000001
Case -6.4 To -6.0:
Porta = &B00000011
Case -5.9 To -5.5:
Porta = &B00000111
Case -5.4 To -5.0:
Porta = &B00001111
Case -4.9 To -4.3:
Porta = &B00011111
Case -4.2 To -3.2:
Porta = &B00111111
Case -3.1 To -2.1:
Porta = &B01111111
Case -2.0 To 1.5:
Porta = &B11111111
Case 1.6 To 2.0:
Portb = &B00000001
Case 2.1 To 3.0:
Portb = &B00000011
Case 3.1 To 10.0: '1.7 max
Porta = &B00000000
Portb = &B00000000
End Select
End Sub
'
Sub Sonnenuntergang
Select Case R_2
Case 9.8 To 10.5:
Porta = &B11111111
Portb = &B00000011
Case 6.5 To 9.4:
Porta = &B11111111
Portb = &B00000001
Case 6.0 To 6.4:
Porta = &B11111111
Portb = &B00000000
Case 5.3 To 5.9 :
Porta = &B01111111
Portb = &B00000000
Case 4.9 To 5.2:
Porta = &B00111111
Portb = &B00000000
Case 3.9 To 4.8:
Porta = &B00011111
Portb = &B00000000
Case -0.8 To 3.8:
Porta = &B00001111
Portb = &B00000000
Case -2.5 To -0.9:
Porta = &B00000111
Portb = &B00000000
Case -5.0 To -2.6:
Porta = &B00000011
Portb = &B00000000
Case -6.6 To -5.1 :
Porta = &B00000001
Portb = &B00000000
Case -10.0 To -6.7:
Porta = &B00000000
Portb = &B00000000
End Select
End Sub
Lesezeichen