Unformatted text preview:

ENGI E1112 Departmental Project Report:Computer Science/Computer EngineeringBy Yiming Ge, Anna Teng, Kaiven ZhouAbstractThis report serves to document the ENGI E1112 Departmental Project. In this project, we used C to program the HP 20b calculator with the goal of turning it into an RPN calculator, one that operates using Reverse Polish Notation. Essentially, we are writing a new firmware for this calculator. We worked on the final product with algorithm efficiency and user friendliness in mind. This project teaches the important lesson of how to work on a limited platform with confined methods and a strict memory limit. Thus, it was paramount that we planned accordingly and wrote the right methods to achieve a functioning RPN calculator.We started out by writing a program that makes a message scroll across the screen. This gave us the necessary background on working with the LCD display and manipulating the output of characters. Then, we worked on a program that scans for a key being pressed, and if so, returns that key. With this knowledge, we were able to proceed by writing a program that lets the user input a number. Finally, there was a sufficient foundation to make a functioning calculator, and in this case we implemented stacks to make an RPN calculator.1 IntroductionIn today's world, processors are found everywhere, whether you realize it or not. While there seems to be a big distinction between something as simple as a four function calculator and a top of the line desktop PC, the difference is actually not that great. Both devices have a processor, memory, and some sort of input and output. Most importantly, both run on firmware and software that has been pre-programmed into memory.The HP 20b calculator contains all of the above; it features a liquid crystal display, a 6 by 7 matrix keyboard, and an Atmel AT91SaM7L128 processor with 128K of flash program memory. In this flash memory is the firmware that allows the calculator to perform all sorts of functions, in this case specialized finance functions which is undoubtedly why this calculator is dubbed the 'business consultant.' In this project, we attempted to reprogram this calculator into an RPN calculator, which required several steps that gradually lead to the final product. This type of programming is called 'embedded programming,' as the calculator doesn't appear to be a computer at first glance but in fact is. We used a JTAG port to communicate with the Atmel processor, and on the other end, we used a USB port to connect to Linux workstations running openOCD software to edit and compile the necessary files. This project attempted to manipulate the LCD screen and other input/output peripherals such as the keyboard to make the calculator behave like a real RPN calculator.In the first lab, we created a scrolling message across the screen. This required knowledge of how for loops and character arrays in C work. In the second lab, we constructed a program that takes input from the keyboard and displays it on the screen. In the third lab, we used the knowledge and methods from the previous programs to make entering numbers possible. Lastly, in the fourth lab, we went one step further by allowing the user to operate on numbers in Reverse Polish Notation.2 User GuideIn order to enter a number, simply press the digits from left to right on the keyboard, then hit the return key. Our calculator has the capacity to store and display any integer, both positive and negative, up to twelve digits long. Leading zeros, however, will not be displayed. In order to toggle between positive and negative, enter the number and then hit the +/- key. Once you have entered a number (A) and pressed the return key, enter a second number (B). Now that there are two numbers, one of the four binary operations we support can be performed on them. Once you have finished entering the second number, press either the addition (+), subtraction (-), multiplication (x) or division (÷ ) symbol. The calculator will then perform A __ B, and display the result.The calculator we have reprogrammed is an RPN calculator. RPN stands for “Reverse Polish Notation,” and is characterized by entering the number first followed by the operation. Additionally, numbers can be stored in what is called a “stack”. A way to visualize it is to image that every time a number is pressed and then return hit, it is added to the top of a literal, vertical stack of numbers. When an operation is pressed, it is performed on the topmost two items of the stack in the format written above. The resulting answer becomes the new top of the stack. In the case of our calculator, the maximum stack height is 30. An RPN calculator provides alternate, and often simpler alternatives to entering long expressions with many terms. For example, if one were trying to perform (9 + 8 + 7 + 6 + 5), he could enter the following keys: 5 return 6 return 7 return 8 return 9 (adding each number to the stack) and then + + + +, adding all of the numbers in correct order of operations. • It scrolls from right to left? YES• If you hit an operation first it returns INTMAX• If you keep hitting an operation after the stack only has 1 term nothing happensSource: http://www.hpmuseum.org/rpn.htm  key in a number hit “return” to tell the calculator that you have finished entering the number Key in another number hit an operation key. The first number will perform that operation on the second number (for example if you entered A return B -, it would perform A-B not B-A There is a stack, so you can do it for more than 2 numbers. A return B return C + +. Or, A return B + C +. You do not need an enter after the B because the operation key makes clear that you are done entering that number.  The only functions our calculator supports are multiplication, division, addition, and subtraction. Negative and positive integers are supported as well.3 Social ImplicationsThe calculator we used is extremely useful because it is easily re-programmable. We were able to turn this calculator into an RPN calculator by writing the necessary code. There is so much flexibility in the use of this calculator because by programming it, we can change its function. The calculator is valuable to people who require technical calculators with specialized functions. We reduce the cost by condensing these many possible calculators into one package.The result of


View Full Document

Columbia ENGI E1112 - Project Report

Documents in this Course
Load more
Download Project Report
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Project Report and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Project Report 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?