(41C) Conversion sur HP 41C
07-02-2020, 11:51 AM
Post: #1
 SlideRule Senior Member Posts: 1,325 Joined: Dec 2013
(41C) Conversion sur HP 41C
An extract from Conversion sur HP 41C, Joel Schlicklin, Megahertz communication-informatique, No 17, Avril 1984, pages 90-91

Qui n'a pas éprouvé certaines difficultés dans l'utilisation des unités comme les décibels, qu' ils soient dBm - dBμv. Toute manipulation de ces unités et de celles qui s'y rapportent demande une certaine expérience afin de jongler avec les logarithmes. Voila pourquoi le programme qui suit va permettre les différentes conversions entre dBm dBμv Uμv et PmW.
Ce programme tourne sur HP 41C.

Who has not experienced certain difficulties in the use of units like decibels, whether they're dBm - dBμv. Any manipulation of these and related units request some experience in order to juggle logarithms. This is why the program which will allow different conversions between dBm dBμv Uμv and PmW.
This program runs on HP 41C.

Includes description, illustration, equations, flowchart, instructions & program listing.

BEST!
SlideRule
12-19-2021, 10:50 AM (This post was last modified: 12-30-2021 10:14 PM by C.Ret.)
Post: #2
 C.Ret Member Posts: 215 Joined: Dec 2013
RE: (41C) Conversion sur HP 41C (adding dB-W)
Bonjour à tous,

At first glance the tittle in french intrigue my curiosity. I then realize that the reference article is written in french.

I try the code on my HP-41C.
It is a bit long code and not so easy to use since units have to be key in without any misspelling. Secondly, it produce quite erroneous results; when we are successively converting a value through all the available units, we get back a really different value from the starting one.

One detail that disturb me is that this code display the results with units mixing engineer notation and sub-unit indication.
For exemple, a value of one volt is display " 1.00E+6 µV " and one picovolt " 1.00E-3 µV " where I would have preferred " 1.00 V " and " 1.00 pV " respectively or at least (for a shorter and easier code) " 1.00E0 V " and " 1.00E-9 V" respectively. I think it's more general for large range of data and easy to read enough since engineer notation only show multiple exponent of 3.
That's the aim on engineer notation having full unit ( E0 ), multiple of unit such as mega or kilo (resp. E6 or E3), or sub-multiple of unit such as expected milli, micro or pico (resp. E-3 , E-6 or E-9 ).

One other detail that had disturbed me is that dB, which are dimensionless value are also expressed in engineer notation. This is useless, one may always display dB = x.xxxE0 since there is no unit. Display as xxx.xx dB is much more appropriate.

A third problem is that, amplification relative to power is missing.

So I rewrite this code to include all the features I was expecting in such a converter.

First, conversion is easy to achieve, I use digit entry detection of the HP-41C (flag 22) to detect no data entry and conversion order.

The indication of units use direct USER Alpha label A through E. So the the user have to key-in a value (that set the Flag 22) and press one key of the first row to indicate the unit.
To convert to any unit, the user may press directly the corresponding label without any digit entry.
Easy multiple conversions to different units are possible.

The impedance have to be entered in OHMS before any conversion in register R00 or using XEQ 00 or XEQ "IMP" to display the value.

Label - Units ( display notation )
"IMP"
00 - OHMS ( engineer) Impedance value have to be key-in in ohms: 50 [XEQ[00]] set Z = 50 Ohms and store value in register R00.
"A" - WATT (engineer) Power entered in Watt; value store in register R01
"B" - dB-W (fixe) Power amplification relative to one Watt : 1 [ A ] [ B ] display 0.00 dB-W. Value store in register R02.
"C" - db-m (fixe) dB-m (decibel-milliwatts) is amplification relative to one milliwatt (mW): 1 [EEX] 3 [CHS] [ A ] [ C ] display 0.00 dB-M . value store in R03
"D" - db-µV (fixe) electric field strength relative to 1 microvolt per meter. The unit is often used to specify the signal strength of a television broadcast at a receiving site (the signal measured at the antenna output is reported in dBμV): 1 [EEX] 6 [CHS] [ E ] [ D ] display 0.00 dB-µV. value is store in register R04
"E" - VOLT (engineer) Electric potential in VOLT : 7.07 [ E ] set value to 7.07 V and display " 7.07E0 VOLT " . Value is store in register R05

Principe of operation:

The unit of the entered value is remained by setting a flag (respectively Flag 01, 02, 03, 04 and 05 for each above unit).
When pressing a unit label-key without digit entry, conversion is achieve by retrospectively testing each flag and executing the corresponding conversion sub-routines:
LBL 01: convert from V (Volt) to power (Watt) ; W := V²/Z
LBL 02: convert from power (W) to power amplification, dB-W := 10*LOG(W)
LBL 03: convert from dB-W to dB-m ; dBm := 30+dBW
LBL 04: convert from dB-m to dB-µV ; dBµV := dBm+10*LOG(Z)+90
LBL 05: convert from dB-µV to Volt ; V := 10^(dBµV/20)

The code is one hundred of instructions:

01 LBL "IMP" SF 27
03 LBL 00 STO 00 CF 11 "OHM" GTO 11 // ENTER impedance Z (Ohm) press XEQ 00
08 LBL "A" FC?C 22 XEQ 01 STO 01 SF 01 CF 11 "WATT" GTO 11 // ENTER or CONVERT to mW ( x.xxxEee Watt ) press USER - A
16 LBL "B" FC?C 22 XEQ 02 STO 02 SF 02 SF 11 "W" GTO 11 // ENTER or CONVERT to dB-W ( xxx.xx dB-W ) press USER - B
24 LBL "C" FC?C 22 XEQ 03 STO 03 SF 03 SF 11 "m" GTO 11 // ENTER or CONVERT to dB-m ( xxx.xx dB-m ) press USER - C
32 LBL "D" FC?C 22 XEQ 04 STO 04 SF 04 SF 11 "µV" GTO 11 // ENTER or CONVERT to dB-µ ( xxx.xx dB-µV ) press USER - D
40 LBL "E" FC?C 22 XEQ 05 STO 05 SF 05 CF 11 "VOLT" // ENTER or CONVERT to µV ( x.xxxEee VOLT ) press USER - E
47 LBL 11 ASTO Y CLA ENG 3 FS? 11 FIX 2 ARCL X "~ " FS? 11 "~dB-"
57 ARCL Y ENG 6 PROMPT RTN // Display ( x.xxxEee unit or xxx.xx dB-unit )

61 LBL 01 FC?C 05 XEQ 05 x^2 RCL 00 / RTN // Convert from V to W := V²/Z
68 LBL 02 FC?C 01 XEQ 01 LOG 10 * RTN // Convert from W to dBW := 10*LOG(W)
75 LBL 03 FC?C 02 XEQ 02 30 + RTN // Convert from dBW to dBm := 30+dBW
81 LBL 04 FC?C 03 XEQ 03 RCL 00 LOG 10 * + 90 + RTN // Convert from dBm to dBµV := dBm+10*LOG(Z)+90
92 LBL 05 FC?C 04 XEQ 04 20 / 6 - 10^X // Convert from dBµV to µV := 10^(dBµV/20)
100 END

The µ and m symbols may be entered on half-nutt HP-41C using a synthetic technique or simply being replaced by capital letters U and M on any other Hp-41.

Typical used:(edited)
Code:
50 XEQ [ALPHA]IMP[ALPHA]     "50.00E0 OHM  "    // Startup program and initiate impedance .6 A                         "600.0E-3 WATT"    // Enter power value in main unit (W). Displayed 'E-3' exponent indicate sub-unit (mW) B                            "-2.22 dB-W   "    // Press label without digits entry display converted value. D                            "134.77 dB-µV "    // Amplifications have no unit (no 'E+00' displayed)   C                            "27.78 dB-m  "    // Power Amplification - no unit   E                            "5.477E0 VOLT "    // 'E0' indicate unit scale (true VOLT) A                            "600.0E-3 WATT"    // back to initial value 600 mW  [<-]                           600.0000  -03    // Actual value in stack's X and register R01 (ENG 6 format) [FIX [ 9 ]]                      0.599999993    // FIX 9 reveal rounding cumulative errors (error unmasked)

