Introduction: C64 USB Joystick Adapter
Programming the microcontroller and testing the joystick with WinVice and International Karate:
Step 1: Tools
See the images for some useful tools for this project and consumption items for soldering: soldering flux, solder, and desoldering wire. A cotton bud is useful for applying the soldering flux.
I recommend a good regulated soldering iron with a 1 mm tip for the SMD parts, like my i-CON 1. The easiest way to solder it is a stereo microscope, but magnifying glasses works, too. But with some practice, the SOP-20 IC needed for this project can be soldered without any magnifying.
Step 2: Parts
The parts list:
C1, C2: 1 uF
C3, C4, C6: 100 nF
C5: 10 uF
IC1: MCP1703CB, Digikey MCP1703T-3302E/MBCT-ND, 0.52 €
IC2: MC9S08JS16L, Digikey MC9S08JS16LCWJ-ND, 0.92 €
IC3: 8 MHz crystal oscillator, Digikey CW515CT-ND, 2.20 €
R1, R2: 33 ohm
R3, R4: 1 k
R5: 1 k
RED-LED: 5 mm LED, 0.20 €
BLUE-LED: 5 mm LED, 0.20 €
S1: programming momentary button, Farnell 1550254, 0.88 €
S2: on/off switch
X1: USB connector, e.g. Farnell 1654060, 1.22 €
X2: sub-D, 9 pin, e.g. Farnell 1653939, 0.33 €
See the images for some of the parts. For the momentary button I like this type, stable and nice to press. For the PCB I have used the type with soldering points on one side, you can get it cheap at eBay. For connecting the USB connector, I have soldered thin wire, 0.4 mm silver-plated copper wire, and for mounting the USB stick I have soldered thick wire, 1 mm silver-plated copper wire, which I soldered at the four outer contacts of the USB connector, which is pretty stable. For the SMD IC you can get cheap adapters from eBay. So without the wire coils, in sum you can build it for less than 20 €.
Step 3: The Board
See the images for the soldered board and the schematic. Eagle schematic file: http://www.frank-buss.de/joystickadapter/eagle/joystickadapter.sch
Step 4: The Software
The developing environment
Freescale provides a free IDE, CodeWarrior Development Suite - Special ( http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=CW-SUITE-SPECIAL ), which is limited to 32 kB, but the chip has only 16 kB anyway, so this is no problem. The microcontroller has an integrated bootloader, so no programmer is required, just the "BOOTLOADER_GUI" from http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=S08JS&fpsp=1&tab=Design_Tools_Tab .
http://www.frank-buss.de/joystickadapter/firmware.zip containts the project file for Code Warrior and all sources. It is based on the keyboard example from the Freescale USB Stack. You can change the switch detection for other types of joysticks in main.c and the key event generation in keyboard.c. The HID protocol is not based on key-press and key-release events, but you have to fill the HID buffer each time it is called with the scancode of all keys currently pressed.