Sunteți pe pagina 1din 6

NetPro Certification Courseware for NetPro Certified Systems Engineer – N.C.S.

JOYSTICKS AND GAME PORTS

Few peripheral devices have come to represent PC entertainment like the joystick
although it is one of the simplest peripherals available for a PC, the joystick allows a
user to bring an element of hand-eye coordination to interactive programs (i.e., flight
simulators and 3D “walk through” games) that would simply be impossible with a
key-board or mouse. The joystick interfaces to the host PC through a board called the
game-port adapter (or simply the game port). CONTENTS AT A GLANCE

Understanding the Game-Port System

The typical game port uses a relatively simple interface to the PC. Only the lower 8
data bits are used (which explains why so many game ports still use the older 8-bit
“XT” card style, rather than switching to a 16-bit “AT” card type). Also, only the
lower 10 address bits are needed. Because the game port is an I/O device, the card
uses I/OR and I/OR control signals. On virtually all PCs, port 201h is reserved for the
game port.

INSIDE THE JOYSTICK

Each analog joystick is assembled with two separate potentiometers (typically 100
kW) arranged perpendicularly to one another—one potentiometer represents the X-
axis, and the other potentiometer represents the Y-axis. Both potentiometers are
linked together mechanically and attached to a movable stick. As the stick is moved
left or right, one potentiometer is moved. As the stick moves up or down, the other
potentiometer is moved. Of course, the stick can be moved in both the X and Y-axis
simultaneously, with the proportions of resistance reflecting the stick’s position. You
can see the wiring scheme for a standard 15-pin dual joystick port in Fig. 19-3. The
pin out for a standard joystick port is listed in Table below .
NetPro Certification Courseware for NetPro Certified Systems Engineer – N.C.S.E

Detecting the stick’s X and Y position is not an intuitively obvious process.


Ultimately, the analog value of each potentiometer must be converted to a digital
value that is read by the application software. This is an important wrinkle—because
the game port does not generate an interrupt, it is up to the particular application to
interrogate the joystick port regularly. You might imagine that such a conversion
would use an Analog-to-Digital Converter (ADC). However, an ADC provides much
greater resolution than is needed and its conversions require a relatively long time.
Current game-port conversion circuits use a multi vibrator element. Ultimately, the
resistance of each potentiometer is determined indirectly by measuring amount of
NetPro Certification Courseware for NetPro Certified Systems Engineer – N.C.S.E

time required for a charged capacitor to discharge through the particular


potentiometer. If a certain axis is at 0 W, the multi vibrator’s internal capacitor will
discharge in about 24.2 ms, and at 100 kW, the multi vibrator’s capacitor will
discharge in about 1124 ms. Because this is a relatively linear relationship, the
discharge time can easily be equated to potentiometer position (an actual routine to
accomplish this requires only about 16 lines of assembler code). The multi vibrator
technique also simplifies the circuitry needed on the game-port adapter—it is really
the application that is doing the work. A joystick also has one or two buttons. As you
see from Figure, the buttons are typically open, and their closed state can be detected
by reading the byte at 201h. Because the game port is capable of supporting two
joysticks simultaneously (each with two buttons), the upper four bits of 201h indicate
the on/off status of all four buttons.

ADAPTING A SECOND JOYSTICK


Although the typical game port is capable of supporting two joysticks, most joystick
products only connect a single joystick. This means that only “half” the game port is
being utilized. You can purchase a joystick Y-adapter from any computer store or
construct a Y-adapter using the pinout in Table You’ll need a DB-15 male connector
to attach to the game port and two DB-15 female connectors to attach to each of the
two joysticks

T
NetPro Certification Courseware for NetPro Certified Systems Engineer – N.C.S.E

ABLE 19-2 PINOUT FOR A JOYSTICK “Y” ADAPTER


DIGITAL JOYSTICKS (GAME PADS)

Where an “analog” joystick uses two potentiometers to provide linear information


about the joystick’s relative position, a “digital” joystick (also called a game pad)
simply uses an array of switches to indicate absolute direction—usually up, down,
left, right, and fire

The game pad actually pre-dates the analog joystick a bit and uses a 9-pin TTL
interface as illustrated in the Amiga-style game pad Table. Current versions of the
digital joystick (such as the Gravis Game Pad Pro) use a 15-pin PC game-port
interface.

JOYSTICK CALIBRATION

Unfortunately, these values of time versus resistance are not the same for every
system. Variations in joystick potentiometers, game-port adapter circuits and
computer speed will all affect the relationship of time-vs.-resistance value. Even
variations in component temperature as the PC warms up can cause changes in
resistance interpretation. This is why some types of game-port boards provide a
separate 15-pin connector for each joystick. Some cut-price game-port boards only
provide one connector and the circuitry for one joy-stick. Verify the capabilities of
your game port before using or replacing a joystick Y-adapter. 9-pin “game pad-type”
joysticks are not directly compatible with the PC analog game port, and you should
NetPro Certification Courseware for NetPro Certified Systems Engineer – N.C.S.E

