. INSTRUCTIONS TO FOLLOW WHEN MODIFYING THIS FILE:
. -
. A period as the 1st character of a line means the line is a
. command line and therefore the line will not be displayed.
. A command, or the period if it is just a remark like this sentence
. MUST be followed by at least 1 space. Some editors suppress all
. spaces after the last character. This is why you see . - for separating
. lines in this text. If a period is followed by a space the rest of the
. line is ignored.
. -
. All command letters MUST be in upper case.
. -
. The structure of the SIM.TXT file MUST be maintained as follows:
. -
. The first block corresponds to the text heading to appear on the opening
. screen, (ITC Microcomponents, etc) and MUST be preceded by .H (for heading)
. This block must be 12 lines or less.
. -
. The second block MUST be preceded by .M (in the line above the block) and
. it is the MENU options in the opening screen.
. -
. The third block is the short demo text which is preceded by .S
. The 4th block is the long demo text which is preceded by .L
. Within this block, the .Cn command before the next paragraph
. line indicates the paragraph number (n). This is used by the main menu
. to jump to a particular chapter and does not apply to the short demo text.
. -
. The 5th Block is the OTHER PRODUCTS block and MUST start by .O (letter O)
. Lines in this block can be up to 76 characters long.
. -
. Finally, the .F command must precede the F1 help text which is the last
. block in this file.
. -
. The demo text for the demonstration needs to be typed or arranged in
. pages 13 lines long and 36 characters wide. If more than 36 characters
. are found in one line, the program will wrap the text around thus creating
. havoc.
. -
. PLEASE leave this heading intact when you change or copy this file.
. -
. The line below marks 36 characters
. 3456789012345678901234567890123456
. -
.H (heading)

  Try the Complete Demo if you are using this program for the first
  time and the itemized chapters once you are familiar with the simulator.

  NOTES:  (1) Most timings are modified for demonstration purposes.
          (2) Any bugs that might be contained in this simulator
              DO NOT represent bugs present in the actual ITC232-A.
          (3) In this version we corrected some small problems present in V 4.0.

  Please feel free to copy and distribute this freeware at will but do not
  modify it or the SIM.TXT file without notifying ITC Microcomponents first.

  For any technical questions or pricing please contact us at:

                          RMV ELECTRONICS INC.
		#230-2250 Boundary Road, Burnaby, BC, Canada.
		Tel: (604) 299-5173	Fax: (604) 299-5174
		Email: customer@rmv.com  Web site: http://rmv.com

.M (Main menu) (the number of options and meaning to follow MUST be always the same)
S   Short demo
C   Complete demo (Includes 1-9)
G   General description
1.  Simulator description
2.  Reading a port
3.  Configure & write to a port
4.  Serial peripheral interface
5.  Interrupts
6.  Reading resistance & capacitance
7.  Pulse Width Modulation
8.  Stepping Motors
9.  Remote control operation
Q or Alt-X to Exit,  Alt-R to reset simulator, Alt-P to print demo text
.S  -
    The short demo is meant
    for people in sales who wish
    to have a basic understanding
    on the features and advantages
    of the ITC232-A in order to
    market it.

    This demo is a condensed
    version of the complete demo
    and it is not available at
    this time. Please use the
    complete demonstration.

.L  -
   ITC232-A DEMONSTRATION PROGRAM

     Welcome to the ITC232-A
      demonstration program.

The purpose of this demonstration
is to let you explore, in detail,
using the ITC232-A simulator, the
capabilities of this revolutionary
integrated circuit. Use PgUp, PgDn,
Home and End to scroll this text.
Alt-X takes you back to the main
menu. Alt-R resets the simulator.
         INTRODUCTION

The preferred way to connect
devices to a PC is through one of
the serial ports at the back. This
however entails implementing a
serial link which is no easy task on
the peripheral side. The ITC232-A is
conceived to render this task
TRIVIAL while packing a great deal
of features that find use in
practically any circuit.

As you will realize later, it is not
uncommon that you will implement a
solution that normally requires
a few days, in less than 1 hour and
this is including the computer
software!

When we developed the ITC232-A, we
kept in mind 2 major goals:

    Simplicity and Performance.


Simplicity comes from the command
structure implemented. Everything is
in ASCII and the commands are the
initials of the English words
describing the actions to be
carried out.

Performance is expressed in the
variety of features that address
most basic requirements in data
acquisition and control circuit
design. As you will see, this IC
often offers more than 1 solution
to any given problem. And as you
become proficient with the ITC232-A
you will realize that there are only
very few situations in which this
integrated circuit is not the best
solution to solve a data acquisition
and/or control problem.

You will also notice that it is hard
to find an alternative solution for
a serial port data acquisition and
control system with a better
cost/performance ratio.
          CONNECTIVITY

Even though most ITC232-A's end up
connected to an RS232 port, any
other asynchronic transmission
protocol, such as the RS422, RS423,
RS485 or a current loop can be used
as long as the Baud rate is standard
and the rest of the parameters (no
parity, 8 bits and 1 stop bit) are
respected. Since these protocols
are computer independent, you can
control this IC from a PC, or a Mac.
We will explore all the features in
the ITC232-A keeping in mind that
this is just a simulator and in some
cases, such as in the stepping motor
section, we had to slow things down
to let you to see what is happening.
We will first describe how the
simulator works and then guide you
through the examples.

