ECE 477 Digital Systems Senior Design Project Spring 2006

Homework 5: Circuit Design and Theory of Operation

Due: Friday, February 24, at NOON

Team Code Name: ______Rubber Ducky______Group No. ___1___

Team Member Completing This Homework: ______Gabi Sarkis______

Evaluation:

Component/Criterion / Score / Multiplier / Points
Introduction & Theory of Operation / 0 1 2 3 4 5 6 7 8 9 10 / X 4
Documentation for Circuit Design / 0 1 2 3 4 5 6 7 8 9 10 / X 4
List of References / 0 1 2 3 4 5 6 7 8 9 10 / X 1
Technical Writing Style / 0 1 2 3 4 5 6 7 8 9 10 / X 1
TOTAL

Comments:

______

______

______

______

______

______

1.0  Introduction

Rubber Ducky is a video game based on Nintendo’s classic Duck Hunt. The player holds a gun-like controller and shoots at moving targets that appear on a TV screen. If the gun is aimed at a target when the trigger is pulled, the shot is a hit and the player’s score goes up. Otherwise, the rubber duck keeps flying. One thing that sets this project apart from the original game is that it uses an image sensor to determine the result of the shot. This approach allows the game to be played on an LCD screen as well as a CRT screen. The original Nintendo can only be played on a CRT screen as it uses a photodiode which requires a level of brightness LCD screen are not capable of.

This report will focus on the various design issues that face the design team, such as proper operation of the NTSC encoder and image sensor interface. In addition, solution to these issues and schematics of the entire system are presented.

2.0  Theory of Operation

As mentioned in the introduction, the system consists of a console and a gun; the console displays the game on a TV using NTSC signals, and the gun determines whether the player hits or misses the target. The distribution of tasks and the difference in physical location between the two units, as the gun is the player’s hand and the console is away, requires splitting the project into two separate systems built on different boards, which communicate with each other over a cable connection. The game operates as follows: when the player pulls the trigger, the image sensor captures a picture of the TV screen. Based on the location of the target relative to the image center, the gun microcontroller determines the result of the shot and sends that information to the console microcontroller. The console updates the screen according to the data it receives from the gun. The console includes a Freescale MC9S12E256 microcontroller, a MAX233A RS-232 transceiver, a CY7C008 512Kb dual-port SRAM, an AD724 RGB to NTSC encoder, a Xilinx X95108 CPLD, and an LP372 5V linear voltage regulator. The gun contains a KAC-9647 image sensor headboard, a PIC 18LF4515 microcontroller, a CY7C4201V FIFO, a MAX3221 RS-232 transceiver, and an LP3997 3.3V linear voltage regulator. The console is powered by a 6V wallwart, and it provides the gun with a 5V power line. In the following sections the functionality of individual components will be discussed and special design considerations will be presented where applicable.

2.1  MC9S12E256 Console Microcontroller [8]

Storing a video buffer to be displayed on a screen requires large amount of memory that surpasses what the on-board microcontroller RAM can provide. Therefore, an external RAM is necessary. The easiest and fastest method of accessing external is bus expansion. The ability to do multiplexed bus expansion was the main reason for choosing this microcontroller. The CPU runs in “Normal expanded narrow mode” and provides the SRAM chip with control signals and 16 address lines multiplexed with 8 data lines. Transparent latches, 74FCT16373 and 74FCT573, and a 74VHC139 decoder are used to enable multiplexing. The 74-16373 and 74-139 are used as examples in a Freescale application note [4], and the 74-573 is used instead of the suggested 74-373 because its pin layout allows for easier trace routing on the PCB. To perform memory I/O operations quickly, the CPU must also be running at a fast speed; a Colpitts oscillator running at 16MHz provides an external clocking signal [8]. To further increase the CPU frequency, the internal PLL can be used, and C50, C51, and R20 form the PLL filter components in the circuit.

In addition to updating the frame buffer, the microcontroller also uses a pulse width modulator to provide audio output. A PWM output pin is connected to a simple active low-pass filter whose output is connected to an RCA jack. The microcontroller also handles communications with the gun via an asynchronous Serial Communication Interface (SCI) that is connected to the MAX233A RS-232 level translator. Finally, only the reset pin has an external pull-up resistor because the other pins have internal pull-up/pull-down devices.

2.2  Cypress CY7C008 Dual-Port SRAM [2]

The CY7C008 is a dual-port asynchronous 64Kx8 SRAM that is utilized as a frame buffer. Each pixel occupies four bits in memory: a bit for red, green, blue, and intensity each.

