\documentstyle[11pt]{article}
\begin{document}
\title{Stiquito Parallel Interface}
\author{Andrew Heininger}
\maketitle

\section{Introduction}
Once we had a working Stiquito robot, we needed a device to link it
to a PC. Having such a device would give us the capability to program
the robot to walk by using: neural networks, production systems,
turtle languages and many other useful programs. Such a device could also
allow the programmability of many crucial variables which
contribute to a walking gait. Variables such as the amount of time
needed to apply an electrical current to a leg and to which legs, can
all be moved into software. By performing this transition we can
have a system which can be used and understood by anyone
who can understand a simple language such as Basic.

\section{Hardware Overview}
First, let's talk about how the parallel port operates. The normal
parallel port for a PC or compatible, is a 25 pin female connector.
Some machines (such as the Radio Shack Tandy line) may use a different
connector type such as a Centronics printer port. The signals should
be similar but we will only consider the normal 25 pin port. Looking
at the parallel port on the PC (figure 1, top), the pins are numbers
13-1  (left to
right on the larger top row) and 25-14 (left to right on the smaller
bottom row). Pins 2-9 are used to transmit data out to the interface
and each time the PC has stabilized these lines it sends a pulse (true
low) on the strobe line. There are also a number of status lines which
run back into the PC which are normally used for printer errors. Some
of these wires can be used for sensor input to the PC, but for now we
will hard wire these to the following values: pin 10 (acknowledge)
wired to +5v, pin 11 (Busy) wired to 0V, pin 12 (out of paper) wired
to 0v, pin 13 (select) wired to 5V, pin 15 (printer error) wired to
5v, and pin 17 (select/deselect printer) wired to 0v. Also note that
ground is pin 18. 


There are three main components to the parallel interface: 

\begin{itemize}
	\item PC Control Software- allows the computer to communicate
with the interface to control Stiquito.
	\item Parallel Interface Receiver- receives the digital signals from
the PC and turns a leg on and off.
	\item Power Driver Board- Amplifies the digital signal so that
there is enough current to power a leg.
\end{itemize}

\section{The Receiver}

The receiver is necessary because there are only 8 data lines coming
out of the parallel port. Since we would like to be able to
individually control 14 we need some way to encode and decode more
lines. Notice that with 8 lines we can encode up to $2^8$ or 256
different outputs. To keep things simple, we will use the following
scheme: we will use the 8th bit to select between two banks of 7
outputs. So for example, if we gave the following sequence: 10000000
this would clear all of the bits (7-13) in the second bank of outputs.
If we sent the command 00000001 we would turn on bit 0 in the lower
bank of outputs. Of course we are free to use any combination such as:
01100110 which would turn on bits 1,2,5, and 6 in the lower bank.

To accomplish this, we have used two 2010 PAL's (programmable array
logic devices) to implement the above behavior. The PAL's provide a
way to select banks with registered output (see figure 1, bottom).
We will not go into the
details of how to program a PAL but will instead concentrate on how
the logic inside of them is represented, the builder should then be
able to make the device from off the self multiplexers, registers,
and buffers.

Each output line, consists of a two input multiplexer whose output is
delivered to a D-flip flop (see figure 2, top). The D-flip flop's clock signal will come
from the strobe pin, remember that when the parallel port has valid
data on the line it will send a pulse out on pin 1. The output of this
Flip flop will be used as both an output to the power driver and it
will be looped back around and used as an input to the multiplexer.
The other input to this multiplexer will be from one of the seven data
lines coming from the PC. The select signal will be generated from the
8th (highest) bit from the PC. In order to build two banks of outputs
all we have to do is change the ordering of the inputs to the
multiplexer on one bank to another on the second. So for example, on
bank one, we will have the A input to the multiplexer be from the flip
flop and input B be from one of the 7 data lines. On the second bank
we will reverse A and B so that A will be attached to one of the data
lines and B will be attached to the flip flop. Notice that we don't
even need an inverter!

\section{Power Driver Board}
Because a Stiquito leg needs enough current to heat up its
Flexinol\copyright  wire we will need to power it with an additional circuit
other than the digital one built above. Fortunately all we need is an
additional transistor per output (see figure 3). This will be needed as a big switch
which we can throw on and off. For this We can use an NPN power transistor
which is rated for 3 amps, 40 volts output, and a 5 volt input from
our receiver, one which seems to work well is the Archer Tip31
transistor (Radio Shack part no. 276-2017). A transistor has three
pins on it, a Base (where our input signal should be attached), a
Collector (+ voltage from a power supply), and an Emitter (which we
connect to our stiquito leg). We can use a bread board to mount the
transistors on and then make the appropriate connections to wire the
whole thing up. Also we should make sure that a common ground signal
run through the entire circuit from both the multiplexer/register
chips and the ground attached to the stiquito.

\section{PC Control Software}
To control the robot, after an interface has been built, the simpliest
programming language to use is GWbasic. We will use basic because it
is widely accessible, many people know it, and it can be easily run on
any machine w	xith a small amount of memory and no hard disk. If a more
elegant language is desired, one can install a version of C or Scheme
on their hard disk. There are two special commands which we will be
interested in, they are the {\it open} command and the
{\it print\#x,chr\$(y)} command (see figure 2, bottom). In order to use the parallel port
from basic, we must first open up a port to be used for output. We do
this by the statement:
\begin{verbatim}

		10 OPEN ``LPT1:'' FOR OUTPUT AS #1

\end{verbatim}
This will open up the lpt1: device so we can write to it and we must
also assign it a port number (in this case, \#1). Once this is done we
can now use the basic {\it print} statement to control our stiquito
robot. Because we will probably want to think about sending a
numerical value instead of a character out to the interface we can use
the basic command {\it chr\$()} to convert our number into a character
the {\it print} statement can understand. 
\begin{verbatim}

		20 PRINT#1,CHR$(my_value);

\end{verbatim}
Also note that if we leave off the trailing semicolon after the 
{\it print} basic will send a return out to the interface 
and possible cancel out any command we just sent and turn on 
new outputs. To avoid this action, we simply place a semicolon 
there. Also Basic seems to send a return out to the
interface after a program ends (flushes the output buffers) so to
avoid this we simply put the program into an infinite loop after we
are done with our program. We can then hit control-break to stop this
loop after we have turned off all power to the robot. 

\begin{flushleft} {\Large References:} \end{flushleft}
\vspace{10mm}

1] Mills, J. W. 1992. {\it Stiquito: A Small, Simple, Inexpensive 
Hexapod Robot.} Indiana University Computer Science T.R. NO. 363a
\newline
2] Luetzow, R. H. 1983 {\it Interfacing Test Circuits with
Single-Board Computers.} Blue Ridge Summit, PA: TAB Books.
\end{document}