By pressing F1 you can get some
help as well as the function keys
list.
It is assumed, in order to take
full advantage of all the features
contained in this integrated circuit
that you have read the ITC232-A User
Manual included in this diskette.








.C1 (chapter 1)
1.  SIMULATOR DESCRIPTION:

The screen is split into 3 main
areas: [1] The window above
represents a computer terminal from
which you issue commands and receive
results (2 different colours are
used for sending and receiving text)
[2] The window displaying this text
will guide you throughout the demo.
Use PgUp, PgDn, Home and End to
scroll throughout this text.
[3] To the right, a replica of the
ITC232-A is represented. Besides
each pin number there are 3 columns
entitled P, C and F.  Column P has
the value on the port pin. Since
each pin can be either an input or
an output, the value on P will
either represent the applied levels
(0 or 1) to the inputs (in blue) or
a written value to the pin when it
is an output (in red). To prevent
"shorts", we shall assume each pin
has a 1K resistor connected
in series.
Column C shows the configuration for
each port (input or output) with an
arrow indicating the data flow
direction. Column F represents the
value of a phantom bit behind each
pin. When a value is sent to a
port, it is actually written to the
phantom bits. A phantom bit is
connected to its pin only if the
latter is an output. In the case of
an input, reading from that pin will
return the level APPLIED to the pin
and not the phantom bit value.
It follows that when you configure a
pin as an output, the value in the
phantom bit is output IMMEDIATELY
to the pin (more on this later).

At power-up all ports are inputs and
the simulator "applies" a level of 0
to each port pin.

You can change the pin levels, as
well as several other simulator
features by using the Alt keys as
described under F1 (Help).
The rest of the pins is as follows:
IRQL and IRQH are interrupts. The
value applied to these pins is
opposite to the one asserting them.
OSC1 & 2 are in real life connected
to a crystal oscillator circuit.
BAUD determines the ITC232-A speed
at start-up (1=9600, 0=300 Bauds).
The RESET pin is not simulated; you
can achieve the same result by
issuing the command: RESET [Enter]
or do a simulator general reset by
pressing ALT-R.
PWM is an output pin which delivers
a Pulse Width Modulation signal.
VDD goes to +5V and VSS goes to GND.

You can go from the simulator to the
Main Menu and back without losing
your previous configuration or
values. Only by issuing a RESET
command (for the ITC232-A) or an
Alt-R for the simulator will
result in data loss.


.C2  (chapter 2)
2.       READING A PORT:

Besides the computer interfacing
port, the ITC232-A has 5 ports that
you can read: PA, PB, and PC (8 bit
each, pin for pin configurable as
inputs or outputs), PD which is
4 bits (always inputs) and PS which
is a  Serial Peripheral Interface
and shares pins with PD.
Note that after a reset all port
pins are configured as inputs and
the simulator "applies" 0's to them.
These 0's would be the result, in a
real circuit, of having the pins
connected to ground via a 1K
resistor.

Type PRA followed by Enter.
You have just read PA. The mnemonic
is <P>ort <R>ead <A> [Enter]. From
now on, type ONLY the characters
within <> (upper or lower case).

Note the simplicity of the command
structure.
The ITC232-A returns OK, the value
and the prompt (>). A line feed (LF)
is sent after each CR (carriage
return) to improve display clarity.
The CR, LF and legends can be
suppressed by changing the default
configuration using the CRA<P>rogram
command. The default can be also
changed to Hex (CRAH) or binary
(CRAB) or it can be overridden for
one particular reading by adding the
corresponding letter after the
command.
Type PRA B or PRA % to see the
result in Binary and PRA $ or PRA H
for Hex (the space is ignored).

Now let's type in an error:
PRF [Enter]. You will notice that
instead of OK you get the error
message: ?4 No such port. 4 is the
error number. Type CRAP [Enter] and
PRF [Enter]. No legend is now
returned. Type CRAD [Enter]
to return to decimal.

If you wish to repeat the last
command type @. The ITC232-A will
echo the command and execute it.
This speeds up repeating the same
command many times in a row.
You can change the value applied to
an input port on the simulator by
pressing Alt-P and then A, B, C, D
or S for the port you are "applying"
the levels to. Try Alt-P followed by
A and make PA=240 (you can exit by
pressing Esc). You will see PA on
column P changing to 1111000.
Now do PRA and the ITC232-A will
return 240. You can also write in
binary (try Alt-P A B1010 1010) or
Hex (do <Alt-P>, <B>, <$f0>).









Notes on reading a port:

1. All the input port values are in
   blue to indicate that they are
   "applied" to an input pin by the
   simulator.

2. An initial value of 1 is applied
   by the simulator to PD.3. This
   is to enable the SPI without
   having to change PD before.


.C3 (chapter 3)
3. CONFIGURING AND WRITING TO A
     PARALLEL PORT (A, B & C)

Type <P>ort <C>onfigure <B> <240>
[Enter]. This results in bits 4-7
of PB configured as outputs whereas
the lower nibble are inputs. The
sense of the arrows under C has
changed in the output pins and the
previous value in the phantom bit
(column F) now appears on the pin,
in red, to indicate that they are
output values.
Type now <P>ort <W>rite <B> <255>
[Enter]. This is all 1's. Note that
while the phantom bits (under F)
became all 1's, the port bits under
P only change in those pins which
are outputs (they are displayed in
red). If you now type <P>ort <C>onf-
igure <B> <255> [Enter] thus making
all pins outputs, then all the
phantom bit values appear on the
port pins.
This strategy allows you to start a
port pin with a 1 WITHOUT going
through a 0 first. Just tie the pin
to VCC via a suitable resistor. At
power-up, the pin is an input in a
high impedance state, but logically
pulled to VCC by the resistor.
Then write a 1 to the pin and THEN
configure it as an output.
You can then override the resistor
later by writing a 0 whenever is
required.



.C4 (chapter 4)
4.  SERIAL PERIPHERAL INTERFACE

The SPI or PS is slightly more
difficult to use than the parallel
ports but this is offset by the
possibility of doing a lot using
only 3 pins.
For example, our I/O-232 line of
data acquisition boards use the SPI
to read the 10 channels of the 8, 10
or 12 bit A/D converters thus
keeping all of the PA, PB & PC pins
available.
           SPI (PS) PINS

PD2/PS_CK clocks data in and out.
The polarity and phase of the CLK
can be changed when configuring PS
(CLK phase is not implemented
in this simulator).

PD1/PS_TX sends data out the ITC232,
PD0/PS_RX gets data into the ITC232
and PD3/PS_VDD must be tied high
(otherwise an error is issued).

To simulate the SPI we shall pretend
that there are 2 external shift
registers (SR) connected to PS_TX
and PS_RX. Data are clocked in and
out the SR's by PS_CK.

The simulator will show the external
registers only once the SPI is
enabled. An arrow showing the sense
of data flow will connect the shift
registers to the SPI pins.
When reading or writing via the SPI
you will see the registers shifting.
Since 2 different devices might be
connected to PS_TX and PS_RX, you
can have 2 different simultaneous
configurations for the SPI: one for
reading and the other one for
writing operations. Thus you have
<P>ort <C>onfigure <S>erial <W>rite
<value> and PCS <R>ead <value>. You
can also configure both at once
using PCS <A>all <value>.

The configuration parameters are set
by the bits in <value> and they are:
Bit.7: 1 = SPI enabled, 0 = disabled
Bit.2: POL polarity of the clock
       (1: the CLK idles High)

Bit.1: PHASE (between CLK & data)
      (Not implemented in simulator)

Bit.0: ORD (1:the order is inverted)

All other bits are irrelevant.

Unlike other ports, PS MUST be
configured before use.
Type PRS [Enter] and you will get
error # 2.

Now type <P>ort <C>onfigure <S>erial
<W>rite <128> [Enter].
You have just set-up how the SPI
will write to an external
device.  Type PWS $F0 [Enter] and
you'll see the data flowing from the
ITC232-A into the external register.

May be it was too fast. Using Alt -
or Alt + you can reduce or increase
the speed of the simulator. Hit
Alt - several times until it no
longer beeps. Type PWS $F0 again.
You might notice that the shifting
occurs when the CLK goes High.
Values are in red because they are
been output. Notice that PS_CK and
PS_TX become outputs, the data come
out and then the pins become inputs
again.
Check the SPI configuration by
typing PCS? [Enter]. PCSR = 0 since
we have not configured it yet.
To configure the SPI for readings
type <P>ort <C>onfigure <S>erial
<R>ead <132> [Enter].
You should see the input external
shift register simulated at the
bottom. Access this register
by pressing Alt-P followed by S and
make it = 170.
Now type PRS [Enter]. Confusing ?
It is just that whenever the SPI
reads data into it, it also clocks
out the last value sent out the SPI
(or 0 if no previous writing).
Try it out again and follow the
events on PS_TX and PS_RX. Note that
even though you have set-up PS_CK
to idle Low on a write operation,
the reading configuration overrides
this. Thus, we recommend the use of
a parallel port pin to enable each
one of the devices connected to the
SPI to avoid writing undesired
values to an external device while
reading another. On the other hand,
writing while reading the SPI has
a major advantage as illustrated
by this practical example:
In our I/O-232 board series, we
use an MC145041 A/D converter (ADC)
connected to the SPI. This IC has 11
A/D channels and in order to make a
conversion you write the channel
address into the ADC. The result is
stored in a register inside the ADC
which can then shifted into the
ITC232-A by a PRS command.
If you require multiple readings
from the same channel, you do not
need to write the channel number
every time you want a conversion;
this is done automatically every
time you read the SPI.

Type PCS <A>ll 0 [Enter]. This makes
both writing and reading configura-
tions the same. 0 disables the SPI.
We designed this simulator to hide
the shift registers if the SPI is
not enabled. If you try to write a
value out you'll get error #2.
However, the last value is still
stored inside the ITC232-A.
To verify this type PCSA128 and PRS.

Finally, some peripheral IC's send
the LSB first whereas others send
the MSB first. To make life easier
the ITC232-A can inverse the byte
returned to the computer. Do Alt-P
and S and set the simulator to $F0.
Now type PRSH[Enter] and you will
get $F0. Type PCSA129 (thus setting
bit.0 to get results reversed) and
type PRSH again. You should get $0F.

There are many applications for the
SPI. Most of them are useful when
you need to expand the number of
lines in or out the ITC232-A. For
example, if you needed to read 48
bits you could connect 4
parallel/serial shift registers in
a chain and use a pin from PA to
latch on the 48 bits. Then you just
read the SPI 4 times thus recovering
the 4 bytes in the computer. You can
also write out words longer than 8
bits this way too.
.C5 (chapter 5)
5.         INTERRUPTS

