Untitled Document

Untitled Document





 


Decoding NES Controllers

Synlor- 27th February 2005

The Genesis controller is quite simple because it just multiplexes 2 buttons onto 1 line, making decoding fairly simple.

History: V. 0.1 First document

Equipment:

  • 16F628 PIC MCU
  • Genesis (3 button) Controller

Disclaimer: I am not responsible of what you do with these directions, nor responsible for what it can do to your dreamcast, vmu, or anything else that is in your possession.

How it works:
The Genesis controller needs 9 wires to function, 2 being +5 volts and ground. The other 7 contain the information on which button is pressed. Inside the Genesis is a quad multiplexer chip, a 74HC157. This chip takes in information from 2 lines (high or low) and puts it togethor in one single line.

Now you may be wondering on how that could work, and the answer is quite easy. There is one pin on that chip that is known as the select pin. This pin determines which of the 2 lines should be outputted on the final line by either being high or low. For example, the A and B button are sent to the console by 1 wire. When this select line is at +5 volts (high) the status of the B button is outputed. When it is low (ground) the status of the A button is sent to the console. The genesis acts as active low, so in the previous example it would work like this. With the select line high, and the B button not being pressed, the output would be +5 volts. If the B button is pressed than the output would be low (ground). Now when the select line is low, and the A button is pressed, the output is once again high. And once again when the button is pressed it is low. We can decode the controller by raising and lowering the select line and reading each output.

Here is a visual example of this:

The letter B represents when the B button is pressed, and letter A represents when the A button is pressed.

The following table is which buttons go with which pin on the Genesis connector, and how they react with the select line:
Pin #Select HighSelect Low
1UpUp
2DownDown
3LeftGround (low)
4RightGround (low)
6BA
9CStart

Program:
The program simply raises the select line, then determines which button is pressed by reading the output lines of the controller. Once it knows which buttons are pressed, it will set the corresponding pin low (active low). The same is done with select low, and then it loops back to the beginning and runs through the whole process again.

Download:
Source Code
Hex file for a 16F628A

Interfacing:

The above 9 pin connector is when you are looking console's plug. The following table shows which pin from the genesis controller connects to the correct pin on the PIC MCU:
Genesis Pin #PIC Pin
1A6
2A7
3A1
4A2
5VCC
6A3
7A0
8VDD
9A4

This table shows which pins on the PIC represent each button (active low):
ButtonPIC Pin
LeftB0
RightB1
UpB2
DownB3
AB4
BB5
CB6
StartB7
Finally the power needs to be hooked up to the PIC, +5 volts to VCC, and ground to VDD.