Forum Updated! 

Main Menu

'Super' Supergun

Started by Hojo_Norem, August 15, 2007, 09:25:26 AM

Previous topic - Next topic


Currently a work in progress...[/size]

I've been toying round with microcontrollers recently (specifically the Atmel Mega8) and after having successfully made one working project based on one (a infra red recorder+repeater for LaserQuest) I thought I would have a go at something I have been wanting to make for a long time:

A SNES control pad compatible SuperGun!

At first I was going to just do a straight SNES>JAMMA translation but then I thought if I'm using a micro why not make it so I can switch between 3 button with dedicated autofire or 4 button MVS compatible with autofire toggle?  Then I thought one step further, why not just be able to remap any of the SNES buttons to any of the JAMMA buttons?  With multiple mappings for different games?  Sounds complicated, but I have figured out a way of making it relatively simple: Each SNES button would have a bit pattern associated with it that corresponds to the JAMMA inputs.  Normally each SNES button would only have 1 bit switched on but there would be nothing stopping you having more than one bit switch on.  EG:

UP would be:100000000
Button 1 would be something like:000010000
Button 2 could be something like:000000101 (two JAMMA inputs active) etc...

all that you would have to do would logical OR the mapping of the pressed buttons together and then output the result to the JAMMA inputs.

The only real complex part is working around the Mega8's limited number of IO pins but I have figured out how I would do that.

(will insert badly drawn schematic here when I get my scanner working again)

Essentially I will be using one of the Mega8's (I'm just going to write 'avr' from here on) 8bit IO ports along with 3 pins from another port to use as LATCH, CLOCK and RESET signals.  How it will go is the avr's portD (a full 8 bits of IO) will feed into a number of octal latches (I have some 74373s lying around).  The LATCH signal will feed via a AND gate per chip into each of the latch's latch pin.  The CLOCK and RESET signals will feed into a counter whose outputs will be connected to the AND gates so that each latch can be addressed in turn via the CLOCK signal.  When all the latches have been served then the counter is reset and the process is restated.  To finish the interface off the latched will output into a bank of 7407s before reaching the JAMMA interface.  The 7407s also make it easy to operate the various indicators what will be present.

EDIT: I will use 7406s instead.  The 7407 is a hex buffer with open collector while the 7406 is a hex inverter with open collector.  With the 07s the latches would need to be initialised to all 1s before normal operation could continue as if I didn't all the JAMMA inputs would be closed on switch on briefly.  With the 06s I don't need to worry about this and I don't need to invert the output from the avr in the code.  It also means that any indicators I am going to use become active high in the eyes of the avr.

The good thing about doing it this way is that it retains a bit of speed and it is easy to add more outputs, for front panel indicators, etc.

Video output is going to be a plain RGBS output and I'm still deciding whether I need to do any alteration to the audio signal.  Power is going to be supplied via a 12v 50w psu built into the case with a additional +5v 5amp regulator stage.  The SNES pads will connect via SNES pad sockets salvaged from a stripped down SNES(read: the case was so cigarette smoke stained that I just kept the motherboard and connectors) and the front panel buttons will be interfaced using the same chip used inside the SNES pads (if the interface works, might as well make the most of it).  I plan on having a 7 segment led display to show which mapping is currently selected and I have some nice light up push buttons.  The box I will be using is just slightly smaller than 2 MVS cartridges led on-top of each-other so there should be plenty of room if I ever want to add more gubbinz to it in the future.

The last of the parts arrived today:
The parts.
From top to bottom there are LM338T 5amp adjustable voltage regulators with a heatsink and a 5Kohm pot.  Under that there is the 12v 3.8A switchmode psu, small enough to mount unmodified inside the case underneath it.  Along with that there is the 7 segment led display along with some veroboard, the hacked up SNES pad port, a JAMMA connector, various connectors and pushbuttons along with most of the decoding and latching logic sitting along with the avr on some protoboard.
Formerly 'butter_pat_head'


Heres an update, I decided to get the outside of my supergun done first.  Now I don't want to mix another batch of epoxy or touch another file again!  :lol:
Outside of supergun
Formerly 'butter_pat_head'


Well, the 5v psu finally arrived so I thought I'd get the power supply, audio and video sections done.  All I need to do now is finish writing the interface code and build the SNES>JAMMA circuit.
Nearly there...
And here it is running Golfing Greats.
Testing Golfing Greats

