Remote Technologies RPC-320 manual Commands, COU NT0

Page 47

MULTI-MODE COUNTER

The following program example returns a frequency.

Input signal is at "A IN" .

100 LINEB 6,1,32

110LINEB 6,1,72 : REM enable inputs

120ONTICK 1,500

130IDLE

140GOTO 130

500A=COUNT(0) : REM get count

510C=A-B : REM figure change from last time

520PRINT "Frequency = ",A

530B=A

530RETI

The fir st frequen cy read will always be a bit off. This is because of the time required to initialize ONTICK. Subsequent readings are more accurate.

Accuracy is increased by stretching readings to every 10 seconds. This is neces sary w hen higher accura cy is needed.

Other factors affecting accurate readings in this program include serial communications and ONITR statement. If ONITR is in process, ONTICK is delayed until ONITR is finished.

The problem w ith this routine is periodically, a large negative number is returned. This is because the multimode counter has rolled over. This is corrected by periodica lly reseting the CN TR or transfer ring P R to CN TR. Refer to the data sheet, Appendix A for counter operating mo des.

This program sets up the LS7166 to cause an interrupt when a pr eset numb er of cou nts is reach ed. W8[7-8] is jumpered to interrupt on a borrow.

10

LINEB 6,1,132

: REM write to CNTR

20

COUNT

0,1000

30

LINEB

6,1,8

: REM transfer PR to CNTR

40LINEB 6,1,72 : REM enable A/B counters

50ONITR 500

100

PRINT COUNT(0) : REM print progress

110

GOTO 100

500PRINT "In Interrupt"

510RETI

Line 10 sets OCCR to divide by N. Line 50 enables interrupts. Line 100 prints the counter. When pulses are applied to the A input, the count will go down. When 1000 pulses are detected at A input, the message in line 500 is printed.

SECTION 13

COMMANDS

The table below lists commands used with the counter .

Comm and

Function

COU NT(0)

Returns value in counter

C O UN T 0, n

Writes value to counter

Page 13-2 RPC-320

Image 47
Contents Revision REVTrademarks Table of Contents Sect ION 13 Multi Mode Counter Description Sect ION 11 Watchdog Timer DescriptionExternal Reset Interrupt CharacteristicsSoftware Revision History Manual Organization OverviewSection DescriptionTechnical Support Symbols and Term inologySystem layout Overview SectionEquipment Operating PrecautionsIntroduction Uploading and Downloading Programs Using a PCUsing a Terminal First Time OperationEditing programs and program ming hints Troubleshooting Where to GO from HereW3 autorun jumper Saving ProgramsSaving a Program EpromChanging Eprom Size AutorunningPreventing Autorun Loading a ProgramBsave CommandsAlternate Eproms BloadCOM1 Serial Port Serial PortsCOM0 Serial Port RS-422/485 Termination network Serial Ports SectionRS-422/485 Operating Information Multidrop Network Accessing Serial BuffersTwo wire RS-485 Serial Port PIN OUT Accessing COM0 and COM1Disabling CONTROL-C RXD CTS Changing Memory Battery BackupChecking the battery RAM MemoryStoring Variables in RAM Reserved MemoryBlock Data Transfer Assembly Language InterfaceDigital Por t J3 Digital and Opto PortsDigital I/O Ports Optically Isolated Input Digital I/O CommandsDigital Port P6 High Current Port L8High Current Output Digital I/ O prog ramm ing exam ple Interfacing to switches and other devicesInterfacing Digital I/O to an opto-module rack Ls e Width Modulation PWM Conne ctor pin ou t J3 Digital and Opto Ports SectionLine B Config LineCount LineM E Setting Date and TimeDate Section Programming Example Connecting DisplaysWriting to the Display Display Types Display Connector PIN OUTProgram explanation Keypad PortKeypad Port PIN OUT J5 Overvoltage conditions Connecting Analog InputsAnalog Input InitializationAcquiring Analog Data Differential ModeExamples u sing CON FIG AIN Noise Notes Temperature MeasurementAnalog Input Section Measuring Higher Voltages Data logging on a timer tickMeasuring 4-20 mA current loops Converting Analog MeasurementsAmplifiers Calibration External Reset Watchdog TimerProgram Example Interrupt CharacteristicsOptically Isolated Interrupt Optically isolated and TTL interrup ts Gate ProgrammingGND LoadCOU NT0 Further Power Reduction Power ManagementProgram Examp le Power Management SectionTechnical Information Electrical SpecificationsBank Mechanical SpecificationsMemory and I/O Bank MAP Jumper Descriptions