80-Bus News |
May–June 1983 · Volume 2 · Issue 3 |
Page 4 of 59 |
---|
D.Parkinson’s article on light pens, in VOL.1 Issue 3 of 80-BUS, prompted me to finish writing this piece on the design of a light pen for use with the Nascom 2. The pen has been in use for quite some time and seems to be reasonably accurate, taking in to account the minimum resolution available with the standard Nascom Graphics chip.
The design for the light pen evolved because of my need for a device that would allow me to select routines from menus of routines. Some of these routines were to be used to input data by using the screen. I wanted a routine that would enable me to define the envelope shape of a particular sound that was to be generated in a micro-processor controlled synthesiser. Thus a peripheral was needed that would permit the definition of envelope shapes by drawing the envelope shapes directly on to the screen. It seemed that a light pen would be the most obvious device to use and so I locked to various manufacturers for a suitable light pen. Unfortunately, it transpired that the majority of pens were either out of my price range, or not quite the design that I required, and so I decided to build a pen specifically for the Nascom 2. The design works with my system, and the pen and its associated hardware is far cheaper than any other pen that I know of.
Having looked at the various photo-electric devices that could be employed in the design of the pen I decided to use a Light Activated Switch, which is an RS component type 305-434 (5v), as the photo-sensitive device. This device includes a variable-threshold switch that not only enables the sensitivity of the pen to be altered, but also reduces the component count by having the threshold switch as an integral part of the sensor.
Refering to figure 1 it can be seen that the output from pin 4 of the sensor is usually buffered by a TTL gate to bring the switched output to a clean TTL compatable level. The time-constant components, R1 and C1, set the sensitivity of the device, large values of RC give a high degree of sensitivity. It would be quite possible to use the circuit in figure 1 to directly interface with an input port. On the prototype, a pulse of 20us duration was output from the photo-sensor every time the raster struck the active area of the pen. This could be used to identify an individual pixel, or sub-pixel, on the screen area. By loading each successive VIDEO RAM location with the data FFH and by scanning the input ports for a HIGH from the pen, it is possible to identify the pen location on the video display unit. For a higher degree of accuracy, each VIDEO RAM memory location can be sequentially loaded with the data C1H, C2H, C4H, C8H, D0H, E0H. This data will then enable the pixel to be subdivided into 6 sub-pixels, and will put a small block of white at the top left-hand corner of the pixel, then at the middle left-hand side, and then at the bottom left-hand corner of the pixel. The last three bytes of data put the small block at the top right, mid right, and bottom left-hand corners of the pixel. Therefore, by successively loading each contiguous pixel with the six bytes of data, it becomes possible to identify the pen location on a screen with a resolution of
(48 x 2) x (16 x 3) = 4608 locations
If the output from the pen were connected to bit 7 of port 4, a program for identifying the pen position might look something like figure 3.
Page 4 of 59 |
---|