A observation I have made:  The 5v psu gets quite warmer when connected to Golfing Greats (A Konami GX061 board) than when it's connected to my MVS, but the picture on my MVS is less stable, a slight waving effect that's barely visible on my Panasonic CRT, but shows up greatly when played on the Sharp LCD shown in the second picture.  The +5v measures at roughly 5.23v.  If I could find some reliable way of filtering this down a tad I guess that would solve that problem.
Formerly 'butter_pat_head'


I like the way that's so clean inside, good work.


Still going at it:
Board in production...

Theres been a few slight design changes.  First of all I wasn't too happy with the 5v supply getting very hot to touch.  This has been solved quite cleanly.  The engineer at my local Laserquest gave me a proper arcade psu. +5v @ 15A ~adjustable~, -5v output if I ever need it and its earthed.  Its a biiiit bigger than the psus I was currently using, but I got it to fit nicely in a separate instrument box, the exact same type as the one I'm using for the rest of the gubbins. (pic to follow soon).

As you can above (hopefully see, as long as the clacks are working in your part of the world) this is a image of the main decoder pcb in the manufacturing process.  In the end I decided to design a board and get a PCB manufacturer to make it.  Double sided to boot!  Good thing as well because when I saw the end result of the routing I thought "I was going to make THAT on veroboard!?" ^_^

I have been able to reduce the number of ICs by one by swapping the counter+and gate latch addressing circuit for a single 2-to-4 demultiplexer.  Anyhoow, now that the psu has it's own box I have a lot more room to play with inside the main box.  I might even consider adding a s-video encoder.
Formerly 'butter_pat_head'


I really like the design of your Supergun. I'm going to build one myself soon and was wondering what case and power supply you are using?

I'm looking for a tabletop power supply to help keep things clean with my design.

Keep us updated. I would like to see where this goes.



Quote from: sparky on September 18, 2007, 05:22:11 PM
I really like the design of your Supergun. I'm going to build one myself soon and was wondering what case and power supply you are using?

Thanks.  The cases I am using are 'ABS Plastic Instrument Case' from Maplin and the power supply is a arcade one.  I don't know the make of it but it just fits into one of said cases.

Anyhoow, the PCB arrived today and I already have started stuffing it with parts:

And heres the revised outside look:
With PSU attached

Theres a panel to attach to the front of the bottom before its finished, thats live mains in there!

As I mentioned earlier, the psu has a adjustable +5v line.  Need to change it?  Just pop the bonnet...
Adjusting the 5 volts
Formerly 'butter_pat_head'


Pretty cool dude. So are you planning on selling those PCBs?


Quote from: XianXi on September 23, 2007, 02:05:13 PM
Pretty cool dude. So are you planning on selling those PCBs?

Heh, thanks! ;D  I haven't any plans on selling the PBC primarily because I don't have the money to support such a venture.  I am however planning on releasing all the relevant files once I have finished.  The PCB has gone through a few changes to get it to work properly (detailed below...) and I'd rather release working schematics and code rather than broken ones.

Anyhoow, it is alive...ALIVE!
Supergun in test.

But not easily.  First of all I killed a snes pad because I connected the pad sockets to the wrong header on the pcb, causing 5 volts to be fed into one of the pad's data output lines.  Secondly the latch address circuitry had a fatal flaw.  The latches are active HIGH addressed while the demultiplexer used to address them has active LOW outputs, essentially achieving the opposite of what needed to happen.  This fault is caused purely due to my lack of experience in doing these things (this is my first major electronic project of nearly any kind).  I got round that by removing the demux chip and wiring the enable signals of the latched directly to the avr.  Why I didn't do this before finalising the pcb design I don't know....

Second problem is that I think I have gotten quite a few wires crossed while wiring up the control signals between the pcb and the JAMMA connector.  Fixed in software thankfully.

ATM the pcb is running a test firmware (hence the 't') that has a single mapping and only supports one controller with no rapid fire.  With the avr running at ~8MHz the response time between pad and JAMMA is visually instant.
Formerly 'butter_pat_head'


I'm really excited about your project.  I look forward to the finished results.


Small update.  The firmware is nearly done.  In addition to the 7 user definable mappings there are two hard coded ones, one fairly standard layout for both pads and a joke one where one pad controls both player 1 and player 2.  Perfect for playing 2 player Metal Slug with yourself! :D

Anyhoow, I brought the gear into work today for a 'endurance' test.  Make sure the PSU and PCB can operate for a few hours straight without problem.  Its been nearly 3 hours so far and no problem...
Further Testing...
Formerly 'butter_pat_head'


Hi.  Ive not been able to work on the supergun for a while so I have decided to release the materials for those who want to look at them.  The firmware for the avr is in a working state but none od the special features are coded yet and the pcb needs a few patched to get it to work under the current firmware.