not attempt to adapt a 9-pin game pad to a 15-pin PC game port without some
appropriate interface circuitry. Game pads specifically marked as PC joystick
compatible (using 15-pin connectors) can usually be attached to ordinary game ports
without problems. Each application program that uses a joystick comes with a
calibration routine. Calibration allows the application to measure values for center
and corner positions. With this data as a base, the applications can extrapolate all
other joysticks positions.

JOYSTICK DRIFT
The term drift (rolling) is used to indicate a loss of control by the joystick. There are
several possible reason for this. As a technician, you should understand the reasons
why drift occurs, and how to correct such problems. First, drift might be the result of
a system conflict. Because the game port does not generate an interrupt, conflicts
rarely result in system crashes or lockups, but another device feeding data to port
201h can easily upset joystick operation. If you have soundboards or multi-port I/O
boards in your system equipped with game ports, be sure to disable any unused ports
(check with the user instructions for individual boards to disable extra game ports).
Another possible cause of drift is heat. Once PCs are started up, it is natural for the
power used by most components to be dissipated as heat. Unfortunately, heating
tends to change the value of components. For logic circuits, this is typically not a
problem, but for analog circuits, the consequences can be much more pronounced. As
heat changes the values of a multi vibrator circuit, timing (and thus positional values)
will shift. As the circuit warms up, an error creeps into the joystick. Well-designed
game-port adapters will use high-quality, low-drift components that minimize the
affects of the heat-related drift. It is interesting that the joystick itself is rarely the
cause of drift. If you can compensate for drift by periodically re-calibrating the
joystick, try a better-quality game-port adapter board. Finally, the quality of
calibration is only as good as the calibration routine itself. A poor or inaccurate
routine will tend to calibrate the joystick incorrectly. Try another application. If
another application can calibrate and use the joystick properly, you should suspect a
bug in the particular application. Try contacting the application manufacturer to find
if there is a patch or fix available.

Cleaning JOYSTICKS

Ordinarily, the typical joystick should not require routine cleaning or maintenance.
Most joysticks use reasonably reliable potentiometers that should last for the life of
the joystick. The two major enemies of a joystick are worn and dust. Wear occurs
during normal use, as potentiometer sliders move across the resistive surface-it can’t
be avoided. Over time, wear will affect the contact resistance values of both
potentiometers. Uneven wear will result in uneven performance. When this becomes
noticeable, it is time to buy a new joystick. Dust presents another problem. The open
aperture at the top of a joystick is an invitation for dust and other debris. Because
dust is conductive, it can adversely affect potentiometer values and interface with the
slider contacts. If the joystick seems to produce a jumpy or non-linear response to the
NetPro Certification Courseware for NetPro Certified Systems Engineer – N.C.S.E

application, it might be worth trying to clean the joystick, rather than scrapping it.
Turn off the computer and disconnect the joystick. Open the joystick that is usually
held together by two screws in the bottom housing. Remove the bottom housing and
locate the two potentiometers. Most potentiometers have small openings somewhere
around their circumference. Dust out the joystick area with compressed air and spray
a small quantity of good-quality electrical contact cleaner into each potentiometer.
Move the potentiometer through its complete range of motion a few times and allow
several minutes for the cleaner to dry. Re-assemble the housing and try the joystick
again. If problems persist, replace the joystick.

JOYSTICKS and Windows 95

Games have traditionally been a domain of DOS, so there has been little support for
joysticks under Windows. However, now that games are routinely using Windows
95(taking advantage of such features DirectX and Direct3D), you can now install and
calibrate a variety of joysticks under Windows 95. open your Control panel and look
for the joystick icon. If the joystick icon appears in your control panel, joystick
support is already installed and you can skip to the Game controller setup. If you
have not yet added your PC game port as New hardware in the Windows 95 Control
panel, you should do this first.

1. Click the Start button.


2. Select Settings, then Control panel.
3. In the Control panel, look for a joystick icon. If it’s there, skip to the Game
controller setup.
4. If not, double click the Add new hardware icon to start the Add new hardware
wizard.
5. When prompted to have Windows search for new hardware, select No. Click
next to continue.
6. Select Sound, video and game controllers, then click next. Select the
Manufacturer and game port joystick (or other appropriate model). This will
add the game port as a device. Click Next. If source settings are given as
0201-0201, click next. Windows will look for the required files. If it can’t
find these files, it will ask you to insert your windows 95 CD or disk.
7. When the files have been installed, click Finished.
8. Shut down your computer and restart Windows 95 to enable your game port
support. Once your game-port driver has been added, a joystick icon appears
in your Control panel. Use this to set up and calibrate your joystick:

 Double click the Joystick icon in the Control panel.


 In the Joystick configuration section, choose the appropriate joystick
type from the list.
 After selecting your joystick configuration, click the Calibration
button and carefully follow the onscreen instructions.

S-ar putea să vă placă și