sunrise/set

wm.chatman

Well-Known Member
Licensed User
Longtime User
Hello folks

I am in need for sunrise/set code. Can i get just a little help on this matter?
Found some code in vb6 for this, cant use it with Basic4PPC.:(
sunrise=lblSR/sunset=lblSS

Sincerely

WmC

PC: Laptop CoreDUo, Windows XP SP2 E
PPC:hp5550"ARM"/Windows CE 4.2
Bayern, Germany
 

wm.chatman

Well-Known Member
Licensed User
Longtime User
:)Hi specci48

Thanks for your help. Iwill ckeck this out.

Regards,
WmC

PC: Laptop CoreDUo, Windows XP SP2 E
PPC:hp5555"ARM"/Windows CE 4.2
Bayern/Germany
 

derez

Expert
Licensed User
Longtime User
Sun Rise and Set

Hi
I have translated the code I found to a small B4ppc program, for the sun rise and set only.
Comments inside show how to make it work with GPS time instead of system time.
It has not been tested thoroughly !!!

Edit:
updated, the calculation should be done with GPS time or Greenwich time, then the delta hours due to time zone are added at the end of calculation.

edit:
To use with gps.dll, replace the beginning with this :
B4X:
ttmp = gps.UTCDate
stryear = "20" & SubString(ttmp,4,2)
strmonth = SubString(ttmp,2,2)
strday = SubString(ttmp,0,2)
 

Attachments

  • Sun.sbp
    4.2 KB · Views: 268
Last edited:

wm.chatman

Well-Known Member
Licensed User
Longtime User
:)Hi Mr.Derez
darn it, you are lightning!

Fantastic, I'd like to thank you very very much for all the help so far!!! It is truly appreciated. Also I sincerely appreciate the time and effort of everyone who responded to my questions.

Problem:
I have tested the proramm using system time. The calculations are: SR=0538h/SS=1806h.
With the Newspaper we get here in Bayern, Germany I took a look at SR/SS. It gives the
SR=0657h/SS=1945h. Difference: SR=0119h/SS=0139h.

Edit:
With Update Sun:
Now the calculations are SR=0642h/SS=1911h. Difference: SR=0015h/SS=0034h. Sure is getting close.
How can I correct the Difference?

To all: Happy Easter Holidays!:sign0089:
Mr. Derez did you get my private msg?

P.S. I am thinking about getting a Smartphone/looking at MDA Pro=WM5.
(Scratching head on this).

Regards,
WmC

PC: Laptop CoreDUo, Windows XP SP2 E
PPC:hp5555"ARM"/Windows CE 4.2
Bayern/Germany
 
Last edited:

derez

Expert
Licensed User
Longtime User
If you change the lat and long which are defined in the program start ,to the coordinates of your home, you'll probably get a closer result....
Can you please write down your coordinates so that i can check too ?

Does anybody know a link to the moon rise and set calculation in VB or C ? I found one in basic and it does take a long time to convert it...:sign0085: ALFCEN ?
 
Last edited:

wm.chatman

Well-Known Member
Licensed User
Longtime User
:)Mr. Derez

here the info you requested:
Germany: Longitude: 10° 58' 0" East Latitude: 50° 9' 0" North

Regards,
WmC

PC: Laptop CoreDUo, Windows XP SP2 E
PPC:hp5555"ARM"/Windows CE 4.2
Bayern/Germany
 

wm.chatman

Well-Known Member
Licensed User
Longtime User
I changed the lat/lon but still not getting the correct data.
Also replaced code as is in #5 (permalink). Now we get Error Dialog!
cant copy paste img, but it states:

Error compiling program.
Error description: gps is not a known control or object.
Occurred on line: 22
ttmp=gps.UTCDate

Regards,
WmC

PC: Laptop CoreDUo, Windows XP SP2 E
PPC:hp5555"ARM"/Windows CE 4.2
Bayern/Germany
 
Last edited:

derez

Expert
Licensed User
Longtime User
When I changed to your coordinates I got 06:57 and 19:43 ! also important to input the time zone difference.

As for the gps error - you should add GPS.dll library, make an object named GPS etc. as you may find in the help for GPS library. At the moment the sun program does not include the gps environment. You can copy it and add it to another program, like GPS4PPC for example.
 

wm.chatman

Well-Known Member
Licensed User
Longtime User
ok. added GPS.dll and new object GPS. Now the sun.sbp is going hay-wire.

:)Could you update sun.sbp?

Edit:
Happy Easter Bunnies!!!
no need to update sun.sbp Mr.Derez. We are also getting the correct Input now.
delta_hour = 2 ' should be provided by the gps program

'coordinates of my home: Longitude: 10° 58' 0" East Latitude: 50° 9' 0" North
'(GMT+01:00)Amsterdam,Berlin,Bern,Rome,Stockholm,Vienna
latlong.lat = 50.9
latlong.long = 10.58

Now have to work on including gps environment.

Edit:still does not function correct. Tryd Changing input in the txt boxes D, M, Y. Bad thing.
also the system time does not show the correct update, with the D, M Y.

edit: Oh I am sorry, think it does work. I got to get some sleep.

Best Regards,
WmC

PC: Laptop CoreDUo, Windows XP SP2 E
PPC:hp5555"ARM"/Windows CE 4.2
Bayern/Germany
 
Last edited:

derez

Expert
Licensed User
Longtime User
coordinates of my home: Longitude: 10° 58' 0" East Latitude: 50° 9' 0" North
'(GMT+01:00)Amsterdam,Berlin,Bern,Rome,Stockholm,Vienna
latlong.lat = 50.9
latlong.long = 10.58

when you change coordinates from DMS to decimal it goes:
10° 58' 0" = 10 + 58/60 + 0/3600 = 10.9667
50° 9' 0" = 50 + 9/60 + 0/3600 = 50.15
 

derez

Expert
Licensed User
Longtime User
Agraham
You are right, but I said I haven't tested it thoroughly...
I also found this problem and corrected it (took the min and max of the hours for rise and set).
to correct the minus I added 24 hours to the sum before the mod(24) so it is always positive now.

And the real good news - I translated the moon rise and set algorithm from old basic, and it works !
Let me just test it a little and arrange the code before i post it.:)
 

wm.chatman

Well-Known Member
Licensed User
Longtime User
Halleluiah...:sign0060::sign0060::sign0060:

Also Changing Time Zone diff: does not show any effect.

Best Regards,
WmC

PC: Laptop CoreDUo, Windows XP SP2 E
PPC:hp5555"ARM"/Windows CE 4.2
Bayern/Germany
 

derez

Expert
Licensed User
Longtime User
Can anybody translate this line for me ?:confused:

i = (xtra > 0.0 ? Math.floor(xtra) : Math.ceil(xtra - 1.0));

Thanks
 

derez

Expert
Licensed User
Longtime User
Thank you Erel, but I found a better algorithm, see in "Share your creation"
 
Top