Introducing the Experimentor’s Universal Input/Output Port

Authors

Publication

Pub Details

Date

Pages

Some of you may remember that a LONG time ago, I said I wanted to offer a simple parallel port and use it as the basis of a series of programs designed to show computer hobbyists the what’s, why’s and wherefore’s of “Programming for Ports”. My plan was (and still is) to provide many interesting applications centering around this I/O port, and then through the documentation, explain how the program works so that you can glean information on programming techniques you can use in your own programs. After many months of design work, by both myself and John Oliger whom I contracted with to manufacture the port boards, as well as considerable time writing the first few applications, I am happy to say the product is ready to be launched.

Port Fundamentals

If you are wondering what in the world a “port” is and why you would ever want one, let me introduce you to a few fundamentals. A “port” is a device which plugs into your computer which makes it possible to exchange data with other devices. Your computer’s mic and ear jacks are connected to a cassette port built right in to the computer. When you LOAD this port takes data from your tape recorder and puts it into the computer’s memory. When you SAVE a program, you do the reverse. Data from memory goes out to the recorder. The picture generated by the computer goes out to the TV through a port. Data you type when you press on the keyboard goes into memory through a port.

Ports are like nerves. Some connect sensory organs with the brain. Others serve as_ the conduit through which the brain sends impulses to muscles telling them to act.

Through ports you can connect motors, temperature probes, electric eyes, vibration sensors, relays, sound instruments, chemical sniffers, lights, and other “real world” devices up to your computer. The data transmitted to the computer through the input ports can be analyzed and then signals can be sent out to turn on other devices as a response.

Imagine a completely computer controlled solar heating system, a motorized robot, a fully automatic weather station, an alarm system, economical and accurate lab testing equipment. Or how about computerized guidance systems for telescopes, cameras, or video recorders. These are some of the things you can do with ports.

Unfortunately, there is a giant gap between imagining these systems and actually implementing them. Programming for ports is a science unto itself. It is a fairly simple matter to get signals into or out of the computer, but interpreting those Signals and knowing if the interpretation

is accurate is another matter entirely. The computer’s eye view of the world presents quite a different reality from everyday affairs. When you program a computer to sense and act on outside events, you must look at the world through the eyes of the computer. To me, its rather like looking through a microscope or some other device which throws a completely different light on your perception of things.

About The Experimentor’s I/O Port

The Experimentor’s Universal Input/Output Port was designed to be useful in many different settings. It will plug into the back of the TS1000/1500, the TS2068, or the Spectrum without any modifications to either the port board or the computer. The board has 8 input lines and 8 latched output lines. This means that a binary series of highs and lows sent to the outputs will remain there until you change them by sending a different series of highs and lows. In addition there are two strobe lines provided. These output lines are active when the computer is inputting or outputting data to the port. They can be used for various forms of “handshaking”.

To make this port board easy for the experimentor to configure and reconfigure many times for different applications, connections to the inputs and outputs are provided by way of two 10 position female sockets. One socket is for the 8 input lines, a ground, and a strobe line. The other socket is the same for the output lines. These sockets allow for temporary solderless breadboard type hook-ups. You can also make your connections with the common 1/10th inch center male headers, or by using crimp-on male connector pins (a supply of these is included with the unit).

Ports are like memory locations in that each port must have a unique address. This board is given the decimal address of 223 (or DF in hex). It is quite easy to change this address in the unlikely event you have a peripheral which already uses this address.

The Basic I/0 Technique

The actual technique of reading values from or writing values to this port varies with both the program and the computer you use. With the Spectrum and TS2068 you can use the Basic IN and OUT commands:

LET X=IN 223

will read the 8 input lines and put the value it finds into the variable X.

OUT 223,X

sends the variable X out to port number 223. These commands are very similar to the PEEK and POKE commands except that instead of reading or writing to a memory location, you read or write to a port.

On the TS1000/1500 there is no Basic command which will access ports. Instead, you must use machine code. (I should mention, however, that this will not be true for long. I expect to have a new program soon which extends the Sinclair Basic with 22 new commands. Among them are IN and OUT which work in the same way as those on the TS2068). Perhaps the simplest machine code routine you’ll ever get from me is the one below which lets the TS1000 access this port:

LD A,00
OUT (DF),A
RET
IN A,(DF)
LD C,A
LD B,00
RET

To enter this into your computer, create a REM line consisting of at least 11 spaces after the REM token. Then make the following pokes:

POKE 16514,62
POKE 16515,0
POKE 16516,211
POKE 16517,223
POKE 16518,201
POKE 16519,219
POKE 16520,223
POKE 16521,79
POKE 16522,6
POKE 16523,0
POKE 16524,201

Write to port 223 by poking 16515 with the value you wish to output. Then, RAND USR 16514. If you connect the port up to the computer and execute the commands below:

POKE 16515,255
RAND USR 16514

You could use a voltmeter to measure the voltage at all 8 output connections and find that each one measures 5 volts. Then if you POKE 16515,1 and RAND USR 16514 the voltage at bit 0 would still be high, but all the others would be low.

Reading data from the input port is accomplished by entering the command: LET X=USR 16519. When the machine code executes, it reads the instantaneous state of the 8 input bits and stores the decimal value in the variable X. If all the inputs are connected to ground, X will equal 0. If they are all tied to 5 volts, X will equal 255.

Scroll to Top