Saturday 4 February 2017

Next project...

It's been a while since I finished the NES, or posted about it.  I realised today I never posted a "final demo" of it working - but I finished it almost as soon as I sorted the power connections out.  I'll hook it up again soon and show it running and finished. :)

In the mean time, I've been thinking of doing another project.  I've made a board of ideas, and the one that's been top of that list for a while was a nixie tube clock.  If you've never seen one before, you can see what I'm thinking of here and here.

Being poor, I can't afford the expensive pre-made ones, but they look awesome and I really do want one for the living room, so I'm going to make one instead!

I'll get to do a little more electronics work which is exciting, I'll (hopefully) get a cool looking clock at the end of it too.

My main list of requirements are:

  1. 6 tube clock (HH:MM:SS)
  2. I don't want buttons on it, or manually have to set it, it should just sync with a timer server online
  3. Run self-tests to make sure the tubes are all good at are start up.
  4. Because of requirement 2, it'll have to involve something connected to my wifi to control it - so a raspberry pi or arduino - possibly a CHIP?  
  5. Run on a standard 5v usb supply (I have lots of these)
  6. It needs to look nice.  I am thinking scavenging an old broken vintage radio, or using a joiner friends workshop to make something out of a decent bit of wood. 
Optional extras might be:
  • Voltmeter or gas discharge tubes to display temperature / humidity readings (so sensors too)
  • Because we'll have a scriptable system with sensors attached, I'd like to be able to store a log of these readings against time - so I can look at historical trends.

I need to do some research, and work out what parts I'll need to build this thing, once that's figured out I'll post something new up going through what parts I think I'll need to order and what they are.





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!


Thursday 23 June 2016

NES + Pi: Controller ports

I managed to get some free time this week to do a little more work on the NES project. This time I decided to get the controller ports wired up. It's been nearly a decade since I'd last done any soldering, so apologies if you're a soldering expert and see the hack job I did today!!

I've got 2 RetroUSB RetroKit chips to solder onto the front ports of the NES - each port needs to connect 5 pins/wires to the chip. I prepared the wires on the back of the port already by removing them from the original NES board, cutting the wires a little shorter, and stripping the ends. The wiring diagram (and order form) for the RetroKit can be found here, but I'll post it here too so it's easier to see.

Normally the RetroKit's are meant to be inside a standard NES controller, converting the pad itself into a usb nes controller - but because I want to use the original ports on the front I'll be putting the RetroKit on the port instead of inside the pad.

The RetroKit and a NES controller port (once removed from the case) are below.



My main concern is that the wire colours on the back of the port might not match the colours inside the pad. If the wiring colours didn't match then we'd have issues with the wrong leads soldered to the wrong contacts. I couldn't find an answer online whether the internal wire colours matched the pads. Unfortunately I don't have a multi-meter at home to just check that either (I know, the shame!!). In the end, I just took the gamble and soldered one to see what happens.



Once soldered on I just wanted to confirm it worked - so I plugged the USB lead into my laptop, and after a few seconds it had registered as a pad. Great - so the RetroKit itself works. :) So next I plugged in a NES pad into the port, loaded up the controller settings in Windows 7... annnnd nothing. Bugger!!

The soldering looked correct, and while the NES did come to me as faulty the port itself looked undamaged. I decided it must be the controller (it is a Chinese replica pad I'd bought off eBay for about £1.50). Luckily I had a couple of original pads that was donated to me by a nice person at work, so I dug one out and plugged that in... it worked! Phew!!

After some checking, all the controller buttons were working in the controller setup tool in Windows, so my soldering is fine. I'll add some pictures below showing me trying the D pad and some buttons.


    

I soldered the other RetroKit to the second controller port, tested the port again with the same pad. Once I was happy both were working as expected I then added them back into the box.

I don't want to have the chips just loose in the case, it'll put pressure on the solder points and could potentially damage the RetroKits if they're just banging around lose in there. To fix them into place I added some velcro stickers to the top of the main chip on the RetroKits, and the other side to this on a section of case near the ports.



This will hopefully keep them fixed in place, but also lets me move them around if needed. I've fed the excess USB wiring under the cartridge loader for now, if it bothers me I may shorten the cable so everything is nice and neat..

So the current state of the NES looks like this:



What's next?
After this, we've got:
  1. The back panel - I need to add in the USB port for power in, and HDMI for video out. 
  2. The power/reset circuit to install, and configure the setup script for handling that on the Pi 
  3. The Pi itself.

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).

Sunday 15 May 2016

NES + Pi: Making room!

The main aim of my project is to replace the internal components of the original NES with a raspberry pi running RetroPie.  So, lets get to it.

Making room!

I knew I'd feel bad destroying a working 30 year old console, so I deliberately bought a faulty box.  Even so, the act of removing the original PCBs from the box still had me feeling a little guilty!  On the otherhand, it was nice making a start on the build, and explaining to my son how this particular console was assembled when I was around his age (he questioned the date on the board).



Taking the top of the case off you're presented with some plates / supports around the cartridge loader and PCB


Once the plating is removed you can get to the main screws that hold the loader and a PCB beneath it - I didn't get a picture of it but that PCB is slotted into place.

 
And we're emptied!! You can see I've kept the wires from the controller ports and power/reset board.  Next step I'll be using a dremel to remove most of the supports in the case and create more space.




 
With the old guts removed, I added back in the loader to check how much room is available if I keep it.  I think there's enough - you can't really tell from the image but there's quite a bit of room beneath the loader too.   




External Ports

One thing I've not covered so far are any external ports - obviously now we've taken everything out we'll need to add some power and video ports.

HDMI is the port of choice for video, and it makes sense to use a standard USB port for power.  I'm considering adding 2 extra USB ports at the side for additional control pads and/or keyboard.  I'll make that decision at a later date I think.




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!