The ITC232-A has 2 interrupt pins:
IRQH, which is asserted when a Low
to High transition takes place and
IRQL which is asserted on a High to
Low edge. These interrupts are
edge sensitive ONLY. Thus, with the
appropriate capacitors and a resis-
tor in parallel, several interrupts
can be applied to each one of these
pins and a port be then used to
determine its source.
Interrupts have the highest priority
within the ITC232-A and they can be
used during PWM generation or motor
stepping. When the IRQL is asserted,
an L is sent to the terminal.
IRQH sends an H.

Alt-L "applies" a Low to the IRQL
pin. Press it and you'll see the pin
value changing to 0 and an L on the
terminal screen. Pressing Alt-H
asserts IRQH in the same fashion.

The IRQ pins find use in a variety
of applications, but there are 2
which are of particular interest
and which will be explored further
in the chapters below: The synchro-
nization of a stepping motor with
a counter inside the computer
program (see under STEPPING MOTORS)
and the answering of a phone call by
asserting IRQL under certain
conditions (see under REMOTE
OPERATION).

The IRQ's can also be used to count
the number of pulses created by the
PWM pin (see chapter 7).
Say you wanted to enable a counter
for exactly 1 second in order to
measure a frequency. You could tie
the PWM pin to the enable pin (High)
on the counter AND to IRQL, put out
a 10 pulses/sec signal and count 10
L's (the counter is at that time
enabled for a total of 1 second).
Then turn off the PWM and read the
counts stored using PA, PB or PC.
.C6 (chapter 6)
6. READING RESISTANCE OR CAPACITANCE

The ITC232-A can be used to read a
resistance or a capacitance. All
that is needed is an RC network. The
resistor is connected to VCC, the
cap to GND and pins PC.0 to PC.3 are
connected to the joint between
the cap and the resistance.

The command is <R>esistance <0> or
<1> or <2> or <3> for each bit
followed by [Enter].
What is actually measured is the RC
time constant of the circuit. For
this, the pin is turned into an
output and it is brought Low thus
discharging the capacitor. The pin
is then turned back into an input
and the time to reach the Low/High
transition is then measured and
sent back to the terminal as a value
in the 0-32767 range (in arbitrary
units). Should the value be larger,
a time out error is returned. Type
R0 to see the error.
Now type Alt-T and you will see
the resistance connected to VCC, the
capacitor connected to GND and the
PC bit (x = 0 to 3) connected in
between. Type in 10000 for R (10K),
PgDn and 100 000 for C (.1uF).
You can go from the R to the C
with PgUp and PgDn (the values will
apply to all 4 pins). Now do R0 and
you should read 820 units.

If you type R1 or R2 or R3 the
simulator will always return the
same value. This is not the case for
the actual IC. In fact, calibrations
done on one pin should NOT be used
for another pin since the L/H thre-
shold for each input is different.

Change the values using Alt-T and
you will realize that when the
result is 0 or > 32767, error 7 is
returned. Also notice that numbers
that can be larger than 256, such as
the value of the RC constant, are
always returned in decimal format:
R0 b for example will result in a
syntax error.

Measuring a resistance can be very
handy. For example you could
mechanically link a pot to a robotic
arm and know where it is positioned
as it moves.
In many cases you can read a
resistor instead of a voltage which
requires an external A/D converter.
You can even read the conductance of
a solution (see the User Manual).
A capacitance can be read too. In
this case a reference capacitor
should be used for calibration
and the resistor should be kept
constant.

Note that the accuracy of the
reading relies on the quality of the
capacitor. Thus, use good quality
poly caps (avoid electrolytics)

Also, as mentioned before, each pin
must be calibrated separately.
.C7 (chapter 7)
7.  PULSE WIDTH MODULATION (PWM)

The ITC232-A has a PWM pin capable
of generating a pulse signal of
variable frequency and duty cycle.
The frequency range is 10-10000 Hz
and the duty cycle (dc) range is
0-100% in 1% intervals. The entire
duty cycle range is not available at
frequencies over 250 Hz; it starts
to shrink around 50% as frequencies
get higher (pulse duration becomes
too short to be properly timed).
The PWM signal is interrupt driven;
that is the ITC232-A can do other
things while the PWM is on, except
when the stepper motor is on (in
this case the PWM remains High or it
is pulled Low while stepping).

The PWM commands are:

<W>idth <f>  where f = frequency and
a 50% dc is assumed.
<W>idth <f> <;> <dc>  where dc is
0-100 (percent).
<WL> and <WH> pull the PWM pin Low
or High (same as Wf;0 or Wf;100)

<W?> returns the last W command
issued.

Type W1000 [Enter]. You will hear a
1 KHz tone produced by the simulator
and you will see an "oscilloscope"
on the screen.
Alt-S toggles ON/OFF the sound and
Alt-O turns the scope ON/OFF.

Notice that (1) the duty cycle is
50% and (2) the message f=00999 is
returned by the ITC232-A. This is
the ACTUAL frequency resulting from
rounding errors and Xtal resolution.
Type W1000;23 [Enter]. You will now
see the duty cycle changing on the
oscilloscope. Try W1000;1 [Enter].
Error 8 occurs since this frequency
is too high for a 1% duty cycle.
Play around with other f and dc
values. You'll notice that the scope
always shows 1 cycle. Just pretend
the sweeping frequency has been
changed accordingly.

W20000 [Enter] results in Error 5.

Type WL [Enter] and see how
the signal on the scope goes Low.
WH [Enter] makes the line go High.

Type W50 [Enter] to create a 50 Hz
signal and then do W50;100 [Enter].
This achieves the same as WH.
W50;0 is the same as WL.
Type W2000;47 [Enter] and then type
W? [Enter]. You will see the last
command issued (with the requested,
not the actual f (which is 2003)
being returned to the terminal.








The PWM pin can be very useful for:

1 Generating an analog voltage
  by integrating the pulses with an
  RC network.

2 Varying the speed of a DC motor.

3 Producing a given number of pulses
  by feeding the PWM pin output to
  an IRQ pin and counting the L's or
  H's received by the computer. Then
  WL or WH stops the pulsing.
Type PRS [Enter] (the SPI must have
been configured first) and see how
the simulator allows you to see what
is happening on the SPI pins behind
the oscilloscope.

Type PWA b11110000 [Enter] and then
toggle the scope ON/OFF with Alt-O.
11110000 is now present on PA. The
PWM pin shows ~ when it is pulsing.

Before leaving, type WL [Enter]
and turn the scope OFF with Alt-O.
.C8 (chapter 8)
8.       STEPPING MOTORS

Steppers are motors which move a
certain angle every time their wind-
ings are energized. We recommend
that you read the stepping motor
chapter on the ITC232-A User Manual
for a detailed view on steppers.

The typical stepper has 2 windings
and 4, 5 or 6 wires coming out. The
logical sequence to drive these
steppers is always the same.
As an example, imagine a stepper
with 2 windings. Winding #1 leads
are A and B, winding #2 leads are C
and D. If you energize the AB coil,
the rotor will align itself with
the stator poles. If you then turn
that coil off and energize the CD
coil (phase) then the motor moves 1
step and aligns itself with the
other phase pole. For the next step
you would turn CD off and energize
the first winding but this time the
polarity is inverted (BA) so that
the rotor aligns with the stator in
the opposite direction. Then you
turn that coil off and you energize
winding #2 again but using the
opposite polarity (DC). Turning DC
off and AB on again completes the
cycle which can be represented by
the sequence AB/CD/BA/DC/AB...
If the stepper stator had only 4
poles (2 per winding) it would have
made 1 full turn. In actuality,
stepper stators have many poles
which are connected to the 2 phases
in alternated order. This increases
the resolution per step. To make a
full turn, the entire sequence would
then be repeated several times. If
the sequence is carried out back-
wards, then the stepper moves in the
opposite sense. Note that in the
example, only 1 winding or phase is
on at a time. This is called mono-
phasic operation. We could also turn
on both 2 phases simultaneously thus
aligning the rotor BETWEEN the
stator poles (ABCD/BACD/BADC/...).
This is called biphasic operation
and it delivers a higher torque and motor
efficiency since both windings are
on all the time. The number of
steps/turn is the same as before
but the rotor position, at the end
of each step, is shifted by 1/2 of
a step. Shuffling the 2 previous
sequences (AB/ABCD/CD/BACD...) makes
the rotor align with the stator
pole, then in between, then with
the other pole, etc thus actually
doubling the number of steps per
turn. This is to say that you get
twice the angle resolution you had
before and therefore this modality
is called half stepping. All 3 modes
(monophasic, biphasic and half step)
are addressed by the ITC232-A.
You could write a program to place
on a port the combinations of 1s and
0s to make a stepper work as
described above, but this is tricky,
particularly in regards to creating
the software interrupts to pace the
steps. Thus, we did the whole thing
inside the ITC232-A. Now all you
have to do is to input the configu-
ration you want to use and then
the port, the number of steps and
the sense of rotation. The four
higher bits of ports A,B and C are
used for this purpose even though
they cannot be used simultaneously.
The configuration applies to the 3
ports but you can change it, drive
another stepper and then change it
back to drive the first motor again
without losing steps.
The configuration command is:

<S>tepper <E>nable <A> or <B> or <C>
<M>onophasic or <B>iphasic or <H>alf
step <Speed> <;> <Brake> [Enter].

<Speed> is in steps/s (10-4000).

<Brake> is the duration in steps of
the last one in order to brake the
motor in the last position before
power is removed (otherwise inertia
might keep the motor turning).
Reset the ITC232-A by typing RESET.
Now type SEAB100;100 [Enter] and
S? or SE? [Enter]. You will get a
status report on the steppers. The
port value returned consists of a
combination of the lower nibble on
the port (same as PRA returns) and
the last upper nibble put out for
the stepper (not the actual F bit).
Type S? B [Enter] and you will see
the last value on PA in binary.
Now type SEB [Enter] (since the
configuration is the same for all
ports you do not need to specify the
parameters). Type S? [Enter] again
and notice that PB is also enabled.

Now let's make the steppers move:
Type <S>tep <A> <L>eft <10> [Enter].

You will see the 4 upper bits on PA
changing values. The simulator
does not work at the real speed and
you can actually slow it down by
pressing Alt- or make it go faster
with Alt+. At the fastest speed
only the last 10% of the pulses are
displayed. This allows you to see
the values left on the port after
a large number of steps without
having to wait for the process.

To make the motor turn in the
opposite direction, type SA<R>ight
10 [Enter]. Note that once the
number of steps is achieved, the
last step is held in place for a
while to brake the motor and then
PA[4..7] turn into inputs. The last
value is left on the phantom bits
and it can be easily output on the
port by configuring PA as outputs.

The last motor value on the port is
stored in memory to allow writing
another value on the phantom bits
and yet not losing steps when the
motor is required to step again.
Write down the value on the phantom
bits on PA (it should be 0101).
Now type PCA255 [Enter] and PWA255
[Enter]. Then do 1 step back (SA
<L>eft <1> [Enter]) and 1 step
forward (SAR1 [Enter]).
You should have the value you wrote
down (0101) on the F column and the
upper nibble of PA configured as
inputs. Type S?B and you will see
the upper nibble last value and
all 1's in the lower nibble (same
as you'd get with PRA).

You can disable the stepper ports
by typing <S>tepper <D>isable <A>
or <B> or <C> [Enter]. Type DSA
[Enter] followed by S?.
If you disable all the ports, the
configuration as well as the last
values are kept. Type SEA [Enter]
and you are back in business as
shown by S? [Enter].
One main property of steppers is
that by counting the number of steps
sent out you can know where the
motor shaft, or a device moved by it
actually are. However, at power-up
the stepper and a counter inside the
computer program controlling the
motor must be synchronized. This
can be achieved using the interrupt
pins. Type SAL 50000 [Enter]. The
stepper will be on for a while now.
Press Alt-L or Alt-H to simulate an
interrupt. An L or an H appears on
the screen WHILE THE STEPPER IS
MOVING. Suppose the IRQ pin was
asserted by an end-of-excursion
switch. When the computer receives
an L (or H) the program sends a
space (or Esc or CR). Press the
space bar and notice that the motor
stops and the number of steps left
is sent to the terminal. In this
particular case that number would
be of no use, since we are resetting
the program step counter, but in
other cases (e.g. an emergency stop)
the value returned can be used to
re-synchronize the counter with
the motor position.




.C9 (chapter 9)
9.   REMOTE CONTROL OPERATION

One of the beauties of the ITC232-A
is its ability to handle a phone
call thus allowing you to use all of
its features from a remote location
with a computer and a modem. The
remote mode is intended primarily
for use over ordinary phone lines
but it can be easily used with radio
links, cellular phones or a 2 wire
link over a long distances.

A simple circuit using a 741 op amp,
a modem IC such as the Am7910 or
Am7911, a transistor and a few
diodes is all you need as shown in
the ITC232-A User Manual. This
solution is inexpensive and works
just as if the ITC232-A was
connected to your computer's serial
port.

For the ITC232-A to enter the remote
mode two conditions must be met:

(1) The BAUD pin must be Low (0) and
(2) An IRQL must take place after a
reset (or an OFF command, see below)
and before the first command
(excepting OFF) is issued.

We will pretend we are in a remote
location and our terminal window
shows what comes through a modem via
a regular phone line.
The simulator starts with BAUD = 1
(9600 Bauds). Let's toggle the BAUD
pin to 0 by pressing Alt-B.
Now reset the ITC232-A by typing
RESET [Enter] (in real life this
reset would be done by pulling the
RESET pin Low).

You will see the "Welcome.." message
(notice the lower speed due to the
300 Bauds). The ITC232-A sends this
message out whenever you reset it
but if you were in a remote location
you probably wouldn't see it since
your computer would likely not be on
line at this time.
Next, create an interrupt Low by
pressing Alt-L. In real life, the
IRQL is asserted by the RING signal
(and a few diodes), when you call
from your remote computer.
Notice that PA.0 immediately turns
into an output and goes High (1).
PA.0 is used to answer the phone.
No matter what you do, from now on
until the IC hangs-up, PA.0 will be
functionally excluded from PA.
You can read it but you cannot write
it or reconfigure it.
The only way to make it zero and
thus hang-up the phone is by issuing
the OFF command (don't try it now,
though, see below).

After 7 seconds to let your
computer recognize the presence of
the other modem (we sped-up the
process here), a message appears on
your terminal alerting you that if
no command (or Enter) is received
within 30 seconds, the ITC232-A will
hang-up.
This strategy prevents the system
from locking up on-line in case of a
"wrong number" phone call.
Also, no more than 5 minutes can
elapse between commands or the same
message will be issued again (this
is not implemented here). This is in
case you are cut-off accidentally.
An ASCII(7) (Bell) is sent
at the end of the message in order
to allow the easy detection of this
situation by the program in your
computer.
During the stepping of a motor,
which might take longer than 5
minutes, the time-out clock stops
ticking.

By now, your 30 seconds are probably
over. If not, then wait for a few
more seconds. The ITC232-A sends
DISCONNECTING> followed by ASCII(7)
(Bell) and then it hangs-up by
making PA.0 = 0 and then turning it
into an input.

"Phone" again by pressing Alt-L and
press Enter. The counter turns off.
Now press Alt-L again. You will
notice that from now on until the
ITC232-A hangs up, IRQL works
normally sending an L to the
terminal when pulled Low (we dis-
courage however the use of ITQL for
other purposes while in the
remote mode).



Do PCA255 [Enter] followed by
PWA255 [Enter]. This places a 1 on
all pins. Now type PWA0 [Enter] and
PCA0 [Enter] to make PA all inputs.
PA.0 stays as an output at 1.

Type PCC255 [Enter] and PWC$F0
[Enter]. Then type OFF [Enter] in
order to hang-up. Notice that all
ports and configurations (except for
Baud rate changes, the ITC232-A all-
ways answers the phone at 300 Bauds)
are retained until you phone again.
You may also hung-up by sending
RESET but then all the information
previously stored is lost.

If you are operating remotely you
don't not know if your commands are
being executed properly. Say you
wish to open a valve in a pipeline.
The valve is actuated using PB.0.
One way around this is to write a 1
to PB.0 and then read it back. If
you get a 1 for that pin then the
command was executed properly.
This is better than any other hand-
shake protocol because what you get
is the actual state of the pin.
It is very easy to debug a project
using the remote mode without using
2 phone lines. You can connect the
ITC232-A to the computer serial port
(via adequate drivers), debug your
entire system in your work shop and
once everything works OK, debug,
very quickly and easily, the phone
link hardware.

We suggest that you play around
with the commands until you feel
comfortable with them. You can also
use this simulator as a FIRST
approach to develop a project using
an ITC232-A, but it is recommended
that you breadboard your project
using the actual IC.

We hope you will find this IC useful
and we thank you for choosing our
products.
             THE END
.O Description of other products
GENERAL DESCRIPTION OF THE ITC232-A IC AND THE I/O-232 LINE OF DATA
             ACQUISITION AND CONTROL BOARDS

An important application of personal computers is data acquisition
and control. Unfortunately, the link between the computer and the
peripheral is neither easy nor inexpensive to implement,
particularly if one is looking for a serial link.

ITC MICROCOMPONENTS has developed a single chip intelligent
interface which not only communicates very easily between a
computer's RS232 serial port and the circuit under control but
which also includes a number of functions to make life easier.
Below is a brief description of the possibilities of this chip
(ITC232-A) and of some data acquisition boards containing them
(I/O-232).




                  ITC232-A INTEGRATED CIRCUIT:

The ITC232-A is an integrated circuit containing an intelligent
serial/parallel interface as well as a number of embedded functions
which find application in data acquisition and control systems.
It provides easy access, from a terminal or computer serial port
(RS-232C), to 32 input/output lines arranged in 5 ports which can
be read or written with extremely simple ASCII commands.
This allows control from within a custom written program as well
as from any commercial communication software package ( Procomm(TM),
Mac240(TM) etc). The possibility of operating the ITC232-A from both
a terminal program or a custom program is very convenient for system
debugging.

The ITC232-A is hardware independent; it will work with any terminal
or computer with an RS-232 serial port from 300 to 115200 Bauds.



SERIAL/PARALLEL/SERIAL INTERFACE:

Ports: PA, PB and PC are 8 bits wide. These 24 pins that can be
individually configured and used as an input or an output. In
addition there is PD, a 4 bit input port and PS which shares pins
with PD and can be used as a serial synchronic port. PS is useful
to interface  multiple channel A/D converters to the ITC232-A
without sacrificing the general I/O lines in PA, PB and PC (as
we have done in the I/O-232 line of boards).

Reading a port cannot be simpler. You just have to send <P>ort
<R>ead <port name> [Enter]. The only characters that need to be
sent are the ones within <> (e.g. PRA[Enter] will read PA).
Transactions are by default in decimal. This can be overridden
by adding <B>inary (or <%>) or <H>exadecimal (or <$>) before
[Enter] or by changing the default format.

At power-up or reset all ports are configured as inputs. Thus,
writing to a port requires the corresponding bits (pins) to be
configured as outputs. This is done with the <P>ort <C>onfigure
<port name> <Value> [Enter] command. A 1 in Value makes the
corresponding pin an output, a 0 makes it an input. Binary, decimal
and hexadecimal formats are supported.

Writing to a port is as simple as reading it. After configuring
a port, <P>ort <W>rite <port name> <Value> will place Value on
the corresponding port. Again, value can be in either one of the
three numeric formats mentioned above.

The flexibility and friendliness of the port commands make the
ITC232-A powerful and yet easy to use. But there is more:

ITC232-A EMBEDDED FUNCTIONS:

In addition to serial/parallel/serial interfacing, the ITC232-A
can directly perform several other functions commonly required
in electronic circuits. These are:

-  Two edge sensitive interrupt pins (IRQL (asserted Low) and
   IRQH (asserted High)). Regardless of the ITC232-A activity,
   these pins will immediately send an "L" or an "H", to the
   computer. By measuring the time between "L"'s or "H"'s the
   computer can measure the frequency of a signal.

-  A Pulse Width Modulation pin capable of delivering 10-10000
   Hz, 0-100% duty cycle signals. The command is <W>idth <Hertz>
   <;> <Duty cycle> [Enter]. If <;> <Duty cycle> is omitted, a
   50% duty cycle is assumed. The PWM signal can be used in a
   variety of applications: The PWM signal can be integrated by
   a capacitor and a resistor to provide a 1 % resolution analog
   output, or to regulate the speed of a D.C. motor (a few rpm
   are attainable without major torque lose).

-  All standard Baud rates from 300 to 115200 are supported. The
   Baud rate at power-up or reset must be hardware selected to
   300 or 9600 Bauds. Any other standard value can be
   implemented by sending <B>aud rate <speed> [Enter].

-  Four lines for reading relative resistance or capacitance.
   The lower 4 bits of PC can be used for this purpose. All the
   hardware required is an RC network in which the resistor is
   connected to VCC and the capacitor to GND; the port pin goes
   to the connection between the capacitor and the resistor. The
   command is <R> <PC bit(0..3)> [Enter]. The pin is first
   grounded to discharge the capacitor and then the time to
   recharge it to a certain level is recorded. This time is
   returned as a decimal number between 0 and 32767 and is
   expressed in arbitrary units (the R or C values can be
   calculated by calibrating the system with components of known
   value).

-  Three stepper motor ports with all the necessary logic to
   instrument monophasic, biphasic and half-step stepping modes.
   This is one of the most exciting features in the ITC232-A.
   Stepper motors are normally troublesome to implement. If you
   add up the difficulties to write the computer program to the
   difficulties involved in the interface, to the problems in
   driving a stepper motor, the result is a long and frustrating
   exercise. Not any more. All is done inside the ITC232-A! Wire
   your stepper through 4 transistors or an H bridge driver such
   as the L298 to the upper 4 pins of PA, PB or PC. Then issue
   from the computer <S>tepper <E>nable <port (A, B or C)> <mode
   (B=biphasic, M=monophasic and H=half step)> <steps/s> <;>
   <duration of last step> [Enter] (an increased duration of the
   last step can be used to prevent the motor to keep turning
   due to inertia). That is about it. To make a stepper turn
   just issue <S>tep <port (A,B or C)> <L>eft or <R>ight <number
   of steps> [Enter]. You can also stop a motor on the fly.

-  Remote operation via a phone link using a modem chip in place
   of the RS-232 voltage driver. The ITC232-A is set to work at
   300 Bauds (using the Baud pin). A few diodes and an op amp
   are used to condition the signal and generate a ring
   detector. Upon a ring signal, the ITC232-A answers the phone
   (using PA.0) and establishes a link through the modem chip
   that gives you access to all of its power from a computer
   with a modem in a remote location. Should no commands be
   received within 30 seconds the ITC232-A hangs-up (wrong
   number calls). The same happens after establishing contact
   should no command be received within 5 minutes (accidental
   cut-off). Once contact has been established you can switch
   using the Baud command to any standard speed (300-115200 Bauds).

Some general features are:

-  All port pins are TTL compatible.

-  A 1 keystroke "Again" command to repeat the previous command.

-  11 error messages that prevent most common problems (syntax,
   wrong port names, etc).

-  On-screen help (a summary of all commands is sent to the
   terminal).

-  An extensive 23 page manual explaining in detail each one of
   the above mentioned features and full of examples and tips to
   implement your application in the minimal amount of time.

The flexibility, ease of use and multiple functions of the
ITC232-A, make it ideal for any circuitry requiring computer
control and/or data acquisition. The fact that all the functions
are provided in one chip makes this solution also inexpensive.
Robotics, environmental control and instrumentation are just a
few examples of fields where the ITC232-A finds application.

                       I/O-232 BOARDS:

The I/O-232 line of boards is conceived as an extremely fast and
easy solution to computerized control and data acquisition. The
core of these boards is the ITC232-A chip. In addition, the
I/O-232 boards have a voltage driver for the serial
port, which also provides a -9 V reference voltage, a voltage
regulator and an Analog/Digital converter.  The voltage regulator
allows the use of any power supply voltage between 7.5 and 18
Volts at 25 mA (this is idle; add to this the consumption of the
devices connected to the output ports if necessary). The A/D
converter has 10 software addressable channels with a resolution
of 8 bits (I/O-232-8) or 10 bits (I/O-232-10). All lines and
analog channels are brought to 0.2" spaced pads near the board's
edge where ordinary screw terminals can be placed if so required.
The power connector and a 3 line screw connector for the serial
port cable are included.

Due to the fact that most operations are carried out by 1 chip,
these boards are inexpensive and really easy to control from
the computer.





. Add as many empty lines as required to scroll properly when End or PgDn
. are pressed.
. -----------------------
.F starts help text.
. Each F1 help page MUST finish with a --> or a <--.
. The 2 lines above and this one MUST be included.
. -
 There are 2 types of controls: Function keys (Alt keys and F1)
 and the commands you type in the simulated terminal window. The latter
 always mimic the action of sending something via the serial
 port to the ITC232-A. The Alt keys are used to assign values to the
 simulated chip.

 The easiest way to see this is to pretend you could modify the
 wiring in a breadboard containing an ITC232-A to which you are connected
 from the simulated terminal window. For example pressing Alt-B toggles
 the level applied to the BAUD pin. What follows is a list of Alt keys:

 Further information on commands can be found in the ITC232-A
 User Manual (File included in this disk).

 You can scroll back the demo text if you chose to start in a chapter
 that is not the first one.

                       PgDn for list of Alt keys
.
. The --> below MUST be there!
-->

                           LIST OF Alt KEYS

 Alt-B : Toggles the level on the BAUD pin. See manual, REMOTE OPERATION
 Alt-H : Generates a High interrupt. See manual, INTERRUPTS
 Alt-L : Generates a Low interrupt. Enters remote mode if BAUD=0
         See manual, REMOTE OPERATION and INTERRUPTS
 Alt-O : Oscilloscope On/Off.
 Alt-P : Applies values to the ports in either Bin, Hex or Dec.
         See manual,READING A PORT
 Alt-R : Creates a simulator reset. This includes an ITC232-A RESET command
 Alt-S : Toggles SOUND.
 Alt-T : Assigns values to R and C in an RC network connected to port C
         See manual, MEASURING A RESISTANCE OR A CAPACITANCE
 Alt-X : Exit the simulator
 Alt - : Slows down the simulator (use in Stepper motors, SPI & IRQ's
 Alt + : Speeds up the simulator

. The <-- below MUST be there!
<--