Sometime, numerous successive conversions may produced a few accumulated rounding errors. Fortunately, the display format in alpha register is masking rounding error (main of the time).
Accuracy can be check by setting in FIX 9 display mode and observing the values in registers.

Thanks to all of you.

EDITED 30-dec-2021 22:36 UTC+1: see following messages
12-30-2021, 12:09 AM (This post was last modified: 12-30-2021 12:10 AM by Dave Britten.)
Post: #3
 Dave Britten Senior Member Posts: 2,154 Joined: Dec 2013
RE: (41C) Conversion sur HP 41C
Nice little program, I've been looking for something like this. I noticed I'm getting different results for dB-uV and dB-m. I think this may just be a typo in your example, but I'm not sure.

Results I get from your example inputs (50 Ohms, 0.6 W):

600.0E-3 WATT
-2.22 dB-W
27.78 dB-m (I think this is correct, it's dBW+30)
134.77 dB-uV (Agrees with dBm+10*log(Z)+90, but not the result in your example)
5.477E0 VOLT

And I'm not sure if this was intentional, but flag 11 is the auto-exec flag. If you weren't meaning to enable that, then a user flag like flag 10 might be a better choice.

12-30-2021, 09:29 PM (This post was last modified: 12-30-2021 09:47 PM by C.Ret.)
Post: #4
 C.Ret Member Posts: 215 Joined: Dec 2013
RE: (41C) Conversion sur HP 41C
(12-30-2021 12:09 AM)Dave Britten Wrote:  Nice little program, I've been looking for something like this. I noticed I'm getting different results for dB-uV and dB-m. I think this may just be a typo in your example, but I'm not sure.

This is effectively a mistake since I mix-up all the values in my example.
I will correct all this mess directly in the previous post.

(12-30-2021 12:09 AM)Dave Britten Wrote:  And I'm not sure if this was intentional, but flag 11 is the auto-exec flag. If you weren't meaning to enable that, then a user flag like flag 10 might be a better choice.

Ah! Thanks you !

Since a few days my HP-41C had a strange behavior; sometimes, it is beeping when I turn it on. I was wondering what it was and was afraid it were broken.

There is no special reason to use this flag. I often use flags on my HP-28S which have a larger range for general purpose flags. I have forgotten that the HP-41C's user flags range from 00 to 10.

Here is a new version of the previous program that use no flag for display format.
I also have change the flags used to remember what entry and unit was inputted. In this new version, the flag from 00 to 04 are used so that corresponding annunciators 0 to 4 are light on or off depending of entry. Eventual erroneous situation (some successive value entries with no conversion may result in situation where more than one indicator is ON) are easily detected.
Also, the results of any conversion is no more store in a register allowing the user to store any results in any register of his choice.

Finally, I reorganized subpart of the code so that after any entry or conversion, the R/S key can be used to scroll from one unit to the next. This also spare a few bytes.

Code:
01 LBL"IMP"  SF 27 03   LBL 00  STO 00  "OHM" 06   LBL 10  ENG 3  ASTO L  CLA  ARCL X  "~ "  GTO 12 13   LBL 01  FC?C 00  XEQ 05  X^2  RCL 00  /  RTN 20   LBL 02  FC?C 01  XEQ 01  LOG  10  *  RTN 27   LBL 03  FC?C 02  XEQ 02  30  +  RTN 33   LBL 04  FC?C 03  XEQ 03  RCL 00  LOG  10  *  +  90  +  RTN 44   LBL 05  FC?C 04  XEQ 04  20  /  6  -  10^X  RTN 53   LBL A  FC?C 22  XEQ 01  SF 01  "WATT"  XEQ 10 59   LBL B  FC?C 22  XEQ 02  SF 02  "W"  XEQ 11 65   LBL C  FC?C 22  XEQ 03  SF 03  "m"  XEQ 11 71   LBL D  FC?C 22  XEQ 04  SF 04  "µV"  XEQ 11 77   LBL E  FC?C 22  XEQ 05  SF 00  "VOLT"  XEQ 10  GTO A 84   LBL 11  FIX 2  ASTO L  CLA  ARCL X  "~ dB-" 90   LBL 12  ARCL L  ENG 6  PROMPT 94 END

Thanks
12-31-2021, 11:55 AM
Post: #5
 Ángel Martin Senior Member Posts: 1,370 Joined: Dec 2013
RE: (41C) Conversion sur HP 41C
Could you list the program steps using one line per instruction?
That'd make it much easier to transcribe...

Of course a RAW file would be even better ;-)
12-31-2021, 12:50 PM
Post: #6
 Dave Britten Senior Member Posts: 2,154 Joined: Dec 2013
