Help with input conversion circuit.

33 views
Skip to first unread message

Miky

unread,
Jun 23, 2017, 1:44:49 PM6/23/17
to 10BitWorks
I'm currently in the process of building out a rather crazy set of Game Boy mods. Most of what I'm planning is well within my realm of knowledge, but one thing in particular is giving me a little grief as I honestly have little working knowledge of transistors.

In short, I plan to use a stock NES controller as an alternate input source for the Game Boy.

For those that aren't familiar with how they work, an NES controller uses an 8-bit parallel to serial shift register to send the data along.

A Game Boy has four output pins on the CPU being connected to one of two input pins via an 8 button matrix with diodes after each button to prevent ghost presses with certain button combos.

While I can do this conversion fairly easily with a microcontroller, I want to do this without one. I think I know how, but need someone with a bit more knowledge on the topic to give a little advice or perhaps offer a better solution.

Remember, my requirements are that I use a stock, unmodified NES controller and no microcontroller in the mix. I'm not concerned with fitting it within the original case as it will not be used. VCC, GND, CLK will be provided by the Game Boy with some kind of counter to trigger the LATCH every 8 CLK cycles. While the Game Boy logic runs at 3.3V as opposed to the 5V the NES controller typically operates it, the IC in it is known to run just fine on the lower voltage. If it doesn't like that for some reason, I can pull 5V elsewhere and throw a resistor to GND to bring the DATA line down to 3.3V.

My current idea is to use an 8-bit serial to parallel shift register to receive the data from the NES controller and 8 NPN transistors to make the connection between the output and input pins if the corresponding bit is High. In theory, would this work?

Kevin Baldor

unread,
Jun 23, 2017, 2:15:28 PM6/23/17
to 10BitWorks on behalf of Miky
I'm pretty sure that we can figure this out, but I'd like to see the actual proposed schematic.

From the description, it sounds like you might be describing a level shifter, which you can purchase pretty cheaply.

Sent from my iPhone
--
You received this message because you are subscribed to the Google Groups "10BitWorks" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sa-hackerspac...@googlegroups.com.
To post to this group, send email to sa-hack...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sa-hackerspace/4619cd45-cb01-40eb-970f-cea53c9359d0%40googlegroups.com.

Miky

unread,
Jun 23, 2017, 6:25:54 PM6/23/17
to 10BitWorks

Nah, that's not the part I've got trouble with wrapping my head around. Like I said, if there's a difference in logic levels, I've got that covered. That will only be an issue if the 4021 takes exception to being run at 3.3v.

Here is what I'm not sure about. Like I said, I don't know much about how transistors work.

The controller sends it's button state as a single byte to the serial-parallel shift register which I forgot to label as such. The 8 outputs will be either High or Low depending on the buttons pressed on the controller. To make it not so complicated I only have one button's output wired up in the diagram. In the bottom right is how the existing buttons on the Game Boy (DMG) are wired up to the CPU.

According to the diagram, pressing A on the Game Boy will connect PL0 to PL5. In the case of the A button being pressed on the NES controller, the corresponding output would register would be High.
In this case, would the transistor perform the same function as if I had pressed the A button on the Game Boy itself?

Do you need more information?


On Friday, June 23, 2017 at 1:15:28 PM UTC-5, Kevin Baldor wrote:
I'm pretty sure that we can figure this out, but I'd like to see the actual proposed schematic.

From the description, it sounds like you might be describing a level shifter, which you can purchase pretty cheaply.

Sent from my iPhone

Kevin Baldor

unread,
Jun 23, 2017, 6:51:20 PM6/23/17
to 10BitWorks on behalf of Miky
That might work. I'll have to refresh myself a bit, but I think that you might be better served with FET instead of BJT. It's a bit more like opening and closing a switch.

On Fri, Jun 23, 2017 at 5:25 PM, Miky via 10BitWorks <sa-hackerspace+APn2wQeVM4__Nst-r...@googlegroups.com> wrote:

