Uze64 Adapter

From Uzebox Wiki
Jump to: navigation, search


This page will describe 2 general methods to use a Nintendo 64 controller on your Uzebox game console. This is done with an adapter utilizing a small, cheap, and low power ATTiny85 MCU(a 25/45 may also work, TBD) with no external parts(even a pin left over for future use). This uses firmware on the ATTiny in a similar manner to the Uzebox Keyboard, which I would recommend reading through first if you have never done something like this. Along the way I will discuss some pitfalls as well as pros and cons to different options you can take on your own custom build. This could take anywhere from 1 hour to 6 if you get real crazy with case modifications and such!

Before you start, though this is not the most dangerous project out there, keep in mind these methods recommend using chemicals that can be dangerous to your health. They can also easily ruin things they leak on, and your significant other might not be so understanding at that point. You should wear appropriate eye protection, gloves, and respiratory protection. You should also do this in a well ventilated area. This can all be had very cheaply from many local stores. Do not skimp on this gear; you can reuse it for projects in the future. And if you think I am kidding about gloves for epoxy, just believe me it somehow always gets on your fingers without them and it will drive you mad! For conciseness, I wont repeat things in different segments. READ AND UNDERSTAND THE ENTIRE TUTORIAL BEFORE YOU DO ANYTHING PLEASE!

It is also worth noting that this has so far only been tested with unofficial controllers. The official specifications say to use 3.6v power supply and 3.3v logic(though logic levels do not matter as an open collector, our MCU never drives the line high). For those that are worried, it would be trivial to add a voltage divider to bring the 5V supply to the MCU down to 3.6V. For simplicity and less parts count, I decided to try things at 5 volts! Of the 2 different after market controllers that I let run testing for more than a day I had no problems so I left it at that and am continuing to develop firmware at 5v. If I ever did feel the need to add a voltage divider I could still open up the SNES plug and add it inside there. I am sorry if it doesn't work out on some other model and I will immediately document it if I find that the case...Do this at your own risk!!

To cover a question you might have, the Uzebox hardware could poll the controller successfully without the aid of a separate MCU. The N64/GameCube protocol operates on 1 us pulses where a bit is specified by the proportion of 4, 1 us pulses high and low. There is no clock line and so once initiated there is no way to slow down the data. The primary issue is the HSYNC interrupt that happens frequently and would ruin any data during that time. Since it is required for video, there is not much way around it for games. It also makes it easier to support multiple controllers, requires less free cycles usage, and less code for games wishing to support both SNES and N64/GameCube controllers.

