Showing posts with label pennsylvania. Show all posts
Showing posts with label pennsylvania. Show all posts

Wednesday, April 7, 2010

Interfacing the NES Controller with the Firefly Microcontroller

Today we successfully interfaced the NES controller with the Firefly microcontroller.

Following the instructions here and here, we programmed three GPIO (General Purpose Input/Output) pins on the Firefly to mimic the NES in retrieving the states of the buttons.

An NES controller contains seven wires. Two of the wires quite literally do nothing. They're not even connected to the 4021 serial IC in the controller. The other five wires are +5 V, Ground, Latch, Pulse, and Data. The NES performs the following operations in order to read the button states from the controller:

  1. Every 16.667 milliseconds (60 Hz), the NES sets the Latch line high for 12 us and then low again.
  2. Six us later, the NES sends out eight 12 us period pulses on the pulse line.
  3. The NES controller sends out the states of the buttons for each pulse in the following order: A, B, Select, Start, Up, Down, Left Right.
It's that simple. Check out the diagram below for a more visual explanation.
The majority of the GPIO pins on the Firefly are hidden under the mini-SD card slot, so eventually we'll probably have to de-solder the mini-SD card slot to access them.



In the mean time, we used the Firefly programmer/debugger board which provides additional access to the GPIO pins. For this experiment, we used NRK_DEBUG_0, NRK_DEBUG_1, and NRK_DEBUG_2. Note the "NRK_" prefix. We omitted that prefix initially, which prevented our program from working for several hours.

NES Controller plug connected to breadboard

Firefly programmer/debugger (left) connected to Firefly node (right)

Firefly node in action

Finally, we'll leave you with a video of our program that prints out to the serial terminal what buttons are being pressed on the NES controller. The next step of the project will be to interface the Firefly directly with the NES game console so that we can play the NES using the keyboard of the computer.

Introductions!

Hello interested readers! This is a blog for the design and implementation of a Wireless Rifle Controller for the Nintendo Entertainment System, specifically for the NES video game "Cabal." This project is being completed for the Spring 2010 ESE 350 (Microcontrollers) class at the University of Pennsylvania.

So what exactly are we doing? Our idea is to create an alternative user interface for a classic Nintendo game: Cabal. We would like to provide the users with a more natural interface instead of the classic Nintendo controller (Directional pad, A, B, Start, Select).

We plan to take a stock toy gun and mount a microcontroller on or inside of it. This will allow the user to physically strafe in front of the display to strafe the character on screen, providing a more in-depth gaming experience. Right now our intention is to use the Firefly microcontroller to achieve this, most likely one on each gun and a receiver node at the NES controller input as well.


An added benefit of using this input device would be that it is wireless, allowing the user freedom of movement when playing. A possible “reach” function would be to add a small vibrating motor to give force feedback to the user when shooting.

Check out our proposal presentation slides here.

We'll post periodically with updates about the project. In the mean time, check out this video of Cabal in action: