Using original GB as controller for FPGA project

Cashews

Member
Hi! I'm going to be starting a project for a class soon that involves cracking open an original 1989 GB and using the buttons as inputs to a game on an FPGA. My professor has never done anything like this and can't help us with specifics much, so I just want a general idea of how hard this will be and what needs to be done.

Some questions I have: Do I need a cartridge inside the GB for my probes (or wires that I solder in?) to register button inputs? Will I need to communicate any data to the GB (such as through SPI, telling it to be in a certain mode for example)? Any other major pitfalls to look out for that I might not see coming? Thanks for your time!

I found this cool site with lots of schematics and examples for my reference. If you know of any tutorials that would be helpful, please link them!
http://www.devrs.com/gb/hardware.php
 
Cashews said:
Hi! I'm going to be starting a project for a class soon that involves cracking open an original 1989 GB and using the buttons as inputs to a game on an FPGA. My professor has never done anything like this and can't help us with specifics much, so I just want a general idea of how hard this will be and what needs to be done.

Some questions I have: Do I need a cartridge inside the GB for my probes (or wires that I solder in?) to register button inputs? Will I need to communicate any data to the GB (such as through SPI, telling it to be in a certain mode for example)? Any other major pitfalls to look out for that I might not see coming? Thanks for your time!

I found this cool site with lots of schematics and examples for my reference. If you know of any tutorials that would be helpful, please link them!
http://www.devrs.com/gb/hardware.php
The simplest solution would be to just cut out all the hardware you don't need and wire up the contacts of the buttons to input pins on your FPGA. I would assume the controls would have two contacts each, one of which is ground. So wire all the grounds into the FPGA's ground, and then all the other contacts to their own input pin on the FPGA. That should take care of the hardware aspect of it. On the FPGA, you'll probably want to implement debouncers on each of those input pins.

edit:
actually, thinking it over, you probably need some pull-up or pull-down resistors and a voltage source.

If you want to do active-high buttons, you'll connect the FPGA input to ground via resistor, and to a voltage source via the button contact. When the button is not pressed, that leaves the input pin reading low. When the button is pressed, contact is made linking voltage directly to ground making it read high.
 
grossaffe said:
The simplest solution would be to just cut out all the hardware you don't need and wire up the contacts of the buttons to input pins on your FPGA. I would assume the controls would have two contacts each, one of which is ground. So wire all the grounds into the FPGA's ground, and then all the other contacts to their own input pin on the FPGA. That should take care of the hardware aspect of it. On the FPGA, you'll probably want to implement debouncers on each of those input pins.

edit:
actually, thinking it over, you probably need some pull-up or pull-down resistors and a voltage source.

If you want to do active-high buttons, you'll connect the FPGA input to ground via resistor, and to a voltage source via the button contact. When the button is not pressed, that leaves the input pin reading low. When the button is pressed, contact is made linking voltage directly to ground making it read high.
Thanks for the reply. I found the schematic here: http://www.freeinfosociety.com/electronics/schematics/computer/pictures/gameboy.gif
I was hoping that I could turn the GameBoy on and have it provide the voltage across the buttons (in the bottom left of the schematic). Wiring up an additional voltage source seems redundant since the GB has a battery pack, but I'll do it if I have to. On the schematic I'm not positive if the inputs P14 and P15 provide Vcc or GND, but a quick probe with a Picoscope or oscilloscope will tell me. Then I'll worry about pull up/down resistors.

I haven't put too much work into this yet because of school, but I'm certainly going to get started soon. Thanks for the reply, I'll post again here or in a new thread if I have any problems in the future. Thanks!
 
Cashews said:
grossaffe said:
The simplest solution would be to just cut out all the hardware you don't need and wire up the contacts of the buttons to input pins on your FPGA. I would assume the controls would have two contacts each, one of which is ground. So wire all the grounds into the FPGA's ground, and then all the other contacts to their own input pin on the FPGA. That should take care of the hardware aspect of it. On the FPGA, you'll probably want to implement debouncers on each of those input pins.

