High Level Design

When trying to decide what project to attempt for our final 476 project, we thought long and hard. We wanted to do something where the user could appreciate the output, and also for us to be able to learn to interface with a new piece of hardware. After years of using popular computer paint programs like Microsoft Paint, we wanted to try and create our own on a microcontroller. A natural user interface device was the mouse, and so we decided to make a painting program that allowed the user to paint using the mouse. Our output of choice was the TV, since we have had experience in using it in a past lab.

Logical Structure

A high level structure of our project is illustrated in the following diagram:


Figure 1: Structure of our project

The mouse and TV interfaces were separated onto two different MCUs for timing reasons. Due to the strict timing nature of the NTSC protocol, we could not fit both the PS/2 interface with the NTSC interface. Basically, the mouse program on MCU1 interfaces with the mouse and keeps track of the software coordinates and click states of the pointer. This is sent to the paint program on MCU2 through ports A,B, and C.

The paint program handles all the pointer updates, GUI interfaces, and painting features. The NTSC interface portion of code on MCU2 blasts the necessary bits out to the TV that represents the current screen state, which is also being continuously updated by the paint program.

Hardware/Software Tradeoffs

The major tradeoff involved in this implementation is the use of two MCUs. The PS/2 interface was too costly timing-wise to be integrated with the NTSC interface. In doing so, this would have caused the video output to be skewed and distorted due to the mouse interrupts and slowness of the mouse clock relative to the MCU clock. We decided, instead of trying to just barely fit those two components on one chip, to offload the mouse interface onto another MCU in order to alleviate timing issues involving the TV. This greatly simplified the paint program, and in the end allowed us to implement many more painting features than with our original plan.

Another tradeoff involved the NTSC interface. When trying to implement different painting algorithms, we found that the timing was not sufficient for some features such as drawing circles, cutting and pasting, and saving. For the latter, we decided against implementing them. When drawing circles and cutting, we decided to blank the video while we calculated the points needed for the operations. If we didn't blank the video, we would obtain undesirable artifacts in the video signal. Another option would have been to also offload the paint program onto another MCU, but we thought this to be a bit too excessive, and decided to instead scale back some of the originally intended functions.

Standards

We used two different standards in the making of this project: PS/2 and NTSC.

The PS/2 standard was created by IBM as a standard to govern the connections between a mouse or keyboard to a computer. The original documentation existed in an IBM Technical Reference Manual, but is now out of print. The standard is based on a serial host/device interface. The device supplies the clock, but the host is in control of when each end communicates, and is ultimately responsible for the communication. We exhaustively used Adam Chapwaske's PS/2 Mouse/Keyboard Protocol page as a tutorial for our PS/2 implementation.

The NTSC video standard was created by the National Television System Committee of the same name. It is a standard for video signals especially for the use as input to TV's. The standard calls for a 30 frames per second rate interlaced so that the even and odd lines are at 60 frames per second. We basically changed the code we used for the oscilloscope lab to function as the paint program.