Controller Reference   1 comment

Here’s a brief explanation of how the controllers works. They can be splitted in two, the nes and the snes who are shift register based and the N64 and GC who rely on a particular protocol on a one bi-directional cable.

The NES and SNES case

Theses are pretty easy, indeed in the nes it’s a simple 4021 8Bit Shift Register. Here’s a datasheet for it. And it’s the only version I know for the original Nes pads. If you know others let me know 🙂

The SNES one used different chips based on the version and region. For example the NTSC SNS-102 use a single Motorola V520B, the NTSC SNS-005 a dual Motorola W545, I’ve seen a PAL with 2 4021 in parrallel, anyway, from the outside they all acts like a 16bit shift register.

NES Pinout

nesportdiag

  1. +5V – White
  2. Unused
  3. Unused
  4. Ground – Brown
  5. Clock – Yellow
  6. Latch – Orange
  7. Data – Red

SNES Pinout

snesportdia

  1. +5V – White
  2. Clock – Yellow
  3. Latch – Orange
  4. Data – Red
  5. Unused
  6. Unused
  7. Ground – Brown

Read datas

Now, let’s read the data from them. Both will work the same way. +5v connected to voltage source and ground to ground. We have 3  wires remaining, latch, clock and data. When Latch is high, the CI store the value of the buttons. For example on the 4021 from the nes, each buttons (A, B, Start, Select, Up, Down, Left, Right) have one input on the 4021, Latch high is like saying : “Store the value of your inputs and keep it”. Then we will use the clock. Each time we send a high on the clock, the data will change between high or low to send the value. It’s a shift bit register because each time we request a value (by putting clock high) the last bit is sent and the other one from from one. So the next time we set clock to high, it’s the “next bit” (who is now the last) who will be sent.

Here’s a little diagram from an article I’ve written some years ago on my blog. In this case A and Select are pushed :

neschronogrammeSo on the µC we just need 3 I/O to read the pad, latch, clock and data. Two are outputs and on is input.

Here’s the list

The N64 and GameCube Case.

This one is a bit more touchy. First it’s not 5V but 3.43V now and there’s no pull-up resistor so you need to put a 1Kohm resistor between the data line and the +3.43V. Also you need to put your arduino data pin in an INOUT state. The N64 have 3 pins, +3.3V, Data and Ground. The GC have 7pins but only 6 used.

n64-pinout
gc-socket1
  1. +5V – Yellow
  2. Data – Red
  3. Ground – Green
  4. Ground – White
  5. Unused
  6. +3.43 – Blue
  7. Cable Shield/Ground – Black
Basically we need to send a first message to the controller and then the controller respond with another message containing the controller state. All these operations are “time based” and could sometimes be really tricky and hard to explain. So if you want more informations you can refer to the two following articles or take a look at the arduino code.

Data composition

Here’s a little table showing you in which order the bits are send from the controller to the arduino. They are splitted in bytes (8bit). Also to make the debug easier I stick exactly to this on my serial protocol too.
Untitled

Posted 14 December 2013 by Emmanuel Istace

One response to “Controller Reference

Subscribe to comments with RSS.

  1. Pingback: Not Rocket Science » Building an Arcade Fight Stick

Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: