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: 9700
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: 9700
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: 9700
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!

User avatar
Ziggy587
Posts: 119
Joined: Fri Oct 08, 2010 6:08 pm
Location: NY, USA

Re: Reading NES controller without additional microcontroller

Post by Ziggy587 » Sat Jan 18, 2020 1:24 pm

I don't mean to thread hijack, but this is the exact question I was going to ask. If this isn't cool, please let me know and I will post a new thread.

Warning: Hobbyist level knowledge here. I don't know much, and there's probably huge gaps in what I do know!
tarrages wrote:
Thu Jan 16, 2020 9:31 am
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?
My goal is to interface a SNES controller with a JAMMA arcade board. Specifically Mortal Kombat II, so I will need to utilize every button on the SNES controller. I know of projects like this one and this one, but they wont work for my needs because they ignore the shoulder buttons.

It looks like I could pretty easily use a pair of 74LS595, and the clock signal seems easy enough to supply, but I'm having a hard time figuring out how to supply the latch signal in sync with the clock.

I did stumble upon one thing, and it's so far the only thing I've been able to come up with that I think could work. I've been learning a lot from the YouTube channel Ben Eater, and he has a couple of videos on a binary counter using a few logic ICs. Would something like this work? Would there be an easier way (less components) than this?

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

Re: Reading NES controller without additional microcontroller

Post by lidnariq » Sat Jan 18, 2020 3:34 pm

Ziggy587 wrote:
Sat Jan 18, 2020 1:24 pm
My goal is to interface a SNES controller with a JAMMA arcade board. Specifically Mortal Kombat II, so I will need to utilize every button on the SNES controller. I know of projects like this one and this one, but they wont work for my needs because they ignore the shoulder buttons.
That's just a restriction of wiring. Pick a microcontroller that has enough pins and adjust the code.

By far the cheapest option will be a microcontroller with enough pins to drive all the JAMMA inputs.
It looks like I could pretty easily use a pair of 74LS595, and the clock signal seems easy enough to supply, but I'm having a hard time figuring out how to supply the latch signal in sync with the clock.
I mean, you need something that will count ABBBBBBBBBBB over and over. This isn't hard when using discrete logic, but it'll involve a lot of different parts because generating the control signals to deserialize things isn't something that was deemed sufficiently useful at the time.

Post Reply