ATIME function HP 41CX versus "ATIME" routine for HP42S
#1

In converting programs over to the 42S I have one program which relies on the built in "ATIME" function of the 41CX but has no analog in the 42S machine.

Quickly, the "ATIME" function of the HP41CX converts a numeric value into a time display format in the ALPHA mode. The numeric value must already have been converted to HMS.

example 1, fix 2 display:

4.20
ATIME
AVIEW

yields 04:20.

Seems simple enought but what went on behind the scene. Firstly a zero is added infront of the 4 in the hours format. A colon is added separating the hours from the minutes. The next digit is added and a final zero is appended after the 2.

using fix 4 will add a seconds display with colon and subsequent zeros;

yielding 04:20:00

The following program will output to a printer:

LBL ATIMES
CLA
ARCL 00
ATIME
"__"
ARCL 01
ATIME
AVIEW
END

Using 4.2 in REG 00 and 10.15 in REG 01 yields:

04:20__10:15

The HP 42S without the ATIME or a subroutine and the following code:

LBL ATIMES
ARCL 00
"__"
ARCL 01
AVIEW
END

As above, using 4.2 in REG 00 and 10.15 in REG 01 yeilds:

4.2__10.15

After creating a program for the HP 41CX, which gives three differing types of break schedules and printing them out in the following form is:

START= 22:35
END= 06:25

TOTAL= 07:50

LONG= 02:00
SHORT= 00:36

# BREAKS= 6

22:35__23:11
23:11__23:48
23:48__01:48
01:48__03:48
O3:48__05:48
O5:48__06:25

you can see the output is similar for each type of number and the columns line up.

The same program for the HP42S without the "ATIME" function is:

Start=  22.35
End= 6.25

Total= 7.50

Long= 2.00
Short= 0.36

# Breaks= 6

22.35__23.11
23.11__23.48
23.48__1.48
1.48__3.48
3.48__5.48
5.48__6.25

A bit messy in my opinion.

Now that the problem has been stated. I had some ideas sent to me and then combined that with a subroutine designed to accomodate hours and minutes (modify for seconds display if you want). I came up with this "ATIME" substitute which I call in the LBL "ATIME" subroutine.

{ 73-Byte Program}
LBL "ATIME"
FIX 02 -fix 2 display
STO 15 -store variable sent to this program
ENTER -duplicate the entry for the y stack
10 -test for less than or equal to 10.00 hours;
X<=Y? do we need to run this routine for a
SF 08 preceding zero? 04.20?
RDN
FS?C 08
GTO 10
APPEND "0"
LBL 10 -did not need preceding zero, do we need the
AIP colon? of course for all cases.
APPEND ":"
FP -get the minutes portion and multiply by 100
1E2
X
X=0? -if minutes equals zero GTO 20 which adds two
GTO 20 zeros to the end of the display
ENTER
10
X<=Y? -if the minutes has only one digit in the
SF 08 ones position; i.e. '4' then stick a
FS?C 08 zero in front of the 4 giving '04'
GTO 15 -if not then proceed
APPEND "0"
LBL 15 -if no 0 is required on the minutes portion.
AIP
RCL 15 -in my main routine this call of the original
RTN number is required for subsequent time
LBL 20 calculations.
APPEND "00" -if two zeros required in the minutes portion.
RDN
RCL 15
RTN

This program in conjunction with my Break program on the HP42S prints identically to the HP41CX:

START= 22:35
END= 06:25

TOTAL= 07:50

LONG= 02:00
SHORT= 00:36

# BREAKS= 6

22:35__23:11
23:11__23:48
23:48__01:48
01:48__03:48
O3:48__05:48
O5:48__06:25

Now I know this is probably not the most elegant way of tackling this but it sure does show the value of Functions versus Subroutines for saving space.

I can now take the HP42S into the cockpit and see how it performs!

Cheers,Geoff

PS thanks Diego for the preliminary suggestions.


Edited: 21 Oct 2008, 7:30 p.m. after one or more responses were posted

#2

Thanks for the credit Geoff,

I think I still may be of some help.

Please try the following:

{ 41-Byte Prgm }
LBL "ATIME"
CLA -ensures nothing remains in ALPHA from previous steps.
FIX 02 -fix 2 display
STO 15 -store variable sent to this program (I keep this as required for your program)
1E2 ** Here comes my trick ;-)
* ** Converts the "time" into "minutes"
1E9
+ ** Adds a lot of time ;-)
AIP ** Appends these "minutes" to ALPHA (without decimal part!)
ASHF ** Removes the unwanted "minutes"
-2
AROT ** Rotates ALPHA 2 characters to the right
APPEND ":" ** Appends the required colon
2
AROT ** Rotates two character back... That's all!!
RCL 15 ** Recovers original value.
RTN

Just 32 bytes shorter, hope you can use them! ;-)

Cheers

Diego.

Edited: 19 Oct 2008, 8:12 p.m. after one or more responses were posted

#3

routine!!!

In my defence it was past 2am with a small glass of scotch!

