*** Series Feature (Part 2) *** *** Xav (Mark Crutch) *** *** Programming/Games/Hardware/DIY! *** *** STe, Jaguar or Falcon *** *** Heading & Standfirst *** Just A Bit Of Padding In the second article on uses of the Enhanced Joystick Ports, Xav takes a more detailed look at the humble joypad. *** Main Text *** In the unlikely event that there is anyone reading this who is unfamiliar with exactly what I mean by a "joypad" let me start with a brief description. The joypad is an input device, designed primarily for games playing, and is the standard controller for a Jaguar. You've probably seen pictures of them, festooned with buttons, back in the "old" days when Atari were actually making some noises about the Jaguar. Standard joypads have three fire buttons, a twelve button numeric keypad, pause and option buttons, and a directional pad (sometimes referred to as a "D-pad"). This article is intended to explain the inner workings of the joypad, as the principles used here are fundamental to many of the EJP projects that can be made. A brief description of the joypad hardware was given in issue 1, and it may be useful to refer back to that if you have a copy. That article included a very simple circuit diagram of part of the hardware, but the full thing can be found just over there, in the corner. *** IMAGE *** pad_1.gem No, please don't turn over just yet - it's not as intimidating as it looks and is quite simple when viewed at as a number of building blocks. Honest. *** Subtitle *** Trigger Happy Taking the circuit diagram vaguely from left to right, the numbered circles (and those along the top) represent the pins of the joypad connector. Those on the left carry the input to the computer as simple high or low voltages - which are provided by that big rectanglular object. This is a "Schmitt triggered octal buffer." Impressive sounding stuff, maybe, but all it does is take signals in from one side (the wide end of the triangles), clean them up a bit so they don't scare the computer too much, then squirt them out the other side (the pointy end of the triangles). At the top is a connection for the positive power supply (from pin 7), and at the bottom is the connection to ground (pin 9). There are also a couple of other inputs at the bottom - the "enable" connections. These effectively switch the whole chip on and off, and are activated when they are pulled low (that's what the bar over the top means). For our purposes we always want the chip active, so they are tied permanently to ground. Next along we have a number of resistors which connect the Schmitt triggers to the positive supply. Their sole purpose here is to ensure that the computer normally receives "high" values unless a button is being pressed and read from. All of which brings us neatly onto... *** Subtitle *** The buttons Each button, as can be seen, is connected at one end to the Schmitt trigger, and at the other end to one of the pins along the top. Associated with most of the buttons is a diode. This can be thought of as a one-way valve for electricity, and prevents the Schmitt trigger from reading the buttons of adjacent columns when it's not supposed to. Since the Pause button doesn't share its Schmitt trigger with anything else, it doesn't need a diode. When a button is pressed it effectively transfers a high or low voltage from the pin to which it's connected, onto the diode. If the voltage is high, the diode blocks it. If the voltage is low, the diode "pulls" the input to the Schmitt trigger low as well. This signal is then cleaned up and passed to the computer. In order to read any one switch, therefore, it is necessary to make the appropriate column low, and all others high. This is done by using some of the pins on the EJP as outputs and setting them accordingly. Then it is a simple case to read the values returned on the input pins. *** Subtitle *** Next Issue It's worth reading through this page a couple of times to make sure you understand what's going on, as a good grounding in the hardware of the joypad will make it much more understandable to program - which is exactly what we'll be starting on next time. Meanwhile you'll find a couple of goodies on the reader disk (you do get the reader disk, don't you?). First of all, there is a GEM file of the joypad circuit diagram, for those hardware hackers amongst you that would like it printed a little larger. Secondly there is a joypad test program - nothing too exciting at the moment, but I hope to develop it in line with this series as an aid to the testing of some of the projects.