
MULTI-MODE COUNTER CHAPTER 14
14-4
Figure 14-2 W7 and W9 jumper detail
HIGH VOLTAGE INPUT
Connector J10, pin 10 can accept a ±15V signal. As
shipped from the factory, it detects a high input level
(output goes low) at about + 3 volts and a low input
(output goes high) at about + 2 volts. This level is
programmable by changing R28.
Lower the value of R28 to incr ease the “ high” level.
For example, changing R28 to 23K raises the high input
level threshold to about 4. 2 volts and the low level to
about 3.2 volts. The thresholds are approximate and
change fr om lot to lot.
The output of the buffer connects to a c ounter inp ut via
jumper W9. When W9 is jumpered it will goto the
counter’s “A” input and to J10-9.
The buffer inver ts the input signal. A count incr ements
when a signal goes “ high to “ low” on this input.
This line is useful for con necting pr oximity sw itches to
the counter. It may be used to filter switch contact
closures by tying a capacitor from its input to ground. A
10K pull-up resistor is connected to the input.
PROGRAMMING
The LS7166 is capable of several operating modes, all of
which cannot be discussed. See Appendix A for this
chips operating modes. What are shown are example of
how to program this chip and some common operating
modes. .
The counter chip must be initialized before using the
COUNT function. You need to write to the ICR (Input
control register), OCCR (Output control register), and
possibly QR (Quadrature register) in order to set up the
counter. Examples are given below for different
operating modes.
The COUNT function returns the current counter value.
Specifically, CAMBASIC writes a 2 to the MCR
(Master Control Register), reads the 3 counter bytes
from the OL (Output latch), and converts it to the proper
internal BASIC for mat.
The LS7166 has several count related registers. The PR
(Preset register ) is a kind of holding register . A bit in
the MCR (Master control register) transfer s the
information to the CNTR (counter). T he PR is used to
pre-load the counter . T his pre-load value can be put into
the main counter by setting a bit in the MCR or bringing
the LCTR (J10-6) line low momentarily.
The CNTR is read by first setting another bit in the
MCR to transfer CNT R to OL (Output latch).
CAM BASIC C OUN T(8) function does this.
The counter is capable of generating an interrupt every
time CNTR equal PR, or when CN TR passes through 0
while counting up or down.
NOTE: Pulses from the LS7166 C Y and BW pins m ust
be long enough for the RPC2350 to recognize
an interrupt. Counting speed is limited to about
100 KHz when interrupts are desired. Even
these can be missed as CAMBASIC shuts off
interrupts at points in the pr ogram , especially
when writing to the graphics screen or Flash.
WARNING:
Do not use the CY or BW pulses to generate an
interrupt in quadrature mode. The pulses are far too
short and are easily missed by hardware. Contact
Remote Processing for solutions.
Program Examples
This code, in CN TR1. BAS, r esets the counter and
enables the inputs. If d esired, connect J2-19 to J10-9 to
see the count increment. The count is printed once a
second. If desired, you can bring J10-9 to another
device.
10 pr "Counter test / demo program"
20 pr "Uses J2-19 to generate pulses."
30 pr "Connect to J10-9 (counter
input)"
40 print "Count continues until there
is an error. (about 16 million)
50 pr "Current count is printed every
second."
100 config pio 0,0,1,1,1,0 :'make
port A output
110 out &f1,32 :'reset counter to 0
120 out &f1,72 :'Enable counter A/B
Comentários a estes Manuais