Anyway here it is: snes_supergun.rar (77KB)

If anybody decides to make this themselves without looking it over and making the appropriate corrections to the schematic and pcb then here are the quick patches to get the unmodified version going.  Don't bother with the 74hc139 and 4021 ics.  Instead connect pin 2 to pin 4 and pin 3 to pin 5 where the 74hc139 would be, connect pins 9 and 10 of the avr to pins 6 and 7 of the 74hc139.  Then connect pin 7 or 6 to pin 3 where the 4021 goes. (pins 7 and 6 run to the front panel connector.  One is used for the map change button).

On a side note, the supergun passed the endurance test at work with no problems and then survived multiple two player sessions of Metal Slug with my brother... ahh fun times... ^_^
Formerly 'butter_pat_head'


wow, talk about do it yourself



It's been a while but I've decided to strip down and re-build the SuperSuperGun as I wasn't entirely happy with the tacked-on look of the psu.  Also I'm re-designing the SNES controller interface.  Where I was using a load of latches to make up for the Mega8's lack of IOs now I'm using a Mega664.  A little overkill but its something that Iv'e had lying around for ages.

The Mega644 is a 40 pin device and has gobloads of IOs so no latches are needed to be able to service 2 players (2 coins, 2 starts, 2 sticks, 8 fire buttons and one test button).  In theory the JAMMA control inputs can be connected directly to the uIC.  The IOs can be set to inputs with the internal pullups disabled.  That would produce a Hi-Z state similar to the 7406s I was using earlier.  TO produce a signal all I would have to do is activate the relevant IO's pullup resistor,  causing a drain to GND and activating the JAMMA input.

I'm not going to do it that way.  I don't like the idea of directly connecting the JAMMA inputs to the uIC so I'm going to use simple transistor buffering on each JAMMA input.  This will greatly reduce the amount of current that the uIC would possibly have to sink if it was directly connected.  It also makes the uIC's code easier.  Rather than having to muck around with resistor pullup registers (or the latches from the old version) the code will work on a direct 'IO=1 > JAMMA Pin=1' that will make implementing the (still to be written) programmable button mapping code a bit easier.  Also the circuit should be quite doable on good-old veroboard.  while the number of parts has increased (all those transistors for the JAMMA inputs) the number of ICs has been reduced to two, the main uIC (the Mega644) and a 8 bit serial shift register with parallel outputs to run the segmented led display.

I've decided to relocate the AV segment of the supergun to it's own smaller enclosure.  Space won't be as tight so I can get away with using 2 isolation transformers for the audio and have proper switching to isolate the JAMMA mono audio when the stereo flylead is in use.

Finally to really put the 'Super' in SUperSuperGun I am building it all (excluding the mentioned AV box) into a PAL Super Nintendo case.

Images to follow...
Formerly 'butter_pat_head'


Well here are those promised pictures:

I'm going to add some darkened transparent plastic over the segmented led display to take a little of the glare out of it and I'm still looking for some suitable plastic grill like stuff to go into the cartridge slot hole.


The main interface board is pretty much done.  All I need do now is build the display driver board (one IC and some resistors) and make the various connections.  Then its firmware writing time.  Street Fighter II style kick harness support is possible, I have enough IOs spare to drive a second serial>parallel shift register to handle the 4 extra buttons and I still have enough wires available inside the main JAMMA harness cable to carry the signals.

If you are wondering about the large resistors on the interface board, I got a little mixed up when ordering them.  Beyond their size they are regular 1KOhm resistors and I wasn't going to waste them so I ended up stacking them on top of each other to get them to fit while the emitter stages of the transistors are sticking up with a bar solder across them to provide the GND plane to them.  Still I found it simpler than trying to wire up several ICs...

BTW, the donor SNES was a working unit so have kept it's PCB stored away save and sound  ;)
Formerly 'butter_pat_head'


Still working on it.  Learned that SNES pads need to start the read cycle with the clock line HIGH and that the ATMega644 comes with JTAG enabled by default, making half of port C useless and rendering the player 2 controls inoperable!  I spent half a day on that one...

Now I'm tackling the shift register that drives the display.  At the moment all I can do is make the top segment blink while the others remain stuck on.  I need to get this working because the kick harness support will rely on a shift register to extend the 644's IOs.

At least those transistor switches work fine and with the correct size of resistor (not the elephantine ones I bought by mistake) a reasonably small PCB could be spun.
Formerly 'butter_pat_head'