Back to the index

Solar Compass for the HP-32SII

Written by Dave Coffin in April 1992.

Overview

Determines the altitude and azimuth of the Sun for any given latitude, longitude, date, and time. Can be solved to determine time of sunrise, sunset, local noon, etc.

The date is a simple day count where 0 = December 31, 1991. If you have enough free memory, you can find the correct day count by running Program C and subtracting 727502 from the result.

Enter the time in decimal hours. If you change the program to accept HH.MMSS format, you won't be able to solve or integrate it.

Usage

Determine the direction of the sun over downtown Boston on May 26, 2006 at 14:42 Eastern Daylight Time:

XEQ S
N? 42.3566
E? -71.0569	Always negative in USA!!
D? 5260		May 26, 2006
T? 14.7		You could type "14.42 →HR"
57.057778985	degrees above horizon
x<>y
239.527634395	roughly west-southwest

When will the sun set on that day?

13		First guess--sun sets after 13:00
STO T
23		Second guess--sun sets before 23:00
FN= S
SOLVE T
N? 42.3566	same as before
E? -71.0569
D? 5260
SOLVING		This takes about 20 seconds
T=2.0072041E1	Sunset at 20.072 decimal hours
→HMS
20.0419346	Sunset at 20:04:19

The official sunset occurs a few minutes later, when the sun's altitude is -0.8333 degrees, to account for atmospheric refraction and the radius of the solar disk. To determine this time, write a wrapper function that executes S and adds 0.8333 to the result.

Program

HP 35s users must read this!!

After verifying the checksum, change lines S07 and S08 to match your timezone. You'll probably need to update it twice a year.

S01 LBL S
S02 DEG
S03 INPUT N		; latitude in decimal degrees
S04 INPUT E		; longitude in decimal degrees
S05 INPUT D		; date in days since Dec 31, 1991
S06 INPUT T		; time in decimal hours
S07 4			; convert to Universal Time
S08 +
S09 STO S
S10 24			; combine Z = date + time/24
S11 ÷
S12 +
S13 STO Z
S14 15.218425		; compute S = sidreal time in degrees
S15 ÷
S16 RCL+ S
S17 15
S18 ×
S19 RCL+ E
S20 98.92477
S21 +
S22 STO S
S23 -3.93		; date of Earth's perihelion
S24 RCL+ Z
S25 1.01461		; degrees of orbit per day
S26 ÷
S27 ENTER
S28 ENTER
S29 0.016711		; orbital eccentricity
S30 STO X
S31 x²			; compute distance from non-solar focus
S32 1
S33 -
S34 x<>y
S35 COS
S36 RCL× X
S37 1
S38 -
S39 ÷
S40 θ,r→y,x		; shift to solar focus
S41 RCL- X
S42 RCL- X
S43 y,x→θ,r
S44 R↓			; discard the Earth-Sun distance
S45 77.2		; celestial longitude of perihelion
S46 -
S47 4.647E-5		; correct for precession
S48 RCL× Z
S49 +
S50 1			; convert celestial longitude to x,y
S51 θ,r→y,x		; and perform a series of rotations:
S52 x<>y
S53 66.56		; earth's axial tilt
S54 x<>y
S55 θ,r→y,x
S56 STO Z
S57 R↓
S58 x<>y
S59 y,x→θ,r
S60 x<>y
S61 RCL- S		; local sidreal time
S62 x<>y
S63 θ,r→y,x
S64 RCL Z
S65 x<>y
S66 y,x→θ,r
S67 x<>y
S68 RCL- N		; latitude
S69 x<>y
S70 θ,r→y,x
S71 STO Z
S72 R↓
S73 +/-			; express azimuth as 0..360
S74 y,x→θ,r
S75 R↓
S76 180
S77 x<>y
S78 -
S79 RCL Z		; get altitude in degrees
S80 ASIN
S81 RTN

HP-32SII: checksum = EE7F, length = 185.5
HP-33S:   checksum = 6EA9, length = 423
HP-35S:   checksum = 2861, length = 308
In Thomas Okken's Free42 emulator, you can run with no inputs thusly:
01 LBL "SUN"
02 LOCAT		; Android and iOS only
03 STO "N"
04 R↓
05 STO "E"
06 MDY
07 12.311991
08 DATE
09 DDAYS
10 TIME
11 →HR
12 DEG
13 4			; Eastern Daylight Time -- change as needed
14 +
15 STO "S"
16 24
...