Showing posts with label Emulation Station. Show all posts
Showing posts with label Emulation Station. Show all posts

Saturday, 6 August 2016

NES + Pi : Power Buttons

I've been a little busy lately, but I got some time recently to do the power / reset buttons, as well as the LED indicator. 

So, as mentioned before I've opted to use a mausberry shutdown circuit - this can handle  on/off switches like the NES, and "momentary" switches too.  It also supports powering an LED too, but for simplicity I decided to hook that directly to the GPIO on the Raspberry Pi itself.

The circuit takes micro-usb in, and has it's own male microusb port onboard, so it basically acts as a power-passthrough to the Pi - albeit it with some light scripting on the Pi itself to handle the GPIO trigger used to initiate a shutdown.

More detailed setup information is on their website here. On that page it shows the only real communication with the Pi itself is through "out" and "in" lines, which are connected directly to the GPIO of the Pi (#23 and #24).  These signals are then handled via a script that is run by updating etc/rc.local on the Pi itself (rc.local just runs scripts/commands during boot).  The instructions to do that are on their setup page too.

The circuit also has solder-points for the power and reset switches, so 4 in total (plus an LED point if you want to run an indicator through the switch rather than the device being powered).  As said above, I'm using the Pi to power the LED instead - and we'll need a resistor on the negative line from the LED.  The positive will be connected to pin #04 on the GPIO (5v DC out), with the negative line going to a ground pin - I chose #39 for convenience due to a short cable length.

I tested it before soldering, thankfully the 5v out does turn off when the Pi shuts down fully, so the LED will turn off and on with the Pi.

I was going to do a wiring diagram for this, but after I'd finished I found mausberry have a really simple wire-colour to solder point diagram on their site here.  I'm pretty sure that's new, I didn't see it before I did my wiring, would have made life easier!

Finished, the wiring looks like this (my soldering is terrible, I know!):

GPIO view

LED - beneath the tape is a resistor

Overview without the cartridge loader

Shutdown circuit - solder points


I had a few problems with the LED indicator - it was driving me nuts!!  Eventually I realised my resistor was incorrect, I'd been distracted by kids running around the house and accidentally connected a 8k resistor rather than 800.

A quick test once I'd replaced the resistor on the LED circuit - all working! :)




I'm not sure if it's obvious from the photos, but I ended up buying a Raspberry Pi 3.  I wanted the convenience of being able to have it connected to wifi, extra grunt for more demanding games, and I decided I wanted a couple of extra USB ports for general use.  Because of that I've also ordered an extra two USB ports for the back of the NES so that I can plug in my Buffalo SNES pads for 16bit games, or my xbox 360 wireless usb connector.

So - the last step is just to cut out the holes on the back of the console of HDMI and USB power - replace the cartridge loader and lid, then we're done!


Monday, 23 May 2016

NES + Pi: Controller / Power button planning

After some thought (and browsing) I've made decisions on how I want to wire up the original power / reset buttons, and get the control ports working for use. 

Keeping the controller ports

This is probably the most important part of the project as without authentic looking ports you don't have an authentic looking box. 

I can either use them, or keep for them show.  I don't like the idea of not having them active so to me it's worth the effort wiring them up so we can use original NES controllers

While looking for some form of wiring diagram for the ports (originally I thought I could just wire them up to the GPIO, and configure them in software) I saw references to RetroUSB, they specialise in circuits that will take wiring from a NES controller and convert that to a standard USB HID controller.

Their intended use is embedding the circuit inside the pad itself (it has a long trailing USB lead attached).  Essentially converting an original NES controller to a generic USB one for use on PCs.

I want to use the original ports, but providing I can map the pins to the right wires on the inside of the console there's no reason why it can't be used internally - and I've seen in one project that this has been done at least once before. 

I've ordered 2 circuits (one for each controller port) - you can find them here.  There is a YouTube video and some images showing the points to solder to.

The power / reset buttons

When I originally thought of doing this I was planning on using the menu system in EmulationStation to shut the system down, and the external power socket to turn the box off and on.  I quickly realised this wasn't a good idea.  Firstly, you can't tell if the box is on - so already I have to link up the LED to the GPIO somehow.  Secondly, my 7 yr old is never going to remember to shut it down before turning it off at the plug.  So, I need working buttons and LED indicator on the front of the box.

Luckily there is a company that specialise in shutdown circuits for Raspberry Pi's.  The Mausberry shutdown circuit should link up both buttons on the front of the NES box, as well as the indicator.  Its a really tidy solution, it sits between the Pi and the 5v micrusb cable that powers the Pi, and takes in wires from the power / reset switch, as well as controlling the LED indicator via a 3v out. 

There is a small amount of configuration needed on the Pi to set up a script to handle the shutdown event before cutting power.

Rear panel

At the back I need to have a USB port and a HDMI port. These will replace the old analogue out and AC adapter connectors.  I need to source some grey plastic sheeting from somewhere or something, to make it tidy looking at the back and make sure the ports are firmly in place. 

All the parts I need have been ordered, while I wait for them to be delivered I can dremel the unused supports out from the box, ready for putting the new stuff into it.

I can also think about how I'll be fixing the Raspberry Pi in place (and where).

Friday, 13 May 2016

NES + Pi = Awesome!

A few years ago I got my Raspberry Pi Model B, my plan was just to tinker with it and see what it could do.  Operating system wise I knew what to expect, I'm a programmer and used Suse and Ubuntu as my main desktop for a few years, as well as for work - but hardware wise I'd never owned anything like the Pi before so I was excited! 

After a few weeks of playing with it, trying various distros (such as raspbmc that turned the Pi into a kodi media player), life kind of got in the way a bit - so it just gathered dust in a box for about a year.  
A little while later I remembered about it, and that was when I decided to show my eldest son what console games I played at his age!  I got a few USB SNES pads on Amazon, loaded a few emulators and it was alright, but not great... then I found the RetroPie project!  If you've not heard of it, RetroPie uses various open source projects such as EmulationStation, RetroArch and a Raspbian OS to create a pre-configured emulation console.  It's a very easy to use UI based on XBM system (think PS3 menu), with in-built emulator cores, and some nice features like box art / meta data scrapers.  

I was blown away by it - took less than 5 minuts to download / install, and it was easier for my 5 yr old to use than the Wii or xbox 360.  I loved seeing box art for games I'd not seen/played in 3 decades - it jogged a lot of memories!! 

So - fast forward to last month - I have set myself up a desk in the dining room, it's become the "dad-corner".  To go in the dad corner my kids created me some Mario pixel-art from hama beads to decorate it which looked awesome, so I got an idea - what if I had a NES box to go in the corner too?  I loaded eBay up and bought myself a faulty NES box for £30, with the intention of using it as a retro case for my Pi.  The NES box is the perfect retro case for a pi - it's just pure 80s gaming!  



Realising I've actually put cash into this now, I decided to get serious  so I started to make a list of the things I want out of the project - a requirement spec.  
  1. Externally it has to look authentic, no visual clues from the front that it isn't a standard NES
  2. I need proper NES controllers for the front ports, otherwise we fail #1
  3. The front power switch needs to be functional! Because my 7 yr old will use this too, it needs to be as user friendly as a console. For that reason, the LED indicator has to work too!
  4. For 16bit and greater consoles I really would like additional hidden ports at the back, or wireless pad capability so we can use 6+ button pads.
  5. I want to keep the cartridge loader!  There is no reason for it, it doesn't have to function - but it feels wrong to not be able to open the front, take a cartridge, insert it in and click down!
Incidentally there was 6th requirement, but it got removed after a little digging into it.  I wanted a working light gun for duck hunt.  I realised there may be issues with differences in TV technology now, so checked how it worked.  The gun uses very precise timings used in CRTs to coordinate flashing up of a binary image with the press of the trigger, with the reading from the light sensor in the barrel of the gun.  The NES and CRTs were very predicable timing wise, which is why this method worked well - but modern TVs, and running games through emulators mean this is very unlikely to work most of the time, if at all.

Obviously I realised I might not be alone in wanting to do all this, I've seem GameBoy mods in the past with a small LCD display and a Pi, so I searched around for projects similar to mine, and there were several!  People mostly did similar things, some remove front ports, some don't use the front buttons, but every single one removed the cartridge loader.  Each project seems slightly different to the others.


I didn't want to be influenced too much by the others who've done this before me so I've tried not to read into the details too much, but I think there should be enough room in the box for the pi and a usb hub around the loader, so I'll try my best to keep that in!  

I'm involving my son in the build (as a learning exercise), he's just turned 7 and is very eager to help - so progress will likely be slow as it'll be restricted to a few hours every weekend.  

I'll be documenting the project on here as we do it, and there will be less waffle from me, and more pictures / build details!