Update: If you want to build one of these, I have added links to the various parts and code in the next blog entry.
Playing Apple II games on the original hardware is great and brings back fun memories of the 80’s and 90’s. But doing so can be challenging. Retro computer hardware is not small. It takes up space to store and to use. And the computers are not getting any younger so capacitors need replacing, disks are failing, bits are rotting (or something like that). I wanted to have the authentic feel of playing Apple II games using a vintage joystick but connected to a modern computer running an emulator. This is how the Apple II to USB Joystick Adapter came about.
Designing the circuit
The heart of the circuit is a Microchip PIC18F14K50. This is one of their 8 bit USB capable microcontrollers. It is a small pin count device which is exactly what I needed. I only needed to support two analog inputs for the joystick potentiometers and two digital inputs for the joystick buttons. Additionally, I added a status LED to one of the output pins.
Creating the Circuit on a Breadboard
After designing the circuit in Eagle, I built the design on a breadboard. This allowed me to verify the circuit would in fact work and also allowed me a way to develop the firmware for the microcontroller. The wiring on the breadboard was a mess but it worked in the end.
Programming the Microcontroller
I used Microchip’s MPLAB X IDE for writing the firmware and my trusty PICkit 2 programmer to burn the firmware to the chip. While the PICkit 2 supports the PIC18F14K50, it is not able to run in debug mode without an external header. I didn’t want to spend $50 on the header and I had already purchased the microcontrollers, so I made due with other debugging techniques like lighting an LED at certain points in the code and banging my head on the desk.
Microchip provides examples in their Microchip Libraries For Applications (MLA) download and this is where I started. I tried to create the USB descriptors using the USB specification. I could get the computer to recognize the device was attached and begin communication but it never fully worked. I finally based my descriptor off of one of the joystick examples in the MLA. Once I was successfully communicating with the computer, the rest of the code fell into place (getting the potentiometer and button values and formatting them for sending to the computer). I will be uploading the code to GitHub soon.
Designing the PCB
Next it was back to Eagle to design the PCB. I used a combination of manual routing and auto routing. There were certain traces that I wanted to keep isolated, such as the USB and clock crystal signals. So I manually routed those and then used the autoroutes to fill in the rest.
I went through several iterations to get the design how I wanted it to be. In between each iteration, I would print out the layout of the top copper and pads and make sure the actual components would fit the pads and with each other. When I was happy with the design, I used OshPark to order the actual boards. Link to the actual board will be provided soon.
Putting it Together
Next was to solder the parts onto the board. I started with the microcontroller as I figured that would be the most difficult part to solder. I used the drag solder method and it turned out pretty well. Oh, and I was wrong. The USB connector turned out to be the most difficult part to solder. The pitch of the pins was slightly tighter.
Creating a Case
Since I have a 3D printer, I figured I would design and custom case for the adapter. I have always used Sketchup but have been wanting to learn Fusion 360 for a while now so I figured this was the perfect opportunity. After a couple tutorials to understand how Fusion 360 works, I started putting it together. It isn’t the greatest design but it is functional. I had to print a few versions before I got it to where I wanted it.
I really wanted to find a way to make the LEDs easier to see with the case on, but ended up compromising on that. I put two holes on either side of the USB jack to allow the light to pass through. A better solution could have been using light pipes to send the light to the top of the case, or use through hole LEDs that would reach the top of the case. Or redesign the case altogether. Maybe later…
The adapter needs to be calibrated to the joystick before being used. This is done by holding down one of the buttons on the joystick while plugging in the USB cable to the computer. The red LED on the adapter will blink indicating it is in calibration mode. You then move the joystick to its full extents in every direction. Once that is done, leave the joystick in the center and press one of the buttons again. This completes the calibration and then the adapter will connect to the computer. This calibration is saved in the microcontroller EEPROM, so it doesn’t need to be redone unless it is attached to a different joystick.
Now to actually use the device! I predominately use OpenEmulator for Apple II emulation. I like the interface and it has worked with most of the games that I have tried with it. I use the compiled snapshot from archive.org so I don’t have to worry about compiling it myself.
The adapter has worked well. It feels much more authentic using a real vintage joystick. Funny how that muscle memory comes back after 30 years!