Tupperware Arcade Controls

Posted by on May 8, 2009 in avr | 28 Comments

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

28 Comments

  1. Snapel
    8. May 2009

    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!

  2. Marcus
    8. May 2009

    AWESOME! Cool that you mastered the USB stuff: Take some casing like this: http://de.rs-online.com/web/search/searchBrowseAction.html?method=getProduct&R=3439489 – they look great when polished!

  3. Alex
    9. May 2009

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

    @Marcus, they look great. But not cheap.

  4. Alex
    9. May 2009

    Oh, I just realized, Tupperware is already a common enclosure for arcade controls.
    http://www.techeblog.com/index.php/tech-gadget/ps2-arcade-stick-made-with-plastic-storage-container

  5. d.i.y. tupperware arcade stick « HIRNWICHSE (ヒルンビクセ)
    9. May 2009

    [...] Videospiele??? =)))) Sobald mein vollgestopftes Semster überstanden ist, bastel ich mit so einen Tupperware Arcade Stick und gönne mir einen gemütlichen 8-Bit Abend! Der Aufbau erscheint mir soweit recht simpel und die [...]

  6. Tom
    9. May 2009

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

  7. Alex
    9. May 2009

    Hi Tom,
    it’s a mash up, done by Miss Cyberpink.
    http://cyberpink.wordpress.com/2009/03/26/like-a-phoenix-from-the-flames/
    Cheers,
    Alex

  8. Ross
    12. May 2009

    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

  9. Alex
    12. May 2009

    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

  10. Control Arcade con TupperWare : Tech-Freaks
    19. June 2009

    [...] duda un proyectito interesante que puedes checar en el blog del del autor: Aquí tienes el enlace. [...]

  11. Bakamoichigei
    22. June 2009

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

  12. Brian
    12. July 2009

    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

  13. Alex
    12. July 2009

    Hi Brian,
    it might be difficult to port this circuit to an Arduino. The Arduino firmware interferes with the v-usb stuff, I think.
    Maybe check the forums at http://www.obdev.at/products/vusb/index.html for more info.
    Cheers,
    Alex

  14. Enrico Tramacere aka bongy
    13. September 2009

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

    Thank you, cheers.

  15. Alex
    13. September 2009

    It was the one of the SNES joy pad.

  16. Jake
    21. March 2010

    Can you tell me the purpose of the Capacitors in your schematic, thanks.

  17. Alex
    21. March 2010

    These are by-pass capacitors to filter voltage spikes.

  18. Jake
    21. March 2010

    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.

  19. CarlV
    31. August 2010

    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

  20. Alex
    1. September 2010

    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

  21. CarlV
    1. September 2010

    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.

  22. CarlV
    10. September 2010

    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.

  23. jjj
    5. November 2010

    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?

  24. Anjan
    9. June 2011

    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!

  25. Anjan Bose
    9. June 2011

    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

  26. anjan
    10. June 2011

    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

  27. Alex
    11. June 2011

    Hi Anjan,
    you could use the fusecalculator to see what the hex values mean.
    http://www.engbedded.com/fusecalc/
    Cheers,
    Alex

  28. anjan
    13. June 2011

    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