Sunday, 12 October 2014

Raspberry Pi NES - Complete!

It's taken a surprisingly long time to polish this project off. Although initially all seemed well I had endless problems with the power switch. I was getting crashes, premature shutdowns, and other issues that seemed to increase in frequency as time went by. For a long time I thought I must have needed better quality USB cables so I kept trying different cables, but that didn't make a difference, and eventually I realised the only possible explanation was the power switch circuit. I bought a second switch circuit from Mausberry Circuits and they were nice enough to include two switches in my order to make up for the broken one, but before it arrived I also purchased a different switch circuit from LowPowerLab called ATXRaspi ( This is a really great circuit, it works similarly to the Mausberry one but only works with a momentary switch and has some extra features.

New power switch

First I had to change the NES power button from a toggle switch to a momentary switch. This is really easy, as you can see in the picture below there is a small copper coloured metal plate and wire on top of the power switch housing (just behind the spring).  These can be easily pulled out, and they can be removed without damaging them, so this is not an irreversible modification.  I didn't know this would be the case so I actually bought a spare NES power/reset button assembly and modified that.

The ATXRaspi is larger than the Mausberry circuit and it has connections coming in from 3 sides, so it takes up significantly more space so I mounted another piece of acrylic to screw it to.

The ATXRaspi has some nice features.  Press the button once to boot up, to shut down hold it down for a few seconds.  You can also connect the NES LED to it and this gives you a bit more feedback; The LED starts to pulse when it starts shutting down and then pulses even more rapidly when it's finished shutting down and before it cuts power completely. Also if your Pi crashes you can hold the button down for 10 seconds (I think) and it will hard reset. I haven't had it crash yet so I haven't tested this but in theory it's a nice feature to have.  I highly recomment this product, it's really great, and the guy who sells them is extremely responsive and helpful via email (Thanks Felix!).

I must confess that having the button as a momentary switch instead of a toggle does bother me slightly as it's less authentic, but it's a minor thing. I do now have the replacement switch from Mausberry Circuits but setting it up requires soldering and I need to replace the tip on my iron because it's not tinning properly at the moment making it a nightmare to use. At the moment I Just want to screw the NES case closed and enjoy the games, but I'll rig up the other switch at some point and then decide which one I want to use.  Doesn't hurt to have different switches, I'm sure I'll come up with other Raspberry Pi projects to do.

Cartridge slot facade

One last little touch I wanted to do was to clean up the cartridge slot so that it didn't looks so amateur. To do this I just cut a piece of black plastic (cut from the cover of one of my uni notebooks) and hot glued it in place.  The cutout around the hub is a little rough if you look closely as my stanley knife is blunt as hell right now, but it's still a massive improvement.

Big improvement.

So that's it, the project is done.  Now back to Punch-Out!!

Saturday, 30 August 2014

Raspberry Pi installed into an old broken NES

First blog post!

Hi all, this is my first blog post, I set this blog up to document some of my projects (only one of which is "complete" thus far) because I thought they might be of interest to others.  Certainly other people's blogs have been invaluable for both inspiration and information for my own projects.

Why put a Raspberry Pi in a NES?

This first project is my Raspberry Pi inside an old NES.  Why did I do this?  I'm really into retro games, yet I never owned a NES, instead I had a SEGA Master System (an awesome console).  Recently I really started to fee like I'd missed out on a whole lot of gaming cultural touch stones, so many often discussed games that I'd never even played.  So I thought I would buy a NES, and then I thought about how many cartridges I would have to buy and how expensive it would be and how much space it would take up (incidentally I am trying to reduce the amount of stuff that I own right now).  So my solution was to buy a NES that was broken beyond repair and put a Raspberry Pi in it.

My approach and goals with this project

Given that's where I'm coming from, just a few notes on how I approached this project.  I wanted to experience the NES as close to what it was really like as possible.  That meant doing this project in a way that kept the gameplay experience and the operation and appearance of the console as authentic as possible.  There are quite a lot of these projects around, and without meaning to offend anyone I think most of them are pretty clumsy implementations.  E.g. many use a dremel to gouge ugly holes in the side of the case to put in HDMI or Ethernet ports or even replace the controller ports on the front with USB ports.  At that point, to me I feel like "what's the point?"  This is of course only my own opinion and relates to what I want to get out of the experience, those other projects are still great and without reading about them I'd never have gotten anywhere with my own.

So my goal with this project was that from the outside there would be no telltale signs that this was a modified NES, it had to look completely original (at least with the cartridge slot lid closed).  That meant using all the original AV ports and original controllers.

Other projects that really helped

Probably the two most helpful blogs along the way were Igor's (, who's project achieves the same goal as mine, using all the original ports, and James' (, who's project had a couple of great features that I also implemented in mine.  Now, on with the show...

The Project

This isn't a proper build blog because I didn't document the process as I went, so I've just photographed everything as I was implementing one of the final features and will try to explain how I went about it.


I won't say too much about the software, I'm using the retropie SD card image, you can find plenty of information about it elsewhere.  I barely understand electronics and I understand Linux even less so thankfully Retropie is very easy to get up and running.  Very unlikely that I can help with any questions regarding it's setup beyond the most basic, I followed the instructions of others.

Mounting the components

Because I didn't want to alter the actual NES case by drilling any holes in it or anything I cut a small sheet of perspex upon which to mount everything.  This sheet then screws onto the mounting posts that the original NES motherboard and other internals were attached to using the same screws, so I just had to drill a few holes in it in the right places.  The Pi is attached to the perspex via the bottom half of a case (you can see the top half of the case in the background in the image above and below) which has been screwed down.  The powered USB hub that I'm using (7 ports) sits on top of a platform at the right height to place it in the cartridge slot, it's attached to the perspex with adhesive velcro and the platform posts are some long screws and the barrel of a ball point pen.

Underneath is a keyboard encoder (I-Pac 2 VE from which is also screwed in (I'll explain it's purpose later)

You can see here that sticking out the front of the hub is a WiFi USB dongle, this one is really small and works out of the box with the Raspberry Pi so I'm really pleased with it.

The AV and Power ports

This is the small chassis that houses all the AV ports, I've removed the PCB that was attached to it and soldered a composite video cable to the video port, and a 3.5mm stereo cable with one channel soldered to the audio out port and the other channel soldered to the RF port, so the option for stereo sound is there if you are running something that needs it.  I've also soldered the power cable from the USB hub to the DC in port.  I then added a compatible male plug to the DC adapter for the hub so that it would plug into the DC port on the NES just like the original power supply (not pictured).

The power and reset buttons

I haven't taken a picture of it specifically but the power buttons and power LED are attached to a small PCB with 5 wires coming off it, this is convenient, all you have to do is remove the blue connector from the end of the 5 wires and then you can hook those wires up to whatever.  Take note of the colours, or just look underneath the board and trace their connections to the various components.

Here's the keyboard encoder, this is basically a keyboard, where you can hook any switch up to the terminals to simulate a keyboard stroke.  These are sold for the purpose of setting up a MAME machine so that you can get arcade controls working with ease on a PC.  This is a bit of an overkill way to implement this but I'm using this so that the reset button functions as the escape key, this is so that I can exit games and get back to the game select screen.  The two original wires from the reset switch just screw into the terminal for the escape key and the ground terminal.  Another option is to just use a specific button combination on the controller to exit the emulator, that can be setup easily, but I didn't like this idea because there's only 4 button ons a NES pad and I wasn't convinced that I wouldn't press the combination by accident or when throwing a tantrum because I died. 

The power switch utilises a small board from Mausberry Circuits.  You can see it between the black and orange usb cables, i've just hot glued it to the perspex sheet.  The two original wires from the power switch are soldered to this switch, and then it has two wires (blue and white) that connect to the GPIO pins.  All the instructions for setting it up are on the Mausberry Circuits website and it's very straight forward.  When you press the power button the Pi boots up, when you press it again it sends a shutdown command to the Pi and then cuts power after a few seconds, very cool.

I originally had this setup by just splicing the power switch into the wire providing power to the hub, which was fine for booting up, but then I had to shut down the Pi from the menu in emulationstation and then press the power button again once it shut down to return it to the off position - a bit clumsy.

Controller ports

This image is from a bit later in the build, but it shows the control port setup.  There are chips you can buy from that have usb cables already attached to them, and all you have to do is solder wires from the back of the control ports to the chip.  Then when you plug an original nes controller into the control port the raspberry pi will recognise this as a normal USB controller.  This is a really great option.  Another way to go is wiring the ports directly to the GPIO pins, and using SNESdev which is included with Retropie.  This is the approach that Igor used and is what I originally tried to do.  I could NEVER get this to work properly, it drove me insane.  I could get one controller working fine but the other never would, and I couldn't get anyone to give me any kind of solution.  I even bought a second Raspberry Pi in case it was a hardware problem.  I also experienced control delay when I did have one controller running like that, something that isn't present at all using the USB chips. I'd save yourself the headache and do this instead, unless your much more comfortable with linux than I am (there is a good chance you might be).  Using these chips didn't require any setup, it just worked and there is no response delay.  I believe it may also add less overhead to the whole thing than using SNESdev does, and you won't run into any problems where something has been updated and breaks SNESdev.  In the picture below the chips are covered in electrical tape cause having them floating around like that makes me a tad nervous.

The full setup, almost done!

Here's a couple of pics just showing the whole layout

Up and running with the lid on and hooked up to a small 9" CRT.  The nintendo logo is one that I made to replace the default Retropie bootscreen.

Running SMB, of course.

Power LED and casing the Raspberry Pi

The last thing I wanted to do was hook up the power LED.  I left this till last because I had no idea what resistors I needed or how to find out.  I simply used the advice of others.  One blog said they used a 10k resistor, another one said they used 170, but two others said 330 so I went with that.  I desoldered a 100 and a 220 from the original broken NES motherboard and put them inline.  It's a little confusing here because there are two sets of blue and white wires, but the blue and white ones that are running along side each other are the ones that connect to the Mausberry circuit and are on side by side pins (see second image), while the other white wire on the right is from the power switch PCB and connects one side of the LED to a ground GPIO pin.  The blue wire on the left connects the other side of the LED (which I detached from the PCB) to the 3.3V GPIO pin - you can see the red heatshrink in the middle which covers the two resistors.

Showing where these wires connect to the Pi

I drilled a few holes in the appropriate places and put the case on the Pi now that there will be no more GPIO connections.

Here you can see where the blue wire connects to the LED on the powerswitch PCB, and you can see the five wires I spoke of earlier disappearing out the other end.

Power LED working

More pics

All done! The usb cable connecting the Mausberry circuits shutdown switch is missing in these pics so that you can see the detail a bit better (need to replace it with a shorter cable that isn't all coiled up in there)

Here you can see the AV ports

Power port and RF port.  One thing to note here, the gap in between had a small switch but it wasn't attached to the same chassis as the AV ports, it was attached to the PCB that I removed.  I'm considering either glueing it back on for aesthetics, or actually mounting a micro HDMI port here (that's right, you can have HDMI without butchering the case!).  I play this on a CRT TV (obviously, that's how it's supposed to be played!)  so it's not something I'm in a hurry to do, but I may do it at some point.

Here you can see the two black USB cables connecting the control port chips to the hub.  These were really long so I cut and resoldered them, hence the red heatshrink.  In hindsight it would have been a thousand times easier to desolder them from the chip and shorten the cable, rather than having to rejoin the five wires inside each cable.

I'm not completely happy with how this looks with the cartridge slot open, the screws and velcro tape don't look very neat or polished, I may put some kind of facade over this to hide everything but the USB ports, but it doesn't really bother me too much right now.


What's left to do?

It's pretty much complete.  The only two further modifications I'd like to make is as mentioned above putting something over the front of the USB hub to make it look neater, maybe a grey piece of plastic with the shape of the hub cut out.  Also still tossing up whether to add a micro HDMI port where the channel switch used to be at the back.

What could I have done better?

I'm pretty happy with the whole thing, I didn't want to permanently alter the Case itself, and I've implemented all the functionality I wanted without doing that, so I'm happy about that.  If someone one day wanted to use this case to restore an original NES they could, and it would be free of blemishes (except those imposed by a hard life of gaming).  I originally wanted to leave the cartridge spring mechanism inside so that you had to push down on the top of the USB hub to make it pop up, but the mechanism was too large and didn't leave me enough space for everything else.  It probably could have been done but would have been cramped.  It also made it problematic to access the back of the hub without drilling holes in the mechanism, which goes against one of my goals with the project.

Can you help me?

One thing I'm not happy about is using a 40 dollar keyboard encoder just to turn the reset button into an escape key.  I'm also building a MAME cabinet so I would like to use the encoder for that and not have to buy another one.  The Mausberry circuit works by activating a bash script (is that the right term?  it's a *.sh file)  that you have to install on the system.  There's a second set of terminals on the circuit for a reset switch which by default resets the whole system.  I'm wondering if by altering the script, a switch hooked up to the circuit's reset terminals could be made to either simulate a keyboard stroke or send the exit emulator command to Retroarch or Emulationstation (whichever handles that function).  If anyone knows how to implement that or has any other suggestions of how to elegantly implement this functionality please get in contact.

Happy to answer any questions you have regarding this project, I'll do my best to help with my EXTREMELY limited knowledge :)