*Parts Required*
*1 N64 generic controller - ~$8.50 shipped
*1 ATTiny85 (25 or 45 may also work, get the 85 to leave room for the future expansion) - ~$3 shipped
*1 SNES controller extension cable - ~$2.50 shipped
*1 Epoxy Adhesive(recommend those labeled to bond with plastic) - ~$4.50 shipped
*1 N64 controller extension cable(optional, depending on your build choice) - ~$2.00 shipped
*1 standard female pin(optional, depending on your build choice) ` ~$1.50 for 40 shipped
*total cost off ebay ~$20.00-$23.00 USD, cheaper if you have some of this stuff already!

What Is The Point

The reason you might want to build this controller is for analog game control. A more accurate term might be digital proportional, or rather, you can move the joystick a little to have a small influence on a game object. Moving it more has a larger influence, perhaps even makes your character run faster. This is in stark contrast to the on/off nature of normal D-pads like the SNES controller. For my purposes, the main motivation is a racing game and the desire to have very fine control of cornering and power slides that is just not possible with a SNES controller. Besides just this, the N64 offers 3 extra buttons over the SNES pad. Also, with future firmware, it should be possible to have force feed back also known as rumble pak. Similar in protocol, the memory card should also be of possible use to store game data in excess of what we can fit onto the small EEPROM of an ATMega644. You might also build some other crazy memory mapped device to plug into the N64 controller in the future, who knows!

Design Choices

Since this requires additional circuitry, you must decide where you want to put it. Essentially you have 2 general choices in a similar manner to the Uzebox Keyboard adapter. You can place the circuitry inside the N64 controller, or you can put it inside the SNES plug. The circuitry is minimal, no parts besides the ATTiny and extra wire, but it can be a challenge for the average hobbyist to do either. I would say this is harder than the keyboard adapter if you want to place it inside the controller. I also believe it can, depending on how you do it, be easier than the keyboard adapter if you decide to go the SNES plug route for placement of your MCU. First, some pros and cons of both:

    • Inside Controller
*arguably a cleaner and more minimal solution
*less people will have it, more 3L1T3 if you will :)
*can be done with only 1 N64 controller, 1 MCU, and 1 extension cable
*must disassemble and reassemble controller components multiple times
*great care must be taken during fitting and placement of MCU and wiring
*higher potential for failure
*likely much more time investment
*more work to replace the joystick in the future

    • Inside Plug
*easier and faster!!
*can be done with only 1 N64 controller, 1 MCU, and 1 extension cable(depending on choice)
*much easier to replace a worn joystick
*you can plug any N64 controller into the port, not just the one you built(though requires 1 extra N64 extension cable then)
*you can have a much longer cord(requires the N64 extension cable)
    • Cons
*less cool than built into the controller?

So the first option is to put the MCU and wiring inside the N64 controller. I'd suggest you read this guide thoroughly before you do so; it can be more error prone than it appears at first. There is not a lot of room inside the controller and the spaces are awkwardly shaped. Great care must be taken to ensure wiring does not hinder button operation or get cinched by a screw. I don't recommend this option unless you like the additional challenge and perhaps the fact that the number of members in this club are smaller.

The second option really has 2 different paths you could take. The first would be to buy an N64 extension cable in addition to the SNES extension cable that all options require anyway. Instead of putting a female N64 controller plug into the SNES plug, which requires some fabrication, instead cut the end off of it and insert the cable into the SNES plug. This way you have much more room to do your wiring inside the SNES plug since the large N64 female plug is not taking up space. This is the method I recommend; your time is valuable and this is the quickest.

The other path for the inside plug option would be to actually put the female N64 plug inside the SNES plug. The first thing that becomes obvious is the N64 plug is taller than the SNES plug. This would require fabrication to cut and graft the 2 different cases together with a rotary tool then expoxy everything together. The plastic is probably 2 different colors and so you would probably want to paint it afterwards. The end result is harder to achieve, and I recommend you do the method in the previous paragraph. If you did decide to go this route, it is arguable this is even more hardcore than putting it inside the controller!

Inside Controller Method

Ok, you are a glutton for punishment and actually want to mess around inside the controller. This guide is written using what I think is the most common controller people will get, the generic controllers off ebay for <$10 shipped to your door. Make sure you do not get one that has a USB end, these will not work. In fact, if you did not know why that is, please do the easier method describe below!!(ha, just kidding, but be careful). The quality of this particular controller is actually quite surprising compared to generic SNES controllers which are noticeably inferior to official pads. The joystick seems to be spring based instead of "whatever compressed powder?" method the original used, so it might even last longer? The accuracy of the stick seems high and the buttons feel crisp so I actually recommend you buy these types, perhaps get 2 in case you mess 1 up ;)

You will need to buy a SNES extension cable since you will be replacing the controller cable with this method. I recommend only buying better grade cables that specify what length they are. I would recommend 6' or more if you can find them. While you are on ebay, you should be able to find your MCU for cheap instead of making a Digikey/Mouser order just for those. I would just buy 10 of them personally, as they seem to be the MCU of choice for Uzebox add-ons, and you can build yourself a Uzebox keyboard/etc. with the extras!

You will need epoxy and I highly recommend getting a cheap hot glue gun. I recommend the liquid type of epoxy though the thicker types can also work. If you might be doing some other projects like this in the future, I would recommend keeping both types on hand. The thicker type will not run and this can be very helpful when you are fastening things to the controller case that you do not want epoxy leaking into like buttons/etc. You can actually build small "dams" or ridges to hold the liquid out of the places you don't want it, or simply use caution and some cotton swabs to ensure you keep those areas clean. Possibly a better method is to construct these ridges out of hot glue. It is also very handy to quickly put a dab of hot glue to hold something where you want, then epoxy over the top. Hot glue will stick to plastic or PCBs, but it is easy to pull off cleanly with no residue after. You can drop the glue, then a couple seconds later it is cool enough to touch and you can form it with your fingers to the desired shape. DO NOT do that with epoxy, you will regret it!!

Ok now to start, you need to fully disassemble the controller and put all the components into a container for safe keeping. The first consideration to take is how you will later program this chip. Normally you might install a full ISP 6 pin plug like the Uzebox console has, but I found this is significantly more work to route wires. Instead we can rely on the fact that all the wires required to program are also connected to the SNES plug wires...except the reset pin. So if we can just give access to the reset pin without disassembling the controller, we can plug wires from our ISP to the controller plug and this extra reset plug to program it. This is the method that will be shown.

If you are doing this at some point in the future that the firmware is "finalized" you could take a chance here and simply program it first before installing it. I would not recommend this but it is an option. You could also probably fit a DIP8 socket and solder to that instead allowing you to take the chip out later and reprogram it. I think this is not very convenient, requires extra parts, and you might struggle to find enough clearance for the added height.

Now that you have the controller apart you will want to cut off excess controller wire and leave about 6 inches to play with. Carefully strip off the sheathing to expose the individual wires. We will trim these down later when we have the wires routed and our location for the MCU decided. You should see something similar to this when you are done:

Disassembled n64.jpg

I want to find a spot for a reset female header so that I can program this later. The SNES plug does not provide enough wires to fully handle the ISP connections, so this is necessary. After some visualizing, temporary hot glue, and reassembling to make sure it fits, I chose this location for the hole:

Hole location.jpg

Now I drill through with my rotary tool using a steel bit. Anything small should work. If you do not have this available you could simple drill 2 small holes next to eachother and trim with a razor or other such objects. Be careful with this part. I chose to wash off all the plastic debris so I could get a better view before I cleaned up the hole to look nicer:

Hole bottom view.jpg

Next I need a way to hold the female header pin in the location I want to epoxy it to. You'll notice I used 2 pins instead of 1. The only reason for this is that I find it more difficult to hold a single in place and 2 provides a little more surface area to work with. I use some normal desk tap and shape it onto the bottom side of the controller then place the header pins on top of it and rub it on until it is secure where I want it.

Hole taped.jpg

Since my intent is to have a strong bond using the epoxy I must consider that the epoxy absolutely will break through the tape bond to the header pins(if we are using the liquid type) and could potentially get in the hold of the header causing me a headache later. In this case I used some thicker rubber type adhesive and pressed it into the sides where the hole is bigger than the header. You could also use hot glue or thicker epoxy. Alternatively you could just plug these holes up with something.

Reset plugged.jpg

Now with the holes safe, I pour epoxy over the top of the whole works. Be careful not to use too much at once as it can quickly get out of control and start running towards the Z trigger button mechanism. Also, be careful not to pour epoxy directly on top of the header pins as it can leak through the backside down into the holes and the contacts inside will be ruined. Remember that you can always apply a second thin coat later if it is not enough and it is easier to deal with a smaller amount at a time. I would always keep some cotton swaps(the kind you clean your ears with) on hand so that you can quickly dispatch any runaway material in short order. The cotton stops it in it's tracks, but will leave behind some residual cotton strands. Epoxy needs to be ground off when it cures, that is, it is harder than plastic to remove. If any gets into the buttons tracks they may never feel quite right or even stick which would ruin your whole project.

Reset epoxy.jpg

You might notice I made a mistake and got some epoxy on the rim of where the 2 parts of the controller come together. This is not good since when it cures it will not allow them to sit flush together. I don't use a cotton swab here because I don't want cotton left behind. Paper can be used to smooth a small amount over a large area or a damp paper towel. You need to work fast because it will quickly bond to he point that you cannot get it all off and will have a permanent residue. In this case I manage to totally remove all evidence it ever happened! Later when I get my soldering iron ready to go, I will solder that reset wire to both of the pins.

Now we need to prepare our MCU to fit inside for easy soldering. Trim about 1/8" off the legs of your DIP ATTiny85 then bend them over like this:

Bent pins attiny.jpg

Next we will need to analyze the best spot to secure our MCU to. The best spot is the place that has enough clearance to close the controller back up properly while also allowing the wires to be routed in an easy manner that is not too close to posts, screws, or moving buttons. This may vary if you are using a different model controller. In this example I determined this was the best location for it. It might appear easier to put this into the bottom half of the shell, but I did not want too many wires stuck to the bottom that might make it more difficult to reassemble or take back apart later. I quick check the pinout of a N64 controller versus the cord that I cut off earlier to determine my VCC, GND, and Data pin colors. Now I run these PCB wires over to the general area of my mcu to do a "sanity check". I secure them with hot glue for now in case it doesn't work out.

Mcu location.jpg

I secure the MCU down with hot glue, then tuck the excess wiring through the hole that I took the Z trigger button out of. I put everything back in place and do a test fit. The hot glue rises the MCU slightly above the board simulating any small soldering blobs I might create later. If things do not go together easily then move the MCU around until it does. Remember hot glue is easy to pull off a PCB and leave no residue. Later I will route the wires from SNES extension cable that I repurposed for this, but it is easier to do 1 thing at a time. You should definitely label the pin numbers on the MCU before you turn it upside down and secure it to avoid error and headaches:

Wire routing.jpg

Now with all the wires in the general vicinity of the MCU, it is just a matter of cutting them to a good length, carefully stripping, and soldering them to the appropriate pins following the schematic. It is a VERY GOOD IDEA to triple check continuity of all the pins to the respective locations on the SNES plug, as well as making sure nothing has continuity to more than the place it should which indicates a solder bridge was formed and needs to be fixed before we go further. Once I am satisfied with my wiring, I glaze some epoxy in a couple key locations to keep my wires secure. I do not put epoxy near any plastic legs/standoffs or screw areas in case I need to adjust things slightly. Do another test fit and make sure your wires are good after this:

Ready for assembly.jpg

Now before I close everything up I want to make sure everything is working. I program the chip(as described later on in this document) and run the controller tester to make sure everything is functioning as intended. At this point I glaze epoxy over all the wiring and over the MCU itself to provide mechanical strength to the solder points during future drops, bends, rough handling, and whatever else it might encounter. It also provides electrical insulation between the pins incase some of your solder or copper wire fibers are pretty close together. Now everything will simply not move and I do not need to worry about reliability problems in the future.

Voila! Now we have ourselves a nice N64 controller we can use with Uzebox game! Give yourself a pat on the back for the successful build!

Reassembled n64.jpg

As you can see I chose to customize this one with some left over vinyl stickers and a sharp scissors. It even makes for a great gift for a friend!

Serial number n64.jpg

Inside Plug Method

What It Is

Programming This Beast

If you decided to wire in your own ISP plug then you don't need this section obviously. If you did the inside plug method or the inside controller method as recommended then it is simply a matter of connecting the appropriate pins off your ISP with jumpers to the SNES plug. The only ping that might be different across builds is the reset(purple line in diagram). Make sure to connect reset to whatever method you used to expose this pin, if you put an extra pin the the SNES plug(requires disassembling a second extension cable) then connect exactly as shown. It would be wise to do this test before you totally epoxy everything together while you can still make changes.

Snes isp.jpg

It should be noted that the ISP will not actually power the device. You would need to connect in parallel a +5v source and Ground for this to work. You can use a breadboard or just tie some jumper wires together. You could also power this from your Uzebox, but you would need to make sure the program running isn't doing anything with the controller ports that might mess up the flash!!

Now it is just a matter of programming the latest firmware found in this thread onto your device. You might also with to upload the controller tester to your Uzebox to make sure everything is functional.