Post Reply 
Group Size program for HP-41CX
05-04-2018, 06:13 PM
Post: #1
Group Size program for HP-41CX
Hi all,

This is my first contribution to the group.

After recently rediscovering my HP-41CX I found myself playing with it. Then I discovered all of the cool new emulators and barcode generators which has made programming so much easier.

The program I'm posting is one that computes several parameters that describe the accuracy and precision of shot placement on a target. I call it Group Size and the main label is GRP. I've attached my documentation for it along with a list of the commands, and the barcode. (I couldn't figure out how to attache the .raw file though.) I used the Virtual HP-41 emulator and BarcodeReader Beta 0.6 by Martin Hepperle.

I'm guessing that the code could benefit from some 'tightening up' so if you see any obvious improvements, please let me know but be kind with any criticisms! It has been a LONG time since I've done any substantial coding. :-)

FYI: I programmed it to work with the IR transmitter module for the IR printer installed and for when the IR module is removed. With the IR module installed, it will run with no halting of the output with the data going to both the screen and printer. With no IR module installed, the output is halted after each output so that the data can be recorded. Flags 21 and 55 are used to enable these functionalities.

Best,

Christine

P.S. As my handle implies I live in Idaho where target shooting, especially in preparation for hunting season, is not an uncommon activity here.


Attached File(s)
.pdf  grp barcode.pdf (Size: 68.34 KB / Downloads: 4)
.pdf  grp.pdf (Size: 247.16 KB / Downloads: 7)
.pdf  Group Size Program doc.pdf (Size: 23.49 KB / Downloads: 13)

Just a nerd girl with too much alphabet soup behind her name and an HP-41CX.
Find all posts by this user
Quote this message in a reply
05-08-2018, 11:23 AM
Post: #2
RE: Group Size program for HP-41CX
(05-04-2018 06:13 PM)ID_girl Wrote:  The program I'm posting is one that computes several parameters that describe the accuracy and precision of shot placement on a target. I call it Group Size and the main label is GRP. I've attached my documentation for it along with a list of the commands, and the barcode. (I couldn't figure out how to attache the .raw file though.)

Since .raw files are not permitted as attachments, simply zip it and attach the zip-file.

(05-04-2018 06:13 PM)ID_girl Wrote:  I'm guessing that the code could benefit from some 'tightening up' so if you see any obvious improvements, please let me know but be kind with any criticisms! It has been a LONG time since I've done any substantial coding. :-)

OK, here we go: ;-)

The program seems to assume that the summation registers are R11...R16. In fact they can be anywhere the user set it sometime before. So you better place a ΣREG 11 at the beginning.

The program does not use R01...R10. Instead it requires registers up to R33. Personally, I prefer a continuous block of registers starting at R00 so that the required SIZE is as low as possible.

At some points the file pointer is reset to zero. Here you place the file name "DATA" in Alpha but then a SEEKPT follows -- which ignores the file name and sets the pointer of the current working file. So you can either remove the "DATA" string or you set the pointer with SEEKPTA (seek pointer of file whose name is in Alpha).

There are loops where the pointer is divided by 2 and the result compared with the number of data points. Since this number is known, why don't you just use a simple DSE counter for this?

The averages for X and Y are calculated manually. Instead you could simply use the MEAN command. ;-)

Calculating sqrt(x^2+y^2) can be done with a simple R-P command.

I would prefer removing all the special printer commands and replace them with AVIEW. For instance, when the printer logs the data input this is currently done with ACX, ACA and PRBUF. You could just as well build the string in Alpha and print it with an AVIEW. Also take a look at line 007...012. To me it looks like this prints a simple blank line -- just as a simple ADV. ;-)

The loops at LBL 31 and LBL 32 can be improved significantly. For each of the four values xi, yi, xj and yj the pointer address is calculated and then the data is recalled from the file. This could be done much simpler if xi and yi (as well as xj and yj) are retrieved by consecutive GETX commands:

In the outer i-loop, recall xi and yi once and store them. Then run through the j-loop and calculate the spread with xj and yj. This way only the latter two have to be recalled in this loop. In something like BASIC it would look like this:

Code:
maxspread=0
for i=0 to n-2
    xx=x[i]
    yy=y[i]
    for j=i+1 to n-1
        spread = sqrt((xx-x[j])^2 + (yy-y[j])^2)
        if spread > maxspread then maxspread=spread
    next j
next i


On the HP41 it may look like this, starting at line 159 of the current program.

Code:
...
"DATA"
CLST
STO 33
RCL 00
2
-
1E3
/
STO 31
LBL 31
RCL 31
INT
ST+ X
SEEKPTA
GETX
STO 34
GETX
STO 35
RCL 31
1,001
+
STO 32
LBL 32
GETX
RCL 34
-
GETX
RCL 35
-
R-P
RCL 33
X<=Y?
X<>Y
STO 33
ISG 32
GTO 32
ISG 31
GTO 31
FC? 55
CF 21
"G:SIZE="
ARCL X
AVIEW
ADV
ADV
ADV
END

Regarding the r_avg calculation I wonder if it can be done without a loop, only with the already existing sums. I'll have to take a closer look at this.

I have tried a streamlined version of your program. But to check the results I need some data. Could you provide an example and the complete data output of your program so that I can compare it with what I got? I am not familiar with what the program calculates, so I don't even know some realistic values for X and Y. ;-)

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)