Previous designs [10] and [11] have used a single-port RAM and used a CPLD to handle writes from the microcontroller to RAM. Using a single-port slows down the system as the CPLD has to wait for the microcontroller to finish writing to memory before reading new pixel data and sending it to the NTSC encoder. However, a dual-port allows simultaneous write and read operation to memory. As an added benefit, it reduces the number of signals between the CPLD and the microcontroller.

Cypress had free samples of their fastest dual-port memory, 12ns; so that was the part ordered. This allows for a faster microcontroller external bus clock, which results in faster write operations.

2.3  Xilinx XC95108 CPLD [12]

The CPLD transfers pixel data from the SRAM to NTSC encoder and generates the clocking signals for the encoder. It is clocked by a 14.318 MHz oscillator and has internal clock dividers to get the correct frequency for the NTSC synchronization signals. When the CPLD receives the start signal from the microcontroller, it begins retrieving data from memory and outputting the color values to the NTSC encoder. When it is done displaying a frame, it will notify the microcontroller so that the frame buffer contents can be updated. The I/O pin placement is based on previous designs [10] and [11] and modified to allow for easier layout. This CPLD is in-circuit programmable through a JTAG header; so debugging and modifying its program does not require removing the part from the circuit.

2.4  AD724 RGB to NTSC Converter [1]

Modern video devices use 24-bit DACs to display images on a screen. However there are simpler approaches that achieve the same basic functionality but with fewer colors displayed. The method that is implemented in this project is to use an AD724 which takes an RGB signal (with VGA timing signals) and outputs an NTSC signal. The color data coming from the CPLD passes through an RC network that acts as a simple high-pass filter. This converts the digital output of the CPLD into an analog signal. The four bits per pixel depth results in fifteen different colors, because the color black appears twice in the list of colors generated by different combinations of these bits.

The AD724 is capable of generating composite and s-video signals; however only composite video is used in the project and the generated signal is connected to an RCA jack.

2.5  LP3872 5V Linear Voltage Regulator [7]

The console powered via a 6V wallwart. This input voltage is regulated by an LP3872 LDO linear voltage regulator. It can supply up to 1.5 A at 5V with a relatively small dropout. 125mA will go to the gun board while the console will consume approximately 500mA, depending on the power consumption of the NTSC encoder.

2.6  PIC 18LF4515 Microcontroller [9]

This is the microcontroller for the gun. The motive for using is its low power consumption because the original gun design was battery powered. Also, since the image sensor interfaces with other devices through I2C, it is important that the microcontroller supports that protocol. The PIC meets all the requirements and it comes in a 44 pin package that has enough I/O pins, but not too many that routing would become cumbersome. The chip is clocked at 4 MHz by an external crystal and runs at 3.3V. When the trigger is pulled, the image sensor is activated and captures an image. The microcontroller reads image data from the FIFO and processes this data without storing the image in its internal memory. The algorithm works by counting the number of blue, green, and red pixels in a 50x50 pixel block in the center of the image. These numbers are used to determine the most prevalent color in the picture. Since the duck is yellow, the shot is a hit if the red and green (yellow) pixel count is high, and the blue pixel count is low. The result of the shot is via a serial port that is connected to a MAX3221 RS-232 transceiver to the console. The PIC also uses a periodic interrupt to de-bounce the trigger and is in circuit programmable.

2.7  KAC-9647 Image Sensor and Headboard [5] and [6]

The Kodak image sensor captures color VGA resolution images at a high frame rate. It has an I2C control interface and 8 or 10 bit data bus. It is possible to purchase the KAC-9647 already soldered on a headboard with a lens mount. This option is a major reason for choosing this sensor over others as it saves time and effort that would otherwise be spent trying to make another PCB. The I2C bus, eight data bits, a reset, and four timing signals, in addition to power and ground, are connected from the headboard to the gun board. The microcontroller controls the reset and I2C pins of the sensor. The clock signal going into the sensor has to run at 12 MHz or faster, as specified by Kodak. At this frequency, the microcontroller cannot keep up with the data coming from the image sensor. However, by introducing delays between image rows and using a FIFIO to buffer data, this problem can be avoided.

2.8  CY7C4201V FIFO [3]

Because output rate of the image sensor is too large for the microcontroller to process, a FIFO buffer is necessary. The CY7C4201V is a 256x9 bit synchronous FIFO. It has two separate clocks for reading and writing. The image sensor controls the write clock; while the microcontroller provides the read clock. This way, after each image row, the microprocessor can read the contents of the FIFO and perform the needed operations. Since the image data is only eight bits wide, the input for the ninth bit is tied to ground. The CY7C4201V is also pin-compatible with FIFO as large as 8Kx9 bits. Therefore, if the need for more buffering space arises, the FIFO can be swapped with a larger one without any modifications to the hardware.