edit:
actually, thinking it over, you probably need some pull-up or pull-down resistors and a voltage source.

If you want to do active-high buttons, you'll connect the FPGA input to ground via resistor, and to a voltage source via the button contact. When the button is not pressed, that leaves the input pin reading low. When the button is pressed, contact is made linking voltage directly to ground making it read high.
Thanks for the reply. I found the schematic here: http://www.freeinfosociety.com/electronics/schematics/computer/pictures/gameboy
I was hoping that I could turn the GameBoy on and have it provide the voltage across the buttons (in the bottom left of the schematic). Wiring up an additional voltage source seems redundant since the GB has a battery pack, but I'll do it if I have to. On the schematic I'm not positive if the inputs P14 and P15 provide Vcc or GND, but a quick probe with a Picoscope or oscilloscope will tell me. Then I'll worry about pull up/down resistors.

I haven't put too much work into this yet because of school, but I'm certainly going to get started soon. Thanks for the reply, I'll post again here or in a new thread if I have any problems in the future. Thanks!

First, your link is broken, but I think I managed to find the picture.

Looking at the schematic, that is an odd setup they have there; not what I was expecting to see. Let me know what you find out about those pins and I may have a better understanding of what's going on with their buttons. Worst case scenario, though, you can always cut traces and set them up as needed.

