Sunday, June 4, 2017

Bluetooth Game Port Receiver

A few months ago 8Bitdo released an Apple II coloured version of their PRO GamePad Bluetooth controller along with a receiver that can replace the need for an actual Apple II joystick I love their controller but the receiver was initially implemented without the full analog range which is required by many Apple II games. I believe they have now released a firmware patch which addresses this issue but it makes me sceptical. Is the receiver's hardware design as polished as the product presentation and packaging? I started building my device without knowing if 8Bitdo were going to fix their receiver. This project was never an attempt to make a competing product but to use this as a stepping stone to build bigger and better things. That's the beauty of being able to make something yourself, you can customise it to do whatever you like.

There is no mystery as to how to hook up a wireless controller to the Apple II. It's just a simple extension of RetroConnector's "USB JOYSTICK INTERFACE FOR APPLE II" product ( which has been out for years. Add a USB Bluetooth Host dongle, a HID game controller and a bit of extra code and you're done. If you wanted to stick with the AVR/Arduino theme then the Bluetooth code can be located at and the write ups can be found on and Alternately there are several other embedded USB hosts around which could be used. For example do a pic based one.

I wanted to build a Bluetooth receiver myself because the task did not look all that difficult, I would have full control of how it would work and because I was looking at playing around with a USB host for another project anyway. Initially I looked at using a single Bluetooth module to do the Bluetooth part and the Apple II game port signal processing all in the one chip but it looked like quite a bit of work since most chip manufactures lock down the Bluetooth part due to proprietary and regulatory radio interference reasons. I ended up deciding that the FTDI's Vinculum-II (VNC2) would be a good compromise. The package version of the VNC2 that I obtained (64pin module) is over kill for this project since I'm only using six Input/Output pins but its size will come in handy on my next project. Using FTDI's examples, I was able to get the game controller working using the USB cable method within an hour or two of trying. The remaining part is to write the Bluetooth driver for the VNC2 or port the one from the Arduino platform. This is still a work in progress.

In terms of my hardware design there were two parts to get working, the digital part and the analog part. The trigger buttons are the digital part which is just the result of digital outputs from the VNC2 controller. However because the VNC2 is a 3.3V chip a level converter was required. At first I just tried using a low forward voltage drop diode and a 330ohm pull down resistor but this wasn't enough to register a trigger on the Apple II side. I had a 4066 chip laying around and I used that to make the triggers work. I'm not confident that this is the best way to do a level shifter for the Apple II Game Port. The analog section (X and Y joystick axes) could have been implemented using pulse width modulation (PWM) feeding a low pass filter however I chose to use the proven method instead. Like the RetroConnector option I went with using the Analog Devices' AD5206 chip which contains six virtual/digital potentiometers in a 256 position ladder divider type implementation. I may still implement the PWM option to see how it compares. I thought that the Serial Peripheral Interface (SPI) communications between the AD5206 and the VNC2 would be straight forward since the VNC2 comes with an SPI code library and examples however this is only valid if using 8bit data packets. The AD5206 chip requires an 11bit data packet so I had to bit bang this information out of the VNC2 instead. On the Apple II a single joystick axis requires a 150k potentiometer but the AD5206 chip only comes in 10k, 50k and 100k configurations so on the RetroConnector product two 100k virtual potentiometers are used and then software scales this back. To do the same job I take one 100k virtual potentiometer and effectively scale that to 150k by using extra capacitors (RC network on the 555 timer chip). Since this is already documented I'm not going to reproduce that here. A good explanation can be found on Quinn's blog After doing the calculations I found that they were slightly out for real world conditions but it did give me a good starting point. I added a diagnostic mode to my Bluetooth receiver which helped in getting the required results. I can fine tune it pretty well however each of my Apple II computers needs slightly different values. Even the x-axis and y-axis setups differ.

I'll add the schematics and code here when I'm done.