Hardware Design


The reason we used Mega103L is because the software program has an extensive amount of floating point operations.  Because it is written in C, the assembly code it assembles was too big to fit on the memory of a 8515 chip, so the only option was to use the Mega103L, which has 10k of flash memory, more than we need for our graphing calculator.


LCD Module:

        We decided to use the 320x200 Seiko G321D LCD as our graphics display.  We chose this LCD because there are a lot of documentation on this product and also because a lot of groups are using it so that we can reference each other.  The LCD comes with a built-in controller that made programming very easy.  We used the Atmega103L chip for this project but we began testing and programming the LCD on the Atmel8515 chip and then incorporated the LCD driver into our main calculator code. 

        The biggest trouble we had with the LCD was at the beginning of setup.  As soon as we got it setup and working, it will not respond the next day with a different chip and different workstations.  The problem ceased once we incorporated the driver into our main code running on the Atmega103L chip.  The LCD datasheet specified that the controller has to have a input voltage of 5V but it ran fine on 3V. 

        We utilized only two out of three layers of the graphics display.  The first layer is the character layer starting with address 0 and ending with address 999.  One byte represents one character and there are 40 characters across, 25 characters vertically.  The second layer is a graphics layer staring with address 1000 ending with address 7999.  There are 40 bytes across horizontally each byte represents 8 pixel in that address.  There are 200 lines vertically. 

        We implemented the following functions in our LCD driver:

                WriteInputScreen(char *input)




                WriteSideBox(int num, char *input)

                ClearSideBox(int num)

                DrawLine(int x1,int x2, int y1, int y2)

                DrawXY(int x, int y)


        WriteInputScreen takes in a string and display keypad inputs into the third to last line of the LCD.  Clear InputScreen clears all the space designated for WriteInputScreen.  WriteStackScreen takes the stack and output each element onto the main display window.  ClearStackScreen clears all the space inside the main display window only. WriteSideBox takes in a number and a string and display the string onto the side box window with the number offset line. For example, WriteSideBox(2,str) will write str into the second line from the bottom of the side box window.  ClearSideBox clears only the line specified by number.  DrawLine takes graphs a line between the two input points.  We used the Breshenham algorithm given in class to implement this function.  DrawXY draws a pixel according to the input screen coordinates.  The address of the pixel is determined by 1000+y*40+x/8.  The byte to be written should be (0x01<<(7-x%8)).  However, we discovered that since we control the pixels by bytes, we experienced some pixels being overdrawn by others.  We then decided to read in a byte from the LCD memory and OR the memory byte to the new byte and preserve the previous pixels drawn.  This is ideal so that the X axis and Y axis would not be overdrawn.  DrawCustomAxis takes uses the Xmin, Xmax , Ymin, Ymax and calculate where the x and y axis are going to be.




        Two keypads are used to implement all of our calculator functionalities.  The function keypad, the one on the left, has a shift key.  When both the shift key and another key is pressed at the same time, the function in blue will be entered, instead of the function in black.  The keypad uses the standard input method used in class, by first reading the lower 4 bits, then the upper 4 bits.  The code for the keypads are in our code Calculator.c.


This is a diagram of our keypads