Remote Technologies RPC-320 manual Keypad Port, Program explanation

Page 34

KEYPAD PORT

INTRODUCTION

16, 20, or 24 position keypads are plugged into keypad port J5. Keys are arra nged in a m atrix for mat. A key is recogn ized whe n a row and a colum n connect.

RPBASIC-52 scans and debounces the keypad every 50 ms. Keypad pr esses are retur ned as a num ber fr om 1 to 24 using the KE YPA D function . Ke ypad scann ing is always active and cannot be turned off. Up to 8 key presses are buffered.

Keypad presses are multi- tasked using ON KEYPAD . When a key is pressed, the program br anches to the subroutine.

Keypads from Rem ote Processing simply plug into J5. The keypad cable length should be limited to less than 5 feet.

Figure 9-1 Keypad connector

PROGRAMMING EXAMPLE

The following example sets up RPBASIC to scan a 16 position keypa d. T he results a re echo ' ed when a key is pressed. Press the 'D' key to enter .

SECTION 9

10 STRING 200,20

20 $(0) = "123A456B789C*0#D"

30 P = 1

40 PF = 0

50 PRINT "Enter a number from the keypad",

REM Rest of program continues

REM Scan keypad and update display

200 GOSUB 500

210 IF PF = 0 THEN 200

220 PRINT

230 PRINT "Entered string is: ",$(2)

240 PF = 0

250 GOTO 50

500 A = KEYPAD(0)

510 IF A = 0 THEN 500

520 IF A = 12 THEN 600 : REM Process clear

530 IF A = 16 then 700 : REM process enter

540A=ASC($(0),A)

550PRINT CHR(A),

560ASC($(2),P) = A

570P = P + 1

580ASC($(2),P) = 13

590RETURN

600REM Clear input string

610$(2) = ""

620P = 1

630RETURN

700REM Enter processing

710P = 1

720PF = 1

730RETURN

Program explanation

Line 20 defines the keypad legend. Letters may be redefined as necessary.

Line 30 sets the position counter used to insert characters into the string.

Line 200 w aits for a ke y press. The enter ed string is printed.

Line 500 checks the keypad. If a character is available, it processe s it.

Lines 540-590 update the input string and position. A < CR> is inserted to mark the end of string.

Page 9-1 RPC -320

Image 34
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