RE: (41C) Conversion sur HP 41C
(12-31-2021 11:55 AM)Ángel Martin Wrote:  Could you list the program steps using one line per instruction?
That'd make it much easier to transcribe...

Of course a RAW file would be even better ;-)

Hey, it's not even 100 steps, that's a cinch to key in. And it's just formatted like the 82143 does it when the switch is set to TRACE mode. You know, to save paper.

I'll type in the revised version later and try it out a little.
12-31-2021, 07:22 PM
Post: #7
 C.Ret Member Posts: 215 Joined: Dec 2013
RE: (41C) Conversion sur HP 41C
(12-31-2021 11:55 AM)Ángel Martin Wrote:  Could you list the program steps using one line per instruction?
That'd make it much easier to transcribe...

You are welcome, but, I am not sure that this type of listing will be of great help !

(12-31-2021 11:55 AM)Ángel Martin Wrote:  Of course a RAW file would be even better ;-)

I use no simulator; Can you be a bit more explicit about which RAW file you are expecting ?
01-01-2022, 07:54 AM (This post was last modified: 01-01-2022 08:15 AM by Ángel Martin.)
Post: #8
 Ángel Martin Senior Member Posts: 1,370 Joined: Dec 2013
RE: (41C) Conversion sur HP 41C
see attached - standard RAW format used by V41.

Code:
01 LBL "IMP" 02 SF 27 03 LBL 00 04 STO 00 05 "OHM" 06 LBL 10  07 ENG 3 08 ASTO L  09 CLA  10 ARCL X 11 >" " 12 GTO 12 13 LBL 01 14 FC?C 00 15 XEQ 05 16 X^2 17 RCL 00 18 / 19 RTN 20 LBL 02 21 FC?C 01 22 XEQ 01 23 LOG 24 E1 25 * 26 RTN 27 LBL 03 28 FC?C 02 29 XEQ 02 30 30 31 + 32 RTN 33 LBL 04   34 FC?C 03   35 XEQ 03    36 RCL 00   37 LOG   38  E1 39 *   40 +   41 90   42 +   43 RTN 44 LBL 05   45 FC?C 04   46 XEQ 04   47 20   48 /   49 6   50 -   51 10^X   52 RTN 53 LBL A   54 FC?C 22   55 XEQ 01   56 SF 01   57 "WATT"   58 XEQ 10 59 LBL B   60 FC?C 22   61 XEQ 02   62 SF 02   63 "W"   64 XEQ 11 65 LBL C   66 FC?C 22   67 XEQ 03   68 SF 03   69 "m"   70 XEQ 11 71 LBL D   72 FC?C 22   73 XEQ 04   74 SF 04   75 "µV"   76 XEQ 11 77 LBL E   78 FC?C 22   79 XEQ 05   80 SF 00   81 "VOLT"   82 XEQ 10   93 GTO A 84 LBL 11   85 FIX 2   86 ASTO L   87 CLA   88 ARCL X   89 >" dB-" 90 LBL 12   91 ARCL L   92 ENG 6   93 PROMPT 94 END

