 |
The theory...
Interfacing arcade controls to a PC
I collected the background info on the PC joystick from several sites. I've
put them all here as none of the individual sites covered everything you
need to build a set of arcade controls. The usual disclaimer applies to
all information here... if you damage anything, then it's your fault, not
mine. :)
Building the circuits is pretty simple. You'll need the controls, some wires
and (100k ohm) resistors and a soldering iron. A multimeter also helps in
making sure you're hooking up the circuit correctly before soldering things
in place and for troubleshooting bad connections. If you're just after the
circuit diagrams, they're at the end of this document, but I've also included
some background info on how the circuits work.
How PC joysticks work
|
PC joysticks are typically simple. They are provided +5v and GND by the
joystick port, and feed provide each output on a seperate pin. A table
of pinouts and circuit diagrams for various joystick configurations are
included at the end of this document. Joystick buttons are simple on/off
inputs, while the x&y axis provide variable resistance for a range of motion.
Analog joysticks basically consist of 2 potentiometers (one for up/down and
another for left/right) and switches for the buttons. The potentiometers
provide variable resistance for the x&y axis. The up/left directions will
have lower resistance values than down/right ones.
Digital joysticks/joypads have 2 switches per axis which are wired to produce
3 distinct resistance values for up/left, center and down/right. The table
shows the values I used in creating the digital joystick circuits.
|
|
How the PC joystick port works
The joystick port is a very simple 8 bit interface which resides in ISA
bus I/O address 201h. The CPU can read and write to the joystick port I/O
address 201h. Writing to that address starts joystick postition measurement.
The joystick interface only uses the signal that somebody is writing to the
I/O address to reset the multivibrators in the card, so the value written
doesn't matter.
Reading a byte from I/O addess 201h returns the joystick interface's status.
The four most significant bits store the state of the joystick buttons. The
four least significant bits store state of the multivibrators which are
used for measuring the resistance value of the joytick position potentiometers.
To determine the value of each stick axis, this byte is polled until all
the joystick bits have flipped. When they have all flipped, the number of
polling cycles each one took to flip is proportional to the resistance on
that pin. Reading the buttons' values is much simpler, the byte is just
read once and the values taken directly from bits 4-7.
| |
| Bit # | Data |
| 7 | Button B2 (pin 14), 0=closed, 1=open (default) |
| 6 | Button B1 (pin 10), 0=closed, 1=open (default) |
| 5 | Button A2 (pin 7), 0=closed, 1=open (default) |
| 4 | Button A1 (pin 2), 0=closed, 1=open (default) |
| 3 | Monostable BY (pin 13), 1=timing, 0=timed-out |
| 2 | Monostable BX (pin 11), 1=timing, 0=timed-out |
| 1 | Monostable AY (pin 6), 1=timing, 0=timed-out |
| 0 | Monostable AX (pin 3), 1=timing, 0=timed-out |
|
Joystick connector
Pinout (front of male D15 connector on joystick)
.------------------------.
\ 8 7 6 5 4 3 2 1 /
\ 15 14 13 12 11 10 9 /
`--------------------'
Use the links in the table headers below for circuit diagrams.
| Pin # |
2 Button stick |
Dual 2 Button sticks |
4 button stick |
6 button stick |
| 1 |
+5v |
+5v |
+5v |
+5v |
| 2 |
Button 1 |
Player 1 Button 1 |
Button 1 |
Button 1 |
| 3 |
X-axis |
Player 1 X-axis |
X-axis |
X-axis |
| 4 |
GND |
GND |
GND |
GND |
| 5 |
GND |
GND |
GND |
GND |
| 6 |
Y-axis |
Player 1 Y-axis |
Y-axis |
Y-axis |
| 7 |
Button 2 |
Player 1 Button 2 |
Button 2 |
Button 2 |
| 8 |
- |
- |
- |
- |
| 9 |
+5v |
+5v |
+5v |
+5v |
| 10 |
- |
Player 2 Button 1 |
Button 3 |
Button 3 |
| 11 |
- |
Player 2 X-axis |
- |
Button 5 |
| 12 |
GND |
GND |
GND |
GND |
| 13 |
- |
Player 2 Y-axis |
- |
Button 6 |
| 14 |
- |
Player 2 Button 2 |
Button 4 |
Button 4 |
| 15 |
- |
- |
- |
- |
Notes:
- Even if you're not going to use pins 11 & 13 for inputs, they should be
wired up, as some programs won't "detect" the joystick otherwise.
- Some (older) cards have only implemented the first joystick functions.
- Some cards also supply +5v on pins 8 and 15.
- Some cards use pin 12 (out) & 15 (in) for midi.
To help in building and testing your controls, you can download this program
which I wrote to help build mine.
|
 |