I will certainly try it, Cheers Geoff

#4

Hi there...

please note I've edited... Just 41 Bytes now!

CLA can be removed if you're sure that ALPHA is empty upon calling "ATIME"

FIX 02 can also be removed if it's not needed for other parts of your program.

This will leave a 38 Bytes routine.

Enjoy your 42s!

Edited: 19 Oct 2008, 8:31 p.m.

#5

Hi, Goeff --

I enjoy reading your frequent, detailed contributions. Someday, I'll try your sticky-key restoration technique for Voyagers.

Quote:
In converting programs over to the 42S I have one program which relies on the built in "ATIME" function of the 41CX but has no analog in the 42S machine.

Quickly, the "ATIME" function of the HP41CX converts a numeric value into a time display format in the ALPHA mode. The numeric value must already have been converted to HMS.

example 1, fix 2 display:
4.20
ATIME
AVIEW
yields 04:20.

I'm sure that you know this, but "ATIME" as well as "ATIME24" are also available on the HP-41 Time Module for the HP-41C/CV. (There are several time functions catalogued under "CX TIME" on the HP-41CX that are not present on the Time Module.)

Since the HP-42S did not have a timekeeping clock, none (to my knowledge) of the HP-41CX time functions were ported to the HP-42S. The HP-41 Extended Functions concerning Extended Memory were also not applicable to the HP-42S, and were not ported.

That said, "ATIME" and "ATIME24" certainly could have been ported, but may have been deemed of limited use. No timekeeping clock is needed for time conversions and calendar functions.

-- KS

#6

Thanks Karl,

I agree but boy what a memory saver. Just because there is not a dynamic time function in the calculator; i.e. and existing quartz timing function as in the HP41CX, doesn't mean time functions are not required for static times.

The BR program I have does not require time inputs from the clock but from the user. The HP42S can also calculate time input from the user as well as many other calculators. HMS, HMS+, HMS- and etc are included.

I think the ATIME function is pretty mandatory for any printed output.

Thanks for the compliment also ;-)

Cheers, Geoff

#7

the first posting.

Hello Diego,

In the 42S program there is no CLA at the begining as an alpha value is sent to the ATIME routine to have the times, then appended.

example:

START= 22:35
END= 06:25

TOTAL= 07:50

LONG= 02:00
SHORT= 00:36

To get this output the "BREAK" program executes the following prior to XEQ "ATIME"

001  LBL "BREAK"
002
.
.
.
"START= "
XEQ "ATIME"
.
.
.
"END= "
XEQ "ATIME"
.
.
.
and so on.

Unfortunately the 1E9 to alpha command in your program disrupts the "START= " etc....

So I will work on getting that to function with some ASTO commands for the "START= " and having the output from your routine appended to that.

Cheers,got to go to bed because of a my flight to Bejing tomorrow, 12 hour flight and I need a functioning break program!

Cheers, Geoff

#8

Hi again,

I think there's no need to mess up your main program.

Also, your 'prompts' are 7 character long ("START= ", "TOTAL= "...) so they'll need extra work to get them fully formated back.

"ATIME" can be easily modified to preserve ALPHA contents adding just two bytes to the count, just I didn't take care of that in my previous routine...

{ 43 Byte Prgm }
LBL "ATIME"
STO 15
ALEN
STO 16 - Or any unused register
RCL 15
1E2
x
1E9
+
AIP
RCL 16
AROT
ASHF
2
AROT
APPEND ":"
AROT
RCL 15
RTN

Good flight!

Diego.


Edited: 20 Oct 2008, 2:38 a.m.

#9

Hi Geoff,

I'm delighted to see the 42S being used in an all modern environment. The program that you wrote seems to perform a necessary task for you in your job as a professional pilot. Can you explain to a non-pilot, why this task can not be performed by the on board computer? Why is it not build in? Is it only you who computes these time tables because you find it nice to give your senior 42S something to do instead of letting him get bored in Florida? Or does every commercial pilot have this need to do the exact same calculation on every single flight?

#10

I am off to Bejing in a few hours:

Diego,

I had the same idea as you did and will try this out on the way to Bejing. Thanks for your time and enthusiasm! And we still managed to save aproximately 30 bytes!

George, Hello!

the break program is strickly a mind puzzle, not required but gives one a practical reason to play with the 42S or whichever calculator is in use.

On flights over nine hours in a 2 man aircraft, by law for fatigue purposes we carry an extra pilot. The pilot is fully trained of course and the title is Relief Pilot. At top of climb and prior to top of descent we have on todays 12 hour Beijing flight about 11 hours to split up. Two in the cockpit at all times and one in the bunk.

Thus about 10:30 minutes can be split up for cycling through the bunk. Bunk timing is usually broken into 6 rotations. 3 breaks and 3 sleep periods. This would be easy if all pilots chose 6 equal breaks. In reality the period is broken into one of three types:

a.  6 equal breaks
b. 2 short followed by 3 long followed by one short

In case (a) which is chosen about 20% of the time you just take the total time and divide by 6 and voila. I have a routine called EQ for this.

