**HP Articles Forum**

[Return to the Index ]

[ Previous | Next ]

**HP41 Trip Computer**

*Posted by Christopher Johnson on 29 Jan 2012, 9:36 p.m.*

:Updated listingTrip Computer v2.1 for HP41C/CV/CX by Christopher J. Johnson

Disclaimer:* Requires a Time Module

* Do NOT use this program while operating your vehicle. Some states might even consider this the same as texting. Have a passanger operate the program or wait until you stop to update your odometer. I strongly discourage this practice. User assumes all risk from the use of this program.

Introduction:Back in the 80's I drove a car down to Florida. The vehicle was a nice Cadillac that had a trip computer. You enter your trip distance and the system would calculate miles traveled, average MPH, distance to destination and ETA. I didn't have a Cady with a trip computer so HP41 to the rescue. This program.

My goal when writing this program was small size and fast operation. I'm a machine language guy. Always looking for minimum size and fast speed.

Operation:To start the program enter.

XEQ "TRPCOMP"

RESET??? R/S

Press R/S to start a new trip else ignore and continue to use the program with the label keys.

Starting a new trip

DIS. TO DEST.? Enter the miles to your destination and press R/S

ODOMETER? Enter your vehicles current odometer reading. .1 miles can be entered. Press R/S

The program will display 'COMP. STARTED' and beep at you, Then display your trip starting time and date.

Now all that is necessary to input is your current odometer and press one of the label keys A-E. The program checks for keyboard input and recalculates if a key press was detected.

The label keys correspond to:

Distance Elapsed Average MPH Distance to ETA Traveled Time Destination A B C D E

I hope you enjoy.

Program Listing:;Registers used ; 00 = Miles Traveled ; 01 = Distance to Destination ; 02 = Starting Odometer ; 03 = Starting Time ; 04 = Current Odometer ; 05 = Current Distance To Destination ; 06 = Average MPH ; 07 = Starting Date ; 08 = Current Elapsed Time ; 09 = Current Date ; 10 = Current Time

;Labels used ; LBL A : Distance Traveled ; LBL B : Elapsed Time ; LBL C : Average Speed(MPH) ; LBL D : Distance to Destination ; LBL E : Estimated Time of Arrival(ETA) ; LBL 00 : Elapsed Time ; LBL 01 : Average Speed ; LBL 02 : Current Distance to Destination ; LBL 03 : Estimated Time of Arrival ; LBL 22 : Same Day ; LBL 33 : Reset Routine ; LBL 44 : Main Formula Routine ; LBL 55 : Past ETA Routine ; LBL 77 : Next Day ETA Routine ; LBL 99 : Common Display Routine

01 LBL "TRPCOMP" 02 FC?C 05 ;Check if this is a reset 03 GTO 33 ;Go to Reset Routine 04 SF 26 ;Set Sound Flag 05 SF 27 ;Set USER mode 06 "DIS. TO DEST.?" 07 PROMPT 08 CLRG ;A quite brutal operation, remove if offensive 09 STO 01 ;Store Distance to Destination 10 "ODOMETER?" 11 PROMPT 12 STO 02 ;Store Starting Odometer 13 DATE ;Get Current Date 14 STO 07 ;Store Starting Date 15 TIME ;Get Current Time 16 FIX 4 17 RND 18 STO 03 ;Store Starting Time 19 NOP 20 "COMP. STARTED" 21 AVIEW 22 BEEP 23 PSE 24 CLA 25 FIX 2 26 ATIME 27 X<>Y 28 ADATE 29 CF 22 ;Clear Keyboard Input Flag

30 LBL 99 ;Common Display Routine 31 CF 05 ;Clear Reset Flag 32 PROMPT

33 LBL B ;Elapsed Time 34 GTO 00

35 LBL C ;Average Speed 36 GTO 01

37 LBL D ;Current Distance to Destination 38 GTO 02

39 LBL E ;Estimated Time of Arrival 40 GTO 03