Attached File(s)
01-01-2022, 04:03 PM (This post was last modified: 01-02-2022 08:43 AM by C.Ret.)
Post: #9
 C.Ret Member Posts: 215 Joined: Dec 2013
RE: (41C) Conversion sur HP 41C
(01-01-2022 07:54 AM)Ángel Martin Wrote:  see attached - standard RAW format used by V41.

Thanks a lot, I just download Warren Furlow's V41 software from Christoph Gießelink site and install it on my laptop.

I now have a way to make standard and useful *.raw files. I also discover an easy way for synthetic programming since the *.lod files of this software allow easy hexadecimal editing of any code for the Virtual 41 !

Playing with this new tool, I enhance a bit my last version of the converter correcting three main quirks :
1. Too many times, when the user enter a value and don't ask for a conversion, multiple flags are set that situation may drive to erroneous results. Now a sub-routine to clear all the flags is call after each new value entry.
2. When dB are close to zero, same bad rounding appears and disturbs the display which may cause misreading. Now a rounding instruction is inserted when displaying unit free values for dB. The rounding limit is set by a FIX 7 instruction just before a RND instruction. This allows to have a correct result displayed when converting 1 µV (displayed as " 1.000E-6 VOLT ") into " 0.00 dB-µV " ( wrong versions was showing " 4.00E-8 dB-µV " ).
3. A new short label F allows to directly enter impedance Z (in Ohm). It can be used to change impedance value (when the user have key-in any digit) or to display back the current value store in R00. This also clear the indicators flags. This again avoid same further erroneous conversions.
When IMPEDANCE? is prompted, the user have to key-in the value (in Ohm) and press R/S to continue.
Whenever no impedance is given at application start, the code will prompt the user when needed. Simply press R/S on prompts to continue the conversion.

Like the previous version after each conversion, R/S can be use to directly convert to the next unit. By repeating the process over all the units available, all registers from R01 up to R05 will be set with the correlated values.

Beware that at the start of the code, a CLRG instruction clear all registers ! Please fill free to remove this instruction or to add any more convenient instructions to clear only expected registers.

[attachment=10226]

Code:
001 LBL"IMP"  CF 00  SF 27  ENG 3  CLRG 006   LBL F   FC?C 22  XEQ 06  STO 00  XEQ 00  SF 00  "OHM"   GTO 11 014   LBL A   FC?C 22  XEQ 01  STO 01  XEQ 00  SF 01  "WATT"  XEQ 11 022   LBL B   FC?C 22  XEQ 02  STO 02  XEQ 00  SF 02  "W"     XEQ 10 030   LBL C   FC?C 22  XEQ 03  STO 03  XEQ 00  SF 03  "m"     XEQ 10 038   LBL D   FC?C 22  XEQ 04  STO 04  XEQ 00  SF 04  "µV"    XEQ 10 046   LBL E   FC?C 22  XEQ 05  STO 05  XEQ 00  SF 05  "VOLT"  XEQ 11  GTO A 055   LBL 00  CF 01  CF 02  CF 03  CF 04  CF 05  RTN 062   LBL 01  FC?C 05  XEQ 05  X^2  XEQ 06  /  RTN 069   LBL 02  FC?C 01  XEQ 01  LOG  10  *  RTN 076   LBL 03  FC?C 02  XEQ 02  30  +  RTN 082   LBL 04  FC?C 03  XEQ 03  XEQ 06  LOG  10  *  +  90  +  RTN 093   LBL 05  FC?C 04  XEQ 04  20  /  6  -  10^X  RTN 102   LBL 06  RCL 00  FS? 00  RTN 106           RDN  "IMPEDANCE?"  PROMPT  GTO F 110   LBL 10  FIX 7  RND  FIX 2 114   LBL 11  ASTO L  CLA  ARCL X  >" "  FS? 40  >"dB-" 121           ARCL L  ENG 3  PROMPT  CF 22 125 END

USAGE:
The following traces illustrate a typical use of this conversion code. These traces are printed in NORM mode, so that user's key-in is right tabulated and displayed results are left justified.

Here is the .raw file: