Interfacing

Gameport

The game port is a bit of computer history. Your computer is unlikely to have one, and if you asked the sales guy at your local big box store if they had a computer with one, you'd (at best) get a blank stare in response.

This section dates from the first incarnation of this site. I've left it here for those who are feeling nostalgic.

Back at the beginning of time a clever individual was looking for an inexpensive way to get analog inputs connected to a personal computer. Now, please understand that this occurred a very long time ago, so long ago that some computers were still made of hand carved, wooden transistors, so it should come as no surprise that hardware was very expensive indeed. Further, these PCs of yore were rather short of resources. They had limited processing power, and, just as today, IRQs were a sparse commodity. But one thing these antiques did have was a relatively accurate clock. What our clever individual determined to do was to use this clock to measure the time required for an unknown analog current to charge a known capacitor to a known voltage. If the current was constant, the time would be directly proportional to that current. Better yet, an integrated circuit capable of handling two inputs already existed, avoiding the need for more wooden transistors. The measurement technique was very simple. Software first wrote to a control register, clearing the voltage on the capacitor. It then polled the register until a bit indicated that the voltage on the capacitor had charged to some predetermined level. By referencing the starting and ending times of this process (or using a high speed system timer), the charging time, and hence the current magnitude was found. Only the most simple of ops: reads, writes and branches, were used, and the IRQs were left untouched.

There is a somewhat more prosaic truth to be known. A motivation for developing these analog inputs was to provide the means to play antediluvian games such as Pong. These games required moving virtual paddles on the game screen. The very early game interface consisted of a couple a knobs to be twisted by the players. Of course, the players were turning potentiometers, and the connector was thoughtfully configured to provide a five volt source. The potentiometer was connected from this voltage source to the current sensing input. Changing the resistance setting of the pot changed the current into the input, and the game was afoot. Now, this didn't make for the best of constant current sources, but it was close enough.

To supplement the analog inputs, switch inputs were added (the better to blow up foes). When it finally settled out, the game port had four analog inputs and four push button switches. Because the circuitry is so simple, today it is generally integrated into a sound card. Not infrequently, sound cards support MIDI, so you will often see game ports with two pins handling MIDI I/O.

Game port

Since game ports have their roots in the mists of time, should you be worried about them being a fading legacy port? Should you avoid building and interfacing custom flight controls to a game port? In answer to both questions: No.

It is true that there is a movement to USB, and that USB is much more versatile than the game port, but if you have one, go ahead and use it. The investment is virtually nil and the drivers already exist. Chances are if you do eventually decide to use USB, you'll be able to make use of the same potentiometers, so you will have lost nothing. Making use of an existing game port will simply get you in the air faster.

There is really nothing magical about interfacing to a game port. The buttons are simply single pole switches that connect from the button pin to ground, while the joystick axis pins connect to a 100 kohm, linear taper potentiometer which is in turn connected to one of the +5 pins. One precaution: the axis inputs are susceptible to electrical noise pickup. Do your wiring with shielded wire.

If you're interested in reading a bit more on the game port you might take a look at The Stickworks, and at Joystick Documents by Tomi Engdal.