NES / SNES USB Adapter
<Photo to be added. I'm working on a case>
So
I just finished up a simple but very fun project, my NES / SNES USB
adapter! This device allows the user to plug in their original,
unmodified NES and SNES controllers to the PC over USB.
Hardware wise, the device is extremely simple. I used an Arduino
Leonardo as it has excellent USB HID device support and I had an extra
Arduino shield laying around. Each controller has 3 simple data lines:
Latch, Data, and Clock, as I wrote about years ago in my NES to serial
adapter. So those take up 3 IO pins each. There's also the DATA line
used as the shifted output, which goes to an input pin on the Arduino.
Speaking of the Arduino, I also absolutely hate the finicky Micro USB
adapter on the Leonardo, so I wired in a USB-B socket on the shield
which is much more sturdy. There's a little extra hardware on the
shield as well, but it's not used for this device.
Here's a few timing diagrams I drew which demonstrate how each
controller works. They both use shift registers (Parallel in, Serial
out) and accessing them is as simple as toggling the correct lines and
polling the DATA line. Each button is active LOW on both controllers,
and I use a +5v supply for each controller. According to the MIT timing
diagram this was based off of in my other project, the pulse period is
a minimum of 12 microseconds. I used the delayMicroseconds function and
gave it 20 microseconds, which is still much faster than necessary to
have near zero input lag.
(Click or open in a new tab for full size).
Writing the code was also pretty trivial, since there exist libraries
already which allow the Leonardo to act as a HID device when connected
over USB. Once the NES controller code was working, it was a matter of
extending the number of read operations from 8 to 16, and the SNES
controller input is done.
I currently
have the software select the SNES controller by default. It would be
pretty trivial to add a switch to select between which one you wanted
to use. Future iterations could also very easily add support for the
Serial plug type controllers - Atari, Sega Genesis, Master System, etc.
I wasn't able to find a donor serial port at the moment, and I'm really
not a fan of the Genesis controller as it is, so I left it out.