Remote Technologies RPC-320 manual Programming, Gnd, Load, Gate, Program examples

Page 46

MULTI-MODE COUNTER

DESCRIPTION

The 24 bit multimode counter is capable of up/down, binary, divide-by-n, and quadrature inputs. C ount frequency is DC to 20 M hz. The R PC-320 uses an LSI Com puter Syste ms LS 7166. Its data sheet is foun d in Appendix C.

The COU NT function and statement are used to read from and wr ite to the counter . L INE B is used to program the chip for various op erating mode s.

An interrupt, using ONITR, may be detected on a carry, borr ow, or either event. The eve nt is jumper selectable through W8. When the counter is used, external interrupts (see Chapter 12) may not be used.

W8 P in

Description

1-2

External TTL level through P2-6 or

 

optically isolated through P3

3-4

Carry or borrow pulse from counter

5-6

Carry pulse from counter

7-8

Borrow pulse from counter

Signals connect to the counter via P2. Use the following table to determine signal input to the LS7166.

P2

Function

Name

 

A IN

Count inp ut A

B IN

Count inp ut B

GND

Ground

LOAD

Load counter/latch (LCTR/LLTC)

GATE

Gate/reset counter (ABGT/RCTR)

Input lines (A IN), (B IN), LOAD, and GATE are pulled to + 5V through a 10K resistor .

PROGRAMMING

The LS7166 is capable of several operating modes, all of which are not discussed here. See Appendix C for this chips operating modes. W hat are shown are exam ples of how to program this chip.

NOTE: Be sure to initialize the counter chip before using COU NT com mands. Failure to do so returns m eaningless results.

The COU NT function returns the current counter value.

SECTION 13

Specifically, RPBASIC w rites a 2 to the MCR (M aster Control Register), reads the 3 counter bytes from the OL (Output latch), and converts it to the proper internal BASIC form at.

100 A = COUNT(0)

COUNT statement writes a 24 bit number to the PR (Preset r egister) only. Its syntax is:

200 COU NT 0, D

To transfer this number to the counter, execute the following in the program:

LINEB 6,1,8

The counter number is always 0 on the RPC -320.

LINEB is used to access specific registers within the chip. Accessing control and status registers is shown below. C ounter bank is 6.

100A = LINEB(6,1) : REM Read OSR

200LINEB6,1,X

Line 200 writes to OCCR, ICR, QR, MCR, and ICR register s. W hich registe r selected is determ ined by bits 6 and 7 in the byte written to the chip.

Program examples

This code resets the counter and enables the inputs. The count is printed once a second. To see the count change, momentarily bring " A IN" or "B IN" on P2 to ground.

When " B IN" is gr ounded, the count decrem ents.

10LINEB6,1,32

20LINEB6,1,64+8

30ONTICK 1,500

40GOTO 40

500PRINT COUNT(0)

510RETI

Line 20 can be shortened somewhat . 64 selects the ICR (Input contr ol register ) and 8 enab les inputs. 72 could have been used.

Page 13-1 RPC-320

Image 46
Contents Trademarks REVRevision Table of Contents Interrupt Characteristics Sect ION 11 Watchdog Timer DescriptionExternal Reset Sect ION 13 Multi Mode Counter DescriptionSoftware Revision History Description OverviewSection Manual OrganizationSymbols and Term inology Technical SupportOverview Section System layoutIntroduction Operating PrecautionsEquipment First Time Operation Using a PCUsing a Terminal Uploading and Downloading ProgramsEditing programs and program ming hints Where to GO from Here TroubleshootingEprom Saving ProgramsSaving a Program W3 autorun jumperLoading a Program AutorunningPreventing Autorun Changing Eprom SizeBload CommandsAlternate Eproms BsaveCOM0 Serial Port Serial PortsCOM1 Serial Port RS-422/485 Operating Information Serial Ports SectionRS-422/485 Termination network Two wire RS-485 Accessing Serial BuffersMultidrop Network Disabling CONTROL-C Accessing COM0 and COM1Serial Port PIN OUT RXD CTS RAM Memory Battery BackupChecking the battery Changing MemoryReserved Memory Storing Variables in RAMAssembly Language Interface Block Data TransferDigital I/O Ports Digital and Opto PortsDigital Por t J3 High Current Port L8 Digital I/O CommandsDigital Port P6 Optically Isolated InputHigh Current Output Interfacing Digital I/O to an opto-module rack Interfacing to switches and other devicesDigital I/ O prog ramm ing exam ple Ls e Width Modulation PWM Digital and Opto Ports Section Conne ctor pin ou t J3Line Config LineCount Line BDate Setting Date and TimeM E Section Writing to the Display Connecting DisplaysProgramming Example Display Connector PIN OUT Display TypesKeypad Port Program explanationKeypad Port PIN OUT J5 Initialization Connecting Analog InputsAnalog Input Overvoltage conditionsExamples u sing CON FIG AIN Differential ModeAcquiring Analog Data Temperature Measurement Noise NotesAnalog Input Section Data logging on a timer tick Measuring Higher VoltagesAmplifiers Converting Analog MeasurementsMeasuring 4-20 mA current loops Calibration Watchdog Timer External ResetOptically Isolated Interrupt Interrupt CharacteristicsProgram Example Optically isolated and TTL interrup ts Load ProgrammingGND GateCOU NT0 Power Management Further Power ReductionPower Management Section Program Examp leElectrical Specifications Technical InformationJumper Descriptions Mechanical SpecificationsMemory and I/O Bank MAP Bank