You are here

Scientific Applications of the Apple Game Port Part II


Kenneth Ratzlaff

Note: This article was scanned using OCR from the Fall 1984 CCCE Newsletter. Please contact us if you identify any OCR errors.
In Part I of this series, which appeared in the June issue, the general approach to the applications of game ports was reviewed. In Part II, a number of potential applications will be described. In the third part of the series some experiments on the principles of data acquisition using game ports will be presented.
The Apple game port has two types of inputs: the paddle input and the button input. The paddle input is an Analog-to-Digital Converter (ADC) of a specialized type: the result of the conversion is proportional to the inverse of the input current. A linear result is obtained when a variable resistor is placed between it and a voltage source (Ohm's Law); in the case of an Apple II, a resistance of 0-150 kO between 5V and the input will generate readings between 0 and 255. The button input accepts a logic level encoded in "TTL" logic (approximated as OV = 'O' and 5V = '1'). ·
Similarly, the annunciator outputs generate logic TTL levels which can be used to control external devices by turning them off or on.
In the following sections, a number of applications of· these input and output units will be described. In many cases, the applications described have not been tested. The components that are requi·red are available from Newark Electronics, 500 N. Pulaski Road, Chicago, IL 60624.
Analog (Potentiometer) Inputs
In this discussion, we will restrict ourselves to transducers (sensors) which are resistive and exhibit large changes in resistance. Three are naturals. The first is an ordinarypotentiometer which is what the Apple paddle contains; the resistance is proportional to the rotary or linear position. The second is a thermistor whose resistance makes large changes with temperature. Finally, the photoresistor makes very large changes with light level. Most other resistive transducers, such as strain gages, make such small changes that a Wheatstone bridge is necessary to amplify the signal; the result is not easily handled by the paddle input.
Potentiometers. Potentiometers (pots) are used to measure position, a parameter less often measured in chemistry than in some. other disciplines. However, some applications can be instructive.
The first and simplest example is a pendulum. Either the shaft or the body of a single turn pot can be mounted in a stationary position; a rod with a bob is attached to the moving member. Since the full excursion of the pendulum will be about 120°, the pot should be selected so that angle will give 150 kΩ the closest commercial unit is 250 kΩ or 500 kΩ. Acquisition of readings as a function of time will produce the typical sine wave. Some attention must be paid to establishing a time base.
Potentiometers are used in weather monitoring. If the bob on the pendulum is replaced with a vane and a mechanism is constructed to position that vane properly with respect to the fluid (air) flow, the reading can be related to wind velocity. Pots exist which do not have stops; when rotation reaches full scale, the rotation can continue at on. Also, a vane attached to the shaft can sense wind direction.
A decade ago, ten-turn pots were used as transducers with strip-chart recorders. The string used to couple the pen with a servo motor was wrapped around the shaft of a ten-turn pot with an appropriately-sized Erector set pulley; the resultant resistance is proportional to the pen position.
Thermistors. Over a short temperature range, the resistance of a thermistor is inversely proportional to temperature. More exactly, the relationship is:
where the R0's are the resistance at the two temperatures T1 and T2• A typical thermistor

The proper thermistor for the temperature range is chosen by determining that the resistance corresponding to the lowest temperature does not exceed the range of the POT input. Conversion of the result to a linear scale is required, but that can and should be done in software. Two free sources of information on thermistors are the Thermistor Manual (Fenwal Electronics, POB 585, Framingham, MA 01701) and the Temperature Measurement Handbook and Encyclopedia (Omega Engineering, Box 4047, Stamford, CT 06907). Fenwal thermistors are available at reasonable prices from Newark.
Thermistors are extraordinarily versatile devices. The obvious application is for temperature monitoring. Since our simple configuration has no provision for offsets in the signal, it may be difficult to obtain sufficient sensitivity for such experiments as Heat of Solution: Harvey Blanck has set up a more sophisticated arrangement using an operational amplifier (see WH0-84) to generate an offset so that he can obtain a sensitivity of .002 °C! Our thermistor above will have a much smaller sensitivity.
Another method of obtaining an offset is shown in Figure 1. The offset is obtained with a negative power supply. We can make some rough calculations (ignoring resistances in the Apple circuitry) by making the following calculations. To get a reading of about 85 on the Apple, we would need a resistance of 150,000 * 85/255 = 50,000. The current passed by that resistance is 5/(50,000) = .1 ma. Using a 5 kΩ thermistor at 25°, 5/(5,000) = 1 ma would flow. If we use a -5v power supply and a resistance of 5Ω, the thermistor current will be bucked out and the reading will be 255, but when the temperature increases by 1°C, the thermistor current will be about 1.1 ma and the net current will be .1 ma; the resultant reading is about 85.
Thermistors are also used to measure heat transfer by placing them in a self-heating mode. If the current through the thermistor can be increased, the thermistor will resistively heat itself (this is also a danger in any thermistor application). If the environment of the thermistor insulates it, the resistance will drop, but if the heat can be carried away by the thermistor environment, the resistance will increase. Two simple applications are use as a liquid level sensor and as an air speed indicator. Both can potentially be implemented with a 4 kΩ thermistor using a higher excitation voltage and a larger offset.
Photoresistors. The resistance of. a cadmium sulfide photoresistor varies greatly with the light level, but it is, alas, too non-linear for quantitative spectroscopy applications. However, there may be some useful applications for which the linearity is only of secondary consequence. Consider the spectroscopic detection of a titration endpoint. In finding the point of inflection, the nonlinearity is not impor.tant. The optical arrangement will require some care to ensure that the proper proportion of light from the source reaches the detector. Also, the classic iodine clock reaction could be automated in some cases, photodiodes and phototransistors can be used with the POT input.
David Jordan (SUNY-Potsdam) sent a copy of an article about image processing (Ronald eelen, Sky and Telescope, page 177, February 1984; see the editor's note in particular). The article outlines the construction of a drum and scanning unit used to scan a photograph with a quantitative photodetector, measuring the reflected light at each position to be displayed on the screen. The editor suggests the use of the photoresistor connected through the game port. The photoresistor might be rastered over the image by an X-Y plotter or digital plotter with the photoresistor in the pen position. The plotter can be controlled through the serial port to position the detector over any specified location on the paper. If an analog X-Y plotter is easier to obtain, the strobe output could be used to feed a counter which generates values for a pair of digital-to-analog converters (see the block diagram in Figure 2).
Physiologists have used photoresistors to measure heart rate. A red light-emitting diode (LED) is positioned to shine onto one's hand; the photoresistor detects the scattered light. Small changes in the amount of light scattered by the tissue occur with each heartbeat. However, the positioning of the components is critical, if the device is to operate satisfactorily.
How may the pushbutton inputs be used? If considered 1-bit analog-to-digital converters, a variety of applications is suggested. First, there are those phenomena which are either in position or
out of position, such as the end of the travel of a stop syringe in a stopped-flow apparatus or a foot pedal to give a command to the computer when the operator's hands are full. The switch is connected between 5 volts and the pushbutton input, and these switches come in a host of configurations.
With any transducer, the signal either is or can be converted to a voltage between 0 and 5 volts; an integrated circuit comparator (such as a National Semiconductor LM139 in Figure 3) will output a '0' or '1' depending on which of the two inputs is greatest.
Annunciator outputs are convenient for controlling switches. Sometimes, an instrument will include a "TTL" logic-level input to turn a funct1on on or off, and the annunciator output can be connected directly to it. Sometimes, a modification of an instrument can be made. In many cases, the pushbutton on the instrument is comfigured to be a TTL input to the instrument's microcomputer. Then the annunciator output can be wired to that input so that when either one goes to ground ('0') level, the button function is actuated; and the computer can
actuate any function now actuated by a pushbutton.
AC power is very easy to turn off and on from the annunciator output by the use of a Solid State Relay (SSR). The SSR is turned on when an internal LED shines onto an internal phototransistor, so the annunciator need only turn on the LED. The (+) terminal of the SSR module is connected to +5 volts, and the (-l terminal is connected to the annunciator; the LED goes on when the annunciator output is at ground level. Again, Harvey Blanck has an example in which a power supply is controlled from computer logic using an SSR. SSR's come in a variety of sizes to switch
currents of a few milliamps to 100 amps.
Some computers, for example the Cornmodore-64, can handle many more bits of digital inputs which accept data in parallel. The Commodore has two connectors, each of which has 5 digital
input bits marked JOYO, JOYl, JOY2, JOY3, and BUTTON. With 10 input bits, one can easily read data that are encoded in parallel such as the output of a panel meter. Another contribution from Harvey Blanck (WH0-85) illustrates how it can be done. Unfortunately, the Commodore game port has no output lines; either the parallel port that is provided.or the cartridge slot may be easier to use for some applications.


09/01/84 to 09/05/84