In case (b), chosen usually on the trip back due to jet lag, and because it places the crew restlong period outside the passenger galley (food) service which is noisy. Case be can be selected in one of 2 ways, a known long period or a known short period. I have two subroutines, one labled LO and on SH. With LO you would enter a known long period, say 2:30 and the routine calculates the short leftover time and then prints three copies similar to the example in the original posting. The SH is handled the same way, for example a known :45 period and the remainder long.

As to your specific question, no computer on board does this, usually the RP calculates this by hand and head at top of climb after all the other duties are completed. I have found that they round the times to be divisible by 3 or 6 evenly and subsequently we miss about 10 minutes each for their dubious math skills ;-)

Besides, it takes about 10 minutes to come up with a sked as other things take priority of course. My program takes about 30 seconds to load and another 30 seconds to print with only 'garbage in, garbage out' errors and prints off 3 copies, one for each.

As to actual navigation and other programs, I intend to right a couple of specific ones up that the on board computer does not do for the HPCC data file.

One involves Low Temperature Altimeter Error which you can google. That is a correction applied via calculation that altimeters do NOT do and have lead to what is called FIT 'flight into terrain'. This program rounds altitude error up in 100's and another subrouting rounds up in the 10's depending on your approach altitude and height above ground.

Another program I have emulates the onboard computer and I use it as an INDEPENDENT check of the onboard navigational computer. This program is a simple LAT and LON with an Intermediate Lat when given a LON. The onboard computer is loaded with named places and their coordinates. This data is input by the vendor for selection by the pilots. The flight plan contains the same data. A comparison of the flight plan to the computer is not a check as far as I am concerned as the data is generated by the same vendor. Granted the data resides and was input in two different places.

I use the 41CX and now for fun, the 42S to calculate the true course and great circle difference INDEPENDENTLY of the onboard FMC flight management computer.

Hope this helps!

Geoff

PS when I started the on board computer was 4k in memory and held only 8 way points at a time. We did 15 hour flights and graphs were used to predict optimum altitude, fuel flow and etc. At that time I had the 41CX and regressed all the graphs into formulae which were modified for ease of use in the hp41CX with the alpha labelling capability. I always surprised the Capt with forward looking predictions printed out for the flight as to the optimum altitude, time to climb to it and etc.

Got to go for dim sum and Sing Tao.

Cheers, Geoff

Edited: 20 Oct 2008, 1:28 p.m. after one or more responses were posted

#11

Geoff,

thank you very much for that insightful description. It was interesting and fun to read. I am only a theoretical flight afficionado, as I studied aerodynamics and flight mechanics and related stuff during engineering studies years back - but never made a real job out of it: I'm now a lawyer ;-)

Have a good time and safely come back!

Regards,
George Bailey

#12

Thanks for showing, Geoff, and many happy landings!

#13

Geoff - what is the 42CX? Emulator or a product of your fantasy?
BTW I googled "HP-42CX" and stumbled over this: http://www.computerhistory.org/collections/accession/102657120

It seems that HP has made a HP-42CX Owners Manual.

I'm really lost here...

Cheers!
Johnny

#14

may I suggest a typo?


:)

#15

;-) perhaps a freudian typo!!!!!!!!!!!!!!!!!!1

#16

Oh yes. I shure have one or two ideas about what a 42CX should be like...
Come on HP - take a hint. We want the 42CX now... ;-)

#17

I second your wish, as you know, just with a different name tag.

Ceterum censeo: HP, launch a 43s.

Walter



Possibly Related Threads…
Thread Author Replies Views Last Post
  HP50g: Writing a function that returns a function Chris de Castro 2 2,188 12-10-2013, 06:49 PM
Last Post: Han
  IFERR function on HP Prime Mic 2 1,876 12-02-2013, 01:33 AM
Last Post: cyrille de Brébisson
  HP Prime: Dirichlet's eta function recognized but not numerically evaluated Helge Gabert 0 1,173 11-16-2013, 03:41 PM
Last Post: Helge Gabert
  Possible bug with sqrt function in the HP prime Michael de Estrada 6 2,597 11-15-2013, 12:49 PM
Last Post: Michael de Estrada
  HP-41 MCODE: The Last Function - at last! Ángel Martin 0 1,108 11-08-2013, 05:11 AM
Last Post: Ángel Martin
  HP Prime 'where' function bluesun08 11 3,490 10-29-2013, 06:56 PM
Last Post: Joe Horn
  HP Prime - Defining a function bluesun08 5 2,350 10-23-2013, 02:43 PM
Last Post: Han
  HP PRIME Function parameters steindid 2 1,474 10-11-2013, 10:20 AM
Last Post: steindid
  HP Prime can't find how to use partfrac function ! dg1969 3 1,690 10-04-2013, 09:25 PM
Last Post: Joe Horn
  HP Prime function APP - Strange limitation ! :o( dg1969 2 1,636 10-04-2013, 12:10 PM
Last Post: dg1969

Forum Jump: