Classic Computer Magazine Archive COMPUTE! ISSUE 48 / MAY 1984 / PAGE 40

The Inside Story: How Graphics Tablets And Light Pens Work

by Ottis R. Cowper, Technical Editor

Many programmers find graphics tablets and light pens among the most mysterious of peripherals, but the principles of both are really fairly simple.

The graphics tablet is similar in operation to the more familiar game controller paddles. A paddle consists of a variable resistor, a device which can vary the amount of electric current passing through it. For example, rotating the paddle all the way clockwise would allow full current to flow; turning it completely counterclockwise would cut off all current. A computer which accepts paddles must have circuitry which can read the varying current and provide a numeric reading which is proportional to the current, and hence to the position of the paddle knob. This is usually zero when the paddle is rotated all the way in one direction, 255 when the paddle is turned completely in the opposite direction. Joysticks for the Apple, Color Computer, and IBM function in a similar manner, with one resistor on the horizontal axis and another on the vertical.

Graphics Tablet Positions

In a graphics tablet, thin sheets of a special film are used in place of the variable resistors. When you press down on the film, a current flows, with the amount of resistance depending on where on the film you press. For example, if the film is set up to register horizontally from left to right, pressing on the left edge is equivalent to turning the paddle for minimum resistance, while pressing on the right edge is like turning the paddle for maximum resistance.

The working area of the tablet consists of two sheets of this film, one arranged to register horizontally and one arranged for vertical measurements. The same circuitry used to read paddles (or Apple and IBM joysticks) can be used to read the tablet—the computer interprets each of the sheets as a paddle. What would normally be one paddle reading is the horizontal position of the point on the pad being pressed, while the other reading gives the vertical location.

One significance of graphics tablet design is that you should be able to substitute paddles (or the joystick for Apple or IBM) in programs which call for the tablet. Conversely, you might experiment with using the tablet in programs which call for paddles, although the tablet isn't likely to replace paddles for playing Pong or Breakout.

Holes Of Light

To understand how a light pen works, you must first understand how screen images are created. The chief element of any video display device, television or monitor, is a cathode ray tube (CRT), a sealed glass funnel with an electron "gun" in the narrow end and a specially coated screen across the wide end. The gun shoots electrons at the screen, leaving tiny bullet holes of light where the electrons strike the dark screen.

The shots are not random; they are carefully targeted by powerful electromagnets, the big coils of wire around the throat of the CRT if you've ever looked inside a TV or monitor. Starting at the upper left corner of the screen, the gun is swept across at a constant speed. Shots are fired at the spots that need to be lit up to form part of an image. When the gun has swept all the way across to the right edge, firing is halted while it is aimed at the left edge again, slightly lower than on the first pass. Thus, the spray of shots forms rows across the screen. Several rows are required to form a character. For example, alphanumeric characters for many computers are eight lines tall. To see this, type some spaces in inverse video. If you look closely, you'll see that the reverse space character is a stack of thin, closely spaced lines rather than a solid block.

The drawing process must be repeated over and over because the bullet holes of light glow for only a fraction of a second before fading away. In most computers, the screen is redrawn every 1/60 second. If you had a very fast stopwatch that you started when the gun began firing at the upper left corner, you could read the elapsed time on the watch when the spray of electrons reached any particular point on the screen and, from this reading, determine how far you were from the starting position at the upper left.

This is the secret of light pen operation. In its simplest form, the pen is a plastic cylinder housing a phototransistor, a light-activated switch. (The phototransistor is what you see behind the lens at the end of the pen.) When the pen is held to the screen, the beam of electrons which light up the screen triggers the phototransistor, causing it to signal the computer that the beam has been detected. The computer must then check its video stopwatch to see how much time has elapsed since it started drawing the screen. It can then compute where on the screen the pen is being held.

If the screen is being drawn many times a second, the pen will detect the spray of electrons each time the screen is drawn. Since the spots of light are so small, the pen may be triggered at a slightly different point each time. The readings you get from simple pens can thus be somewhat unsteady, especially for the horizontal location of the pen. Programs written for simple pens usually require that you touch a key on the keyboard to tell the computer when you want the reading to be accepted.

More sophisticated (and hence more expensive) pens have additional circuitry which allows them to latch after triggering so that the readings do not change every time the screen is drawn. This means the readings will be much more stable, and that you will not need to use the keyboard. A switch in the pen tells it when to hold the current reading. In some, the switch is built into the nose of the pen so that you latch the reading by simply pressing the pen against the screen.

If you want to use a light pen or a graphics tablet with your own programs, keep in mind that they won't draw on the screen for you. Like a joystick or a set of paddles, the pen or pad provides only numeric readings. It's up to you to write the software which will decipher the input from the pen or tablet and then accomplish something in your program.