41 LBL A ;Distance Traveled 42 FS?C 22 ;Check for Keyboard Input 43 XEQ 44 ;Go To Main Formula Routine 44 RCL 00 ;Miles Traveled 45 FIX 1 46 "MTV: " 47 ARCL X 48 GTO 99 ;Go To Common Display Routine

49 LBL 00 ;Elapsed Time Display 50 FS?C 22 ;Check for Keyboard Input 51 XEQ 44 ;Go To Main Formula Routine 52 RCL 08 ;Current elapsed Time 53 FIX 4 54 "ELAP:" 55 ATIME24 56 GTO 99 ;Go To Common Display Routine

57 LBL 01 ;Average Speed 58 FS?C 22 ;Check for Keyboard Input 59 XEQ 44 ;Go To Main Formula Routine 60 RCL 06 ;Recall Average MPH 61 FIX 1 62 "AVG. MPH=" 63 ARCL X 64 GTO 99 ;Go To Common Display Routine

65 LBL 02 ;Distance to Destination 66 FS?C 22 ;Check for Keyboard Input 67 XEQ 44 ;Go To Main Formula Routine 68 RCL 05 ;Recall Miles to Destination 69 FIX 1 70 "DEST: " 71 X=0? ;Check if We Have Reached Destination 72 BEEP 73 X<0? ;Check if We Have Passed Destination 74 TONE 9 75 ARCL X 76 GTO 99 ;Go To Common Display Routine

77 LBL 03 ;Estimated Time of Arrival 78 FS?C 22 ;Check for Keyboard Input 79 XEQ 44 ;Go To Main Formula Routine 80 RCL 05 ;Recall Miles to Destination 81 X<0? ;Check if we Have Passed the Destination 82 GTO 55 83 RCL 06 ;Recall Average MPH 84 / ;Calculate Travel Time to Destination 85 HMS 86 RCL 10 ;Recall Current Time 87 HMS+ 88 24 89 X<Y? ;Check if ETA will be the Next Day 90 GTO 77 ;Go To ETA Next Day 91 FIX 2 92 X<>Y 93 "ETA:" 94 ATIME 95 GTO 99 ;Go To Common Display Routine

96 LBL 44 ;Main Formula Routine 97 STO 04 ;Store Current Odometer 98 RCL 02 ;Recall Starting Odometer 99 - 100 STO 00 ;Store Miles Traveled 101 RCL 01 ;Recall Distance to Destination 102 X<>Y 103 - 104 STO 05 ;Store Current Distance to Destination 105 TIME 106 STO 10 ;Store Current Time 107 DATE 108 STO 09 ;Store Current Date 109 RCL 07 ;Recall Starting Date 110 X<>Y 111 X=Y? 112 GTO 22 ;Go To Same Day 113 DDAYS 114 24 115 * 116 RCL 10 ;Recall Current Time 117 HMS+ 118 RCL 03 ;Recall Starting Time 129 HMS- 120 STO 08 ;Store Current Elapsed Time 121 RCL 00 ;Recall Miles Traveled 122 X<>Y 123 HR 124 / 125 STO 06 ;Store Average MPH 126 RTN

127 LBL 22 ;Same Day 128 RCL 10 ;Recall Current Time 129 RCL 03 ;Recall Starting Time 130 HMS- 131 STO 08 ;Store Current Elapsed Time 132 RCL 00 ;Recall Miles Traveled 133 X<>Y 134 HR 135 / 136 STO 06 ;Store Average MPH 137 RTN

138 LBL 77 ;ETA Next Day 139 - ;Subtract 24 Hours From Time 140 RCL 09 ;Recall Current Date 141 1 ;Add 1 Day to Starting Date 142 DATE+ 143 CLA 144 FIX 2 145 ADATE 146 "T:" 147 X<>Y ;Recall Time From Y 148 ATIME 149 GTO 99

150 LBL 55 ;Past ETA Routine 151 "ETA: PAST ETA" 152 TONE 0 153 GTO 99

154 LBL 33 ;Reset Routine 155 SF 05 156 "RESET??? R/S" 157 AVIEW 158 "2.1" 159 END

*Edited: 21 Feb 2012, 5:03 p.m. *