Nah, that's not the part I've got trouble with wrapping my head around. Like I said, if there's a difference in logic levels, I've got that covered. That will only be an issue if the 4021 takes exception to being run at 3.3v.

Here is what I'm not sure about. Like I said, I don't know much about how transistors work.

The controller sends it's button state as a single byte to the serial-parallel shift register which I forgot to label as such. The 8 outputs will be either High or Low depending on the buttons pressed on the controller. To make it not so complicated I only have one button's output wired up in the diagram. In the bottom right is how the existing buttons on the Game Boy (DMG) are wired up to the CPU.

According to the diagram, pressing A on the Game Boy will connect PL0 to PL5. In the case of the A button being pressed on the NES controller, the corresponding output would register would be High.
In this case, would the transistor perform the same function as if I had pressed the A button on the Game Boy itself?

Do you need more information?

On Friday, June 23, 2017 at 1:15:28 PM UTC-5, Kevin Baldor wrote:
I'm pretty sure that we can figure this out, but I'd like to see the actual proposed schematic.

From the description, it sounds like you might be describing a level shifter, which you can purchase pretty cheaply.

Sent from my iPhone

On Jun 23, 2017, at 12:44 PM, Miky via 10BitWorks <sa-hackerspace+APn2wQeVM4__Nst-rGzFuwLHcl4T2zUgmS-1qmEwQaxf_9...@googlegroups.com> wrote:

I'm currently in the process of building out a rather crazy set of Game Boy mods. Most of what I'm planning is well within my realm of knowledge, but one thing in particular is giving me a little grief as I honestly have little working knowledge of transistors.

In short, I plan to use a stock NES controller as an alternate input source for the Game Boy.

For those that aren't familiar with how they work, an NES controller uses an 8-bit parallel to serial shift register to send the data along.

A Game Boy has four output pins on the CPU being connected to one of two input pins via an 8 button matrix with diodes after each button to prevent ghost presses with certain button combos.

While I can do this conversion fairly easily with a microcontroller, I want to do this without one. I think I know how, but need someone with a bit more knowledge on the topic to give a little advice or perhaps offer a better solution.

Remember, my requirements are that I use a stock, unmodified NES controller and no microcontroller in the mix. I'm not concerned with fitting it within the original case as it will not be used. VCC, GND, CLK will be provided by the Game Boy with some kind of counter to trigger the LATCH every 8 CLK cycles. While the Game Boy logic runs at 3.3V as opposed to the 5V the NES controller typically operates it, the IC in it is known to run just fine on the lower voltage. If it doesn't like that for some reason, I can pull 5V elsewhere and throw a resistor to GND to bring the DATA line down to 3.3V.

My current idea is to use an 8-bit serial to parallel shift register to receive the data from the NES controller and 8 NPN transistors to make the connection between the output and input pins if the corresponding bit is High. In theory, would this work?

--
You received this message because you are subscribed to the Google Groups "10BitWorks" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sa-hackerspac...@googlegroups.com.
To post to this group, send email to sa-hack...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sa-hackerspace/4619cd45-cb01-40eb-970f-cea53c9359d0%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "10BitWorks" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sa-hackerspace+unsubscribe@googlegroups.com.
To post to this group, send email to sa-hackerspace@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sa-hackerspace/7b18650d-03bf-4f68-8c79-e7b259c30de8%40googlegroups.com.

Mike Garis

unread,
Jun 23, 2017, 6:59:04 PM6/23/17
to 10BitWorks
Given that you are not looking at any kind of high voltage you might be served to use some kind of op-amp set up maybe, since you can also get multiple of those on a chip as well, that or maybe an basic logic gate?  Been to long since I have touched an op-amp though... 

Just a thought. 

Jeremy Zunker

unread,
Jun 23, 2017, 11:15:18 PM6/23/17
to 10BitWorks on behalf of Kevin Baldor

Sounds like fun Mike.

 