2.9  LP3997 Linear Voltage Regulator

The LP3997 is a 3.3V LDO linear voltage regulator capable of supplying 125mA. It is supplied a 5V input that comes from the regulator on the console. Even though the voltage coming from the console is regulated, it is still important to regulate the voltage in the gun because the power through an unshielded cable for a relatively long distance.

3.0  Summary

This report discussed the design of the video game Rubber Ducky. It gave a detailed view into what each part does in the circuit and how it communicates with other parts. The console include a microcontroller that controls the game and updates the frame buffer which is a dual-port SRAM. A CPLD is also connected to the SRAM and it reads its contents and outputs color information to the NTSC encoder that generates a composite video signal. In the gun, another microcontroller controls the image sensor and reads image data from a FIFO buffer. The microcontroller also processes the image data to determine the result of a shot and relays that information to the console.


List of References

[1]  AD724 Datasheet, Analog Devices

http://www.analog.com/UploadedFiles/Data_Sheets/40671345AD724_b.pdf

[2] CY7C008V Datasheet, Cypress

http://www.cypress.com/portal/server.pt/gateway/PTARGS_0_2_1524_209_259_43/http%3B/sjapp20%3B7001/publishedcontent/publish/design_resources/datasheets/contents/cy7c008_5.pdf

[3] CY7C4201V Datasheet, Cypress.

http://www.cypress.com/portal/server.pt/gateway/PTARGS_0_2_1524_209_259_43/http%3B/sjapp20%3B7001/publishedcontent/publish/design_resources/datasheets/contents/cy7c4201_5.pdf

[4] Examples of HCS12 External Bus Design, Freescale Corp.

http://www.freescale.com/files/microcontrollers/doc/app_note/AN2408.pdf

[5] KAC-9647 Datasheet, Kodak.

http://www.kodak.com/global/plugins/acrobat/en/digital/ccd/products/cmos/KAC-9647LongSpec.pdf

[6] KAC-9647 Headboard Datasheet, Kodak

http://www.kodak.com/global/plugins/acrobat/en/digital/ccd/evaluationBoards/cmos/KAC9647HEADBOARD.pdf

[7] LP3872 Datasheet, National Semiconductors

http://www.national.com/ds.cgi/LP/LP3872.pdf

[8] MC9S12E256 Datasheet, Freescale Corp.

http://www.freescale.com/files/microcontrollers/doc/data_sheet/MC9S12E256DGV1.pdf

[9] PIC 18LF4515 Datasheet, Microchip Technology, Inc.

http://ww1.microchip.com/downloads/en/DeviceDoc/39636a.pdf

[10] Sparky ECE477 Project

http://shay.ecn.purdue.edu/~dsml/ece477/Webs/S04-Grp08/index

[11] The Electronic Lives Manufacturing, General Purpose Display Controller.

http://elm-chan.org/works/crtc/report.html

[12] Xilinx XC9500 CPLD Family Guide, Xilinx Corp.

http://direct.xilinx.com/bvdocs/publications/DS063.pdf


Appendix A: Design Rule Check Report

Checking Pins and Pin Connections

------

Checking Schematic: SCHEMATIC1

------

Checking Electrical Rules

Checking for Unconnected Nets

Checking Off-Page Connections

Checking for Invalid References

Checking for Duplicate References

Check Bus width mismatch


Appendix B: Bill of Materials Report

Duck Hunt/Gun Schematic Revised: Friday, February 24, 2006

Team 1: Gun Schematic Revision: 1.1

Bill Of Materials February 24,2006 5:13:43 Page1

Item Quantity Reference Part

______

1 1 C1 10u

2 11 C2,C3,C4,C5,C6,C7,C8,C9, 0.1u

C12,C14,C16

3 2 C10,C11 15p

4 2 C13,C15 2.2u

5 1 D1 1N5817

6 1 J1 HEADER 14x2/SM

7 2 J2,J8 4 HEADER

8 4 J9,J10,J11,J12 HEADER 6X2

9 1 J13 TRIGGER

10 1 R1 330

11 2 R2,R4 1K

12 1 R5 470K

13 1 R6 R

14 1 R7 10K

15 1 U3 PIC18LF4515

16 1 U4 MAX3221/SO

17 1 U5 CY7C4201/FP

18 1 U6 LP3997

19 1 Y1 ECS-42-12-5P-TR

20 1 Y2 CB3LV-3C-12M3520

Rubber Ducky/Console Schematic Revised: Friday, February 24, 2006

Team1: Console Schematic Revision: 0.2