Tupperware Arcade Controls

If you want to play some retro arcade games, you will install the amazing MAME and run your favorite ROM. One of my best-of-all-times is Bomb Jack.

But you have to play it with the keyboard. Bah!

Or an USB game pad. Better, but still — bah!

Nothing compares to real arcade controls. And with a bit of tinkering, you can get a tiny step closer to the real gaming experience.

USB HID

HID stands for Human Interface Device class. Common devices of this class are keyboards, mice and joysticks. The great thing, that this interface brings in, is, the devices don’t need a specific device driver. If they behave according to the USB HID spec, then they are automatically recognized by all OSs. Every device sends a report, in which it states, which kind of device it is and how it wants to report its data.

The next great part is the fantastic USB driver V-USB that is developed by Objective Development. This driver can be run on most of all Atmel AVR controllers, even on ATtinys. It does not require any other chip, only a couple of standard components. The library is licensed under GPL, a commercial license is available as well.

Needed components

I ordered my arcade controls at ArcadeShop.de, a german shop for Arcade parts. The joystick is great. Heavy and solid. And makes nice clicks.

The buttons, that I ordered are ok. They are working fine but seem to be a bit too small. They have a diameter of 27 mm. Next time I would take bigger ones.

Nothing special about the rest of the needed parts. A breadboard, an ATmega48 and a couple of resistors, capacitors and diodes. And of course a plastic box as enclosure. Keeps the electrons fresh. BTW, mine is not Tupperware, but super cheap IKEA.

The circuit

The circuit is almost one of the standard setups, that Obdev recommends. I used 47 Ohm instead of 68 Ohm for R2 and R3 because I had them laying around. The two 1N4148 diodes reduce the supply from 5 V to about 3.6 V. This is a “poor mans” voltage regulator. A better solution would be a low drop 3.3 V voltage regulator. But for prototyping the two diodes will do the job.

First I tried to run it with a 16 MHz crystal. I thought that it should be enough to change the F_CPU setting, but that didn’t work out. The device was not recognized. When I switched to the 12 MHz crystal it worked almost at once.

All controls, the stick and the buttons, are connected to the controller and to ground. Therefor the internal pull-up resistors have to be enabled.

Firmware

The firmware is based on the examples provided at the V-USB page. Two projects, that I played with are the HIDKeys example and the SNES-Joypad. The first one is used to build a simple keyboard. The second was made to play emulated SNES games with a SNES pad.

The biggest problem was to find a matching USB HID report descriptor. This descriptor is used to tell the PC, what kind of device is attached to the USB port and what kind of data it sends. At the moment I am using the “Game Pad” device class.

Conclusion

This is a work in progress. The plastic box works but is way too wobbly. It was more of a joke. The next version should have a more sturdy enclosure. And the circuit should be more permanent and not that place consuming.

I am planning to have a two player version (Gauntlet!). For that I am still unsure, if I should switch to the USB-HID keyboard class. Or maybe implement two gamepads with one controller. We will see.

Over all, it’s great to play some of the old games again. Even if this is nothing compared to a real cabinet.

Links and Downloads

