Reading NES controller without additional microcontroller

Discuss hardware-related topics, such as development cartridges, CopyNES, PowerPak, EPROMs, or whatever.

Moderators: B00daW, Moderators

Post Reply
tarrages
Posts: 3
Joined: Fri Jan 10, 2020 1:12 pm

Reading NES controller without additional microcontroller

Post by tarrages » Thu Jan 16, 2020 9:31 am

Hey all. I'm working on a hardware project that involves interfacing with an NES controller. Using an Arduino, I've connected the NES controller to some pins inside a USB keyboard, so it now functions as a USB controller for use with emulators. (I.e., pressing a button on the controller triggers a USB keypress.) But now I want to see if I can replace the Arduino altogether, because I think that's probably overkill for a simple task like this.

Basically I plan to use a serial-in parallel-out shift register. It's easy enough to supply a clock and 5V to the controller. But how can I supply the latch signal so that it's coordinated with the clock?

lidnariq
Posts: 8902
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: Reading NES controller without additional microcontroller

Post by lidnariq » Thu Jan 16, 2020 11:43 am

The chip inside your USB keyboard is another microcontroller, basically the same as the Arduino. It's not really overkill to use one USB-capable microcontroller vs another...

I don't want to re-explain things you already know, so would you will be willing to say how you did this?
tarrages wrote:
Thu Jan 16, 2020 9:31 am
connected the NES controller to some pins inside a USB keyboard,

tarrages
Posts: 3
Joined: Fri Jan 10, 2020 1:12 pm

Re: Reading NES controller without additional microcontroller

Post by tarrages » Thu Jan 16, 2020 11:55 am

That's true, but it's still a question of using 1 microcontroller versus 2! And the keyboard is being recycled. If I could replace the Arduino, then I could use it for a different project.

Right now I've got the arduino reading the controller by repeatedly sending a latch signal and then reading the serial button data from the NES controller. Then each button corresponds to one arduino pinout, and I set the pin high if the button is down. Each of these 8 pinouts is attached to one transistor, and each transistor is configured as a switch connecting two keyboard pins to send a USB keypress.

The Arduino's task seems like a fairly straightforward operation, so I wondered if it could be achieved with some more basic circuit.

lidnariq
Posts: 8902
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: Reading NES controller without additional microcontroller

Post by lidnariq » Thu Jan 16, 2020 12:06 pm

What's the shape of the electrical matrix of keys that goes into the OEM keyboard controller? 16x8?

If you're lucky, you might be able to get away with using one row select as the shift register LOAD signal, and then maybe there's a way to use the other row selects out of the keyboard microcontroller to serve as the shift clock...

lidnariq
Posts: 8902
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: Reading NES controller without additional microcontroller

Post by lidnariq » Thu Jan 16, 2020 12:22 pm

... or were you instead asking about ways to reimplement what the Arduino is doing? Nowadays the cheapest answer is definitely "buy a non-arduino microcontroller"— The V-USB framework will let almost any AVR microcontroller serve as a USB device.

Generating the right signals for the 74'165 inside the controller and a 74'164 isn't hard, but all the ways that come to mind to do so feel more than a little Goldbergian.

tarrages
Posts: 3
Joined: Fri Jan 10, 2020 1:12 pm

Re: Reading NES controller without additional microcontroller

Post by tarrages » Thu Jan 16, 2020 2:20 pm

These are two very good ideas I hadn't considered. I didn't think of trying to work with the existing keyboard read signals -- but more compellingly, I didn't realize how cheap these atmega chips are. I'm going to try one or both of these approaches. Thank you very much!

Post Reply