Calculator Synopsis
Calculator Synopsis
Calculator Synopsis
Computer Science/ComputerEngineering
Joshua Boggs and Shensi Ding
May, 2012
Abstract
At the beginning of the semester, Professor Stephen Edwards informed
his students that he had wiped the firmware on a set of HP 20b Calculators. Students were then assigned the daunting task of rebuilding the
software from the ground up. Project partners Joshua Boggs and Shensi
Ding collaborated to complete this task along with the assistance of Professor Stephen Edwards and Teaching Assistant Yoonji Shin. The following report provides details about the calculator operated on, instructions
on using the calculator, and an in depth look at the software written to
complete the assignment.
Introduction
User Guide
The calculator we have programmed uses reverse Polish notation. In this notation, the operators come after the operands. No parentheses are used, simply
number keys, operators, and the input key.
To carry out a simple operation, begin by typing your first operand into
the keyboard. Then, press INPUT. The number you entered will appear on
the LCD. Next, type out the second operand, and again press INPUT. Finally,
press the operator you would like to use. The answer will then appear on the
LCD. The following examples should illustrate this concept.
Social Implications
The Platform
4.1
The Processor
The calculator utilizes an Atmel AT91SAM7L128 processor. It is a 30MHz lowpower ARM7 System with 128 Kbytes of internal high-speed flash.
4.2
The calculator has a large 2-line liquid crystal display. The primary section of
the display, the bottom line, can show up to 12 7-segment characters at a single
time, and 3 exponents. Above is an 8-character scrolling top line.
The LCD interacts with a few different functions in the code:
lcd put char7 Prints the value specified in the argument.
lcd print int(stack[pointer]) Prints the specified value in the stack.
lcd print7() Prints the value in the argument.
4.3
The Keyboard
The portion which takes up most of the real estate on the calculators facade
is the numeric keyboard. It contains both digits and a plentitude of various
operators. For the project, we only utilize the basic arithmetic operators, along
with the digits and input key. When a key is pressed, one pin is shorted for the
column, and another pin is shorted for the row. This is how we are able to read
Software Details
This section includes the code we wrote to solve each lab. Explanations of
the code are commented throughout the figures. In order to fix bugs, various
functions and loops had to be written in the code. These are included in the
figures as well. Our solutions seem to solve each of the tasks correctly and
efficiently. If they were to be perfected, it is possible that they could be shorter.
5.1
5.2
For the next portion of the project, we wrote the code to respond to a pressed
key by displaying that key on the screen.
5.3
The next portion of the code we worked on allows users to enter and edit numbers. In this portion of the code, we implemented the useful switch function,
which we were taught to use in class.
10
Figure 9: The solution for Lab 3: Entering and Displaying Numbers (Part 1)
11
Figure 10: The solution for Lab 3: Entering and Displaying Numbers (Part 2)
5.4
The final portion of our software building endeavors allows users to perform
calculations using reverse Polish notation. This required implementing an array
stack to hold onto various operands being manipulated by users.
12
13
Lessons Learned
14
necessary. Accuracy and efficiency were key, and we were able to get a first-hand
experience at dealing with buggy code. Bugs are not good! It is important to
consider all possible scenarios and error-prone cases when writing code.
We advise that all future students fully understand the existing code and
hardware system before beginning to write their own code. This will make the
coding process less difficult, and it will improve the overall learning experience.
The course assumes that everyone knows computer programming. Acknowledging that it is difficult to appeal to students with varying levels of experience,
perhaps there could be some more instruction on programming for less experienced students. We would have also appreciated an intro to C++ before we
began the first lab, because even the more skilled students were mostly only
trained in Java. The code reviews were also helpful, and it would be nice to
do some more of this for future classes. Overall, the class was a great learning
experience, and we enjoyed doing the hands-on work.
15