The other thing I wanted to say was that you can always provide power and ground through your FPGA (I assume you'll be using an experimenter board such as a Basys or Nexys, and those should have power and ground pins you can connect to external components).
 
grossaffe said:
First, your link is broken, but I think I managed to find the picture.

Looking at the schematic, that is an odd setup they have there; not what I was expecting to see. Let me know what you find out about those pins and I may have a better understanding of what's going on with their buttons. Worst case scenario, though, you can always cut traces and set them up as needed.

The other thing I wanted to say was that you can always provide power and ground through your FPGA (I assume you'll be using an experimenter board such as a Basys or Nexys, and those should have power and ground pins you can connect to external components).
Sorry about the broken link! (How embarrassing) I fixed it now, so verify that you were looking at the same picture. Here's a link to a picture I took after cracking open the GB case: http://i.imgur.com/qgVrG9V.jpg

The black pads underneath where the buttons are (on the arrow pad for example) are pretty clearly connected when a button is pressed. But those black pads don't appear to be a metal (unless it's just very old metal? The GB is rather old after all) and I'm hesitant to solder anything to them. It'll be tricky to get the GB to turn on without the case, but once I get that I can get an oscilloscope in there I suppose and try to see a current. Any suggestions on how to get a probe in there temporarily? How about permanently? (By permanently, I mean in a way where we can close the case and use it, would require soldering I assume.)

And we're using a Nexys Spartan6 FPGA, I'm sure it has Vcc and GND pins but I've never used them before.
 
Cashews said:
grossaffe said:
First, your link is broken, but I think I managed to find the picture.

Looking at the schematic, that is an odd setup they have there; not what I was expecting to see. Let me know what you find out about those pins and I may have a better understanding of what's going on with their buttons. Worst case scenario, though, you can always cut traces and set them up as needed.

The other thing I wanted to say was that you can always provide power and ground through your FPGA (I assume you'll be using an experimenter board such as a Basys or Nexys, and those should have power and ground pins you can connect to external components).
Sorry about the broken link! (How embarrassing) I fixed it now, so verify that you were looking at the same picture. Here's a link to a picture I took after cracking open the GB case: http://i.imgur.com/qgVrG9V.jpg
Oddly enough, the link is forbidden access when clicked, but it's perfectly fine if I go to a previous point in the url and then navigate from there. But still, same diagram.

The black pads underneath where the buttons are (on the arrow pad for example) are pretty clearly connected when a button is pressed. But those black pads don't appear to be a metal (unless it's just very old metal? The GB is rather old after all) and I'm hesitant to solder anything to them. It'll be tricky to get the GB to turn on without the case, but once I get that I can get an oscilloscope in there I suppose and try to see a current. Any suggestions on how to get a probe in there temporarily? How about permanently? (By permanently, I mean in a way where we can close the case and use it, would require soldering I assume.)
You're on your own here.

Taking a second look at that diagram, here's what I hypothesize is going on: The gameboy polls the buttons, and does so 4 at a time. I think it sets pin 15 to a negative voltage when it wants to check the A, B, Start, and Select buttons, and it sets pin 14 to a negative voltage when it wants to check the d-pad. So if we look at when pin 15 is negative (and pin 14 is not; probably 0 volts or something), if the buttons aren't pressed, it remains an open circuit and nothing happens. If one of the buttons is pressed, then the diode associate with it becomes forward-biased allowing a current through and pulls the pin associated with the button to a negative voltage.

If both the A button and the Right button are pressed (still pin 15 negative and 14 0), the diode associated with the Right button will be reverse-biased, not allowing any current through, so it does not matter. If the A button is not pressed and only the Right button is, then there will likely be no bias on the diode thus nothing happens. If pin 15 is 0 and pin 14 is set to negative, now the diodes associated with the D-pad will be forward biased when the d-pad directions are pressed and the diodes of the buttons will be reverse-biased and thus the buttons are ignored.

After having written all of that out, I also realized they could just be using pull-up resistors on the input pins (10-13), and then set whichever output pin they want "active" to zero, and that should have the same effect, except you wouldn't be using negative voltages on the device.

So anyways, I would think you could replicate this if you had your FPGA poll the buttons in the same way. Use a register to store the most recent value for each button and only overwrite it when you've polled that button again, so it doesn't look like the button is being pressed multiple times, but rather just being held down.

And we're using a Nexys Spartan6 FPGA, I'm sure it has Vcc and GND pins but I've never used them before.
I assume that to be the Nexys3, then which is the board I have. Each of those PMOD connectors on the bottom has two voltage pins and two grounds to go with eight data pins. Voltage and ground should be labeled right on the board, so you don't even need to look it up in your reference manual (although you'll probably want to use to figure out your UCF for the data-pins.
 
grossaffe said:
Taking a second look at that diagram, here's what I hypothesize is going on: The gameboy polls the buttons, and does so 4 at a time. I think it sets pin 15 to a negative voltage when it wants to check the A, B, Start, and Select buttons, and it sets pin 14 to a negative voltage when it wants to check the d-pad. So if we look at when pin 15 is negative (and pin 14 is not; probably 0 volts or something), if the buttons aren't pressed, it remains an open circuit and nothing happens. If one of the buttons is pressed, then the diode associate with it becomes forward-biased allowing a current through and pulls the pin associated with the button to a negative voltage.

If both the A button and the Right button are pressed (still pin 15 negative and 14 0), the diode associated with the Right button will be reverse-biased, not allowing any current through, so it does not matter. If the A button is not pressed and only the Right button is, then there will likely be no bias on the diode thus nothing happens. If pin 15 is 0 and pin 14 is set to negative, now the diodes associated with the D-pad will be forward biased when the d-pad directions are pressed and the diodes of the buttons will be reverse-biased and thus the buttons are ignored.

After having written all of that out, I also realized they could just be using pull-up resistors on the input pins (10-13), and then set whichever output pin they want "active" to zero, and that should have the same effect, except you wouldn't be using negative voltages on the device...
This has been very helpful thank you! I have checked some of the buttons with an oscilloscope and it does seem like it's polling half of the buttons at a time. Any given pad (the black pads in my imgur picture above) has a square wave going across it with a period of about 210 us when the GB is on and game inserted. The amplitude of these square waves is about 0.2V for half of them and 0.5V for the other pad in each "pair". (some of the pads are redundant, such as on the start and select button)

However I got a perplexing voltage curve when I probed both pads of the left button and zoomed out. http://i.imgur.com/iakFd9j.jpg Over time it looks like the average voltage of the pads varies drastically (I'm using 10:1 probes by the way), from about 1V to 3.3V once every ~17ms. The top curve is the top pad of the left button and the bottom curve is the bottom pad of the left button. If you zoomed in on any of those individual curves it'd look like a square wave more or less. This curve looks almost like the dis/charging of a capacitor, is this "normal"?

I'm also not sure I'll be able to poll the buttons myself with the FPGA since I can't get a wire in to where P14 and P15 are. In this picture I took you can see the backside of the PCB that holds the LCD and button pads: http://i.imgur.com/mUtj1ZT.jpg and the diodes that are listed on the schematic are in the upper right (DA1, DA2, DA3 and DA4). Problem is the LCD is on the other side so I can't access the wires connecting into those diodes (ie P14 and P15) while also keeping the LCD intact. I don't think that's a big problem though.
 
Cashews said:
This has been very helpful thank you! I have checked some of the buttons with an oscilloscope and it does seem like it's polling half of the buttons at a time. Any given pad (the black pads in my imgur picture above) has a square wave going across it with a period of about 210 us when the GB is on and game inserted. The amplitude of these square waves is about 0.2V for half of them and 0.5V for the other pad in each "pair". (some of the pads are redundant, such as on the start and select button)

What do you mean about the start and select pads being redundant? Are you referring to the where the wires cross on the diagram? If that's the case, my understanding is that they are not connected there, but the diagram could not be done planar so they had to have a wire cross over another (hence no circle denoting a connection).

However I got a perplexing voltage curve when I probed both pads of the left button and zoomed out. http://i.imgur.com/iakFd9j.jpg Over time it looks like the average voltage of the pads varies drastically (I'm using 10:1 probes by the way), from about 1V to 3.3V once every ~17ms. The top curve is the top pad of the left button and the bottom curve is the bottom pad of the left button. If you zoomed in on any of those individual curves it'd look like a square wave more or less. This curve looks almost like the dis/charging of a capacitor, is this "normal"?

Have you checked the signal you get from any of the other directions on the D-pad? I noticed on the right of the schematic, there's a diagram that has pin 14 connected to a capacitor via a 220 ohm resistor.

I'm also not sure I'll be able to poll the buttons myself with the FPGA since I can't get a wire in to where P14 and P15 are. In this picture I took you can see the backside of the PCB that holds the LCD and button pads: http://i.imgur.com/mUtj1ZT.jpg and the diodes that are listed on the schematic are in the upper right (DA1, DA2, DA3 and DA4). Problem is the LCD is on the other side so I can't access the wires connecting into those diodes (ie P14 and P15) while also keeping the LCD intact. I don't think that's a big problem though.
I'm sure you'll be able to figure something out.
 
grossaffe said:
What do you mean about the start and select pads being redundant? Are you referring to the where the wires cross on the diagram? If that's the case, my understanding is that they are not connected there, but the diagram could not be done planar so they had to have a wire cross over another (hence no circle denoting a connection).
By redundant, I mean when you look a the physical place where the button makes a connection on the PCB, you'll see multiple black pads. Under the start and select buttons there are 8 such pads, under A and B there are 4. Half of the pads have higher voltages than the other half (meaning half of the pads correspond to the wire on the left side of the button on the schematic, the other half correspond to the right). When the GB is on, you only need to connect 1 pair of the pads with a wire for the system to register it as a button press. So you don't have to connect all 4 pairs of select's pads to have it work, you only need to connect a minimum of 1 pair.
Have you checked the signal you get from any of the other directions on the D-pad? I noticed on the right of the schematic, there's a diagram that has pin 14 connected to a capacitor via a 220 ohm resistor.
I haven't checked any of the other signals yet, that will be my next step. Thanks again for your input, I am using this thread partially to ask questions but also partially as a documentation of my progress on the project.
 
Back
Top