02-14-2022, 09:16 PM
Hi, I am new to this forum but would like to share a small program that I frequently use and might be usefull.
Series are used in electronics to have a logarithmically based sequence and this enables the different values to be spaced in such a way that they relate to the component tolerance or accuracy. Since not every value are available, the goal of this program is to calculate the nearest value in the E24 normalized serie.
This program works in RPN mode and is mainly based on stack manipulation. To discriminate between choices (program branches), flag mechnism has been preferred over LABEL and GOTO to save limited labels availability (HP32Sii).
Given a value in X register (let's call it R), the first step of the program is to calculate the value exponent.
This is done through steps 6 to 7 : LOG(IP(R)). Exponent is named D in the stack detail for simplicity
The second step consist in finding the place in serie ROUND(LOG((R/10^D)^24), 0). Serie place is named M in the stack detail
Once the place is found, E24 serie values will require an OFFSET correction:
- if M = 22 : the offset will be -0.1
- if M≥10 and M≤16 the offset will be +0.1
- Offset = 0 for other place
The third step consist in calculating the final value from serie's place and exponent : 10^D * ROUND(OFFSET + 24*SQRT(10^M), 1)
Testing the serie's place is done in the program from instruction R19 to R29. Flags 0 and 1 are used to identify the offset correction.
Final value calculation starts at step R30, offset decision is done from R34 to R40.
R45 revert the calculator in 5 digit display (engineering format), but one may modify this step at convenience. Keep in mind that program checksum is calculated with ENG 5.
Original value is availbale in Y,Z,T registers while final value is available in X register.
On HP35S both values are displayed on the two lines screen while on HP32Sii X and Y register exchange key (X<>Y) needs to be pressed to visualize X and Y registers.
Having both values in X and Y registers still allows further calculations like %chg or more ...
A PDF reader friendly version is joined to the thread.
Have fun.
Series are used in electronics to have a logarithmically based sequence and this enables the different values to be spaced in such a way that they relate to the component tolerance or accuracy. Since not every value are available, the goal of this program is to calculate the nearest value in the E24 normalized serie.
This program works in RPN mode and is mainly based on stack manipulation. To discriminate between choices (program branches), flag mechnism has been preferred over LABEL and GOTO to save limited labels availability (HP32Sii).
Given a value in X register (let's call it R), the first step of the program is to calculate the value exponent.
This is done through steps 6 to 7 : LOG(IP(R)). Exponent is named D in the stack detail for simplicity
The second step consist in finding the place in serie ROUND(LOG((R/10^D)^24), 0). Serie place is named M in the stack detail
Once the place is found, E24 serie values will require an OFFSET correction:
- if M = 22 : the offset will be -0.1
- if M≥10 and M≤16 the offset will be +0.1
- Offset = 0 for other place
The third step consist in calculating the final value from serie's place and exponent : 10^D * ROUND(OFFSET + 24*SQRT(10^M), 1)
Testing the serie's place is done in the program from instruction R19 to R29. Flags 0 and 1 are used to identify the offset correction.
Final value calculation starts at step R30, offset decision is done from R34 to R40.
R45 revert the calculator in 5 digit display (engineering format), but one may modify this step at convenience. Keep in mind that program checksum is calculated with ENG 5.
Original value is availbale in Y,Z,T registers while final value is available in X register.
On HP35S both values are displayed on the two lines screen while on HP32Sii X and Y register exchange key (X<>Y) needs to be pressed to visualize X and Y registers.
Having both values in X and Y registers still allows further calculations like %chg or more ...
A PDF reader friendly version is joined to the thread.
Have fun.
Code:
R001 LBL R
R002 ENTER
R003 ENTER
R004 CF0
R005 CF1
R006 LOG
R007 IP
R008 10^x
R009 ENTER
R010 1/x
R011 R↑ (or REGZ)
R012 x (multiplication)
R013 24
R014 y^x
R015 LOG
R016 FIX 0
R017 RND
R018 ENTER
R019 22
R020 x=y?
R021 SF 0
R022 CLx
R023 16
R024 x<y?
R025 SF 1
R026 CLx
R027 10
R028 x>y?
R029 SF 1
R030 R↓
R031 10x
R032 24
R033 x√y
R034 0.1
R035 FS? 0
R036 CF 1
R037 FS? 1
R038 CLx
R039 FS? 0
R040 +/-
R041 +
R042 FIX 1
R043 RND
R044 x (multiplication)
R045 ENG 5
R046 RTN