|
|||||
Typical PC joytick circuit diagram and inside
picture The joystick port is a very simple 8 bit I/0 card 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. Joystick interface only uses the signal that somebody is writing to the I/O address to reset the multivibrators in the card. The data value is not stored anywhere, so it is really same what value is written to this address. When you read one byte from I/O addess 201h, you get the status information of the joystick interface. The following table will show how the bits are mapped in the value you get. Game port 201h byte:
_______________________________________________________
| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| but4 | but3 | but2 | but1 | stk4 | stk3 | stk2 | stk1 |
|______|______|______|______|______|______|______|______|
The four most significant bits tell you the state
of the joystick buttons. Four least significant bits tell the state
of the multivibrators which are used for measuring the resistance value
of the joytick position potentiometers. More accurate description of
the bit meanings can be found at the table below:
7 6 5 4 3 2 1 0 * . . . . . . . Button B2 (pin 14), 0=closed, 1=open (default) . * . . . . . . Button B1 (pin 10), 0=closed, 1=open (default) . . * . . . . . Button A2 (pin 7), 0=closed, 1=open (default) . . . * . . . . Button A1 (pin 2), 0=closed, 1=open (default) . . . . * . . . Monostable BY (from pin 13), 1=timing, 0=timed-out . . . . . * . . Monostable BX (from pin 11), 1=timing, 0=timed-out . . . . . . * . Monostable AY (from pin 6), 1=timing, 0=timed-out . . . . . . . * Monostable AX (from pin 3), 1=timing, 0=timed-out Resistive analogue inputs (joystick position)Joystick position inputs are simply inputs where a variable 0-100 kohm joystick potentiometer is connected to. The potentiometers are wired between the +5V power pin and one potentiometer input pin. The following picture tries show how the wiring is done: The resistance value of the joystick potentiometers are measured using very simple monostable multivibrator circuit, where a small capacitor is loaded through the joystick potentiometer to a certain voltage level. The joystick interface has four this type of monostable multivibrators. Typically joystick interface multivibrators are all in one 558 IC (that IC is like four simplified 555 type timers in one IC) for two joystick ports and 556 (dual 555 timer) for one joystick only port. Switch inputs (joytick buttons)The joystick buttons are simple on/off inputs. Joystick button either leaves the pin floating or connect it to the ground. The state of the buttons is directly fed to the joystick interface and through it to ISA bus data lines when somebody reads the joystick interface I/O address. The buttons are very easily wired. Every input has 1 kohm pull-up resistor R1 which ensires that the joystick button pins stay in +5V potential (logic 1) when no button is pressed down. NOTE: Reference design in Crystal Semiconductor CD4376B calls for 4.7 kohm pullup resistor and 1000 pF capacitor from input to ground. When one button is pressed down, that input is grounded which caused the voltage on that pin goes to 0V which means that the joystick interface then gets logic 0 form that input. If you just keep reading the joystick port I/O address contantly, you will get a real-time sate of the button pins. |
Free Software Lesson 1 Lesson
4
|
||||