Can you use the serial port on the GB? I’m guessing that’s not an option, external controllers probably not supported stock. So…

 

You’ll need any sort of appropriate speed clock (probably around 500 Hz or faster) for the clock could even be free running and not synced with the GB. This clock will drive the circuitry to poll the NES controller and bring that data into an 8-bit serial-in parallel-out shift register (74x595 or CD4094) just as you’re planning.

 

Then to interface with PL0 through PL3, I’d use a 4 pole double throw switch, aka a Quad SPDT switch to map the 8 pins of the shift register to the 4 input pins of the GB microcontroller (TS3A5018 is one, there are several that look to fit the bill). Then PL4 or PL5 on the Gameboy could drive that “bank” switching directly. I’d probably disconnect PL4 and PL5 from the button multiplexer circuitry on the GB (unless you need both working), then you’d have a little less interface circuitry to mess with (I’d suggest desoldering the 4 diode arrays, DA1 through DA4).

 

So the serial-in parallel-out shift register presents a voltage representing each state for each button. Then the Quad SPDT has four switches(1 through 4), each with two inputs (A and B) and one output (Y), all four switched by one input we’ll call W (they’re generally bidirectional and done with FETs (like Kevin mentioned using), many will even pass an analog voltage). So for example you’d connect NES_B_Button on the shift register to A1 and NES_Left_Button to B1. Y1 is tied to PL1. And PL4 or PL5 is tied to W.  If W is high you get NES_B_Button at Y1/PL1, if W is low you get NES_Left_Button at Y1/PL1.

 

There may also be some more “glue logic” needed to tie everything together, but I think that’s the gist of my interface idea.

 

Make sense? I can do a schematic sketch and elaborate if it’s not clear.

 

Cheers,

Jeremy

 

From: 10BitWorks on behalf of Kevin Baldor [mailto:sa-hack...@googlegroups.com]
Sent: Friday, June 23, 2017 5:51 PM
To: 10BitWorks on behalf of Miky <sa-hack...@googlegroups.com>
Subject: Re: [10BitWorks] Help with input conversion circuit.

 

That might work. I'll have to refresh myself a bit, but I think that you might be better served with FET instead of BJT. It's a bit more like opening and closing a switch.

On Fri, Jun 23, 2017 at 5:25 PM, Miky via 10BitWorks <sa-hackerspace+APn2wQeVM4__Nst-r...@googlegroups.com> wrote:

Image removed by sender.

--
You received this message because you are subscribed to the Google Groups "10BitWorks" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sa-hackerspac...@googlegroups.com.
To post to this group, send email to sa-hack...@googlegroups.com.

~WRD000.jpg

Miky

unread,
Jun 24, 2017, 12:19:51 PM6/24/17
to 10BitWorks
The serial port could be used for things if the title you're running supports it. For example, you can build a MIDI or even a PS/2 adapter for use with LSDj.

I plan to pull the Clock signal from the Game Boy Itself so it's in sync. It's running on 4MHz, but if I need to I can drive the input converter on its own crystal.

Correct me if I'm wrong, but wouldn't using SPDT switches in that setup result in 4 buttons always being pressed? Also, the first IC in question does not flip each switch independantly. It's all four in one position or the other. Sure, you can disable all the inputs on it when low, but you still have the problem of 4 buttons being active at any given time. Also,  PL4 and PL5 don't supply voltage. The diodes are there to prevent certain button combos from triggering ghost presses; for example, if I hit Up, Right, and A, Select would be triggered without the diodes in place. While it would be possible to use an IC like that, it would be way too complex to make it work in that fashion.

However, you did put me on the right track there and I looked up switch ICs. A DG212 or ADG1412 should work just fine. I did look into SP3T switches (remember I'd need to control two buttons without having one always on) and didn't find anything that looked userful, but a pair of either of those 4xSPST ICs will work just fine.

Jeremy Zunker

unread,
Jun 24, 2017, 2:28:30 PM6/24/17
to 10BitWorks on behalf of Miky

Hmm, I don’t think the switch IC would result in 4 buttons being pressed.

 

Here’s a rough sketch of my idea with the Quad SPDT switch, I didn’t connect all of the lines so that it would be easier to read (no rats nest of wires):

(If you don’t care about still using the GB’s buttons then the diodes can be removed, I think it should also work ok if they’re left in)

  

 

The GB uses a 2x4 matrix keypad scanning method. PL4 and PL5 and used to multiplex the buttons, so you have 8 buttons only using 6 I/O lines. If PL4 goes high, and PL5 goes low then you’re reading the A/B Start/Select button group, if PL5 is high and PL4 low then you’re reading the D-pad button group. If both are high you read nothing. If both are low then the readings could be of either set of buttons. PL0-PL3 read low if a button is pressed, high if floating or otherwise not pressed, but those Input lines are only affected by one button group at a time. The GB can only be sure of what it’s reading when PL4 and PL5 are in opposite states. If they’re the same and are both low then you read both button groups and don’t know which is being pressed. Or if they’re both are high you can’t read any button presses as there’s no way to ground PL0-PL3, no electron flow path. So you should be able to assume that the GB will never read the buttons when PL4 and PL5 are in the same state. Additionally there don’t seem to be any interrupts for the buttons either.

 

The diodes are there to make sure you’re only reading the 4 D-pad buttons or the A/B/St/Se keys, but not both at once. I don’t understand how you think Select would be registered if Up+Right+A are pressed. In this case it’s going to read the D-pad and see Up+Right, then shortly after that it’ll read the A/B/St/Se group. A and Right are both connected to PL0 but because PL4 and PL5 plus those diodes we’re able to distinguish between the A and Right.

 

The NES controller works with button presses as a low value and unpressed buttons are high value. Since buttons are only registered as pressed if a low value is present on both the GB and the NES, there should be no need for inversion between the ser-in par-out shift register and the switch/GB.

 

And yes I know that all 4 switches are switched simultaneously, that’s the point, “bank switching”. Yes 4 outputs from the shift register will always be connected to the GB but that shouldn’t matter as long as PL4 or PL5 is being used to make sure the correct bank is connected at the correct time.

 

Tapping into the processor’s crystal could cause problems depending on how you do it. Often crystal oscillator bits of processors are sensitive to having things connected to the crystal. It generally causes the clock circuit to stop oscillating but it can also cause the frequency to change although this probably doesn’t matter much in this situation. A buffer circuit could help with both those issues if they end up actually being a problem and you still want to use CPU clock. I bet you might also be able to use the LCD’s clock input line coming from the processor. Should be plenty fast enough, but it might not oscillate continuously, just when certain display stuff is going on.

 

 

From: Miky via 10BitWorks [mailto:sa-hackerspace+APn2wQeVM4__Nst-r...@googlegroups.com]
Sent: Saturday, June 24, 2017 11:20 AM
To: 10BitWorks <sa-hack...@googlegroups.com>
Subject: Re: [10BitWorks] Help with input conversion circuit.

 

The serial port could be used for things if the title you're running supports it. For example, you can build a MIDI or even a PS/2 adapter for use with LSDj.

I plan to pull the Clock signal from the Game Boy Itself so it's in sync. It's running on 4MHz, but if I need to I can drive the input converter on its own crystal.

Correct me if I'm wrong, but wouldn't using SPDT switches in that setup result in 4 buttons always being pressed? Also, the first IC in question does not flip each switch independantly. It's all four in one position or the other. Sure, you can disable all the inputs on it when low, but you still have the problem of 4 buttons being active at any given time. Also,  PL4 and PL5 don't supply voltage. The diodes are there to prevent certain button combos from triggering ghost presses; for example, if I hit Up, Right, and A, Select would be triggered without the diodes in place. While it would be possible to use an IC like that, it would be way too complex to make it work in that fashion.

However, you did put me on the right track there and I looked up switch ICs. A DG212 or ADG1412 should work just fine. I did look into SP3T switches (remember I'd need to control two buttons without having one always on) and didn't find anything that looked userful, but a pair of either of those 4xSPST ICs will work just fine.

On Friday, June 23, 2017 at 10:15:18 PM UTC-5, Jeremy Zunker wrote:

Sounds like fun Mike.

 

Can you use the serial port on the GB? I’m guessing that’s not an option, external controllers probably not supported stock. So…

 

You’ll need any sort of appropriate speed clock (probably around 500 Hz or faster) for the clock could even be free running and not synced with the GB. This clock will drive the circuitry to poll the NES controller and bring that data into an 8-bit serial-in parallel-out shift register (74x595 or CD4094) just as you’re planning.

 

Then to interface with PL0 through PL3, I’d use a 4 pole double throw switch, aka a Quad SPDT switch to map the 8 pins of the shift register to the 4 input pins of the GB microcontroller (TS3A5018 is one, there are several that look to fit the bill). Then PL4 or PL5 on the Gameboy could drive that “bank” switching directly. I’d probably disconnect PL4 and PL5 from the button multiplexer circuitry on the GB (unless you need both working), then you’d have a little less interface circuitry to mess with (I’d suggest desoldering the 4 diode arrays, DA1 through DA4).

 

So the serial-in parallel-out shift register presents a voltage representing each state for each button. Then the Quad SPDT has four switches(1 through 4), each with two inputs (A and B) and one output (Y), all four switched by one input we’ll call W (they’re generally bidirectional and done with FETs (like Kevin mentioned using), many will even pass an analog voltage). So for example you’d connect NES_B_Button on the shift register to A1 and NES_Left_Button to B1. Y1 is tied to PL1. And PL4 or PL5 is tied to W.  If W is high you get NES_B_Button at Y1/PL1, if W is low you get NES_Left_Button at Y1/PL1.

 

There may also be some more “glue logic” needed to tie everything together, but I think that’s the gist of my interface idea.

 

Make sense? I can do a schematic sketch and elaborate if it’s not clear.

 

Cheers,

Jeremy

 

From: 10BitWorks on behalf of Kevin Baldor [mailto:sa-hack...@googlegroups.com]
Sent: Friday, June 23, 2017 5:51 PM
To: 10BitWorks on behalf of Miky <
sa-hack...@googlegroups.com>
Subject: Re: [10BitWorks] Help with input conversion circuit.

 

That might work. I'll have to refresh myself a bit, but I think that you might be better served with FET instead of BJT. It's a bit more like opening and closing a switch.

 

On Fri, Jun 23, 2017 at 5:25 PM, Miky via 10BitWorks <sa-hackerspace+APn2wQeVM4__Nst-r...@googlegroups.com> wrote:

Image removed by sender. Image removed by sender.

~WRD000.jpg
image001.png

Devin DuMont

unread,
Jun 28, 2017, 8:43:28 PM6/28/17
to 10BitWorks
I'd use logic chips. TTL is super cheap and durable with solder heat. That's the 7400 series chips. You want to decode the serial NES to a parallel 8 signal just like the physical game boy buttons, then still use the diode circuit. After a quick google search it's been done. This guy describes how:
If you want to go the logic route, it's still pretty freaking easy. You need:

-74HC04
-74XX161
-74XX595

-use 3 inverters to create an RC oscillator, buffer it with a fourth -- you now have the clock signal
-clock the controller and counter with the clock signal
-connect the counter's Q3 to the controller's load input
-connect the controller's data output to the 594's serial input
-use the 5th inverter to invert the clock, feed it to the 594's serial clock
-use the 6th inverter to invert the load signal, feed it to the 594's output register clock

Since it takes 16 states to sample the pad and pad is typically polled 60 times per second and you want 2+x oversampling, better set the oscillator above 2 kHz.

Reply all
Reply to author
Forward
0 new messages