29 Comments

  1. Awesome! I would like to see it in smaller dimesion. Maybe on custom made PCB? Or Even better! In your shop, to buy as a kit!

    Like

  2. @Snapel, a custom PCB? I will look into that.

    @Marcus, they look great. But not cheap.

    Like

  3. Hey, great work !
    Btw, what is the song name you’re playing ? thanks for the answer in advance.

    Like

  4. Good stuff!

    I have a question regarding the snes usb though, i’m fairly new to microcontrollers and i tried the code from the ralphnet.com to get the snes pad working but as i recall i had problems with fusebits.

    My question is, i’v downloaded your stuff for the snes usb, do i, just burn the firmware.aws onto the atmega 8 and connect it up?

    My main source of confusion with this is the usb bit, i tried just copy and pasting the main.c into a new project and burning it but it didn’t work.

    If you could help me that would be brilliant.

    Cheers,

    Ross

    Like

  5. Hi Ross,
    my circuit just uses arcade controls as switches. The SNES has a bit of cicuitry in it (I think), so my code will not help you with that.
    Cheers,
    Alex

    Like

  6. I actually bought a little board a while back that does exactly this does, but I think it used custom chips… Knowing you can do it with an AVR, it makes me want to take a closer look at the board. (Besides the fact that I have to make my own now, just because!)

    Like

  7. Hi Alex,

    My wife saw this and I now have to build her one, have been trying to get this to work on an Arduino @ 16MHz for the last 3 weeks and it’s driving me crazy…it might help if I knew something about programming.

    Brian

    Like

  8. Hi Alex awesome concept…where did you find the gamepad report specification, the ones used into the usbHidReportDescriptor array ?

    Thank you, cheers.

    Like

  9. Thanks for that info, I am new to all this and that part makes sense to me now. As for the arduino question asked above, I thought it would not work because of the FTDI serial connection that is used on the arduino.

    Like

  10. Alex,

    Tried your schematic, used a 12mhz crystal but your fuse settings don’t look right, shouldn’t the low be 0xdf instead of 0xdd ???

    I’m using an AVR ISP programmer and an atmega48-20AU, used 68ohms and 1.5k resistors, 27pf on the caps to the crystal instead of 22pf’s as all I had were 27’s and that should’nt matter.

    I appears to program okay, tried your fuse settings and also tried 0xdf as well, same results…. then when I plug it in, the system just says unrecognized deviced and keeps looping and repeating until I unplug.

    Can you reconfirm your fuse settings, also what is your exact version of atmega48 that you are using? Are you using an external 16mhz or 12mhz crystal (I don’t have any 16mhz)

    Just doesn’t seem to be working for me.

    CarlV

    Like

  11. Hi CarlV,
    0xdf or 0xdd should make no difference, as it’s only enabling the brown out detection. It was a standard atmega48 and I used a 12 MHz crystal.
    Cheers,
    Alex

    Like

  12. OKay, maybe I goofed up elsewhere, I’ll try again from scratch and build another and see if I can get things going, thanks for the quick reply.

    Like

  13. Alex,

    I have tripled checked, I think I am compiling it wrong and that is where the issue is, could you repost your mame-controller.zip and include a compiled .hex file that I could test with, at least then I’ll know I got the h/w portion right, thanks very much.

    Like

  14. Hi Alex… Why are you powering atmega at 3.6v? It’s just for protection that you are using the diodes, or there is some reason why you can’t use the VBUS 5V to power the atmega?

    Like

  15. Hi Alex
    Would you be able to mail me the hex file for this? Alternately can you guide me to create the same under AVR studio 5?
    I had communicated to you earlier on another project (8X8 matrix project) and really appreciated your quick response that time. At home I use a MAC and could compile the file very easily with AVR studio but dont have the software any more. What would be the easiet way to do it on a MAC. really appreciate your help with this.
    Anjan
    BTW, i have already got the joystick and the buttons, so really excited to put this together. Keep up your good work!

    Like

  16. HI Alex

    Managed to compile the file. I used your make file this time and compiled using the avr tool chain within avrmacpac. Works fine. I need to try out the circuit though after flashing the controller.
    will keep you posted once i have assembled the circuit

    Cheers

    Anjan

    Like

  17. Hi Alex

    what fuse settings should be used if I program using AVR studio and using AVRISP interface? Can u please advise the external crystal oscillator frequency and the start times?
    I am not using avrdude so the hex values of the fuse as indicated in the makefile does not give easy indication of those

    best regards

    anjan

    Like

  18. Hi Alex

    Thanks very much for this. Actually I had visited the site before and did not realise that one could also input the hex values to convert them into the individual settings. Thanks very much for enlightening me on this! I will try the code and the hardware very soon.

    cheers

    Anjan

    Like

  19. Your video is wonderful: the 8-bit sounds and the hand’s movements are touching.
    Thanks for sharing your project!

    Like

Comments are closed.