Home > HP > Calculator > HP 15c Manual

HP 15c Manual

    Download as PDF Print this page Share this page

    Have a look at the manual HP 15c Manual online for free. It’s possible to download the document as PDF or print. UserManuals.tech offer 1114 HP manuals and user’s guides for free. Share the user manual or guide on Facebook, Twitter or Google+.

    							 Section 6: Programming Basics 81 
     
    Problems 
      1. The  village  of  Sonance  has  installed  a  12-oclock  whistle  in  the 
    firehouse  steeple.  The  sound  level  at  the  firehouse  door,  3.2  meters 
    from  the  whistle,  is  138  decibels.  Write  a  program  to  find  the  sound 
    level at various distances from the whistle. 
     Use the equation L = L0 – 20 log (r/r0), where: L0 is the known sound 
    level (138 db) at a point near the source, 
    r0 is  the  distance  of  that  point  from  the  source  (3.2  m), L is  the 
    unknown  sound  level  at  a  second  point,  and r is  the  distance  of  the 
    second point from the source in meters. 
     What is the sound level at 3 km from the source (r = 3 km)? 
     A possible keystroke sequence is: 
    |¥ ´bC 3.2 ÷ |o 20 * “ 138 
    + |n |¥ taking  15  program  lines  and  15  bytes  of 
    memory.  This  problem  can  be  solved  in  a  more  general  way  by 
    removing  the  specific  values  3.2  and  138  from  the  program,  and 
    instead  recalling  the L0 and r0 values  from  storage  registers;  or  by 
    removing  3.2  and  138  and  loading L0, r,  and r0 into  the  stack  before 
    execution: L0 v r v r0. 
     (Answer: for r = 3 km, L = 78.5606 db.) 
      2. A  typical  large  tomato  weighs  about  200  grams,  of  which  about 
    188  g  (94%)  are  water.  A  tomato  grower  is  trying  to  produce 
    tomatoes of lower percentage water. Write a program to calculate the 
    percent  change  in  water  content  of  a  given  tomato  compared  to  the 
    typical  tomato.  Use  a  programmed  stop  to  enter  the  water  weight  of 
    the new tomato. 
     What  is  the  percent  change  in  water  content  for  a  230  g  tomato  of 
    which 205 g are water? 
     A possible keystroke sequence is: 
    ´bÁ .94 v ¦ (enter water weight of new tomato) 
    v ¦ (enter total weight  of  new  tomato) ÷ |∆ 
    |n taking 11 program lines and 11 bytes of memory. 
     (Answer: for the 230 g tomato above, the percent change in percent 
    water weight is -5.1804%.)  
    						
    							 
    82 
    Section 7 
    Program Editing 
    There  are  many reasons to  modify a program after  youve  already stored it: 
    you might  want  to  add  or  delete  an  instruction  (like O, ©,  or 
    ¦),  or  you  might  even  find  some  errors!  The  HP-15C  is  equipped  with 
    several editing features to make this process as easy as possible. 
    The Mechanics 
    Making  a  program  modification  of  any  kind  involves  two  steps:  moving  to 
    the  proper  line  (the  location  of  the  needed  change)  and  making  the 
    deletion(s) and/or insertion(s). 
    Moving to a Line in Program Memory 
    The Go To (t) Instruction. The sequence t “ nnn will move 
    program  memory  to  line  number nnn, whether  pressed  in  Run  mode  or 
    Program mode (PRGM displayed). This is not a programmable sequence; it 
    is  for manually finding  a  specific  position  in  program  memory.  The  line 
    number must be a three-digit number satisfying 000 ≤ nnn ≤ 448. 
    The  Single  Step (Â) Instruction.  To  move  only  one  line  at  a  time 
    forward  through  program  memory,  press  (single  step). This  function 
    is not programmable. 
    In  Program  mode: Â will  move  the  memory  position  forward  one  line 
    and display that instruction. The instruction is not executed. If you hold the 
    key  down,  the  calculator  will  continuously  scroll  through  the  lines  in 
    program memory. 
    In  Run  mode: Â will  display  the  current  program  line  while  the  key  is 
    held down. When the key is released, the current instruction is executed, the 
    result displayed, and the calculator steps forward to the next program line to 
    be executed.  
    						
    							 Section 7: Program Editing 83 
     
    The  Back  Step (‚) Instruction. To  move  one  line backwards in 
    program  memory,  press ‚ (back  step)  in  Program  or  Run  mode.  This 
    function is not programmable. ‚ will scroll (with the key held down) in 
    Program mode. Program instructions are not executed. 
    Deleting Program Lines 
    Deletions  of  program  instructions  are  made  with − (back  arrow)  in 
    Program  mode.  Move  to  the  line  you  want  to  delete,  then  press −.  Any 
    remaining following lines will be renumbered to stay in sequence. 
    Pressing − in Run mode does not affect program memory, but is used for 
    display clearing. (Refer to page 21.) 
    Inserting Program Lines 
    Additions to a  program are  made  by  moving to the  line preceding the  point 
    of  insertion.  Any  instruction  you  key  in  will  be  added following the  line 
    currently  in  the  display.  To  alter  an  instruction,  first  delete  it,  then  add  the 
    new version. 
    Examples 
    Lets  refer  back  to  the  can  volume  program  on  page  71  in  section  6  and 
    make a few changes in the instructions. (The can program as listed below is 
    assumed to be in memory starting on line 001.) 
    Deletions: If we dont need the summed base area, volume, and surface area 
    values, we can delete the storage register additions (lines 007, 011, and 
    020). 
    Changes: To  eliminate  the  need  to  stop  the  program  to  enter  the  height 
    value (h), change the ¦ instruction to a l 1 instruction (because of 
    the  above  deletions,  R1 is  no  longer  being  used)  and  store h in  R1 before 
    running  the  program.  To  clean  things  up,  lets  also  alter O 4  (line  006) 
    to O 2  and l 4  (old  line  016)  to l 2,  since  we  are  no  longer 
    using R2 and R3. 
    The editing process is diagrammed on the next page.  
    						
    							84 Section 7: Program Editing 
     
    Lets  start  at  the  end  of  the  program  and  work  backwards.  In  this  way,  deletions 
    will not change the line numbers of the preceding lines in the program. 
    Keystrokes Display  
    | ¥ 000- Program mode. (Assumes position is at line 000.) 
    t “ 020 
    (or use Â) 020-44,40, 3 Moves position to line 020 
    (instruction O + 3.) 
       
    						
    							 Section 7: Program Editing 85 
     
     
    Keystrokes Display  
    − 019-      40 Line 020 deleted. 
    | ‚ (hold) 016-   45  4 The next line to edit is line 
    016 (l 4). 
    − 015-      20 Line 016 deleted. 
    l 2 016-   45  2 Line 016 changed to l 2. 
    t “ 011 
    (or hold ‚) 011-44,40, 2 Moves to line 011 (O+ 
    2). 
    − 010-   42 31 Line 011 deleted. 
    | ‚ (hold) 008-      31 Stop! (Single-stepping 
    backwards to line 008: ¦.) 
    − 007-44,40, 1 ¦ deleted. 
    l 1 008-   45  1 Line 008 changed to l 1. 
    | ‚ 007-44,40, 1 Back-step to line 007. 
    − 006-   44  4 Line 007 (O+ 1) 
    deleted. 
    − 005-      20 Line 006 (O 4) deleted. 
    O 2 006-   44  2 Changed to O 2. 
    The replacement of a line proceeds like this: 
     
    Further Information 
    Single-Step Operations 
    Single-Step  Program  Execution. If  you  want  to  check  the  contents  of  a 
    program  or  the  location  of  an  instruction,  you  can  single  step  through  the 
    program in  Program  mode. If,  on  the  other hand,  running  the  program 
    produces  an  error,  or  you  suspect  that  a  portion  of  the  program  is  faulty,  
    						
    							86 Section 7: Program Editing 
     
    you  can  check  the  program  by executing it  stepwise.  This  is  done  by 
    pressing  in Run mode. 
    Keystrokes Display  
    | ¥  Run mode. 
    ´ CLEAR Q  Clear storage registers. 
    t A  Move to first line of program 
    A. 
    8 O 1 8.0000 Store a can height. 
    2.5 2.5 Enter a can radius. 
    Â (hold) 00142,21,11 Keycode for line 001 (label). 
         (release) 2.5000 Result of executing line 001. 
    Â 002   44  0 t 0. 
     2.5000 Result. 
    Â 003   43 11 | x. 
     6.2500 Result. 
    Â 004   43 26 | $. 
     3.1416 Result. 
    Â 005      20 * 
     19.6350 Result: the base area of the can. 
    Wrapping. Â will  not  move  program  position  into  ―unoccupied‖ 
    program territory. Instead, the calculator will ―wrap around‖ to line 000. (In 
    Run  mode, Â will  perform  any  instructions  at  the  end  of  program 
    memory, such as n, t or G.) 
    Line Position 
    Recall  that  the  calculators  position  in  program  memory  does  not  change 
    when  it  is  shut  off  or  Program/Run  modes  are  changed.  Upon  returning  to 
    Program mode, the calculator line position will be  where  you left it. (If you 
    executed  a  program  ending  with n,  the  position  will  be  at  line  000.) 
    Therefore, if the calculator is left on and shuts itself off, you need only turn 
    it on and switch to Program mode (the calculator always wakes up in Run 
    mode) to be back where you were.  
    						
    							 Section 7: Program Editing 87 
     
    Insertions and Deletions 
    After  an  insertion,  the  display  will  show  the  instruction  you  just  added. 
    After  a  deletion,  the  display  will  show  the  line  prior  to  the  deleted  (now 
    nonexistent) one. 
    If  all  space  available  in  memory  is  occupied,  the  calculator  will  not  accept 
    any program instruction insertions and Error 4 will be displayed. 
    Initializing Calculator Status 
    The  contents  of  storage  registers  and  the  status  of  calculator  settings  will 
    affect a program if the program uses those registers or depends on a certain 
    status  setting.  If  the  current  status  is  incorrect  for  the  program  being  run, 
    you  will  get  incorrect  results.  Therefore,  it  is  wise  to  clear  registers  and  set 
    relevant modes either just prior to running a program or within the program 
    itself.  A  self-initializing  program  is  more  mistake-proof—but  it  also  uses 
    more program lines. 
    Calculator-initializing  functions  are: ´ CLEAR ∑, ´ CLEAR 
    M, ´ CLEAR Q, | D, | R, | g, | 
    F, and | . 
    Problems 
    It  is  good  programming  technique  to  avoid  using  identical  program  labels. 
    (This  shouldnt  be  hard,  since  the  HP-15C  provides  25  different  labels.)  To 
    ensure against duplication of labels, you can clear program memory first. 
    1. The  following program is used by the  manager of a  savings and loan 
    company to compute  the  future  values of savings accounts according 
    to  the  formula FV  =  PV (l  + i)n, where FV is  future  value, PV is 
    present  value, i is  the  periodic  interest  rate,  and n is  the  number  of 
    periods. Enter PV first (into the Y-register) and n second (into the X-
    register)  before  executing  the  program.  Given  is  an  annual  interest 
    rate of 7.5% (so i = 0.075).  
    						
    							88 Section 7: Program Editing 
     
     
    Keystrokes Display 
    ´ b . 1 001-42,21,.1 
    ´ •O 002-42, 7, 2 
    1 003-       1   
    . 004-      48  
    0 005-       0 Interest. 
    7 006-       7  
    5 007-       5  
    ® 008-      34  
    y 009-      14 (1 + i)n 
    * 010-      20 PV (1 + i)n 
    | n 011-   43 32  
     
     Load  the  program  and  find  the  future  value  of  $1,000  invested  for  5 
    years; of $2,300 invested for 4 years. Remember to use G to run 
    a program with a digit label. (Answers: $1,435.63; $3,071.58.) 
     Alter the program to make the annual interest rate 8.0%. 
     Using  the  edited  program,  find  the  future  value  of  $500  invested  for 
    4  years;  of  $2,000  invested  for  10  years.  (Answers:  $680.24; 
    $4,317.85.) 
    2. Create a program to calculate the length of a chord ℓ subtended by an angle  (in degrees) on a circle of radius r, according to the equation 
     
    ℓ=2r sin 
     
     
    Find ℓ when θ = 30° and r = 25. 
     (Answer:  12.9410.  A  possible  program  is: ´bA |D 
    ´•4  2 * ® 2 ÷ [ * |n).  (Assumes 
     in Y-register and r in X-register when program is run.) 
     .2
    θ   
    						
    							 Section 7: Program Editing 89 
     
    Make any necessary modifications in the program to also find and display s, 
    the length of the circular arc cut by θ (in radians), according to the equation 
    s = r θ. 
    Complete the following table: 
    θ r ℓ=s 
    45° 50 ? ? 
    90° 100 ? ? 
    270° 100 ? ? 
    (Answers:  38.2683 and 39.2699;  141.4214  and  157.0796;  141.4214  and 
    471.2389.  
    A possible new sequence is: 
    ´bA |D ´•4 O0  2* ® O1 2÷ 
    [ * ´© ´© l0 l1 ´r * 
    |n). 
      
    						
    							 
    90 
    Section 8 
    Program Branching 
    and Controls 
    Although  the  instructions  in  a  program  are  normally  executed  sequentially, 
    it is often desirable to transfer execution to a part of the program other than 
    the next line. Branching in the HP-15C may be simple, or it may depend on 
    a certain condition. By branching to a previous line, it is possible to execute 
    part of a program more than once – a process called looping. 
    The Mechanics 
    Branching 
    The  Go  To (t) Instruction. Simple  branching – that  is,  unconditional 
    branching – is  carried  out  with  the  instruction t label. In  a  running 
    program, t will  transfer  execution  to  the  next appropriately  labeled 
    program or routine (not to a line number). 
     
    The  calculator  searches  forward  in  memory,  wrapping  around  through  line 
    000  if  necessary,  and  resumes  execution  at  the  first  line  containing  the 
    proper label. 
    Looping. If  a t instruction  specifies  a  label at  a  lower-numbered  line 
    (that  is,  a  prior  line),  the  series  of  instructions between  the t and  the 
    label will  be  executed  repeatedly – possibly  indefinitely.  The  continuation   
    						
    All HP manuals Comments (0)