+ All Categories
Home > Documents > o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is...

o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is...

Date post: 11-Jun-2020
Category:
Upload: others
View: 7 times
Download: 0 times
Share this document with a friend
148
... o .... o o Compumotor Division Parker Hannifin Corporation pIn 88-005548-01 Y1 ilarker
Transcript
Page 1: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

... o .... o

o Compumotor Division Parker Hannifin Corporation pIn 88-005548-01 Y1 ilarker

Page 2: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

TABLE OF CONTENTS PART I - OPERATIONS

l.l Introduction l.2 This Manual l.3 Model 52 Description l.4 Quick Start l.5 Initialization

1.5.1 INSPECTION 1. 5.2 POWER l. 5. 3 CONSOLE REQUIREMENTS l. 5.4 OPENING COMMUNCATIONS l. 5.5 GETTING STARTED

1.6 Installation 1.6.1 MOUNTING l. 6 . 2 WIRING: POWER l. 6 . 3 WIRING: SIGNALS

l.7 Control l. 7 . 1 TIMING l. 7.2 ENCODER FEEDBACK FUNCTIONS l. 7.3 FREQUENCY OUTPUT FUNCTIONS 1.7.4 ANALOG I/O 1.7.5 REMOTE SIGNAL CONDITIONING I/O

PART II - HARDWARE REFERENCE

2.1 Specifications ........ . 2.2 Screw Terminal Connections ..... .

2.1.1 ISOLATED INPUTS - IN A through IN D 2.1.2 ISOLATED OUTPUTS: "OUT A" through "OUT D" 2.2.3 ISOLATED RESET INPUT: "RST+" and "RST-" 2.2.4 ENCODER INPUTS: "CH A+" through ItCH Z_" 2.2.5 MOTOR OUTPUTS: "STEP+" through "DIR-2.2.6 ANALOG OUTPUT and GND ....... . 2.2.7 ANALOG INPUTS: "IN#l" through "IN#4"

2.3 PARALLEL I/O Connections 2.3.1 PARALLEL OUTPUTS 2.3.2 PARALLEL INPUT

2.4 RS-232 CONNECTIONS 2.4.1 PRINTER PORT 2.4.2 RS-232 USER PORTS

2.5 GROUNDING ...... . 2.6 Analog Input Details

2.6.1 CONFIGURING ANALOG INPUTS 2.6.2 ANALOG INPUT ACCURACY.

PART III - PROGRAMMING CONSIDERATIONS

3.1 MODEL 52 BASIC . . . . . . . . . . . 3.1.1 VARIABLES .......... . 3.1.2 MANIPULATING CHARACTER STRINGS 3.1.3 INSTRUCTION ANOMALIES .....

i

1 1 2 4 4 5 5 5 6 6 8 8 8 9

10 12 12 13 13 14

16 17 17 19 19 20 22 23 23 25 25 27 27 28 29 29 30 30 33

34 34 35 36

Page 3: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

3.1.4 HARDWARE DEVICES 3.2 Program and Memory Manipulation

3.2.1 GENERATING AND EDITING PROGRAMS 3.2.2 SAVING PROGRAMS ... 3.2.3 RECALLING PROGRAMS 3.2.4 AUTOMATIC OPERATIONS 3.2.5 ACCESSING MEMORY

3.3 Input/Output Programming Fundamentals 3.3.1 BASIC I/O READ AND WRITE INSTRUCTIONS 3.3.2 BITS, BYTES, AND DISCRETE I/O LOGIC. 3.3.3 SETTING BITS: THE LOGIC "OR" FUNCTION 3.3.4 CLEARING BITS: THE LOGIC "AND" FUNCTION 3.3.5 INVERTING: THE "XOR" LOGIC FUNCTION 3.3.6 READING INPUTS 3.3.7 INPUT DECISIONS ......... .

PART IV - PROGRAMMING

4.1 I/O Devices. 4.1.1 ANALOG INPUT 4.1.2 ANALOG OUTPUT 4.1.3 PARALLEL OUTPUTS 4.1.4 PARALLEL INPUTS. 4.1.5 MULTIFUNCTION DEVICES 4.1.6 FREQUENCY OUTPUT AND MOTOR CONTROL

4.2 Custom BASIC Instructions ..... .

4.3

4.2.1 ANLG: THE ANALOG I/O INSTRUCTION 4.2.2 DIO: THE DISCRETE I/O INSTRUCTION 4.2.3 SCAN: THE I/O LOGIC INSTRUCTION. 4.2.4 CTR: THE COUNTER/TIMER INSTRUCTION 4.2.5 QUAD: THE ENCODER INSTRUCTION ... 4.2.6 COM: THE RS-232 SETUP INSTRUCTION. 4.2.7 RCV: THE RS-232 RECEIVE INSTRUCTION 4.2.8 XMT: THE RS-232 TRANSMIT INSTRUCTION 4.2.9 THE STR INSTRUCTION. 4.2.10 THE VAL INSTRUCTION 4.2.11 THE LOAD INSTRUCTION 4.2.12 THE SAVE INSTRUCTION Interrupts 4.3.1 AUTOMATIC INTERRUPT SYSTEM 4.3.2 REAL TIME CLOCK: THE ONTIME INTERRUPT 4.3.3 OTHER BASIC INTERRUPTS 4.3.4 ENABLING DISCRETE INPUT INTERRUPTS 4.3.5 BASIC INTERRUPTS 4.3.6 DISABLING INTERRUPTS

4.4 Machine Language Routines . 4.4.1 CALL 0: INITIALIZE 4.4.2 CALL 1: PASS INTERRUPT CODE 4.4.3 CALL 2: DISABLE ALL INTERRUPTS 4.4.4 CALL 3: SET ANALOG INPUT RANGE 4.4.5 CALL 4, 6, and 8: PARALLEL BCD INPUT 4.4.6 CALL 5, 7, and 9: PARALLEL BCD OUTPUT

ii

38 39 39 40 41 42 43 45 46 46 48 48 49 49 49

51 51 52 52 54 55 59 60 62 63 66 67 70 71 73 76 78 79 81 81 82 83 84 85 86 86 90 91 93 93 94 94 95 95

Page 4: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

4.4.7 CALL 10: ISOLATED BCD INPUT 4.4.8 CALL 11: ISOLATED BCD OUTPUT 4.4.9 CALL 12: PARALLEL BINARY INPUT 4.4.10 CALL 13: PARALLEL BINARY OUTPUT 4.4.11 CALL 14: INVERT PARALLEL INPUTS 4.4.12 CALL 15: INVERT PARALLEL OUTPUTS 4.4.13 CALL 16: CONFIGURE 16 PARALLEL OUTPUTS 4.4.14 CALL 17: CONFIGURE 24 PARALLEL OUTPUTS 4.4.15 CALL 18: CONVERT 16 BIT BINARY . 4.4.16 CALL 19: CONVERT 32 BIT BINARY . 4.4.17 CALL 20: CONVERT A BINARY POSITION REPORT 4.4.18 CALL 21: ENABLE CH Z INTERRUPT . 4.4.19 CALL 22: DISABLE CH Z INTERRUPT 4.4.20 CALL 23: ENABLE IN D INTERRUPT 4.4.21 CALL 24: DISABLE IN D INTERRUPT 4.4.22 CALL 31: RECEIVE BUFFER 0 SIZE 4.4.23 CALL 32: RECEIVE BUFFER 1 SIZE 4.4.24 CALL 49: REPORT REVISION LEVEL 4.4.25 CALL 127: PURGE EEPROM .

PART V - SAMPLE PROGRAMS

5.1 Discrete and Timed Analog I/O Control Program 5.1.1 PROGRAM DESCRIPTION 5.1.2 I/O DESCRIPTION 5.1.3 PROGRAM LISTING .. 5.1.4 USE OF THE SCAN INSTRUCTION

5.2 Sample Parts Counting and Motor Control Program 5.2.1 PROGRfu~ DESCRIPTION 5.2.2 I/O DESCRIPTION 5.2.3 PROGRAM LISTING ..

5.3 The Directory Program .. 5.4 The Test and Demonstration Program

5.4.1 PROGRAM DESCRIPTION .. . 5.4.2 PROGRAM LISTING .... .

5.5 The CX/372/2l00 Control Program

APPENDIX A: PARALLEL I/O CONNECTIONS

APPENDIX B: THE M&~ORY MAP

APPENDIX C: SAMPLE I/O CONNECTIONS C-1 SIGNAL CONDITIONING CIRCUIT C-2 OPTICALLY ISOLATED INPUT CIRCUIT C-3 OPTICALLY ISOLATED OUTPUT CIRCUIT C-4 OPTICALLY ISOLATED MULTIPLEXED THUMBWHEEL SWITCHES C-5 DRIVING A SPEAKER WITH THE STEP OUTPUT C-6 DRIVING A TRANSLATOR WITH THE STEP OUTPUT

APPENDIX D: DIMENSIONAL DRAWING ...

APPENDIX E: CIRCUIT ASSEMBLY DRAWING

iii

97 97 98 98 99 99 99

100 100 100 100 101 101 101 101 102 102 102 102

103 103 104 105 106 107 108 109 109 112 114 114 117 131

137

138

141 141 142 143 144 145 146

D-1

E-l

Page 5: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8{86

PART I OPERATIONS

1.1 Introduction

The Parker Compumotor Model 52 microcontroller is a small computer designed to perform input and output signal control. For the sake of brevity, the Model 52 will be referred to as the "B52" throughout this document.

As a controller, the B52 is most often employed in a dedicated control function which it remembers and executes when power is turned on.

As a computer, it is flexible enough to store multiple operations, and may be reprogrammed to perform new tasks, permanent or temporary, at any time.

Programming requires familiarity with the BASIC programming language. Parker Compumotor Corporation does not assume responsibility for providing instruction in BASIC programming.

1.2 This Manual

This manual is organized in five parts, follwoed by several Appendices. The five include Operations Guide, Hardware Reference, Programming Fundamentals, I/O Programming, and Sample Programs.

The Operations section provides an overview of how the B52 is organized, and what is required to apply it to a given task.

The Hardware Reference section goes into detail on Input and Output characteristics, and how to make connections to B52 I/O (Input/Output hardware).

The Programming Fundamentals section describes the B52's BASIC language and goes into detail on how to manipulate memory, and implement I/O functions.

The I/O Programming section deals with B52 BASIC I/O instructions, interrupts, and machine language tools.

1

Page 6: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8/86

Refer to the Table of Contents for details on subjects of interest. Much specific reference information is included in the various Appendices.

BASIC programming code examples are printed as follows:

100 PRINT "Example"

In the text, B52 connector names are printed as follows:

CONSOLE

1.3 Model 52 Description

The B52 is designed for small scale industrial process control. Many I/O functions and a high level programming language are built in. A standard terminal device is all that is required to program the Model 52, standard I/O signal conditioning equipment is all that is necessary to meet most control requirements. The input and output functions supported are as follows:

2 RS232C ports for remote device control I RS232C port for operator console I RS232C port for printer output 4 On board optically isolated inputs 4 On board optically isolated outputs 2 24 channel I/O connectors for signal conditioning I Differential pulse output I Differential level output 3 Differential encoder inputs with quadrature detection 4 16 bit counter/timers 4 Analog input channels 1 Analog output

All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs, three counters, four timers, and two RS232C ports.

The B52 uses the Intel 8052 microprocessor clocked at IlMhz. The internal BASIC interpreter provides fast execution with simple BASIC instructions for I/O control. Floating point math functions are supported.

The B52 comes equipped with 16 kilobytes of read/write memory (RAM) and 16 kilobytes of solid state non-volatile read/write memory (EEPROM) for power-off program storage. Multiple programs can be stored in EEPROM and run from either EEPROM

2

Page 7: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8{86

or RAM. An additional 24 kilobytes of permanent memory (EPROM) contains machine language "device drivers" for B52 peripheral devices, and some Compumotor utility programs. See Section 4.2.11 and Chapter 5 for listings and details on the functions of these utilities.

The B52 can be configured to run programs from power on without operator input. Programs are easily transmitted into or out of the unit for editing or storage.

The B52's analog inputs can be used to read temperature, pressure and other transducers with analog voltage outputs. The analog output can be used to control servo amplifiers and other voltage controlled devices. Figure 1.1 below depicts the system block diagram.

The programmable peripheral I/O devices used in the Model 52 are the 8255 and the 8256. Specifications for these devices and the 8052 microcontroller can be found in the Intel Microprocessor and Peripheral Handbook and the Intel Components Data Catalo~. Specifics on the Basic programming language used by the 8052 can be found in the Intel MCS BASIC-52 USERS MANUAL. Machine language programmers will need the Intel Microcontroller Handbook.

Console_ FlS232

Printer RS232-

Step_ (PNM)

8052

/

8255

II 24 Inputs

Figure 1.1 System Block Diagram

16K RAM (User

Programs)

l 8255

V 24 Outputs

16K EEPROM

(User Programs)

DAC

Analog Output

3

24K EPROM (Utility

Routines)

ADC

I I I I Analog Inputs

8256

1---- Optically Isolated

1---- Inputs

f--- RS232

l...------I'1L E,""'" Counter k:!.f C"'''o'

8256

1---- Optically Isolated

f--- Outputs

f--- AS232

f--- Direction

Page 8: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Yl) 8/86

1.4 Quick Start

It is a simple matter to get the B52 running if a suitable terminal device is on hand.

Required Equipment:

Terminal - some keyboard/display device with RS232 communications capability, configured for three wire operation (no handshaking)

115 VAC Power and cord

If 230 VAC operation is required, or other questions come up, refer to the Initialization and Installation sections below.

How to do it:

1. Connect power to the B52. 2. Connect the terminal with a standard RS232 cable to the CONSOLE connector. 3. Press the Space bar - the B52 should respond with its opening message

If no user programs have been saved in EEPROM, the resident Compumotor Directory program will run automatically. Use it to access other internal B52 test and demonstration programs. Press "Control C" to stop the program.

The B52 is then ready for programming.

The experienced operator will need the Intel BASIC-52 USERS MANUAL for syntax reference.

Section 3.1 of this manual deals with the quirks of BASIC-52, Sections 4.2 through 4.5 describe the custom instructions and programming tools provided for I/O operations.

1.5 Initialization

This section the installation procedure for the Model 52 Industrial Control Module, including options and considera­tions for remote terminal operation and auxiliary RS-232C ports and printer alternatives.

4

Page 9: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8/86

1.5.1 INSPECTION

Inspect the shipping carton carefully for evidence of physical abuse or damage. Report any such findings im­mediately to your receiving department and to the carrier. Compumotor Corporation cannot be responsible for in transit damage.

Unpack the shipping carton and inspect the B52 for any damage, cracks, broken parts, or damaged cables. Save the packing materials until functional checks have been completed.

1. 5.2 POWER

The Model 52 will run on 120 or 240 VAC. The unit is factory set for 120 VAC. To convert to 240, it is necessary to remove the top cover, locate the four pin jumper connector J5 near the fuseholder, and move it to the adjoining 240 volt plug, J6 as shown on the circuit assembly drawing in Appendix E. The l20VAC .25A fuse should then be replaced with the 240VAC .125A fuse supplied.

1.5.3 CONSOLE REQUIREMENTS

Any full duplex serial device which allows the operator to enter alphanumeric commands, and displays echoed characters will serve as the console for the B52. The unit supports Baud rates up to 19200. Programmers will want to use another computer to communicate with the B52 for programming in order to take advantage of their computer's editing facilities.

When a computer is used to emulate a dumb terminal, care must be taken when using the PRINT and LIST commands. The B52 sends characters at a high rate, and is likely to overflow the computer's input buffer unless the computer uses the "XON/XOFF" protocol. LIST small portions of code, and re­strict or delay PRINT operations to avoid this condition. By the same token, if a computer and communications utility software are used to transfer (download) programs to the B52, programs might be transmitted too fast for proper reception.

To avoid this problem, either the downloading software must wait for the B52 to respond with a prompt (">") after each line, or a time delay must be added between transmitted program lines. A delay of 250 to 500 milliseconds is adequate. This will give the Model 52 time to process each incoming line, and higher Baud rates can be used.

5

Page 10: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Opera~ors Manual (88-005548-01 Rev. Y1) 8/86

1.5.4 OPENING COMMUNCATIONS

After power has been applied, the B52 initializes its internal devices. Unless it has been programmed, to a specific Baud rate, it enters an automatic baud rate setup routine. The operator must send a Space character (press the space bar).

Once the space character is received (ASCII 32), the Model 52 measures the transmission rate and sets it's own baud rate to match that of the console device. Following this "AUTO-BAUD" setup, the B52 will run a program. If programmed to do so, it will run a stored program, otherwise it will run its internal Directory program.

NOTE: If a space character is not the first character sent to the B52, it will set it's Baud rate to an unpredictable value. If this happens the screen of the remote console will display random characters, and it will be impossible to communicate. In this event, a reset will be necessary, either by cycling the power, or by activating the reset input.

If the B52 fails to respond at all, either the terminal (Console device) configuration is incorrect, or it is automatically running a stored program. To correct Console problems, make sure the terminal is configured for three wire DTE operation:

The terminal output must connect to B52 CONSOLE connector pin 2. This output will measure -12 volts or so to Ground (pin 7). Also, any required hand­shaking protocol must be disabled (or defeated: jumper terminal pins 4 to 5 and 6 to 20).

Note that the Model 52 can be programmed to a fixed Baud rate and can automatically run a stored program after reset if desired. See Section 3.3.2: Saving Programs.

1.5.5 GETTING STARTED

Once the Model 52 has been initialized as discussed above, the operator can begin to use the BASIC interpreter right away to explore the capabilities of the computer. The Directory program provides access to the internal Test and Demonstration program, and any user programs that have been saved in memory.

6

Page 11: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Opera~ors Manual (88-005548-01 Rev. Yl) 8/86

The Test and Demonstration program will present a menu of options for I/O testing.

To stop any program, type "Control C". The B52 responds:

STOP IN LINE nnn

then:

READY > The BASIC-52 is now in Direct command mode. As with most

BASIC interpreters, MCS BASIC 52 allows operating in either a Direct mode (no program line numbers), or in program Run mode.

Direct mode will only allow the execution of a single command line at a time. Even so, the operator can calculate equations, or control various I/O devices in this mode without doing any programming.

Example:

> PRINT PI*3**2*6

(volume of a 6 by 6 cylinder)

Other Direct mode commands include program control commands.

Type:

Type:

LIST (and RETURN) to inspect the program

RUN (and RETURN) to restart it.

This program and others can be stopped, and the B52 returned to direct command mode by typing "Control C". (hold down the Control key and type "C").

Once communications have been established, programming can begin for the desired application. Once an application program is entered, debugged, and saved (in "EEPROM"), the unit is ready for site installation.

7

Page 12: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Opera~ors Manual (88-005548-01 Rev. Y1) 8(86

1.6 Installation

Field installation of B52 units involves mechanical mounting and various connections.

1.6.1 MOUNTING

The Model 52 is designed for vertical mounting. Number 10 screws are suitable for fixing the unit to a vertical surface using the mounting ears on the rear corners. Refer to Appendix D for dimensional details.

Vertical orientation provides the optimum convection cooling of internal components.

The B52 must be mounted in an environment protected from contamination by particles, corrosive atmosphere, excessive humidity, and fluids. In this situation, the unit should be mounted in a suitable enclosure. Enclosures should be ventilated to prevent internal heat build up.

1.6.2 WIRING: POWER

The B52 must be wired for Power and signal connections. Connect standard color power wires to B52 power terminals as follows:

LINE NEUT EARTH

BLACK WHITE GREEN

(BROWN) (BLUE) (GREEN/yELLOW)

Suitable wire guage for Power: 18 AWG

In industrial environments where heavy power use may upset the line, it may be necessary to use a line filter to protect the B52.

8

Page 13: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Opera~or~ Manual (88-005548-01 Rev. Yl) 8/86

1.6.3 WIRING: SIGNALS

Signal wiring includes RS-232, Parallel Input and Output, and screw terminal connections.

RS-232 connections should be made with shielded cable, the shield being connected at the other end of th~ cable. Cables are plugged into the appropriate connectors in the bottom of the unit, and must be screwed down to avoid intermittant connections, or cables falling out. The maximum recommended cable length is 50 ft. The connectors used include:

RS292#1 PRINTER

RS292#O CONSOLE

Parallel connections are usually made to standard signal conditioning panels using standard flat cables obtained with the panels. These cables are not shielded so cable lengths below three feet are recommended. The connectors used are:

PARALLEL INPUT PARALLEL OUTPUT

Refer to Control Outputs section 1.7.5 for additional details on signal conditioning connections.

Screw terminal connections (other than Power) include both optically ISOLATED and non- isolated terminals. Non- isolated connections should be shielded (or at least twisted pairs) to avoid electrical interference. The sheild can be connected to the SHIELD and EARTH terminals or the frame.

DO NOT CONNECT SHIELDS TO THE "GND" TERMINALS

Suitable wire guage for discrete wiring: 24 AWG

References:

I/O Functions: Section 1.7 Screw Terminals: Section 2.2 Parallel I/O: Section 2.3 Signal Conditioning: Section 1.7 RS-232: Section 2.4

9

Page 14: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operaeors Manual (88-005548-01 Rev. Yl) 8/86

1.7 Control

Process control involves monitoring various process conditions, the inputs, and actuating various devices, the outputs, to keep the process under control. Like any feedback control system, the controller measures the error in various process parameters, and decides what response is called for.

The process controller must make logical decisions. In a simple temperature control situation, for example, the controller needs to shut off the heat when an over-temperature detector becomes active. The controller logic has the form:

"If Input #1 comes ON then turn OFF Output #1"

In the Model 52 BASIC computer language, one or two statements will convert any single input condition to any single output condition.

A common design for an industrial control program is to organize it in two sections, input and output. The program "scans" or "samples" the inputs, and then processes the outputs. This sequence constitutes the main body of the program, and is repeated as fast as possible. The time required to complete one cycle is the scan time or sample rate.

Some process control requirements do not lend themselves to a linear programming approach, such as serial data input or input timing. When processing reqirements cannot wait for the program to get around to them, it is advantageous to use the interrupt capability of the Model 52.

Several kinds of interrupts may be employed:

Discrete inputs Timer timeout Preset event counter Incoming RS-232 characters

The programmer has the option to have his program be interrupted on any, all, or none of the above of conditions.

When interrupts are used, the portion of the program devoted to handling them, known as the Interrupt Service Routine, is separate from the body of the main program, and operates independently.

10

Page 15: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Opera~or5 Manual (88-005548-01 Rev. Y1) 8/86

A simple control program might be organized as follows: (Examples are provided. in parentheses)

Preliminaries

1. Initialize process control variables: (Set outputs, preset a counter)

2. Establish any interrupt conditions: (Emergency stop switch, end of count sequence)

Main program

3. Scan discrete inputs, set any discrete outputs: (Read control switches, turn on indicators, etc)

4. Calculate any other response to discrete inputs: (Convert BCD switches to analog output value)

5. Read Analog inputs, calculate output response: (Transmit input voltage to remote display)

6. Return to step 3 and repeat.

Interrupt Service

7. Shut off all outputs, zero analog output, wait for instructions.

The following scetions describe the various control and Input/Output functions available on the Model 52.

References:

I/O Programming: Interrupts: Sample Program:

Sections 3.3, 4.2 Section 4.4 Section 5.1

11

Page 16: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Yl) 8/86

1. 7 . 1 TIMING

Process control frequently requires that events be timed, or separate activities be coordinated in time. The B52 has a considerable variety of ways to manage time. Elapsed time is easily managed with the 8052 BASIC real-time clock function, and multiple external events may be timed to the millisecond with the numerous Model 52 hardware counter/timers.

The encoder input and optically isolated input connections below have alternate functions which can facilitate the timing (or counting) of external events.

References:

Real-time clock: Counter inputs: Counter/timers:

BASIC-52 USERS MANUAL: Chapter 4.20 Section 2.2.4: Encoder inputs Section 4.2.4: CTR Instruction

1.7.2 ENCODER FEEDBACK FUNCTIONS

One of the more specific counting function capabilities of the B52 is its ability to decode and count quadrature signals, typically from incremental encoders. This capability provides a good way to monitor the speed or position of physical objects in motion.

References:

Encoder Inputs: Section 2.2.4 Counting quadrature: Section 4.2.5: QUAD Instruction

12

Page 17: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8/86

1.7.3 FREQUENCY OUTPUT FUNCTIONS

Many devices used in process control are pulse or frequency controlled, ranging from audible signalling devices, to pulsed motor drive amplifiers. Two outputs are provided to facilitate low level motor control, the pulse output, and a level output for direction control.

The pulsed output frequency range is suitable for audible signals. Maximum frequency is about 23kHz. This function is handled by the 8052 processor's PWM instruction.

References:

Motor Outputs: Motor control: 1.7.4 ANALOG I/O

Section 2.2.5 Section 4.1.6

Some industrial devices will require a continuously adjustable signal for proportional control. This signal is most often a low power control voltage or current. Either type of signal can be produced using the B52 analog output and little or no external circuitry. Higher power signals for voltage or current driven devices will require an external amplifier which itself can be controlled by the analog output. The analog output device is an "8 bit" device; the ±lO VDC output range is divided into 256 discrete output voltages.

Any industrial control operation requires monitoring various aspects of the process. In addition to the discrete (on/off) I/O above, many types of monitoring devices or transducers provide a continuously variable voltage output signal which must be measured.

The B52 has four analog inputs which allow measuring voltage from temperature and pressure transducers or other analog voltage output devices. The analog input device is also an eight bit device. Each input range is also divided into 256 discrete values.

References:

Analog connections: Analog Programming:

Sections 2.2.6, 2.2.7 Sections 4.1.1, 4.1.2, 4.2.1

13

Page 18: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8/86

1.7.5 REMOTE SIGNAL CONDITIONING I/O

For most applications I/O is connected to the B52 through signal conditioning panels. The point of using signal conditioning equipment is to allow monitoring and control of high voltage and high power signals, AC or DC, with the low level inputs and output signals generated by the B52. This signal conditioning equipment provides optical isolation to protect the B52.

One signal conditioning panel is connected to the Model 52 for input, and another is connected for output. These panels or "module mounting racks" are available in 8, 16, and 24 channel versions.

There are two connectors for 50 conductor flat cable on the front of the Model 52 for programmable I/O. These connections are compatible with standard optically isolated signal conditioning equipment. One connector provides 24 inputs, the other provides either 24 outputs or 16 outputs and 8 additional inputs for maximum flexibility.

For example, a single 16 channel I/O rack may be set up for eight inputs and eight outputs of mixed low or high voltage AC or DC.

OPTO-22, Crydom, and Potter & Brumfield all manufacture signal-conditioning products suitable for use with the Model 52. These modules come in different voltage and current ratings. There are versions for interfacing with signals ranging from 5VDC to 280 VAC. Consult your local OPTO-22, Crydom, or Potter & Brumfield distributor for details.

14

Page 19: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model S2 Operaeors Manual (88-005548-01 Rev. Yl) 8/86

The following Opto-22 module mounting racks and flat cables work with the Model 52:

a.

b.

Module mounting racks

(1) PB8 - 8 lines (2) PB16A - 16 lines (3) PB24

Cables

(1) 00-2 (2) 00-4 (3) 00-8

- 24 lines

- 2 feet - 4 feet - 8 feet

Where I/O requirements are minimal, the four optically isolated inputs and outputs may eliminate the need for the above signal conditioning hardware.

References:

Parallel I/O: Sections 2.3, 3.3 Programming: Sections 4.1.3, 4.1.4, 4.2

15

Page 20: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

PART II HARDWARE REFERENCE

£.1 Specifications

POYER:

OPERATING ENVIRONMENT: Temperature Humidity

SIZE: Height, Width, Depth

YEIGHT: Pounds (Kg)

I/O: Optically Isolated I/O

Input current max. voltage

Output current max. voltage

Differential Outputs Step

Pulse width resolution frequency resolution Step and Direction

Differential inputs Signal high Signal low Max. Input Freq.

Analog Output resolution:

Analog Inputs resolution: Impedance

Parallel Inputs

Parallel Outputs

RS-232 all ports Baud rates

* Bits Parity

100-125 VAC, .25A 200-250 VAC, .12SA (50/60 Hertz)

o - 50 deg C o to 9S% non-condensing

14.80 by 2.60 by 7.60 in.

Net 6.0 (2.7) Shipping

ISmA min. 60mA max 7VDC (+ to -) 150mA min. 1.2VDC ON, 40VDC OFF

Frequency range-7hz to 23khz Accuracy - .02% of set rate 1.08S usec .001% at 10 Hz, 1% at 10 kHz +25ma at 4VDC min. -2Sma at IVDC max. (Channel A,B and Z) 2.6VDC min 2.4VDC max 125 kHz from encoder 200 kHz CH B alone (min. pulse width 2 usec) +/-10 Volt at +/-10mA 78mV +/-10 Volt (factory range) 78mV 47.7 kohm

0.7SVDC max low, 1.SmA sink 2.5VDC min high, 10k pu11up 0.5VDC max at -24 mA sink 3.5VDC min at +lS mA source Max. Volts any pin, +S.SVDC +/-12VDC limited to +/-lOmA 110 to 19200 BAUD 7 or 8 Data, 1 or 2 Stop Odd, Even, or None None Handshake protocol

* (PRINTER port is 8 Data and 2 Stop bits with no Parity)

16

Page 21: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Opera:or3 Manual (88-003548-01 aev. Y1) 8{86

2.2 Screw Terminal Connections

2 . 1 . 1 ISOLATED INPUTS - IN A through IN D

The top eight ISOLATED screw terminals are connected to the four optically isolated inputs, two terminals each. Each isolator requires DC current to turn it on. This calls for an external power supply. Input drive current must flow from the "+" terminal to the "-"

The input circuits have 100 ohm current limiting resistors and are designed to be driven by a +5 VDC voltage source. Figure 2.1 below shows the circuit configuratio~.

The easy way to check the state of an input is to use the BASIC 010 (discrete I/O) instruction.

Otherwise, these inputs are read by the 8052 from an internal register at address FA08 hex. This "input port" register is an 8 "bit" register. The 8052 reads the state of the 8 bits in this register as a number. Discrete inputs must be logically separated for individual processing in a program. The four most significant register bits are driven by these inputs. Input register bits are normally high (1), and are driven low CO) when their optical isolator is turned on.

The most significant bit (bit 7) of the port register corresponds to "IN D", and bit 4 corresponds to "IN A". Bits o through 3 have no connection.

Typical I/O Connections:

Switches and relays Programmable Controller DC outputs Integrated circuit drivers Transistors, open collectors

The IN D input may also be configured as an edge triggered (latched) hardware interrupt.

References:

Accesssing Inputs: Optical isolators: I/O Connections: IN D interrupt:

Section 4.2.2: 010 Instruction Section 2.1: I/O Specifications Appendix C: Sample I/O Section 4.3: Interrupts

17

Page 22: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Hodel 52 Opera~or~ Kanual (88-005548-01 Rev. Yl) 8/86

Figure 2.1 Optical Input Circuit

+5

10 K 100

IN+

IN -

eFTO I"CT6

JY PI CA L OPT! CA L INPUT CI RCUIT

Figure 2.2 Optical Output Circuit

+5 vex: 100

OJT +

OJTPUT OJT -I~ICI'\TCF I _____ -0001

L..-__ ----I LED -

741-5240 eFTO !'CT6

TYPICAL OPTICAL OOTPlJT CIRCUIT

18

Page 23: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Hodel 52 Operaeors Manual (88-005548-01 Rev. Yl) 8/86

2.1.2 ISOLATED OUTPUTS: "OUT A" through "OUT D"

The second eight ISOLATED screw terminals are connected to the four optically isolated outputs, two terminals each.

Each output consists of an opto-driven "Darlington" transis­tor with the collector and emitter brought out to the terminals. Transistors are normally "off" but will conduct at least 50 milliamperes from the "+" to the "-" terminal when the output is turned on. These outputs are normally used as a small signal DC "switch".

A series current limiting resistor is required to prevent transistor damage, a resistance of 20 ohms or more per volt is suitable. The voltage between the two terminals must not exceed 40 volts. Figure 2.2 above shows the circuit configu­ration.

The easy way to turn on an output is to use the BASIC 010 (discrete I/O) instruction.

Otherwise, these outputs are controlled by the 8052 as the most significant 4 bits of an output port (address FC09h). The four bits are normally written to the port as a number. The lower four bits are unused. Discreet output bits must be logically isolated for individual access. The most signifi­cant bit (bit 7) of the port register corresponds to "OUT Du, and bit 4 corresponds to "OUT A". An output is off when its associated bit in the output port register is zero.

Typical I/O Connections:

Relays Programmable Controller/Computer inputs Power Transistors

References:

Accessing outputs: Optical isolators: I/O Connections:

Section 4.2.2: 010 Instruction Section 2.1: I/O Specifications Appendix C: Sample I/O

2.2.3 ISOLATED RESET INPUT: "RST+" and "RST-"

When the Reset input is energized, it resets the 8052 processor, turns off all outputs (except the ANALOG and DIR outputs) and restores the B52 to its power up state. This input may serve as a Panic Stop input, but all program data in volatile memory will be lost when the 8052 is reset.

19

Page 24: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Hodel 52 Op.ra~ors Kanual (88-005548-01 aev. Yll 8/86

Reset input ON current is 20 to 40 mAo

2.2.4 ENCODER INPUTS: "CH A+" through "CH Z-"

These terminals are designed to allow connection of a two phase linear or rotary incremental encoder with index channel. Encoder feedback is used to monitor position or speed.

Channels A and B are connected through a quadrature detector circuit to 16 bit counters with interrupt capability. Channel B also goes to a separate counter. Pulse counting operations are normally done with this Channel B counter.

The ENCODER inputs may be programmed for al terna te func tions as follows:

quadrature detection pulse counting interrupt input counter/timer retrigger level detection general purpose input

(CH A and B) (CH A and B) (CH Z) (CH Z) (CH A, B, and Z) (CH .A, B, and Z)

The easy way to manage quadrature counting is with the BASIC QUAD instruction. Pulse counting operations use the CTR instruction.

The encoder outputs should be TTL compatible, with or without complementary outputs. The encoder must be externally powered with a +5 VDC power supply. B52 encoder inputs are compatible with line driver, or TTL encoder outputs and are "pulled up" internally to accomodate open collector encoder outputs. Figure 2.3 below shows the circuit configuration.

The complementary inputs (eH A-, B-, and Z-) are not required. They should be left unconnected if unused. If so, the "+" input drives comparators which will switch at a nominal 2.SVDC input voltage with 100 mV hysteresis. Forcing a reference voltage onto any "-" input allows changing the threshold switching voltage for that channel.

20

Page 25: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model ~2 Opera~ors Manual (88-00~548-01 Rev. Yl) 8186

Encoder inpu~ signals are referenced ~o ~he GROUND terminals. so the external supply Common must be connected to GROUND. See Sec~ion 2.5 on GROUNDING below.

Typical uses:

Posi~ioning feedback Rate measuremen~ feedback Parts counting Sensor threshold detection

Typical I/O Connections:

Incremental encoders Proximity sensor (timing. interrupt) Transducers (level sensing. interrupt)

References:

Accessing inputs: Quadrature counting:

Section 4.2.2: 010 Instruction Section 4.2.5: QUAD Instruction Sec tion 4.2.4: CTR Instruction Section 4.4

Pulse counting: Interrupts I/O Connections: Appendix C: Sample I/O

Figure 2.3 eH .A, eH B. and eH Z input circui ts

+5

3.3(

TV PI CA L EN:ODEB I NA.JI

Page 26: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Oper.~ors Manual (88-005548-01 Rev. Y1) 8/86

2.2.5 MOTOR OUTPUTS: "STEP+" through "DIR-"

These two pairs of terminals have TTL level outputs which will both sink and source in excess of 25 milliamperes. One output pair is a pulse output, controlled by the PWM output of the 8052 microprocessor. The other is a level output which may be set high or low by the programmer. For either pair, the "-" output state will be opposite that of the "+" output.

These outputs are compatible with Compumotor motor drives. They mate with the optically isolated Step and Direction inputs typical of these drives. In practice, they may be used for any practical purpose requiring frequency control, timed pulse width, or just a single on/off control output.

The Step output frequency range is approximately 7 Hz to 23 kHz. Pulse widths are controllable in increments of 1 microsecond from 21.7 usec to 17.1 msec. Frequency resolution is much better at the lower frequencies.

The pulse output may also drive an on board counter if independent pulse counting is desired.

Typical uses:

Motor Positioning control (jog) Audible signal generation Pulse width modulation

Typical I/O Connections:

Stepping Motor and Regenerative drives Speakers or other Audible devices Solid state relays

References:

Level output: Signal generation: Pulse generation: Motor control:

Section 4.2.2: 010 Instruction Appendix C: Sample I/O BASIC Manual: Chapter 4.2.7 Section 4.1.6: Motor Control

22

Page 27: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8(86

2.2.6 ANALOG OUTPUT and GND

The analog output is driven by an eight bit digital to analog converter (DAC). The device used is the Analog Devices AD7524. The output voltage is referenced to ground (GND) , and some care must be taken when making remote connections. See Section 2.5 on GROUNDING below.

This output signal has a voltage range of +10 to -10 volts, suitable for controlling a servo amplifier or other voltage controlled device. The BASIC ANlG instruction sets the output voltage.

The output voltage range is divided into a total of 256 increments of 78 mV. An external attenuator (voltage divider) may be added to reduce the range and increase the resolution.

This is not a power output, and must be amplified for any power application. Maximum output current is 10 mAo The output device is an operational amplifier, LM324.

Typical uses:

Motor Speed control Power level control

Typical I/O Connections:

Servo amplifier Power amplifier

References:

Setting output value: Section 4.2.1: ANLG Instruction

2.2.7 ANALOG INPUTS: "IN#l" through "IN#./."

The analog inputs feed a multichannel eight bit analog to digital converter (ADC). This device is the National Semiconductor ADC0809. The inputs are is referenced to ground (GND) , and some care must be taken when making remote connections. See Section 2.5 on GROUNDING below.

Input voltage can be read using the BASIC ANLG instruction.

In the factory configuration, these inputs have a nominal input voltage range of +10 to -10 volts, for monitoring devices with variable output signal voltages.

23

.",-- \

Page 28: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model '2 Opera~Dr. Manual (88-00"48-01 aev. Y1) 8/86

Yith this input range, an input channel voltage is resolved in 256 increments of 78 mV. Internal components may be removed,or altered to reduce the input range and increase the resolution. Socketed resistor networks can be removed or reinstalled to set the nominal input range to one of the following:

o to 1 volt o to 10 volts

-1 to +1 volt -10 to +10 volt

The input amplifier circuit consists of three sections. These include an input. attenuator, the amplifier, and an output attenuator.

The input attenuator reduces the input signal amplitude by a factor of 10. The amplifier has a gain of 10. The output attenuator attenuates the signal by a factor of 2 while adding a 2.5 volt offset to convert a bipolar input signal to the ADe's required 0 to 5 volt range. The input attenuator and the output offset may be eliminated by unplugging components.

Typical uses:

Temperature measurement Pressure measurement Postion measurement

Typical I/O Connections:

Temperature transducer Pressure transducer LVDT

R.eferences:

Input range: Monitoring inputs:

Section 2.6.1: Configuring inputs Section 4.2.1: ANLG Instruction

24

Page 29: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 32 Operarors Manual (88-005548-01 Rev. Y1) 8/86

2.3 PARALLEL I/O Connections

In the standard configuration, the B52 has 24 outputs acces-sible on the PARALLEL OUTPUTS connector, and 24 inputs acces­sible on the PARALLEL INPUTS connector. These connectors are configured to be plug compatible with standard signal conditioning equipment.

2.3.1 PARALLEL OUTPUTS

The output drivers are TTL "bus" drivers (74LS244 and 74LS245) which can be used to drive whatever falls within their specifications. Outputs can be individually set high or low, or they can be used eight at a time for byte output functions. All 24 outputs (and the ISOLATED outputs) can be disabled (high impedance).

These outputs are assigned numbers (0 through 24) for reference, numbers which correspond to their associated module numbers on an I/O rack. This numberi~g convention is used when controlling outputs with the DIO and SCAN instruc­tions. (These output numbers are also arranged in the logical order in which they would be addressed in software.)

25

Page 30: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Hodel 52 Opera~ors Manual (88-005548-01 Rev. Y1) 8/86

PARALLEL OUTPUT drivers DO NOT invert the output signal. Write a "0" to a given output port bit to switch that output at the connector will switch from a high to low voltage. A "I" will set the output high again.

NOTE: Ouputs 0 through 7 are driven by the 74LS245. This is a bi-directional device. When configured for input, these eight are assigned input numbers 100 through 107.

Typical uses:

Solid state relay power outputs Discrete TTL signal outputs Binary or BCD byte or word output

Typical I/O Connections:

I/O racks Remote device control signals Data bus

References:

Output control: Connector pin numbers:

Section 4.1.3: 010 Instruction Appendix A

26

Page 31: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model ~2 Opera~ors Manual (88-005~48-01 Rev. Yl) 8/86

2.3.2 PARALLEL INPUT

These inputs are assigned numbers (0 through 24) for refe­rence, numbers which correspond to their associated module numbers on an I/O rack. This numbering convention is used when reading inputs with the 010 and SCAN instructions. (These input numbers are also arranged in the logical order in which they would be addressed in software.)

Inputs can be read individually as high or low (lor 0), or they can be read eight at a time for byte input functions.

Typical uses:

Solid state relay power inputs Discrete TTL signal inputs Binary or BCD byte or word input

Typical I/O Connections:

I/O racks Remote device signal monitoring Data bus Absolute encoder

References:

Input read: Connector pin numbers:

2.4 RS-232 CONNECTIONS

Section 4.1.3: 010 Instruction Appendix A

The 852 comes equipped with four RS-232C communication ports. Two of the ports are intended for remote device control (for Compumotor CX series indexer/drives for instance). The other two are for the use of the programmer or operator. One is dedicated to the operator's console, the other is dedicated to be a printer output port.

All RS-232C ports are three wire implementation. Handshaking protocol is not supported by the Model 52. Communication devices having this feature must be configured to match, or may have to be ntrickedn into accepting their own signals as the required handshake. To implement this, it is necessary to connect pin 4 to pin 5 and pin 6 to pin 20 on the standard 25 pin connector.

The 852 does support XONjXOFF protocol on the Console and the two auxiliary RS-232 ports to control transmission rates.

27

Page 32: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Op.ra~ors Manual (88-005548-01 Rev. Y1) 8/86

This function cannot work on the Printer port, however because it has no receiver input. All four ports are configured as Data Communications Equipment (DCE) as opposed to Data Terminal Equipment (DTE). This means the ports transmit from pin 3 and receive on pin 2 of the standard 25 cnnector. This makes them compatible with terminal devices, and most personal computers using a standard pin to pin RS-232 cable.

NOTE: There is no cable shield connection in the B52. RS-232 cable shields should be tied to Earth at the other end. Cable length should be limited to 50 feet.

2.4.1 PRINTER PORT

This output, labelled PRINTER is a minimal RS232 implementa­tion. There is no facility for halting printer output to wait for the printer to catch up. As such, the printer port should be set for a low Baud rate.

This output may be best suited to driving remote RS-232 display devices.

The BAUD instruction must be issued to set this Baud rate prior to printing anything.

This output is accessed by the PRINT # and LIST # instructions.

Typical uses:

Remote device control Text display Printer

Typical I/O Connections:

Compumotor indexers Display terminal

References:

Printer: BASIC-52 USERS MANUAL: Chapter 4.1

28

Page 33: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Opera:ors Manual (88-005548-01 Rev. Y1) 8/86

2.4.2 RS-232 USER PORTS

These two ports, labelled RSESE#O and RSESE#1, may only be accessed from within a program. The programmer has full control of these ports for input and output using supplied custom instructions. The COM instruction sets up port protocol, XMT and RCV are used to transmit and receive characters.

Typical uses:

Remote device control Text display Printer System communications

Typical I/O Connections:

Compumotor indexers Display terminal Master computer

References:

RS-232:

2.5 GROUNDING

Section 4.2.6: COM Instruction Section 4.2.7: XMT Instruction Section 4.2.8: ReV Instruction

There are two terminals labeled G~D available. These are the zero volt reference point for all terminal connections not marked ISOLA TED. They also happen to be the ground reference point for the 8052 microprocessor itself. Consequently, connections at these terminals that are brought out into the environment have the potential to pick up enough electrical interference (noise) to knock out the processor. When remote wiring is called for, using the STEP and DIR outputs, the A~ALOG I/O, or the E~CODER inputs, steps should be taken to protect the B52 from environmental electrical fields.

A terminal is provided marked SllIELD. Cables attached to the terminals mentioned should be shielded from electrical inter­ference, and the shield should be connected to its own terminal. This SErIELD terminal has a direct connection to power line EARTEr and the chassis of the B52. There should not be any connection between the above G~D, and the SErIELD terminal.

29

Page 34: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

The Earth-to-Ground connection will often be made on some other piece of associated equipment. Multiple earth to ground connections can result in a -ground loop" creating mysterious failure modes.

Use of the differential outputs STEP and DIR may not require shielding, but when no shield is present, using twisted pairs of wires would give some protection from electrical inter­ference.

Note: There is no Shield connection on the two auxiliary RS-232 port connectors. Cabling to these ports should be shielded at the other end of the cable to insure the integrity of transmissions.

2.6 Analog Input Details

2·.6.1 CONFIGUlUNG ANALOG INPUTS

Figure 2.4 below depicts the circuit schematic of a typical analog input channel. Each channel consists of an input attenuator, the amplifier, and an output attenuator. In the factory configuration, the input attenuator divides the input signal voltage by ten. The amplifier multipiles the attenu­ated input signal by ten, and the output attenuator divides it again by four while adding an offset voltage. This offset makes a zero volt input correspond to midrange (2.5 VDC) of the Analog to Digital Converter. Resolution is 78.025 mV.

Total signal voltage range into the ADC must be 0 to 5 VDC. Voltages outside this range are -clipped" by the circuit to protect the ADC. In the figure below, if the resistor marked Rl is removed from the circuit, the input attenuator is eliminated. This increases the input resolution for low level signals by a factor of 10. Input range becomes -1 to +1 volt.

If the resistors marked R2 and R3 in the figure are removed, the output attenuation is reduced from a factor of 4 to a factor of 2, and the offset is eliminated. Input range is reduced to 0 to 1 volt. Resolution becomes 3.90625 mV.

The intent of this circuit arrangement is to allow two bipolar and two single ended input ranges.

30

Page 35: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Hodel 52 Opera~or3 Manual (88-005548-01 Rev. Yl) 8/86

Figure 2.4 Analog input circuit

U'lPUT OUTPUT ATTENUATOR AMPLIFIER ATIENUATOR

(~ 10) (X 10) ( ~ 4. +2.5VDC) _ ...................................................................................................................................................................... . : ANALOG : INPUT

:~

. . .

: : 5.0 VRFJEF • : R2 ').:

~ R3 ~ ~ · . · . · .

+5VDC

4.~~ ~~I _._. ______ --4 __ ±~~_A_L_L_4_.7_K_-----.;_--lt ..

. . .............................. __ ................................................................................................................. .

Figure 2.5 Resistor network circuit (Bourns 430BR-I02-472)

31

TO ADC

Page 36: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8/86

The input attenuation network which can be removed is referred to as U47. Removing this network will eliminate. the input attenuator for all four channels. Removable Output attenuation networks are referred to as U45 and U46. Network U46 provides output attenuation and offset for channels [li;#1 and [li#2, network U45 for channels [li#S and [li#-I. All resistor networks may be located on the circuit board using the circuit assembly drawing in Appendix E. The internal network circuit is shown in Figure 2.5 above.

Installing and removing various resistor networks has the following effect:

Installed llilf1 [lilfE [lilfS [li 1fJ. U47, U46, U45 ±10 VDC ±10 VDC ±10 VDC ±10 VDC

U47,U46 ±lO VDC ±10 VDC 10 VDC 10 VDC U47,U45 10 VDC 10 VDC ±10 VDC ±10 VDC U46,U45 ±l VDC ±l VDC ±l VDC ±l VDC

U47 10 VDC 10 VDC 10 VDC 10 VDC U46 +1 VDC +1 VDC 1 VDC 1 VDC U45 1 VDC 1 VDC ±l VDC ±l VDC

The input attenuator is simply a voltage divider circuit using standard component values in a ratio of 9 to 1. Selection of resistance values for Rl in the figure would allow controlling the amount of input attenuation according to the formula:

Attenuation factor - 43,000 + Rl I Rl

The factory value for Rl is 4,700 ohms. Resistors used in the Model 52 are Single In-line Package (SIP) networks. The adventurous hardware designer may attempt selection of discrete resistors for installation in place of the network to achieve different attenuation levels for each input channel.

Step by step approach:

1. Determine the actual input signal voltage range 2. Configure the output offset attentuator for bipolar or single ended input signals 3. Configure the input attentuator to account for amplifier gain and output attenuation

Final signal voltage for measurement should be restricted to the 0 to 5 volt range. The ADC is protected from excessive positive or negative voltages, but these will be outside the measurement range.

32

Page 37: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 32 Opera~ors Manual (88-005548-01 Rev. Y1) 8{86

2.6.2 ANALOG INPUT ACCURACY

The basic accuracy of the Model 52 analog inputs depends on the accuracy of the following components:

ADC0809 Analog to Digital Converter - ± 1 LSB (0.4% of full scale)

AD584 Voltage Reference - ± 15 mV (0.3% of full scale)

Resistor networks - ± 2%

Clearly the absolute accuracy is limited by the accuracy of the resistive components. Although the absolute accuracy is only 2% from network to network. the tolerance between resistors in the same network will be more like 0.1%. The distribution of resistive networks in the Model 52 analog input circuit is such that each channel will behave like the other three to this tolerance.

Improved accuracy can therefore be obtained by using the analog inputs in a relative measurement mode. where a voltage reference is connected to one of the four channels. This technique calls for measuring the reference and determine whatever corrections may be needed. This correction is then applied to measurements made on the other channels. Any resulting errors will be due to variation between single resistors within a resistor network.

33

Page 38: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Opera~ors Manual (88-005548-01 Rev. Y1l 8/86

PART m - PROGRAMMING CONSIDERATIONS

3.1 MODEL 52 BASIC

It is not within the scope of this document to instruct the user in the fundamentals of general BASIC programming.

The INTEL 8052 microprocessor comes with its own BASIC inter­preter coded in ROM on the chip. On chip space limitations require that some features of popular BASIC interpreters have been sacrificed. As such, the 8052 interpreter, referred to here as "BASIC-52" lacks a number of the commands common to other BASICs. Most functions provided by these commands can be duplicated, but more instructions are required to do so.

There are no graphics or screen control capabilities other than control characters that can be sent to the console.

This document provides a summary list of the BASIC-52 instruction set, but for a detailed reference on BASIC-52, the programmer will need Intel's MCS BASIC-52 USERS MANUAL, available from Intel or Compumotor. Order Compumotor part number 88-005680-01 or from Intel, publication #270010-002.

The Hodel 52 has twelve instructions that have been added to the BASIC-52 language to facilitate I/O operations, handling numerical strings, and program management. These are itemized in Sections 4.2 and 4.4 below.

3.1.1 VARIABLES

BASIC-52 has three kinds of variables. These are scalar, one dimension arrays, and string variables. Memory space must be reserved in advance for strings and for arrays that exceed 10 elements, using the STRING and DIM instructions.

Both scalar and array variable names may be up to eight letters and numbers in length. The programmer must take care that these names do not incorporate any of BASIC-52's reserved words.

34

Page 39: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Opera~ors Manual (88-005548-01 Rev. Yl) 8186

Program execution is faster if variable names are restricted to one letter or a letter followed by a number as follows:

A, B, C, ... , Z and AO, AI, ... , A9 , ... ,ZO , ... ,Z9

These variables are always "real" floating point numbers. For variables with values less than 65,536 (2 to the 16th power), it is also possible to do logical operations on them such as AND, OR, XOR, and NOT.

String variables all take the form "$(n)" where n must be a number between 0 and 8. String variables are limited to a fixed length which is declared in the STRING statement. String variables always start with variable "$(0)" and count up to the limit of declared space. The STRING statement also reserves the total amount of memory to be used by strings variables, thereby limiting the number. String space management requires an extra byte for each string variable, plus one overall.

Example: STRING 100, 10

reserves just enough memory for the 9 string variables, $(0) through $(8), 10 characters each.

References:

Variables: Strings: STRING:

BASIC-52 USERS MANUAL - Chapter 1.4 BASIC-52 USERS MANUAL - Chapter 6

BASIC-52 USERS MANUAL - Chapter 4.3

3.1.2 MANIPULATING CHARACTER STRINGS

Handling character strings in BASIC-52 is quite different. The following common string handling commands are not available in BASIC-52.

MID$, LEFT $ , RIGHT$, STRING$

All of the above functions commands may be implemented with the BASIC-52 "ASC" and "CHR" commands. These two commands can incorporate a charcters pointer, and therefore operate very much like the MID$ command, in addition to duplicting the function of the regular ASC and CRR$ commands common to most BASICs.

35

Page 40: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operaeors Manual (88-005548-01 Rev. Y1) 8/86

BASIC-52 alone doesn't support the usual STR$ and VAL functions, but these have been added to the B52 instruction set as STR and VAL to facilitate RS232 transmission of numerical values.

String Examples:

The following instructions would display the ASCII code for the Nth character string variable A$ in Microsoft BASIC and from string variable $(1) in BASIC-52:

Microsoft: PRINT ASC(MID$(A$,l,N)) 8052: PRINT ASC($(l).N}

The following instructions would display the Nth character from the string variables:

Microsoft: PRINT MID$(A$,l,N) 8052: PRINT CHR(ASC($(l)'N),l)

References:

Strings: STR and VAL:

BASIC-52 USERS MANUAL: Chapter 6 Section 4.2: Custom Instructions

3.1.3 INSTRUCTION ANOMALIES

BASIC-52 has limited capacity for manipulation of stored pro­grams. The following common program control commands have no counterpart in BASIC-52.

MERGE, COMMON, KILL, NAME, EDIT, AUTO, RENUM, TRON, TROFF

There is no data transfer between programs.

Note that BASIC-52 does not have the usual LOAD and SAVE instructions. These are replaced after a fashion by the ROM and PROG instructions. The function of the CHAIN instruction is partly reproduced in BASIC-52' s RROM instruction. Modified LOAD and SAVE instructions are provided as discussed below.

36

Page 41: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Kadel 52 Operaeors Kanual (88-005548-01 Rev. Yl) 8(86

The following BASIC commands assume a somewhat different form in BASIC-52:

WHILE ... YEND, PEEK, POKE, AND, OR, XOR, LPRINT, LLIST

WHILE ... YEN!): This function is replaced by the "DO" loop instruction which has two forms; OO ... WHILE and DO ... UNTIL, where the statements to be repeated appear between the DO and the WHILE or UNTIL as follows:

Example:

10 DO 20 PRINT A, 30 A=A+l 40 WHILE A<10

10 DO 20 PRINT A, 30 A=A+l 40 UNTIL A=10

Displayed results for either case:

o 1 2 3 4 5 6 7 8 9

PEEK, POKE: These BASIC functions are replaced in the 8052 by the XBY function.

Logical operators AND, OR, and XOR take the form .AND., .OR., and .XOR. in BASIC-52.

Printer port commands LLIST and LPRINT are replaced by LIST # and PRINT #. Note that the printer port must first be configured with the BAUD instruction.

The following BASIC commands have a somewhat different function in BASIC-52:

INT, LIST

The INT command has the same function as the FIX command found in other BASICs. Fractions are truncated, not rounded.

37

Page 42: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Mod.l '2 Op.racors Manual (88-00"48-01 a ••. Yl) 8/86

The 8052 LIST command takes only three forms:

LIST LIST [xl LIST [x] - [y]

References:

EDIT, RENUM ROM, PROG: LOAD, SAVE: RROM:

The entire current program is listed The program is listed from line number "x" Line numbers "x" through Ny" are listed

Section 3.3: Editing Programs BASIC-52 USERS MANUAL - Chapter 3 Section 3.2: Memory Management Section 3.2.2: Recalling programs

3.1.4 HARDVARE DEVICES

BASIC-52 has no capacity to handle "files", notably I/O files. The following common file control commands do not appear in BASIC-52.

FILES, OPEN, CLOSE, INPUT#, INP, OUT, EOF, LOF, LOC, WRITE, GET, PUT

Programming to control hardware devices is implemented by custom B52 instructions, CALLs, or writing control and data information byte by byte to registers in these devices.

Device registers are located in the 64K byte memory space of the Model 52 starting at address FOOO hex. They include the auxiliary RS232 ports, counter/timers, various I/O ports, and analog devices.

As for the keyboard, single character keystrokes may be captured as ASCII code numbers with the GET function. This is similar to the INKEY$ function of other BASICs.

References:

Hardware devices:

CALLs:

Section 4.1: I/O Devices Appendix B: Memory Map Section 4.2: Custom Instructions Section 4.4: Machine code

38

Page 43: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 32 Operators Manual (88-005548-01 Rev. Y1) 8/86

3.2 Program and Memory Manipulation

3.2.1 GENERATING AND EDITING PROGRAMS

There are two ways to get a program into the B52. New programs are typed in from scratch, or downloaded from another computer. Small programs are usually typed in while in the Direct command mode. Larger programs are best created on another computer where the programmer can take advantage of sophisticated editing software and "keyboard macros" to avoid the repetitive typing of often used B52 commands.

Otherwise, the programmer must suffer with the limited editing capability of BASIC-52.

There is no way to edit a line once Return is entered. The only recourse is reentering that line. There is no renumbering facility common to other BASICs.

Tools that are provided include Backspace (ASCII 127) which appears as "Rubout" on some terminals. Also, a "delete line" facility is provided. A "Control 0" will erase the line currently being typed if Return has not yet been entered.

Model 52 programs are ASCII files which can be manipulated by most editing software, even other Advanced BASIC software such as Microsoft BASIC.

Advanced BASIC can be used to renumber (RENUM) and MERGE B52 programs if the programmer is careful about restoring any code altered in this process. Microsoft BASIC has trouble wi th the BASIC-52 ".OR." and" .AND." functions, large numbers, and hex numbers. Look for the telltale exclamation marks "I". Code alterations are easily fixed and renumbered programs then can be SAVEd using the ASCII save option.

Example: SAVE "B52.PRG",A

References:

Memory: Appendix B: Memory Map

39

Page 44: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Kadel 52 Opera~ors Manual (88-005548-01 Rev. Yl) 8/86

3.2.2 SAVING PROGRAMS

To save a program in E"EPROM, you ordinarily use one of the "PROGn commands. In response, the B52 stores the program which is currently in RAM memory. This process takes quite a while for longer programs. During the storing operation, the the B52 displays the number assigned to the program. Multiple programs can be saved up to the limit of EEPROM memory space.

EXAMPLE: Once your first program is entered (and is known to work), in the Direct command mode;

You type: B52's Response:

at length ...

>PROG <cr> 1

READY >

At this point, the B52 has allocated the necessary amount of non-volatile memory space, stored the program, and labeled it program number 1. The next program stored in EEPROM will be labeled number 2.

The easy way to deal with EEPROM program control is to use the DIRECTORY program to find out what's in there, and use the SAVE instruction provided to augment the BASIC PROG instructions. iJhile the PROG instruction merely adds the program currently in RAM to the end of the list of stored," EEPROM programs, SAVE allows you to select which location will be used for storage. This instruction avoids the storage of multiple copies of a single slightly modified program.

Program boundaries are marked with an end of program charac­ter (01 hex) followed by a begin program character (55 hex), if any.

40

Page 45: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Yl) 8/86

The factory supplied DIRECTORY program allows examining the programs in EEPROM, and running programs stored there. In the Direct mode, type LOAD to run the DIRECTORY program.

This DIRECTORY program will display the first line of any stored program that begins with a "REM" statement, and so the first line should be reserved for the program title.

References:

PROG: SAVE:

BASIC-52 USERS MANUAL: Chapter 3.3 Section 4.2.12

Accessing Memory: Section 3.2.5

3.2.3 RECALLING PROGRAMS

To access a program from EEPROM, the ROM command is used. This will access the first stored program. For access to other stored programs, the ROM command is followed by a pro­gram identification number. The command "ROM 3" will access the third program in EEPROM. Following this instruction, the program can be LISTed.

To edit a stored program, it must be transferred to RAM with the XFER command. The XFER command places the selected pro­gram into RAM, automatically switching to RAM mode. It is not necessary to transfer the program selected with the ROM command into RAM to run the program. The selected program may be run by issuing the RUN statement immediately following the ROM command. This allows you to have a program residing in RAM while accessing and running a different program directly from EEPROM. The program residing in RAM will remain intact while a program is running in EEPROM.

Note: It is not possible to edit, or download an external program while in ROM mode. If downloading is attempted, no error message will be generated. Any subsequent RUN instruction will run the wrong program. The download is lost.

41

Page 46: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operaeors Manual (88-005548-01 Rev. Yl) 8/86

When running a program from EEPROM, it is possible to exit and run a different EEPROM program without stopping. The RROM command does this. The programmer must specify the identification number of the target program. No program variables can be passed from one program to another.

References:

ROM: XFER: RROM:

3.2.4 AUTOMATIC OPERATIONS

BASIC-52 USERS MANUAL: Chapter 3.1 BASIC-52 USERS MANUAL: Chapter 3.2 BASIC-52 USERS MANUAL: Chapter 4.35

Once the Model 52 is programmed, it is possible to automati­cally recall and run a program on power up. This can eliminate the need to have a remote console for operator input. It is neccessary to have the program you wish to automatically recall and execute at the first EEPROM location (ROM 1). It is therefore important to make sure that the first program stored with the PROG command is the program that you wish to automatically recall and execute.

To enable this "autorecall autorun" function, enter the PROG2 command. After the PROG2 command is entered the B52 will automatically recall and run the first stored program every time it is powered on. The PROG2 command also saves the current console communication protocol. Thus, console communications are automatically initialized on power up. In this mode, a console may not even be needed if no operator input is called for.

The PROG1 command option allows automatic console initiali­zation without running a program. The PROG1 command stores the current baud rate information in EEPROM and automatically initializes the console on power on. This eliminates the need to send a space character before beginning operation.

BASIC-52 provides other PROG options, up to PROG6, but the value of these functions is obviated by the machine language power-up routines executed by the B52. Do not use them.

References:

ROM: PROG:

BASIC-52 USERS MANUAL: Chapter 3.1 BASIC-52 USERS MANUAL: Chapter 3.3

42

Page 47: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Yl) 8/86

3.2.5 ACCESSING MEMORY

The 8052 processor has the capacity to access a full l28k of memory, half "Data Memory" (RAM: 0 to 64k) , half "Program Memory" (ROM: 0 to 64k). The Model 52 architecture has RAM space from address 0 up to 32k and ROM also from 0 to 32k. The first 8k of ROM is internal to the 8052 (BASIC-52), the remaining 24k is permanent EPROM.

EEPROM (and the I/O devices) occupy the space from 32k up. EEPROM can be treated as either RAM or ROM. The B52 has 16k of both RAM and EEPROM installed.

NOTE: The processor itself also has a separate 256 bytes of internal RAM. This memory is almost exclusively used by the BASIC-52 interpreter. Ordinarily the programmer will not need to access this memory. BASIC-52 provides the "DBY" instruc­tion to do this.

BASIC- 52 provides the "XBY" instruction to access RAM.

Example: PRINT XBY(1000H)

(display the contents of Data Memory location 1000 hex)

XB Y (BOOOH) =123

(set memory location address 1000 hex to the value 123)

This instruction can also be used to access the I/O devices if desired. This is ordinarily unnecessary when the I/O instructions described in Section 4.2 are used.

CAUTION: The B52 uses 612 bytes of memory at the top of RAM (3D9Bh to 3FFFh) for storing operating parameters. Do not write to this space. Program variables are stored at the top of memory and just above the program. BASIC stores two addresses representing the boundaries of variable storage space. See BASIC-52 USERS MANUAL: Appendix 1.7

43

Page 48: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

..

Model 52 Opera~or. Manual (88-0055.8-01 aev. Y1l 8/86

BASIC-52 provides the ·CBY- instruction to access ROM.

Example: PRINT CBY (4000H)

(display the contents of Program Memory location 4000 hex)

B52 circuitry is such that both the 8052 PROG and XBY instructions will write to EEPROM and both XBY and CBY operators will read from it. Only XBY works in RAM, only CBY works in EPROM.

NOTE: When writing more than one byte to successive memory locations in EEPROM, it is necessary to allow sufficient time for data to be stored. To guarantee that data is properly stored, the program should wait and test for verification after each write before writing again.

Example:

100 XBY(8S00H)=Xl 110 IF XBY(8S00H)<>Xl THEN 110 120 XBY(8SC1H)=X2 130 (wait again)

(write to EEPROM) (wait for verification)

(write the next byte)

BASIC-52 allows the operator to run programs in EEPROM without first loading them into RAM. This is the result of BASIC-52's two operating modes which are called RA~ mode and ROM mode. The instructions RA~ and ROM allow transferring between modes. No editing or downloading is possible in ROM mode.

Normally a PROG instruction is used to save a BASIC-52 program, but repeated PROG instructions during editing will result in multiple saved copies of the same program. The B52 has a SAVE instruction whereby the programmer can specify where in EEPROM the program should be saved. Note that execution of a SAVE may involve substantial relocation of currently stored programs, resulting in long delays. To avoid this, use the LOAD function and DIRECTORY program to keep track of the contents of programs from EEPROM.

NOTE: The LOAD instruction will erase any program currently in RAM. You cannot LOAD to inspect the DIRECTORY and then SAVE or RUN the program you had in RAM.

The DIRECTORY program displays the start address of all stored programs. A program and all those above it can be erased by setting the start address location to zero:

44

Page 49: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Hodel 52 Operaeors Hanual (88-005548-01 Rev. Y1) 8/86

XBY(8010H)=O (erase all stored programs)

Most dedicated control applications will have B52 programs running automatically from EEPROM, while the RAM is used only for data storage and manipulation.

B52 permanent EPROM contains a number of handy machine language routines to enhance 1/0 control, as well as the custom instructions that have been added to BASIC-52.

The B52 repertory of demonstration programs also resides here. These may be accessed in the Direct command mode by issuing the LOAD instruction. The factory supplied programs below are provided. Program listings appear in Part IV.

DIRECTORY - This program shows what is saved in EEPROM TEST - This program provides 1/0 test and demonstration INDEXER - This program provides test and control of

References:

RAM, ROM: LOAD, SAVE: XBY. CBY: Memory:

Compumotor models CX, 372, and 2100

BASIC-52 USERS MANUAL: Chapter 3.1 Section 4.2: Custom Instructions

BASIC-52 USERS MANUAL: Chapter 7.1 Appendix B: The Memory Map

3.3 Input/Output Programming Fundamentals

The following discussion deals with the binary nature of the microcomputer. The the operations and functions described are implemented by the custom instructions and CALL functions of the B52 discussed in Section 4.2.

All I/O functions in the Model 52, from turning on an output to receiving a transmitted character require that the processor handle a "byte" of data. This is an 8 bit quan­tity. reflecting the 8 bit data bus of the processor. "Bit" means binary digit.

When the processor "reads" the 8 data bus inputs from an I/O device. the state of those inputs may reflect the status of 8 external switches. the current value of an event counter, or an RS-232 character code. The processor treats such a byte of data as a binary number between 0 and 255. In BASIC these bytes can be handled as decimal or hexadecimal numbers; decimal for floating point math and hexadecimal for logical control of discrete 1/0.

45

Page 50: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8/86

3.3.1 BASIC I/O READ AND WRITE INSTRUCTIONS

The hardware I/O devices in the Model 52 all have internal registers with "addresses" in its memory space. The 8052 BASIC "XBY" instruction is used to read from or write to any address whether a hardware device or a memory location is at that address.

For example, the Analog to Digital input device is located at address F200 hex. The Digital to Analog Converter output device is at address F400 hex. To set the analog output, a number corresponding to the desired output voltage (say 128 for 0 volts out) is written to the designated address as follows:

XBY ( OF400H ) = 127

(write the value 127 to address F400 hex)

To read an analog input, a number is read from the designated address:

A = XBY ( OF200H ) (set variable A to the value found at address F400 hex)

Ordinarily, the "ANLG" instruction would be used for analog operations.

References:

Addresses: XBY, CBY: ANLG:

Appendix B: Memory Map BASIC-52 USERS MANUAL: Chapter 7.1

Section 4.2.1

3.3.2 BITS, BYTES, AND DISCRETE I/O LOGIC

Each discrete input and output in the Model 52 is part of a group or channel of eight. These I/O channels will be referred to as "ports". I/O Ports are read from or written to a byte at a time. To examine a single input, or switch a single output, it is necessary to separate it from the other seven. This is accomplished by logically "masking" the desired bits.

This can result in some laborious programming that runs comparatively slowly. The B52 has two custom instructions that eliminate the need for most bit masking operations when handling discrete I/O. These are the 010 and SCAN instruc-

46

Page 51: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operaeors Manual (88-005548-01 Rev. Y1) 8/86

tions. These instructions automatically handle the "negative . true" nature of B52 discrete I/O discussed below. The discussion on boolean logic that follows is for information.

B52 discrete I/O assumes Negative True logic on all discrete I/O operations except the ISOLATED outputs. Standard signal conditioning equipment requires a low voltage output to sink current and drive the output module. To turn on a single output, it is necessary to set the appropriate bit of the output port register to O. The corresponding PARALLEL OUTPUT voltage will go from high to low (the ISOLATED outputs, however, require a 1 to turn On and conduct current).

By the same token, inputs are normally high (1) if uncon­nected, and go low (0) when input devices turn On. This is true for all discrete inputs.

Two special CALL instructions are provided to invert input and output operations for the 010 and SCAN instructions when Negative True logic is not desired. See Section 4.4.

Any byte may be logically inverted using the ".XOR." function discussed below.

Register bits are numbered 0 through 7, where bit 7 is the most significant bit (MSB) . To set bit number 5 to a 1 while the other seven remain 0 is a simple matter of writing the binary number

(MSB) o 0 1 0 0 0 0 0 (LSB)

to the register. This binary number has a decimal value 32, hexadecimal 20. This value is simply 2 raised to the power 5, 5 being the number of that bit.

Example:

bit 3 has the value 8, 2 to the third power (2 cubed) bit 7 has the value 128, 2 to the 7th power the maximum value of any byte is 255, with all bits set:

128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 - 255

To handle binary numbers, the programmer uses hexadecimal notation which makes it much easier to convert from the binary numbers, or visualize discrete I/O.

A program statement would have the form Woutput port - 37 hex". Any pattern of outputs can be set by writing a number to the port in this way.

47

Page 52: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operaeors Manual (88-005548-01 Rev. Y1) 8/86

In practice, it will be necessary to turn an output on or off without changing the others in the same port. To do so, the programmer must know the current status of the port, in order to logically determine the new status once the bit is changed.

3.3.3 SETTING BITS: THE LOGIC "OR" FUNCTION

To set a register bit, determine the hex value of a byte where only the desired bit is set as in the case above. This number becomes the logical mask.

To set a bit in a byte register (or port output) to a 1, read the target byte value, logically OR the mask with the byte value, and write the result back to the register (or port).

Example:

The Model 52 has a parallel output port at address F600 hex. The following statement would turn off output 5 (set the port register bit 5 to a 1), without affecting the other outputs of the port:

XBY( OF600H ) - 20H .OR. XBY( OF600H ) (set bit 5)

3.3.4 CLEARING BITS: THE LOGIC "AND" FUNCTION

To clear (reset) a register bit and set it to a 0, the logical mask must be set to the inverse of the mask for the OR operation. In the above case, this would be

(MSB) 110 1 111 1 (LSB)

which is equivalent to hexadecimal DF. To reset the register bit (and turn on output 5), read the current value, logically AND this mask with the value, and write the result back to the register. Syntax for the output port example is:

XBY( OF600H ) = ODFH .AND. XBY( OF600H ) (reset bit 5)

48

Page 53: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Kodel 52 Opera~~r. Kanual (88-005548-01 aev. Tl) 8/86

3.3.5 INVERTING: THE "XOR" LOGIC FUNCTION

Outputs may be simply inverted, or "toggled" using the XOR (Exclusive OR) function. The mask is the same as for the OR function above. This logical operator may also be used to invert an entire byte, useful for converting from negative to positive true logic. This requires performing an exclusive OR of the byte with FF hex (all ones). Syntax for printing an inversion of the byte read from the above port:

PRINT XBY( OF600H ) .XOR. OFFH

3 . 3 . 6 READ ING INPUTS

Inputs are read from 8 bit ports also. A single input may be examined by masking off the other seven bits (reset them to 0). This requires a single bit mask like that used above for the OR function, with the AND function. To read any port input, read the port register, AND the mask with the port value, and see if the result is zero. If so, the input is On.

The Model 52 has an parallel input port at address F800 hex. The following statement would display the state of input 5:

IF (XBY(OF800H) .AND. 20H) = 0 THEN PRINT "OFF!" ELSE PRINT "ON!"

3.3.7 INPUT DECISIONS

In practice, using the above technique to test a large number of interdependent inputs can result in a large and difficult program. The SCAN instruction can greatly simplify this kind of requirement. Otherwise, when more than one input is involved in the decision about what to do with the outputs, it becomes practical to handle the input port byte values as numbers.

49

Page 54: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operaeors Manual (88-005548-01 Rev. Yl) 8/86

In any program, the state of an input port is assigned to a program variable. The BASIC ON (variable) GOTO ... or ON (variable) GOSUB ... statements can be used to good advantage to organize program code in a decision process based on an input port. This helps insure that all possible combinations of input states are properly dealt with.

References:

I/O Port Addresses: 010, SCAN: .OR., .AND., .XOR.:

Appendix B: Memory Map Section 4.2:Custom Instructions BASIC-52 USERS MANUAL:Chapter 5.1

so

Page 55: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Opera~ors Manual (88-005548-01 Rev. Y1) 8/86

PART IV - PROGRAMMING

4.1 I/O Devices

The hardware I/O devices in the Model 52 are all located at addresses above FOOO hex. These include the following:

F200 - analog input device: analog to digital converter F400 - analog output device: digital to analog converter F600 - parallel output port controller F800 - parallel input port controller FAOO - Multifunction device

quadrature counters, timers optically isolated input port internal device control port Auxiliary RS-232 Port RS292#O

FeOO - Multifunction device pulse counters, timers optically isolated output port external input port Auxiliary RS - 232 Port RS292#1

All of these except the analog output device have multiple internal addresses or registers that can be read or written to for configuring the function of the device, or imple­menting I/O functions. The custom instructions in Section 4.2 below handle general purpose requirements for controlling these devices.

The Memory Map in Appendix B provides a list of device registers by address.

4.1.1 ANALOG INPUT

There are four analog input registers, located at addresses F200, F201, F202, and F203 hex. These correspond to analog inputs IN#l, IN#2, IN#9, and IN#4 respectively. Only one input channel is read at a time. The ADC requires a signal to initiate the analog to digital conversion. This takes the form of a write operation to the desired channel. Then the converted result may be read from it.

The ANLG instruction allows reading analog input channels and setting the analog output voltage. See Section 4.2.

51

Page 56: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8/86

4.1. 2 ANALOG OUTPUT

To set the analog output, it is only necessary to write an appropriate value to the device address. The total output range is - 10 volts to +10 volts. The total 20 volt range is divided into 256 increments of 78.125 millivolts each. To set a given voltage, divide it by .078125 and round off the result. This converts the output value to the required 8 bit number. Write that number to address F200 hex.

The ANLG instruction allows setting the analog output voltage and reading the analog input channels. See Section 4.2.

4.1.3 PARALLEL OUTPUTS

In the standard configuration, the B52 has 24 outputs for connection to standard signal conditioning equipment. These are arranged as three 8 bit ports. Before attempting to write to these ports, it necessary to configure (initialize) the I/O device for the output function. This is ordinarily handled by the B52 power on routine, which sets the 24 outputs high, but doesn't enable the output drivers.

This device is an 8255 Peripheral Interface Adapter. It has four internal registers, one for control, and the three ports. The control register is at address F603 hex. To configure this device for output, the value 128 (80 hex) is written to the control register.

In BASIC: XBY ( OF603H ) = 128

The three output ports are found at addresses F600 through F602. Writing a program byte variable (0 to 255) to an output port takes a statement like this:

XBY ( OF600H ) = Pi

Use the 010 instruction to turn single outputs on or off. Prior to operation, it is necessary to enable the output drivers at the connector. The 010 instruction also provides the output enable function. The SCAN instruction and several CALL functions provide more complex output control.

52

Page 57: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8/86

PARALLEL OUTPUT drivers DO NOT invert the output signal. Write a "0" to a given output port bit to switch that output at the connector will switch from a high to low voltage. A "1" will set the output high again.

NOTE: A low output turns a signal condi­tioning module ON. These modules employ Negative True logic for both input and output. Output logic may be inverted using CALL 15.

Alternate 1/0 configuration:

The output port at address F600 may be configured as an input port instead. This allows mixing inputs and outputs on a single I/O module rack. In this case, the PARALLEL OUTPUT connector becomes 16 outputs and 8 inputs instead of 24 outputs. This configuration will allow a 16 channel module rack to be half input, half output, for example.

A machine language routine is provided to implement this alternate configuration. The program must CALL the routine:

CALL 16 (set outputs 0 through 7 to input mode)

Similarly, the port may be switched back from input to output:

CALL 17 (set inputs 24 through 31 back to output mode)

As inputs these eight channels will behave like those on the PARALLEL INPUT connector below. Although they have no "pullup" resistors, they will read "I" when unconnected.

References:

Connector pin out: 010, SCAN: Alternate Configuration: Invert outputs:

Appendix A: Parallel I/O Sections 4.2.2, 4.2.3 Section 4.4.12: CALL 16, 17 Section 4.4.13: CALL 15

53

Page 58: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operaeors Manual (88-005548-01 Rev. Y1) 8/86

4.1. 4 PARALLEL INPUTS

In.the standard configuration, the Model 52 has 24 inputs for connection to standard signal conditioning equipment. These are arranged as three 8 bit ports. Before attempting to read these inputs, it necessary to configure (initialize) the I/O device for the input function. This is ordinarily handled by the B52 power on routine, which sets the port control device to input mode.

This device is an 8255 Peripheral Interface Adapter. It has four internal registers, one for control, and the three ports. The control register is at address Fa03 hex. To configure this device for input, the value 155 (9B hex) is· written to the control register.

In BASIC: XBY ( OF803H ) = 155

The three input ports are found at addresses FaOO through F802. Reading an input port to a program variable takes a statement like this:

P1 = XBY( OF800H )

The 010 instruction is used to read individual inputs. The SCAN instruction and several CALL functions provide more complex input formats. Input logic for these functions may be inverted using CALL 14.

The only components between this 8255 and tha I/O connector are 10K ohm pull-up resistors. Consequently the experienced hardware programmer can use this device for any other 8255 function desired, such as interfacing with ASCII keyboards, displays, printers and the like.

References:

Connector pin out: 010, SCAN: Alternate Configuration: Invert outputs:

Appendix A: Parallel I/O Sections 4.2.2, 4.2.3 Section 4.4.13: CALL 16,17 Section 4.4.12: CALL 15

54

Page 59: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8/86

4.1.5 MULTIFUNCTION DEVICES

These two IC's are INTEL 8256's. For a detailed itemization of all internal functions of this device, it will be neces­sary to obtain the INTEL Microsystem Components Handbook or Intel applications note AP-153. Custom instructions and machine language routines provided will handle any general purpose requirements for these devices.

The Model 52 functions handled by these "chips" include:

Auxiliary RS-232 communications Optically isolated I/O All counting and hardware timing (including quadrature) All hardware interrupt handling Internal device control

More specifically, each 8256 device has:

2 eight bit I/O ports (I/O Ports 1 and 2) 5 eight bit counter/timers (1 through 5) RS-232 receiver/transmitter Interrupt control hardware

The two chips reside at base addresses FAOO hex and FCOO hex. Internal register functions for each are assigned to Model 52 hardware functions as follows:

Register address: FA08 hex (inputs, 8256 "Port 1")

bit #:

7: 6. 5. 4. 3. 2. 1. O.

Optically isolated input I~ D Optically isolated input I~ C Optically isolated input I~ B Optically isolated input I~ A - Quadrature counter input + Quadrature counter input no connection Analog Conversion complete

Register address: FA09 hex (outputs, 8256 "Port 2")

bit #:

7. 6. 5 through O.

Parallel port direction Output enable no connection

55

Page 60: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8/86

RS-232:

Transmit/receive register address: FA07 hex Status register: FAOF hex

bit #:

7. 6. 5.

Interrupt pending Character received Ready to transmit

4. 3.

Ready to accept transmit character Break-in detected

2. Receiver Parity error l. Receiver Overrun error O. Receiver Framing error

RS-232 transmit and receive hardware: connected to Auxiliary port RS292#O

CounterLtimers l. Unassigned timer (FAOA hex) 2. Lower 8 bits of - Quadrature counter (FAOB hex) 3. Lower 8 bits of + Quadrature counter (FAOC hex) 4. Upper 8 bits of - Quadrature counter (FAOD hex) 5. Upper 8 bits of + Quadrature counter (FAOE hex)

Register address: FC08 hex (inputs, 8256 "Port 1")

bit #: 7. CH Z Encoder input 6. CH A Encoder input 5. CH Z Encoder input 4. DIR output 3. CH B counter input 2. STEP counter input l. no connection O. no connection

56

Page 61: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8/86

Register address: FC09 hex (outputs, 8256 "Port 2")

bit #:

7. 6. 5. 4. 3 through O.

RS-232:

Optically isolated output OUT D Optically isolated output OUT C Optically isolated output OUT B Optically isolated output OUT A no connection

Transmit/receive register address: FC07 hex Status register: FCOF hex

bit #:

7. 6. 5. 4. 3. 2. l. O.

Interrupt pending Character received Ready to transmit Ready to accept transmit character Break-in detected Receiver Parity error Receiver Overrun error Receiver Framing error

Transmit and receive hardware: connected to Auxiliary port RS292#1

CounterLtimers l. Unassigned timer (FCOA hex) 2. Lower 8 bits of STEP counter (FeOB hex) 3. Lower 8 bits of CH B counter (FeOe hex) 4. Upper 8 bits of STEP counter (FeOD hex) 5. Upper 8 bits of CH B counter (FeOE hex)

Each 8256 has 16 internal registers for control and data. Each of the functions above requires a specific initiali­zation of internal control registers. For example, the ports must be configured as inputs or outputs, the counters must be configured as 8 or 16 bit counters or timers, the RS-232 protocol must be established, and any interrupts must be enabled.

Hardware interrupts are handled in the background by machine language routines. Interrupts are enabled by the custom instructions for automatic handling of RS-232 transmit and receive, and counter/timers. A machine language CALL routine will pass Interrupts to the BASIC program if desired.

57

Page 62: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operacors Manual (88-005548-01 Rev. Y1) 8/86

Internal registers are set to default initial conditions following power on (or reset) as follows:

8256 at FAOO hex:

UART: (Auxiliary port RS292#O) 9600 BAUD, No Parity, 8 Data bits, 1 Stop bit, DISABLED

Counter/timers: 2 16 bit counters for quadrature

Ports: Port 1: assigned inputs as above Port 2: outputs as above

8256 at FCOO hex:

UART: (Auxiliary port RS292#1) 9600 BAUD, No Parity, 8 Data bits, 1 Stop bit, DISABLED

Counter/timers: 1 16 bit counter (CH B), 1 16 bit timer

Ports: Port 1: assigned inputs and one output as above Port 2: outputs as above

All interrupts are initially disabled.

References:

I/O Ports: Section 4.2.1: 010 Instruction Counter/timers: Section 4.2.4: CTR Instruction

Section 4.2.5: QUAD Instruction RS-232 ports: Section 4.2.6: COM Instruction

Section 4.2.7: XMT Instruction Section 4.2.8: ReV Instruction

Interrupts: Section 4.3

58

Page 63: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 32 Operator3 Manual (88-003548-01 Rev. Yl) 8/86

4.1.6 FREQUENCY OUTPUT AND MOTOR CONTROL

Frequency output signals are available at the STEP+ and STEP­terminals. These signals are generated by the PVV~ instruc­tion.

The PVV~ instruction has the form:

PW~ <h>, <1>, <n>

h pulse high duration 1 pulse low duration n number of pulses

Although the 8052 PW~ instruction provides good control of pulse count and pulse frequency within limits, the Model 52 STEP output is less than ideal for sophisticated motor control. This is because multiple PVV~ instructions must be used to generate speed changes, or runs greater than 65,535 pulses in length. A minimum 1 millisecond processing time delay between PW~ instructions puts gaps in the output pulse train that can interefere with motor performance. This delay. increases if variables are used for the PVV~ parameters.

For step motors, this will not be a problem at speeds below the Stop/Start rate of the motor. Microstepped motors, and motors with lower stiffness will be more forgiving.

NOTE: Yhile the B52 is executing the PW~ instruction, it is busy and will not respond to BASIC interrupts, or ·C. Low frequency ouput of many pulses can take a long time.

59

Page 64: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8{86

! Custom BASIC Instructions

The following custom instructions have been added to BASIC-52 to facilitate I/O operations and program management. Each is described in detail in the following sections.

ANLG -010 SCAN -CTR QUAD COM XMT RCV

STR VAL

LOAD -SAVE -

analog input and output discrete input and output process inputs to output operate counter/timer count quadrature input RS-232 port setup transmit RS-232

receive RS-232

convert numbers to strings convert strings to numbers

run directory program save program

4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8

4.2.9 4.2.10

4.2.11 4.2.12

Most of these instructions have a number of variable para­meters which must be specified each time they are used. These parameters are enclosed in angle brackets "<>" in the following descriptions. Optional parameters are further enclosed in square brackets. Where applicable, default values for optional parameters are enclosed in parentheses.

NOTE: Many of the following instructions assign input data to a program variable, or use a variable as a source for output data. Variable numerical parameter values are evaluated by BASIC-52. As such, any legal numerical expression should work.

60

Page 65: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Opera~or5 Manual (88-005548-01 Rev. Y1) 8(86

The B52 allows the use of a default variable for input, this being the first variable declared. Execution of the given instruction is faster in this case. To take advantage of greater execution speed, put a statement at or near the beginning of the program using the variable of choice. Be sure the statement follows any STRING statement used.

Example: 10 STRING 67, 32 20 V1 = 0 30 ...

(reserve string space) (reserve default variable)

The subsequent program can now execute analog input opera­tions, for example, without specifying a variable for the ANLG instruction. Variable V1 would always be used.

61

Page 66: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

4. 2 . 1 AN L G: THE ANALOG I/O INSTRUCTION

This instruction is used to read analog input channel voltages from the analog-to-digital converter, and to set the output voltage of the digital-to-analog converter.

Syntax is as follows:

ANLG <f>, [<m>], [<v>J, [<c>J

f - Function: or 0

I - Input: o - Output:

read the specified channel voltage set the specified output voltage

m - Mode: V, or B

V-Volts:

B - Byte:

the input or output value is a floating point Voltage

the input or output value is a byte value (0 to 255, default)

v - Variable: Input: target variable for input value, (default variable is valid)

Output: value or variable (no default)

c - Channel number: "1" to "4", inputs IN#1 to IN#4 (Input only, default IN#1)

Input Function: If no other parameters are specified, the Input function returns a value between 0 and 255 from input IN#1 to the first program variable that is named in the program. An error message is generated if none is specified and no variables have been used previously. Specifying an undeclared (unused) variable will also give an error.

Example: ANLG I, V, Ai, 3

(set variable Ai equal to the voltage on analog input IN#9)

Example: ANLG I, BII 4

(set the 1st program variable used to the binarJ represen~ tation of the IN#4 input voltage, 0 to 255)

If the voltage Mode is specified, an input range of -10 to +10 volts is assumed. The input voltage range may be changed to match the input hardware configuration using CALL 3.

62

Page 67: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Madel 52 Operaears Manual (88-005548-01 Rev. Y1) 8/86

Output Function: The Output function will output a voltage between -10 and +10 volts in response to the specified data format. If the value of the specified variable is out of range, or no variable exists, an error message will result. Literal numbers may be used in place of a variable name.

Example: ANLG 0, V, 3.25

(set the analog output to 3.25 VDC)

For both output and bipolar input, 0 volts is represented by binary 128 (80h).

References:

Input Range: Section 4.4.3: CALL 3 Section 2.6.1: Configuring Analog

Inputs

4.2.2 010: THE DISCRETE I/O INSTRUCTION

This instruction is used to turn on and turn off PARALLEL OUTPUTs, the ISOLATED'outputs IN A through IN D, and the DIR output. It also serves to'-read the state of PARALLEL INPUTs, ISOLATED inputs IN A through IN D, as well as the Encoder inputs CH A, CH B, and CH Z.

The instruction also accesses "dummy" I/O. A dummy input or output is actually a memory location used to store an input or output state. This feature is mostly used with the SCAN instruction.

63

Page 68: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Opera~ors Manual (88-005548-01 Rev. Yl) 8/86

Syntax is as follows:

DIO <f>,<n>, «v>]

f Function: 5, C, I, E, D, 0, R

5 - Set discrete output C - Clear discrete output I - Invert discrete output

(low voltage state) (high voltage state)

E - Enable discrete outputs D - Disable discrete outputs o - Output is set to match variable R ~ Read discrete input

<v>

n - Output or Input identifier:

Outputs: "A", "B", "Crt, "D", "E", and "0" through "23" plus dummy outputs "24" to "31" or a Program Variable

A, B, C, and D refer to the ISOLATED outputs E refers to the DIR output o to 23 refer to PARALLEL OUTPUTs dummy outputs are memory locations

Inputs: nAn, "Brt. nCn, "0", "X", nyu, "Z", "0" through "23", "100" through "107", dummy inputs "24" through "31" or a program variable

A, B, C, and D refer to the ISOLATED inputs X, Y, and Z refer to inputs CH A, CH E, CH Z o to 31, and 100 to 107 refer to PARALLEL INPUTs, dummy inputs are memory locations

v - Variable (Read and Output only)

Read: target variable (default variable valid) Output: source variable (no default)

This instruction executes the indicated function on the specified input or output using the specified variable, if any. All of the Functions above except Read are output functions.

64

Page 69: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8/86

Functions: The Enable function must be executed to enable output drivers, or no outputs but DIR will work. The Disable function could be useful in "Emergency Stop" situations.

The Set and Clear functions are designed to work with signal conditioning equipment. Therefore the NEGATIVE TRUE logic convention is used. Set will result in a low voltage output which turns On an I/O module. Clear turns it off. Invert will reverse the state of the output.

Input and output logic for this instruction may be inverted using CALLs 14 and 15.

If the output to be accessed is identified by a number, a Program variable or expression can be used to specify the output. (The five outputs identified by letters above may be accessed using a variable set to their ASCII code).

Example:

010 E 010 5, A 010 5, ASC(A) 010 C, Xl

(enable all outputs) (turn on OUT A)

(turn on OUT A) (evaluate variable Xl, set the output of that number low)

The Output function sets the specified output to the state of the specified program variable <v>. If the specified variable is zero the output is Set ON (low), if the variable is anything else, a Clear results (OFF, output high).

Example:

010 0, Xl, X2

(variable Xl is evaluated, and the resulting number defines which output is used. That output is set low if variable X2 is zero, otherwise it is set high.)

The Read function reads the state of the specified input and sets the specified program variable accordingly. If the input is low, the variable is set to zero, otherwise to 1.

References:

Connector pin out: Invert inputs: Invert outputs:

Appendix A: Parallel I/0 Section 4.4.12: CALL 14 Section 4.4.13: CALL 15

65

Page 70: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8/86

4.2.3 SCAN: THE I/O LOGIC INSTRUCTION

This instruction allows the direct Boolean conversion of ONE OR MORE inputs to one or more outputs. It is designed to operate much the way Ladder Logic operates on contacts and coils. Dummy outputs may be used to "store" the result of some logical combination of inputs. This stored value can then be used again as an input in the same or in other SCAN insructions, or read with the 010 instruction.

Syntax is as follows:

SCAN <i> [op<j >op<k>op .... <n>] - <0> [ ,<p>, <q>, ... <z> ]

i,j ,k, ... n: Inputs "0" through "23" and dummy inputs "24" through "31" *

o,p,q, ... z: Outputs "0" through "23" and dummy outputs "24" through "31" *

op: Logical Operator - "#", "&", "@", "!,,

#: OR the next input is logically ORed &: AND the next input is logically ANDed @: XOR - the next input is Exclusive ORed ! : NOT - this symbol can be placed in front

any input or output of

* Variables may be used to represent input and output identification numbers, at the expense of execution speed. ISOLATED inputs and outputs A through D may be used when represented by their ASCII codes (65 through 68).

Example: SCAN 2 # 5 & !6 = 7, !9

(if 2 or 5 but not 6 in, then 7 but not 9 out)

Here, 2, 5, and 6 refer to inputs, 7 and 9 refer to outputs. When the B52 executes this instruction it reads input 2, ORs it with input 5. The result is ANDed with the inverse of input 6. If the result of all this is "true", output 7 is turned on and 9 is turned off.

Processing of logic operations proceeds from left to right. There is no prededence of operators, no nesting with paren­theses. The number of inputs and outputs is limited only by the maximum length of program statements (79 characters).

Once again, these operators assume NEGATIVE TRUE logic. If the programmer wants a high state on an input to be a "logic

66

Page 71: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operator~ Manual (88-005548-01 Rev. Y1) 8/86

1 n or a logic 1 result to set an output high, the inversion symbol must precede each input and output.

It is not sufficient to invert outputs only! Input and output logic for all inputs and outputs may be inverted using CALLs 14 and 15.

To emulate ladder logic operation, the programmer would set up a program loop consisting of SCAN statements that are repeatedly executed. The following type of input/output problem is easily handled with a single instruction. If the START switch (II) or REMOTE START switch (12) closes and the SAFETY (110) switch is closed then turn on the MOTOR STARTER coil (05) and keep it on until the STOP switch (13) opens (or the SAFETY switch opens).

10 5 I / r------r-( )

L 25 ( )

In this simplified ladder diagram; output 25 is fed back to input 25 to keep the MOTOR STARTER (5) on.

In BASIC:

10 SCAN 1#2#25&3&10 5,25 20 GOTO 10

If inputs 3 and 10 are ON (true), the dummy output 25 is set ON when 1 or 2 are momentarily turned ON. The dummy output is a memory location, and is read each time this instruction is executed. It will keep the outputs ON until 3 or 10 are turned OFF. Note that the Normally ON STOP input device (3) could be replaced with a Normally OFF one by placing the invert symbol n!" in front of the 3.

4 . 2 . 4 CTR: THE COUNTER/TIMER INSTRUCTION

This instruction is used to access the four 16 bit counter/timers in the B52. Following power-up (or reset), these are arranged as 2 16 bit counters which handle encoder signals, a sixteen bit counter to count pulses on the CH B input alone, and a sixteen bit millisecond timer.

67

Page 72: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operaror3 Manual (88-005548-01 Rev. Y1) 8/86

All four counters count down. Any will serve as a counter or a timer. They can be loaded with initial values, they can be read at any time.

A sixteen bit counter has a maximum count capability of 65,536. All four of these counters have the capability of interrupting the program when their count reaches zero.

When the CTR (or QUAD) instruction is used, counter/timer "underflow" interrupts are enabled and automatically handled by the B52 machine language interrupt service routine. This routine keeps track of total count to a maximum of 16,777,216 (24 bits).

The instruction has the following syntax:

CTR <n>,<f>,<m>, [<v>]

n Counter #: "1" through "4"

f Function: C ,T

C - Count T - Time (count milliseconds)

m Mode: D, T, R

D start preset Down count T start Totalized count R Read the counter

v Variable

Down counting: variable - 1 to 16,777,216 (no defaults allowed) Reading: target program variable (default variable is valid)) Total count: no variable used

Counter 1 is connected to the Cll B input. When the encoder inputs are not in use for counting quadrature, this may be employed as an "event counter" input. The counter is decremented each time the Cll B input goes from a low to high voltage state.

Counter 2 is ordinarily configured for timing. It may be used as a counter for pulses output by the PVV~ instruction on the STEP output.

68

Page 73: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8/86

Counters 3 and 4 are connected to the ENCODER input quadra­ture detector. They may each be used as timers, OR in quadrature counting operations. Caution must be observed are to avoid interfering with encoder operations using this instruction. Encoder counting operations use the QUAD instruction.

Counter/timers can either start from a preset value and count Down to zero, or start from zero and maintain a running Total count. The preset count function calls for an initial value which may be specified as a declared program variable or a literal number.

For either function, Reading the counter returns the number of counts away from zero. The read operation is instant and does not interfere with the ongoing count. The counter value is assigned to the specified program variable. The default variable is the first declared variable.

Example: CTR 2, T, T, Xl

(set timer 2 to the value of Xl and start timing)

CTR 2, T, R, X2

(read the above timer, set X2 to the number of milliseconds remaining)

The Down counting mode is typically used with the B52's interrupt capability. If interrupts are not used, the counter can be read to see if it has gotten to zero. If any counter counts down to zero in this mode, SUBSEQUENT COUNTS WILL BE IGNORED. The counter will still read zero.

The use of interrupts allows rapid response to an end-of­count or timeout condition. A sample program appears in Section 5.2.

If program interrupts are used in the Down counting mode, and the counter preset is larger than 65,535, the program must be prepared to deal with (ignore) multiple interrupts.

Example:

100 ONEXl 200 110 CTR 1,T,D,100000 120 etc.

The CTR instruction above will result in two interrupts, because the preset value exceeds 65,535. The interrupt

69

Page 74: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8/86

service routine at line 200 must ignore the first counter interrupt.

The Total counting mode will also generate an interrupt every 65,536 counts. Any BASIC interrupt service routine should be prepared to ignore them.

References:

Counter/timers: Interrupts:

Intel AP-153 Section 4.4

4.2.5 QUAD: THE ENCODER INSTRUCTION

Like the CTR instruction, this instruction provides access to counters, but only to counters 3 and 4, the two counters driven by the B52 quadrature detector. One counter counts "positive" and the other "negative". The QUAD instruction manages both counters, and provides total quadrature count by subtracting the negative count from the positive. The quadrature counter can be read or started from zero.

The instruction has the following syntax:

QUAD <m>, [<v>] (Quadrature counter control)

m = Mode: "C" or "R"

C - Count: initialize the count to zero and start counting

R - Read: the specified variable is set to the current count

v - Declared target variable (Read only: default variable is valid)

When program interrupts are enabled, both counters 3 and 4 may generate interrupts which the interrupt service routine should be prepared to ignore.

Example:

10 Xl=O 20 QUAD C 30 QUAD R,Xl 40 PRINT "Position 50 GOTO 20

",Xl

70

(declare variable) (start counting) (read counter)

(display count) (repeat)

Page 75: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8/86

4.2.6 COM: THE RS-232 SETUP INSTRUCTION

This instruction is used to set up the auxiliary RS-232 ports for input and output communications. This involves estab­lishing RS-232 protocol for the port, initializing the receive buffer for incoming characters, and enabling auto­matic receive interrupts. After this instruction is executed in a program, the XMT and RCV instructions can be used to send and receive ASCII characters.

Protocol for either port includes Baud rate, Parity selec­tion, and control bits. There is no handshaking capability on any B52 RS-232 channel. These signals such as Clear To Send/Request To Send, and Data Set Ready/Data Terminal Ready are not supported or even connected on the B52. Remote devices must be configured to operate without them.

The receive buffers are located at the top of RAM memory, and incoming characters are automatically put there by the interrupt service routine. No "null" characters (ASCII zero) are put in the receive buffer.

71

Page 76: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Opera~ors Manual (88-005548-01 Rev. Y1) 8/86

Command syntax is as follows:

COM <n>, [<b>] , [<p>] , [<d>] , [<s>] , [<m>]

n - Port: "0" or "1" o auxiliary port RS292#O 1 - auxiliary port RS292#1

b - Baud rate: "0" to "9" (default 9600 Baud)

1 110 Baud 2 150 Baud 3 300 Baud 4 600 Baud 5 1200 Baud 6 2400 Baud 7 4800 Baud 8 9600 Baud 9 19200 Baud

p Parity "E", "0", "N" (default No Parity)

E Even Parity o Odd Parity N No Parity

d Data bits: "7" or "8" (default 8)

s = Stop bits: "1" or "2" (default 1)

m Mode: "T", "R", "E" (default "R")

T - Transmit only R = Receive and Transmit both E - Both with Echo

The protocol parameters above are straightforward. Note that Odd or Even Parity requires a setting of 7 Data bits. Both the Mode and protocol options must be selected to conform with the requirements of the device to be connected.

Transmit only: if the remote device does not transmit anything back, or it only echoes, this mode may be chosen to ignore any incoming characters. If the remote device echoes the characters it receives (like most Parker Compumotor indexers), this mode prevents overflow of the receive buffer. The XON/XOFF protocol is disabled in this mode because the receiver is disabled.

72

Page 77: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model S2 Operaeor~ Manual (88-00SS48-01 aev. Yl) 8/86

'Receive and Transmit: this is the default mode in which characters may be both transmitted and received. If the remote device echoes transmitted characters, they will be accumulated in the receive buffer. The programmer must extract them using the RCV instruction to avoid buffer overflow. The XONjXOFF protocol is active.

Echo: this is a special form of the Receive and transmit mode in which all received characters are retransmitted. This is for operation with full duplex devices like the Console device. The CONSOLE port operates in a similar echoing mode. This mode should not be used with remote devices which also echo what they receive.

Example:

COM 0

(enable transmission and receipt of characters on Auxiliary port RS292#O, at 9600 Baud, with No parity, 8 Data bits, and 1 Stop bit)

COM 1,3,O,7,2,E

(enable transmission and receipt of characters on Auxiliary port RS292#1, at 300 Baud, with Odd parity, 7 Data bits, and 2 Stop bits. Echo all received characters.)

References:

Receiver/transmitter: Intel AP-153

4.2.7 RCV: THE RS-232 RECEIVE INSTRUCTION

ASCII characters can be received on either of the B52's two auxiliary RS-232 ports. This instruction is used to fetch received characters from the receive buffer for processing in the program. The auxiliary RS-232 port to be used for receiving must be initialized with the COM instruction above before this command can be used.

73

Page 78: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operator~ Manual (88-005548-01 Rov. Y1) 8/86

The syntax is:

Rev <p>, [<s>] , [<n>]

p - Port: "0" or "1" o auxiliary port RS292#O 1 - auxiliary port RS292#1

s - Target String variable: "0" to "8" representing variables $(0) to $(8) (default $(0)) - this number may be represented by a program variable

n - Number of characters to fetch omitting this parameter results in input up to the first carriage return or null (0) character, the maximum number is the declared string size - this number may be represented by a program variable

The specified number of characters is taken from the receive buffer of the specified port and placed in the specified string variable. If no number is specified, all characters up to the first carriage return, or as many as will fit in the target string variable are returned.

NOTE: If no number is specified and the number of characters returned equals the declared string size, it is almost certain that more characters are waiting in the receive buffer. The number of characters waiting in receive buffer 0 can be obtained using CALL 31. The number of characters waiting in receive buffer 1 can be obtained using CALL 32.

If an insufficient number of characters is available, the B52 will wait one second before giving up. When it gives up, the first charcter of the target string is set to zero.

NOTE: String space must be reserved at the beginning of the program to provide a variable where received characters can be put for program access.

74

Page 79: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operacors Manual (88-005548-01 Rev. Y1) 8/86

Either the literal string in the statement, the character code, or the specified number of characters from the speci­fied string variable is transmitted from the specified port.

Literal strings are enclosed in quotes.

Example:

10 STRING 43,20 (20 bytes each for $(0)' $(1)) 20 COM 0 (enable RS232#O) 30 XMT 0, " Message: ", (send literal string) 40 $(0)=" READY " (create string) 50 $(1)=" and WAITING" (create 2nd string) 60 XMT 0", (transmit default variable) 70 XMT 0,1,10 (transmit 10 characters from

variable $(1))

In the example, the literal string" Message: " is trans­mitted in line 30. The comma at the end of the line suP-. presses transmission of the normal carriage return/line feed. In line 60, the default string variable ($(0)) is transmitted without a carriage return. The extra commas cause BASIC to (1) use the default variable and (2) omit the carriage return. Line 70 transmits 10 more characters and a carriage return/line feed. The result at the receiving end of the line is:

Message: READY and WAITI

Note that the last two characters are missing because line 70 only sends 10 of the 12 characters in the string. Line 70 should be changed to XMT 0,1 or XMT 0,1,12.

The character code provision allows transmitting a single ASCII character by specifying the ASCII code. The expression used for the code must be preceded by the $ character. This is an abreviated form of the CHR instruction for XMT only.

Example:

XMT 0,$65 transmit "A" (ASCII 65) XMT 1,$Xl Xl is evaluated, and the corresponding

ASCII charcter is transmitted

References:

STRING: Section 3.1.1: Variables BASIC-52 USERS MANUAL: Chapter 4.31

77

Page 80: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-0055~8-0l Rev. Yl) 8/86

4.2.9 THE STR INSTRUCTION

This instruction is used to convert BASIC numbers and variables into character strings suitable for transmission. Scientific notation is not used.

, The syntax for the instruction is:

STR <n>o [<s>]. [<p>]

n - Number for conversion or program variable name max. 8 significant digits with up to 8 zeroes

s - Target string variable: "0" to "8" representing string variables $(0) to $(8) (defaul t $ (0))

p - Pointer to target string variable character (default: 1st character)

The number represented by the first expression following STR is converted to ASCII characters which are loaded into the target string variable starting at the character location specified. Error messages are produced if the resulting string is too long for the string variable or the pointer is out of bounds.

Example:

10 STRING 12,10 20 A1=PI 30 STR A1 40 PRINT $(0)

(reserve string space) (PI is a constant in BASIC-52)

(convert A1 to characters) (display results)

The resulting display: 3.1415926 (approximation of Pi)

Some Parker Compumotor indexers require alphanumeric RS-232 commands of the form:

"AlO V20 0100000".

There is no way to transmit these instructions even from the CONSOLE port without string conversion, because the normal PRINT statement will put spaces between the letters and numbers. The STR instruction converts a number into a series of ASCII characters and it becomes simple to attach the letter to the front of the string for transmission.

78

Page 81: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Re~. Y1) 8/86

Error messages will be generated if the specified number of characters exceeds the string variable size or if a variable is named for which the string space declared is too small.

Example:

10 STRING 52,50

20 COM 0

100 RCV 0 110 PRINT $(0)

(reserve space for $(0), 50 characters long) (enable RS292#O with default

protocol)

(see below) (display received characters)

The response of the RCV instruction in the above example depends on what is in the receive buffer when the statement is executed. The STRING statement reserves memory space for one string variable ($(0)) with a size of 50 characters. This is the maximum number of characters that can be returned by the RCV statement in this example.

If no characters have been received after the timeout period (1 second), the first character of the target string variable ($(0)) is set to zero (ASCII "null").

If fewer than 50 characters total have been received, and no carriage return characters (ASCII 13), after the timeout period the first character of the default target string variable is set to zero.

If more than 50 characters precede any carriage returns, the first 50 characters will be returned.

If a carriage return character has been received, all characters up to the carriage return are moved to the string variable (maximum of 50). (A carriage return character is used by BASIC-52 to locate the end of the string within the variable.)

Example:

RCV 1,X1,X2

(variable X2 is evaluated, and that number of characters is moved from the RS292#1 receive buffer to a string variable. The value of X1 determines which string variable is the target.)

75

Page 82: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8/86

In the above example, variable X2 must not exceed the declared size of string variables. Variable X1 must not reference a string variable for which space has not been reserved.

Assume that X1-3 above, and X2-l0. The instruction would move 10 characters to variable $(3). The minimum space allocation required to make the statement valid in a program would be:

STRING 45,10

(reserve space for four 10 character string variables)

References:

STRING: Section 3.1.1: Variables BASIC-52 USERS MANUAL: Chapter 4.31

4.2.8 XMT: THE RS - 232 TRANSMIT INSTRUCTION

This instruction is used to transmit ASCII characters from either of the B52's two auxiliary RS-232 ports. The auxiliary RS-232 port to be used for transmitting must be initialized with the COM instruction above before this command can be used.

The syntax is:

XMT <p>, [<s>] , [<n>] [,]

p - Port: "0" or "1" o auxiliary port RS292#O 1 - auxiliary port RS292#1

s - String for transmission: literal, character code, or "0" to "8" representing variables $(0) to $(8) (default $(0) - this number may be represented by a program variable

n - Number of characters to transmit (default (or 0) results in transmission up to a null (0) character, or up to the variable length Program variables may be used.

omit carriage return/line feed

76

Page 83: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8/86

Example:

10 STRING 23,10 20 COM 0 30 INPUT "Enter Distance 40 Al=Al *128 50 ASC($(1),1)=68 60 STR A1,1,2 70 XMT 0,1

(reserve string space) (enable RS292#O)

",Al (get number) (calculate value)

(set 1st character to "D") (add on number) (transmit)

This example transmits a typical indexer command. The INPUT statement gets a number from the operator. In line 50, the ASC command is used to set the first character of variable $(1) to a "D". In line 60, Al is converted to characters. The second and third STR command parameters cause the characters to be loaded into variable $(1) starting at character 2, right behind the "D". If the operator enters a "Distance" value of 100, the resuting transmission would be:

D12800

References:

Strings, ASC: BASIC-52 USERS MANUAL: Chapter 6

4.2.10 THE VAL INSTRUCTION

This instruction is used to convert numbers in the form of characters into numbers useable by BASIC. As such it is the opposite of the STR instruction. When numbers are received using the RCV instruction, VAL can convert them for mathe­matical processing.

79

Page 84: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8/86

The syntax for the instruction is:

VAL [<s>] , [<v>] , [<p> 1 , [<1>]

s - Source string variable: "0" to "8" representing string variables $(0) to $(8) (defaul t $ (0))

v - Target variable for conversion result (default variable is valid)

p - Pointer to 1st character of source string (default: 1st character of variable)

1 - Pointer to last character of source string (default: last character of variable)

The number stored as characters in the source string variable is converted to a BASIC number and put in the target program variable. If the number for conversion is mixed in with other characters, the optional character pointers may be used to extract a field of number characters from the string.

Example:

Suppose the B52 is receLvLng four character numbers on RS2S2~O and converting them from Centigrade to Fahrenheit degrees for display. The remote temperature sensor used transmits four characters followed by a carriage return every time it receives a carriage return.

10 STRING 13,5 (reserve space: $(0), $(1) 20 Tl=O (declare default variable) 30 COM 0 (set up default protocol RS2S2#O) 40 XMT 0,1 (transmit carriage return/line feed) 50 RCV 0 (receive a line) 60 VAL (convert $(0) to Tl) 70 Tl=Tl*9j5+32 (convert to Fahrenheit) 80 PRINT "Temperature=",T1 (display) 90 GOTO 40 (repeat)

String variable $(1) is empty, so nothing will be trans­mitted in line 40 but the carriage return/line feed. Line 50 moves received characters to default $(0). Line 60 converts default $(0) putting the resulting number in default Tl.

80

Page 85: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8/86

Example:

Suppose variable $(3) contains the characters: "$557.32"

100 VAL 3,Al,2 110 PRINT A1

(Convert variable $(3) starting with the second char­acter. Put the result in A1 and display it.)

The result: 557.32

4.2.11 THE LOAD INSTRUCTION

This instruction has no arguments. It is valid in the Direct mode only, and may not be included in a program. The function of this instruction is to transfer the DIRECTORY program from EPROM to RAM, and run it. Any program in RAM at the time LOAD is executed will be lost.

This instruction is automatically executed following a Reset or power up if no user programs are set up to run automati­cally.

The DIRECTORY program provides access to demonstration programs in EPROM, as well programs in EEPROM by their first line. run directly from the DIRECTORY.

4.2.12 THE SAVE INSTRUCTION

the other test and as identifying user Any program can be

This instruction is similar to the PROG instruction. The principal difference is that it allows the user to dictate where the program will be saved. It is valid in the Direct mode only, and may not be included in a program.

When the PROG instruction is used, it responds by indicating the number of the program being saved. Saved programs may be accessed using this number with the ROM instruction.

The same set of program identification numbers is used by the SAVE instruction to locate programs in EEPROM memory. This instruction is typically used to allow editing of stored programs with the purpose of storing them again without storing multiple copies.

The SAVE instruction is followed by the numerical location where the program is to be stored. If the number is invalid,

81

Page 86: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Opera~ors Manual (88-005548-01 Rev. Y1) 8/86

an error message is generated. The B52 will replace the program in the designated location with the one currently in RAM.

If the program being SAVEd is larger or smaller target space, other programs will be relocated. very time consuming with large programs.

Example:

than the This can be

The user has a working program saved in the second EEPROM location. He wants to retain this program but needs to correct an embarrasing spelling error in line 1230. He enters the following commands:

>ROM 2 READY

>XFER READY

(select 2nd program)

(move it to RAM)

>L1ST 1230-1230 (inspect the offending line) 1230 INPUT "How many times must the poop repeat" ILl

1230 INPUT "How many times must the loop repeat" III >SAVE 2 (fix the line and re-save the program)

READY >

4.3 Interrupts

The typical Model 52 process control program operates in a repetitive loop, processing inputs and controlling outputs in a linear fashion. Some process control events are too fast and unpredictable to be handled in this fashion. For these situations the programmer will want to be able to interrupt the normal progression of the program to go take care of a pressing situation.

Strictly speaking, there are fourteen potential sources of interrupts in the Model 52 architecture. One of these is the internal BASIC ONTIME interF'upt provided with the 8052 real time clock function. The others are all handled through the 8052 INTI interrupt input, accessible via the ONEXl state­ment. In practice, only eight of these external interrupts are supported by B52 interrupt processing. All of them are generated by the B52's two 8256 multifunction devices.

82

Page 87: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Opera~ors Manual (88-005548-01 Rev. Yl) 8/86

Using interrupts provides two major benefits:

1. Quick handling of high speed events.

2. Reduced "pollingA of input conditions.

Without interrupt capability, the BS2 would have to check (or "poll") all the input conditions one at a time to see if any required action. A timer or counter might run over, or an incoming RS-232 character could be missed while the processor was doing some thing else. Overall execution time would be increased due to the constant checking of inputs required.

Interrupt inputs are only checked when an actual interrupt condition occurs, eliminating the need to pay attention to them at other times. A control program might con~ist of:

1. a list of SCAN statements controlling discrete I/O to be executed repeatedly as fast as possible

2. a control routine using analog I/O that is executed every few minutes with a timed interrupt

3. interrupts to handle event counting and remote communications.

Some typical external events that lend themselves to proces­sing by interrupt include:

Communications Process timing Object detection Parts counting Emergency Stop

4.3.1 AUTOMATIC INTERRUPT SYSTEM·

There are two conditions that the B52 must handle with interrupts. These are counter/timer "overflow", and RS232 "character received" conditions. Because there are multiple sources of such high speed interrupts, BASIC interrupt service routines alone are not adequate to handle them.

Except for the real time clock interrupt, the BS2 manages all interrupts in machine language. This is not described in the MCS BASIC-52 USERS MANUAL.

83

Page 88: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8/86

TJhen the COM, CTR, or QUAD instructions are used, the inter­rupts for these functions are automatically enabled, and are handled by machine language routines outside of the BASIC program. Unless the programmer specifically needs to handle some input condition on an interrupt basis, no BASIC inter-rupt handling is required in the program.

COM interrupts result from incoming characters. These characters are automatically placed in a receive buffer. Characters in the buffer are retrieved with the RCV instruc­tion. Unless the programmer needs to take immediate action on receipt of a character, no BASIC interrupt handling is re­quired in the program.

CTR and QUAD interrupts occur when a counter/timer reaches zero. The Totalized counting or timing functions handle counter interrupts automatically as part of the counting or timing process. Total count or time is retrieved with the Read option for either instruction. Once again, no BASIC interrupt handling is required in the program.

If the CTR preset Down counting or timing functions are used, the programmer may wish to use a BASIC interrupt service routine to process the end-of-count interrupt.

A BASIC interrupt service routine is required to take advantage of the interrupt capability of the two discrete interrupt inputs, CH Z and IN D.

4.3.2 REAL TIME CLOCK: THE ONTIME INTERRUPT

The simplest interrupt is the real time clock interrupt pro­vided with 8052 BASIC. This feature is useful for accurately timing events, or initiating some operation on a periodic basis. To initialize interrupt operation, it is necessary to set the clock variable TIME, and start the clock with the CLOCKl instruction. Timing may be suspended or stopped by the CLOCKO instruction. To enable a timed interrupt, the ONTIME instruction is used, which specifies when to inter­rupt, and at what line number the interrupt service routine is l.ocated.

References:

CLOCKO, CLOCK1: ONTIME:

BASIC-52 USERS MANUAL: Chapter 4.5 BASIC-52 USERS MANUAL: Chapter 4.20

84

Page 89: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operaeors Manual (88-005548-01 Rev. Y1) 8/86

4.3.3 OTHER BASIC INTERRUPTS

The Model 52 can be configured to generate interrupts on any or all of the following conditions:

Zero Count (counter/timers 1 through 4) Discrete input signal (elf Z, Ilf D) Character received (RS232#O, RS232#1)

When an interrupt occurs, the processor completes execution of the current instruction, branches to the interrupt service routine, services the interrupt, and returns to the next instruction.

To implement interrupts, in short the program must:

1. Enable external interrupts 2. Enable program interrupts 3. Provide an Interrupt Service Routine

1. The custom BASIC instructions detailed in Section 4.2 are used to enable all interrupts except the discrete input interrupts. The COM instruction enables an interrupt on incoming characters, the CTR and QUAD instructions enable counter/timer interrupts.

2. Interrupts must be enabled within the program. The programmer must have statements in the program that enable the external interrupt conditions, and the ONEXl statement to enable the program interrupt. ONEXl further indicates where the interrupt service subroutine is located in the program.

3. BASIC interrupt service routines are described below.

References:

ONEX1: Custom BASIC: Interrupt Service:

BASIC-52 USERS MANUAL: Chapter 4.19 Section 4.2 Section 4.3.5

85

Page 90: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8/86

4.3.4 ENABLING DISCRETE INPUT INTERRUPTS

The Model 52 has two independent screw terminal inputs which are capable of interrupting the program. These include Ilf D, and GIl Z. If enabled an interrupt will be generated if the GIl Z input goes from low to high, or if the other two inputs go from an On to Off condition. These signals need not remain active for the interrupt to take place. The lli D and GIl Z interrupts are "latched" such that momentary signals will be recognized after the fact. This feature can be quite useful in an encoder referenced homing operation (to find the Z Channel).

To enable discrete input interrupts on Ilf D and GIl Z, it is necessary to use the B52's machine language routines. A CALL instruction is required for each input as follows:

CALL 21 CALL 22

CALL 23 CALL 24

enable interrupt on GIl Z input disable interrupt on GIl Z input

enable interrupt on I]v D input disable interrupt on I]v D input

These instructions may be placed anywhere in the program where it is advantageous to turn the interrupt on or off. Input interrupts are "edge sensitive" and "latched" meaning that even a momentary signal is captured, and an interrupt is generated even after the signal has gone away.

The ONEX1 statement must be issued in the program to get an interrupt response from these inputs.

References:

ONEXl : CALLs:

4.3.5 BASIC INTERRUPTS

BASIC-52 USERS MANUAL: Chapter 4.19 Section 4.4

The BASIC interrupt function has the disadvantage that it allows only one external interrupt to be serviced at a time. Furthermore, the ONTIME interrupt has priority and can interrupt the ONEXl interrupt service routine. Consequently, given the nine possible external interrupts normally handled by the B52, it is necessary to handle multiple interrupts at the machine level. Therefore, all external interrupts are handled by the B52 machine language interrupt service routine.

86

Page 91: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8/86

This routine has priority over both BASIC interrupts, insuring that no interrupt will be missed. Any external interrupts is handled in the background even while the B52 is executing a BASIC interrupt service routine.

This routine interacts with the interrupt priority controller in each of the B52's 8256 devices. Therefore, they are not available to the programmer.

To process external interrupts, it is necessary to interact with the machine language interrupt service routine. This routine notes the various interrupts that occur, and can notify the programmer as to what interrupts have occurred.

How to identify interrupts:

The B52 maintains an "interrupt byte" register where the occurence of external interrupts is recorded. It is an eight bit register, and each bit represents one of the possible interrupts. Register bits are set to 1 if their interrupt has ocurred and are otherwise O. When this byte value is passed to the BASIC interrupt service routine, it is in the form of a number from 0 to 255. Each bit that is set to 1 adds a value to the number as shown below.

The BASIC interrupt service routine must ask the B52 inter­rupt service routine for this code number to determine what action to take to service the interrupts. Interrupt register bit assigments are as follows:

bit bit-l number value significance

msb 7 128 Character received RS232#O 6 64 Character received RS232#1 5 32 Cll Z input interrupt 4 16 IN D input interrupt 3 8 counter/timer 1 zero (Cll B) 2 4 counter/timer 2 zero (STEP) 1 2 counter/timer 3 zero (quad+)

lsb 0 1 counter/timer 4 zero (quad- )

87

Page 92: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8/86

The first thing the programmer must do in the BASIC interrupt service routine is to execute CALL 1. This instruction puts the interrupt code number on the Argument Stack. The programmer must then POP the stack and retrieve the number into a program variable.

Example: 1000 CALL 1 1010 POP Z1

(get interrupt code) (move it to variable Zl)

If variable Zl has the value 81, interrupts have taken place on RS292#1, IN D, and counter/timer 4.

The following example enables all eight interrupts and shows how to identify which interrupts are active in the interrupt service routine. An alternate algorithm is provided in sample program Section 5.2.

10 ONEXl 1000 20 COM 0,9600 30 COM 1,1200 40 CALL 24 50 CALL 25 60 CTR l,C;D,100 70 CTR 2,T,D,1000 80 CTR 3,T,D,60000 90 CTR 4,T,D,360000

(end of

(enable program interrupts) (interrupt on RS292#O receiver) (interrupt on RS292#1 receiver) (interrupt on IN D input) (interrupt on CH Z input) (interrupt on CH B, 100 counts) (interrupt on timer 2, 1 second) (interrupt on timer 3, 1 minute) (interrupt on timer 4, 1 hour)

initialization)

88

Page 93: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Opera~ors Manual (88-005548-01 Rev. Y1) 8/86

(Interrupt Service Routine) 1000 CALL 1 (get interrupt code) 1010 POP Xl (move it from the stack to Xl) 1020 IF Xl=O THEN RETI (exit if code=O) 1030 IF Xl>=128 THEN Xl=Xl -128:G05UB 1100 (test for 1030 IF Xl>= 64 THEN Xl=Xl 64:G05UB 1200 (test for 1030 IF Xl>= 32 THEN Xl=Xl 32:G05UB 1300 (test for 1030 IF Xl>= 16 THEN Xl=Xl 16:G05UB 1400 (test for 1030 IF Xl>= 8 THEN Xl=Xl 8:G05UB 1500 (test for 1030 IF Xl>= 4 THEN Xl=Xl 4:G05UB 1600 (test for 1030 IF Xl>= 2 THEN Xl=Xl 2:G05UB 1700 (test for 1030 IF Xl>= 1 THEN Xl=Xl 1:G05UB 1800 (test for 1040 GOTO 1010 (check for new interrupts)

1100 '" (process RS292#O receiver interrupt) ... :RETURN 1200 '" (process RS292#1 receiver interrupt) ... :RETURN 1300 '" (process CH Z input interrupt) ... :RETURN 1400 ... (process IN D input interrupt) ... :RETURN 1500 '" (process counter interrupt, 100 counts) ... :RETURN 1600 '" (process timer 2 interrupt, 1 second) ... :RETURN . 1700 '" (process timer 3 interrupt, 1 minute) ... :RETURN 1800 '" (process timer 4 interrupt, 1 hour) ... :RETURN The above example is fairly elaborate given the number of interrupts in process. If only one interrupt is enabled, no testing is required. If a small number is enabled, the number of bit test instructions is reduced accordingly.

CAUTION:

bit bit bit bit bit bit bit bit

Do not use variables in the interrupt service routine that are used elsewhere in the program if it is not necessary. Variable Xl above should not appear elsewhere in the program for fear that it could be changed by the interrupt service routine at any time.

References:

Argument Stack: POP: CALL 1:

BASIC-52 USERS MANUAL: Chapter 1.4 BASIC-52 USERS MANUAL: Chapter 4.26 Section 4.4: Machine Language

Routines

89

7) 6) 5) 4) 3) 2) 1) 0)

Page 94: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8/86

4.3.6 DISABLING INTERRUPTS

Program interrupts may be disabled at any time via the CLEARI instruction. This instruction will inhibit program branching to the BASIC interrupt service routine, but interrupts will still be monitored by the B52's machine language routines, even when no program is running.

To inhibit this process and clear out any logged interrupts, another CALL instruction is required:

CALL 2

Following this instruction any desired interrupts must be specifically enabled to function again.

References:

CLEARI: CALL 2:

BASIC-52 USERS MANUAL: Chapter 4.4 Section 4.4.3

. 90

Page 95: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operator~ Manual (88-005548-01 Rev. Yl) 8/86

4.4 Machine Language Routines

The Model 52 has several additional functions likely to be useful in a variety of control situations. These are accessible using the CALL instruction. Some have been mentioned in passing elsewhere in the text.

The CALL instruction is very much like the BASIC GOSUB instruction, except that the subroutine is in machine language. The number following the CALL refers to an EPROM address just as GOSUB is followed by a line number. CALL numbers between 0 and 127 are coded representations of EPROM addresses 4l00H through 4l7FH by twos. As with the GOSUB, following execution of a CALL processing continues with the instruction after the CALL.

Some of the following CALLs require data or parameters, and some pass parameters back to the BASIC program. In either case, the B52 takes advantage of the ARGUMENT STACK.

When a CALL requires a parameter, the programmer must put it . onto the stack using the PUSH instruction.

Example: CALL 9 below requires a numerical parameter

100 X1=123456 110 PUSH Xi 120 CALL 9

(set parameter value) (place the value on the stack) (output 6 BCD digits)

When a CALL passes a parameter to the program, the parameter is retrieved from the stack with the POP instruction.

Example: CALL 8 below passes data to the program

200 CALL 8 210 POP X2

(read BCD inputs to the stack) (put the data in variable X2)

A list of the available CALL routines follows. A CALL may be included as a statement in any program. The function of each CALL is discussed in subsequent sections.

91

Page 96: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Yl) 8/86

CALL 0

CALL 1

CALL 2 CALL 3

CALL 4 CALL 5 CALL 6 CALL 7 CALL 8 CALL 9

CALL 10 CALL 11

CALL 12 CALL 13

CALL 14 CALL 15

CALL 16 CALL 17

CALL 18 CALL 19

CALL 20

CALL 21 CALL 22 CALL 23 CALL 24

CALL 31 CALL 32

CALL 49 CALL 127

References:

initialize the B52

pass the active interrupt code

disable all interrupts set ANALOG input range

read 2 PARALLEL BCD digi ts write 2 PARALLEL BCD digits read 4 PARALLEL BCD digits wri te 4 PARALLEL BCD digi ts read 6 PARALLEL BCD digi ts wri te 6 PARALLEL BCD digits

read an ISOLATED BCD digit write an ISOLATED BCD digits

read a PARALLEL binary number wri te a PARALLEL binary number

invert all PARALLEL INPUTs invert all PARALLEL OUTPUTs

configure 16 PARALLEL OUTPUTs configure 24 PARALLEL OUTPUTs

convert 16 bit binary convert 32 bit binary

convert binary position report

enable CH Z interrupt disable CH Z interrupt enable IN D interrupt disable IN D interrupt

receive buffer 0 size receive buffer 1 size

Report revision level Purge EEPROM

Section 4.4.1

Section 4.4.2

Section 4.4.3 Section 4.4.4

Section 4.4.5 Section 4.4.6 Section 4.4.5 Section 4.4.6 Section 4.4.5 Section 4.4.6

Section 4.4.7 Section 4.4.8

Section 4.4.9 Section 4.4.10

Section 4.4.11 Section 4.4.12

Section 4.4.13 Section 4.4.14

Section 4.4.15 Section 4.4.16

Section 4.4.17

Section 4.4.18 Section 4.4.19 Section 4.4.20 Section 4.4.21

Section 4.4.22 Section 4.4.23

Section 4.4.24 Section 4.4.25

Argument Stack: BASIC-52 USERS MANUAL:Chapter 1.4 BASIC-52 USERS MANUAL:Chapter 4.25

BASIC-52 USERS MANUAL:Chapter 4.1 POP. PUSH: CALL:

92

Page 97: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Yl) 8186

4. 4. 1 CALL 0: INITIALIZE

This instruction resets all I/O devices to their power on state, and initializes memory space used by the B52. I/O device configuration includes:

ANALOG Output ANALOG Inputs PARALLEL OUTPUTs

RS292#O

RS292#1

Counter 1 Counter 2

and Disabled

Stop bit, No

Stop bit, No

Counter 3 and 4 ISOLATED Outputs DIR Output Interrupts

References:

Set to 0 volts Set for +10 to -10 Volts Set for 24 outputs, all high,

Set for 9600 Baud, 8 Data and 1 Parity, Disabled Set for 9600 Baud, 8 Data and 1 Parity, Disabled Set to count pulses on eH B Configured as a timer Set to count encoder quadrature All turned off, and Disabled Set low

Disabled

Section 4.1

4.4.2 CALL 1: PASS INTERRUPT CODE

This instruction is normally used within a BASIC interrupt service routine to notify the program as to what interrupts are active. A byte value must be POPped from the stack, wherein each bit represents an interrupt source. A logic 1 indicates an active interrupt. Bit assignments are as follows:

bit bit=l number value significance

msb 7 128 Character received RS292#O 6 64 Character received RS292#1 5 32 eH Z input interrupt 4 16 IN D input interrupt 3 8 counter/timer 1 zero (eH B) 2 4 counter/timer 2 zero (STEP) 1 2 counter/timer 3 zero (quad+)

Isb 0 1 counter/timer 4 zero (quad-)

All eight bits are cleared after this CALL is executed.

References:

Interrupts: Section 4.3

93

Page 98: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8/86

4.4.3 CALL 2: DISABLE ALL INTERRUPTS

This instruction disables all sources of harware interrupts. After this CALL, no external interrupts will occur. The ONTIME interrupt is not affected.

The interrupts that are disabled include the two RS-232 receiver interrupts, all four counter/timer interrupts, and all three discrete input interrupts. Each of these must be re-enabled, if necessary, after this call.

After this call, incoming characters on RS!!9!!#O and RS292#1 will be lost, timer and pulse or quadrature counters will overflow unnoticed, and external input interrupt signals will be ignored.

References:

Interrupts: Section 4.4

4.4.4 CALL 3: SET ANALOG INPUT RANGE

This function is used with the Input Voltage option of the ANLG instruction to match the voltage returned by the instruction to the input range configuration in hardware.

The program must PUSH both the channel number, I through 4, and the total voltage range value of the input circuitry onto the stack prior to the CALL. Bipolar ranges must be expressed as negative numbers. The default ±10 VDC range would be PUSHed as -20.

Example:

100 PUSH 3,-2 (set IN#9 for the ±1 VDC input range)

The B52 will use this number when converting binary ADC data to volts. Input range settings are not retained after reset.

References:

Input range: Section 2.6.1

94

Page 99: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8/86

4.4. 5 CALL 4, 6, and 8 : PARALLEL BCD INPUT

These instructions are useful when the PARALLEL INPUTs are used to read BCD digits. CALL 4 reads 2 BCD digits from inputs 0 through 7. CALL 6 reads 4 BCD digits from inputs 0 through 15. CALL 8 reads 6 BCD digits from inputs 0 to 23.

The B52's response is to read the required inputs, convert them to a number and put it on the Argument Stack. The program must POP the stack to access the data. BCD input could be from thumbwheel switches or active BCD outputs.

BCD values for inputs and outputs are indicated in the table below.

Example: display the BCD value on the PARALLEL INPUTs

10 CALL 6 20 POP X1 30 PRINT "The BCD input IS ",Xi

References:

Connector pin out: BCD inputs:

Appendix A: Parallel I/O Table 4.1 (below)

4.4.6 CALL 5, 7, and 9: PARALLEL BCD OUTPUT

These instructions are useful when the PARALLEL OUTPUTs are used to read BCD digits. CALL 5 outputs 2 BCD digits on inputs 0 through 7. CALL 7 outputs 4 BCD digits on outputs o through 15. CALL 9 outputs 6 digits on outputs 0 to 23. ,

The program must PUSH the desired output value onto the stack prior to the CALL. The B52's response is to fetch the number from the sta~k, and turn on the appropriate outputs. Upper outputs that are not accessed by CALL 7 and CALL 9 are unaffected.

BCD input and output values are indicated in the table below.

Example: output the BCD value 2577 on the PARALLEL OUTPUTs

10 PUSH 2577 20 CALL 7

References:

Connector pin out: BCD inputs:

Appendix A: Parallel I/O Table 4.1 (below)

95

Page 100: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operacors Manual (88-005548-01 Rev. Y1) 8/86

Table 4.1 PARALLEL BCD

BCD inputs and outputs have the following values when they are ON (low), zero value when OFF (high):

PARALLEL Input o 1 2 3 4 5 6 7

8 9 10 11 12 13 14 15

16 17 18 19 20 21 22 23

BDC value ------~----~-----,

1 2 4 8 10 20 40 80

_:rs 100 200 400 800 1000 CALL 6, 7 2000 I 4000 8000 --------'

1,000 2,000 4,000 8,000 10,000 CALL 8,9 20,000 I 40,000 80,000 _______ --1

96

Page 101: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operaeors Manual (88-005548-01 Rev. Y1) 8/86

4.4.7 CALL 10: ISOLATED BCD INPUT

This instruction is valuable when the four ISOLATED inputs are used to read a BCD digit. The B52's response is to read the inputs, convert them to a number and put it on the Argument Stack. The program must POP the stack to access the data. BCD input could be from a thumbwheel switch or active BCD outputs. This instruction works for hexadecimal input. BCD input weighting is assigned as follows:

ISOLATED BDC Input value IN A 1 IN B 2 IN C 4 IN D 8

Example: display the BCD value on the ISOLA TED inputs

10 CALL 2 20 POP Xl 30 PRINT "The BCD input is ",Xl

References:

BCD Wiring: Appendix C: Sample I/O

4.4.8 CALL 11: ISOLATED BCD OUTPUT

This instruction is used to output a BCD digit on the four ISOLATED outputs. The output digit value, 0 to 9, must be PUSHed onto the stack before the instruction is executed. The instruction works for hexadecimal output also.

BCD output weighting is assigned as follows:

ISOLATED BDC Output value IN A 1 IN B 2 IN C 4 IN D 8

Example: output the BCD value 7 on the ISOLATED outputs

10 PUSH 7 20 CALL 3

97

Page 102: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Yl) 8{86

4.4.9 CALL 12 : PARALLEL BINARY INPUT

This instruction is useful when the PARALLEL INPUTs are connected to a device having 9 to 16 bit binary (or hexa­decimal) outputs. Following this CALL, the program must POP the stack to retrieve the value read from the inputs. Input 15 is the most significant bit, input 0 the least.

When input 15 is On, the number is interpreted as a two's complement negative number. Input range is -32,767 to 32,767.

Example: display the binary value on the PARALLEL INPUTs

10 CALL 6 20 POP X1 30 PRINT "The binary input is ",Xi

4.4.10 CALL 13 : PARALLEL BINARY OUTPUT

This instruction is useful when the programmer wants to connect the PARALLEL OUTPUTs to a device having 9 to 16 bit binary (or hexadecimal) inputs. The value for output must be PUSHed onto the stack before this CALL is executed. Output 15 is the most significant bit, output 0 the least. Negative numbers are expressed in two's complement form. The range of allowable numbers is 32,767 to -32,767.

Example: set PARALLEL OUTPUTs to 2577 binary

10 PUSH 2577 20 CALL 11

98

Page 103: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Yl) 8/86

4.4.11 CALL 14: INVERT PARALLEL INPUTS

This instruction is used to defeat the Negative True logic convention employed on PARALLEL INPUTs by the 010, and SCAN instructions, as well as CALLs 4, 6, and 8. The action taken by the 010 instruction for all other inputs is unaffected. Input logic may be switched back to negative true by issuing this instruction again.

References:

Flags: Appendix B: Memory Map

4.4.12 CALL 15: INVERT PARALLEL OUTPUTS

This instruction is used to defeat the Negative True logic convention employed on PARALLEL OUTPUTs by the 010, and SCAN instructions, as well as CALLs 5, 7, and 9. The action taken by the DIO instruction for outputs OUT A, OUT B, OUT C, and OUT D is unaffected.

Output logic may be switched back to negative true by i"ssuing this instruction again.

References:

Flags: Appendix B: Memory Map

4.4.13 CALL 16: CONFIGURE 16 PARALLEL OUTPUTS

This instruction is used to maximize the number of inputs. Following the CALL, PARALLEL OUTPUTs a through 7 become inputs "laO" through "107". These numbers are assigned for the purpose of accessing the new inputs with the 010 instruc­tion. This CALL provides a total of 32 inputs in favor of the normal 24. CALL 17 restores the outputs to their normal function.

References:

Hardware: Section 2.3.1

99

Page 104: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operacors Manual (88-005548-01 Rev. Y1) 8/86

4.4.14 CALL 17: CONFIGURE 24 PARALLEL 0 UTP UTS

This instruction is used to restore PARALLEL OUTPUTs a through 7 to their normal output function after CALL 16 has been used make them inputs.

References:

CALL 16: Section 4.4.13

4.4.15 CALL 18: CONVERT 16 BIT BINARY

This instruction is useful when the programmer needs to convert a 16 bit binary number to a number for use in the program. The 16 bit number is in the form of 2 bytes. Prior to the CALL, the two bytes must be PUSHed onto the stack. The most significant byte must be the first one PUSHed. This binary number is interpreted as a two's complement number.

After the CALL, the resulting number may be POPped from the stack for program use.

4.4.16 CALL 19: CONVERT 32 BIT BINARY

This instruction is useful when the programmer needs to convert a 32 bit binary number to a number for use in the program. The 32 bit number is in the form of 4 bytes. Prior to the CALL, the four bytes must be PUSHed onto the stack. The most significant byte must be the first one PUSHed. This binary number is interpreted as a two's complement number.

After the CALL, the resulting number may be POPped from the stack for program use.

4.4.17 CALL 20: CONVERT A BINARY POSITION REPORT

This instruction is useful when the programmer is operating a single Parker Compumotor indexer on an RS-232 port. The programmer must ReV the four characters of the report, and PUSH them onto the stack in order of receipt (MSB first). This instruction is used with the "binary position report" functions of the model 2100, 372, and CX indexing products. Binary number format is 31 bits with sign.

After the CALL, the resulting position information may be POPped from the stack for program use.

100

Page 105: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8/86

4.4.18 CALL 21: ENABLE CH Z INTERRUPT

If the programmer is using BASIC interrupts with the ONEX1 instruction, this instruction can be used to enable a program branch to the BASIC interrupt service routine when a low to high transition occurs on the CH Z encoder input. This interrupt will occur every time such a transition takes place unless the interrupt is disabled with CALL 22.

The response to this interrupt is entirely determined by the interrupt service routine.

References:

Interrupts: Section 4.4 ONEX1 : BASIC-52 USERS MANUAL: Chapter 4.19

4.4.19 CALL 22: DISABLE CH Z INTERRUPT

This instruction is the reverse of CALL 21 and disables program interrupts for the CH Z input.

4.4.20 CALL 23: ENABLE IN D INTERRUPT

If the programmer is using BASIC interrupts with the ONEX1 instruction, this instruction can be used to enable a program branch to the BASIC interrupt service routine when an ON to OFF transition occurs on the ISOLATED IN D input. This interrupt will occur every time such a transition takes place unless the interrupt is disabled with CALL 24.

The response to the CALL 23 interrupt is entirely determined by the interrupt service routine.

References:

Interrupts: Section 4.4 ONEX1: BASIC-52 USERS MANUAL: Chapter 4.19

4.4.21 CALL 24: DISABLE IN D INTERRUPT

This instruction is the reverse of CALL 23 and disables program interrupts for the IN D input.

101

Page 106: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operaeors Manual (88-005548-01 Rev. Y1) 8/86

4.4.22 CALL 31: RECEIVE BUFFER 0 SIZE

This instruction reports the number of characters that have been put into the receive buffer for Auxiliary RS-232 port RS292#O. This number is typically used in the RCV instruc­tion. Following the CALL, the number of characters is POPped from the Argument Stack.

Example:

100 CALL 31 110 POP Xi 120 RCV O,O,X1

References:

RCV:

(fetch no. Charcters) (move to Xi)

(get those characters)

Section 4.2.7

4.4.23 CALL 32: RECEIVE BUFFER 1 SIZE

This instruction reports the number of characters that have been put into the receive buffer for Auxiliary RS-232 port RS292#1. This number is typically used in the RCV instruc­tion. Following the CALL, the number of characters is POPped from the Argument Stack.

Example:

100 CALL 32 110 POP Xi 120 RCV 1,O,X1

References:

RCV:

(fetch no. Charcters) (move to Xi)

(get those characters)

Section 4.2.7

4.4.24 CALL 49: REPORT REVISION LEVEL

This instruction is useful in identifying the vintage of the Compumotor software supplied with the Model 52. The response is the software part number and revision letter which are printed to the Console device. This command may be entered in Direct command mode.

4.4.25 CALL 127: PURGE EEPROM

This instruction is for desperate troubleshooters that need to insure that EEPROM memory contents are not interfering with operations.

102

Page 107: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operacors Manual (88-005548-01 Rev. Y1) 8/86

PART V - SAMPLE PROGRAMS

The following programs include short samples of how to implement various Input/Output combination functions, as well as listings of the three programs stored in EPROM memory.

S.l Discrete and Timed Analog I/O Control Program

This example uses the program model described in Section l. 7.6.

5.1.1 PROGRAM DESCRIPTION

The hypothetical process control problem involves m~x~ng solvent which must be kept hot. Assume that the hot fluid mix is flowing out at a constant rate, and equal volumes of two fluids (A and B) flow into the mixing pot and maintain a fairly constant level.

The control program for this simplified example must read temperature and the state of all input switches, control all the outputs, and display status on a remote CRT. An Auto/Manual switch allows operator control without shutting down the machine. All discrete switches except Emergency Stop are alternate action (toggle) type switches.

The Heater can be switched On or Off in Manual or Automatic mode. Heating power level is controlled with the Analog output, from 0 to 10 VDC. Temperature is measured with an Analog input. For the sake of simplicity, assume that the temperature sensor output ranges from 0 to 10 VDC, from 0 to 127 degrees. BCD thumbwheel switches are used to input temperature set point, from 0 to 99 degrees. The mixer must be on when heat is on.

In Auto Mode, a crude proportional control algorithm is used to set the heater ouput based on the temperature deviation from set point. This algorithm is not recommended for general use. In Manual Mode, the set point value is output directly to the heater.

To avoid over control' of temperature, the heat is adjusted once every two minutes.

Interrupts are used for the timing function and the Emergency Stop switch.

103

Page 108: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8/86

5.1.2 I/O DESCRIPTION

. Model 52 Inputs

Function

ISOLATED: Emergency Stop

PARALLEL: BCD Temperature Set Point (0 to 99) Auto/Manual Heater Enable/Disable switch Manual Mixer On/Off switch Manual Heat On/Off

ANALOG: Temperature Sensor (0 to 10VDC)

Model 52 Outputs

PARALLEL: Auto Mode Enabled Indicator Heater On Mixer On Temperature High indicator Temperature Low indicator

ANALOG: Heater Control

RS-232: Status Display

104

Assigned inputs

IN D

o to 7 8 9 10 11

IN#l

Assigned outputs

o 1 2 3 4

ANALOG OUT

PRINTER

Page 109: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8/86

5.1.3 PROGRAM LISTING

Initialization

10 CALL 0 20 PUSH 1,10:CALL 3 30 BAUD 9600

(shut off all outputs just in case) (set analog input range, 10 VDC) (set Baud rate to remote display)

40 CALL 23 50 ONEXl 600 60 010 E

(enable E. Stop switch interrupt) (enable E. Stop program interrupt)

(enable outputs) 70 Tl=0:T2=0 (declare variables) 80 TIME=O:CLOCKl 90 ONTIME 120,400

(start the real time clock) (enable 2 minute timer interrupt)

Main Program

100 SCAN 10=2,24 110 SCAN 10&9=1,25 120 SCAN 10&8=0,26 140 GOTO 100

(see SCAN discussion below)

Timed Heat Control Interrupt

400 CALL 4:POP Tl (read BCD Setpoint from inputs 0-7) 410 ANLG I,B,T2,1 (read temperature from analog IN#l) 420 El=INT(Tl-(T2/2)) (calculate error) 430 010 R,8,Al (read Auto/Manual switch) 440 IF A1=0 THEN ANLG O,B,T1 (output set point if manual) 450 IF A1<>0 THEN ANLG 0,B,E1 (calculated output if auto) 460 IF E1<>0 THEN 470 470 010 C,3:DI0 C,4:GOTO 500 (indicators off if no error) 480 IF E1<0 THEN 010 C,27 ELSE 010 S,27 490 SCAN 27=!3,4 (turn one indicator off, one on) 500 GOSUB 800 (display status) 510 IF TIME>=3600 THEN H1=H1+1:TIME=TIME-3600 (count hours) 520 ONTIME TIME+120,400:RETI (re-enable, end interrupt)

Emergency Stop Interrupt

600 CALL 0 610 PRINT# 620 END

n**** (shut off all outputs)

EMERGENCY STOP! ****n,CHR(7) (program must be restarted)

105

(beep)

Page 110: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Opera~ors Manual (88-005548-01 Rev. Yl) 8/86

Remote Display Subroutine

600 PRINT# "Mixer ", 610 010 R,24,11:GOSUB 700 (read Mixer output state) 620 PRINT# "Heater ", 630 010 R,25,11:GOSUB 700 (read Heater output state) 630 PRINT# "Temperature: ",T2," Degrees" 640 PRINT# "Set Point: ",T1," Degrees" 650 PRINT # "Operating Mode: ", . 660 010 R,26,I1 (read Auto/Manual state) 670 IF 11=0 THEN PRINT# "MANUAL" ELSE PRINT# "AUTO" 680 PRINT# "ELAPSED TIME: ",H1,":", (display hours) 690 M1=TIME/60:PRINT# INT(M1) (display minutes) 690 RETURN

700 IF 11=0 THEN PRINT# "OFF" ELSE PRINT# "ON" 710 RETURN

Sample Display Output

Mixer: ON Heater: ON Temperature: 87 Degrees Set Point: 89 Degrees Operating Mode: AUTO Elapsed time: 1:36

5.1.4 USE OF THE SCAN INSTRUCTION

The program above provides some examples of how the SCAN instruction can be used to reduce program size. Lines 100 through 120 each do an input to output conversion that would otherwise require many lines of IF ... THEN statements.

Each of the three lines takes advantage of "Dummy" I/O where dummy outputs are 'used to record the state of real outputs. Dummy outputs can be read as inputs also, such that the program is able to test the state of real outputs by checking their corresponding dummy inputs. The dummy I/O used have the following significance.

24 the Mixer is [ON or OFF] 25 the Heater is [ON or OFF] 26 the system is in [Auto or Manual] Mode 27 the fluid temperature is [High or Low]

When Heater output 1 is turned ON in line no, dummy output

. 106

Page 111: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operator~ Manual (88-005548-01 Rev. Yl) 8/86

25 is also turned ON. In line 630, dummy input 25 indicates whether the Heater output is ON or OFF.

In line 490, the SCAN instruction is used to control the "Temperature High" and "Temperature Low n indicators connected to outputs 3 and 4. Most of the time these two will have opposite state. Line 490 uses a dummy input to establish under or over temperature and efficiently converts that to two outputs with opposite state using the invert symbol on output 3.

These examples are simplified by the use of alternate action switches. When momentary switches are used to turn a function on or off, like the Heater, the program must keep track of whethe.r the switch means on or off.

Example:

100 SCAN 25&10@28=2,28 110 SCAN !10=25

Here, the Exclusive OR function is used to invert the state of Heater output 2 every time Heater ON/OFF switch 10 goes ON. Once again, dummy variable 28 is used to represent the state of output 2. When input 10 first goes ON, "10@28" will result in an inversion of 28 (and 2). When 10 is OFF, the result is no change.

If the switch is ON too long, the output might be inverted several times as the program loops through the SCAN state­ments. Dummy output 25 is used to prevent the inversion from taking place again before the switch goes OFF. When input 10 goes ON, input 25 goes OFF due to line 110 above. Then, the AND function "25&10" in line 100 prevents a second Exclusive OR inversion of the Heater output.

The combination of a dummy input with the Exclusive OR function is very handy. When the input is true (ON), the Exclusive OR inverts. When the input is false (OFF), it doesn't.

5.2 Sample Parts COlllting and Motor Control Program

This program takes advantage of the STEP and DIR outputs to jog a step motor. Analog inputs are used for set point and position feedback. Parts are counted and events are timed.

107

Page 112: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8/86

5.2.1 PROGRAM DESCRIPTION

The Model 52 is in charge of painting widgets which pass by hanging from a conveyor. The speed at which they pass is controlled elsewhere, but the B52 must control the pressure used to drive the spray paint according to line speed.

Each time 100 widgets have passed, the B52 must provide a one second signal to a transfer line which controls packaging.

A 1,000 step motor is used to drive a pressure valve con­trolling the spray rate. The valve has 320 degrees of travel. A potentiometer is mounted to the back shaft, and wired to produce -10 VDC when the valve is closed, +10 VDC when full open. The valve should be half open whenwidgets are passing once per second.

The stepper translator is driven by the STEP and DIR outputs. Jog switches are required for manual valve control.

The operator wants to be able to adjust spray rate, so another potentiometer with the same voltage range is wired to provide a set point.

A photoelectric detector senses the passing widgets.

Interrupts are used for widget timing, widget counting, and output signal timing.

108

Page 113: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Opera~ors Manual (88-005548-01 Rev. Y1) 8/86

5.2.2 I/O DESCRIPTION

Model 52 Inputs

ISOLATED: Run/Stop Switch Jog CW Switch Jog CCW Switch

ENCODER: Widget detector Widget detector

ANALOG: Motor Position Set Point

Model 52 Outputs

ISOLATED: Widget count complete Fault

MOTOR: Motor Step Direction

5.2.3 PROGRAM LISTING

Initialization

10 CALL 0 20 Al=O:ll=O:Tl=O 30 010 E 40 A2=.5:GOSUB 600 50 010 R,C,ll 60 IF 11>0 THEN 100 70 GOSUB 700:GOSUB 800 80 GOTO 50

Assigned input

IN C IN B IN A

CH B CH Z

IN#l IN#2

Assigned output

OUT A OUT B

STEP DIR

(shut off all outputs) (declare CTR, ANLG variables) (enable discrete outputs) (close spray pressure valve)

(read Run/Stop switch) (go to Main Program if Run)

(otherwise check Jog switches)

109

Page 114: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operaeors Manual (88-005548-01 Rev. Yl) 8/86

Main Program

100 CALL 21:0NEXl 300 110 CTR 1,C,0,100 120 ANLG I,B,Al,2 130 A2=(Al+ Tl)/2 140 ANLG I,B,Al,l

(enable widget interrupt) (enable interrupt on 100 widgets) (read set point)

(average the set point with line rate) (read valve position)

150 IF Al<A2 THEN GOSUB 600 160 IF Al>A2 THEN GOSUB 500 170 010 R,C,ll

(open the valve) (or close the valve)

(check Run/Stop input) 180 IF 11=1 THEN 120 190 CALL 22:CLEARI:GOTO 40 (disable interrupts if Stop)

Interrupt Service routine

300 CALL l:POP Xl 310 IF Xl=O THEN RETI 320 X2=2 (ini tialize 330 FOR 12=1 TO 5

(fetch interrupt source code) (return if no more interrupts)

logical mask for interrupt bits) (test interrupt bits 1 to 5) (ignore bit if zero) 340 IF Xl.ANO.X2=0 THEN 360

350 ON 12 GOSUB 430,490,450,400 360 X2=X2+X2

(go process the interrupt) (increment bit mask)

370 NEXT:GOTO 300

400 010 S,A 410 CTR 1,C,0,100 420 CTR 3,T,0,1000 430 RETURN

450 CTR 2,R,Tl 460 CTR 2,T,T 470 Tl=128/Tl 480 RETURN

490 010 C,A:RETURN

(signal 100 widgets) (restart widget counter) (start 1 second signal timer)

(read widget timer) (restart widget timer) (scale time to valve position)

(shut off 100 widget signal)

llO

Page 115: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Yl) BfB6

Motor Control Subroutines

500 010 C,E 510 OO:PWM 200,200,5 520 ANLG R,B,Al,l 530 UNTIL A1>A2 540 RETURN

600 010 S,E 610 OO:PWM 200,200,5 620 ANLG R,B,A1,1 630 UNTIL A1<A2 640 RETURN

700 010 S,E 710 010 R,B,11 720 IF 11=0 RETURN 730 PWM 2000,2000,10 740 GOTO 710

800 010 C,E 810 010 R,A,11 820 IF 11=0 RETURN 830 PWM 2000,2000,10 840 GOTO 810

(set motor direction to Close valve) (send 5 steps to the translator)

(read the valve position pot) (repeat until feedback is correct)

(set motor direction to Open valve) (send 5 steps to the translator)

(read the valve position pot) (repeat until feedback is correct)

(set motor direction to Open valve) (read the Jog switch)

(return if it has gone OFF) (send 10 steps to the translator) (repeat)

(set motor direction to Close valve) (read the Jog switch)

(return if it has gone OFF) (send 10 steps to the translator) (repeat)

III

Page 116: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8/86

5.3 The Directory Program

The following program is stored permanently in the B52's permanent EPROM memory. It is available for running for inspecting memory contents and running stored programs by issuing the LOAD instruction while in the Direct command mode.

10 REM *** MODEL 52 DIRECTORY PROGRAM *** 20 PRINT:PRINT:PRINT 30 PRINT "Compumotor Model 52 Program Directory" 40 PRINT" (use UPPER CASE, please)" 50 Nl=l:IF XBY(8010H)=55H THEN 300 (any EEPROM programs?) 60 PRINT "No Programs are Saved in Memory" 70 Nl=O:GOTO 300 (SSh starts EEPROM programs)

100 Al=8011H (Nl is the program counter) 110 PRINT "Press 'Escape' to stop the search" 120 PRINT:GOSUB 200 (display 1st program) 130 DO (start search loop) 140 A2=GET:IF A2=27 THEN Al=OBFFOH (test for Escape) 150 IF XBY(Al)<>OlH THEN 180 (test for end of program) 160 IF XBY(Al+1)=55H THEN 170 (test for next program) 165 Al=OBFFOH:GOTO 180 (end) 170 Nl=Nl+l:Al=Al+2:GOSUB 200:GOTO 180 (count & display) 180 N2=XBY(Al):Al=Al+N2 (advance one program line) 190 UNTIL Al>=OBFFOH (repeat search for Olh) 195 PRINT "That's all":GOTO 300

200 PRINT "Program No.",Nl," Starts at address", 210 PHO. Al-1, (display program no.& start address) 220 IF XBY\Al+3)=96H THEN 240 (test for REM statement) 230 PRINT I (no title)":RETURN (no REM) 240 PRINT:PRINT "Title: ", (REM found) 250 A2=XBY(Al)-5:A3=A1+3 (juggle character pointers) 260 FOR 11=1 TO A2 270 PRINT CHR(XBY(A3+11)), (display REM remark) 280 NEXT:PRINT:RETURN

112

Page 117: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model '2 Operacors Manual (88-005548-01 Rev. Y1) 8/86

300 PRINT:PRINT "Press a Key to Select an Option:" 310 PRINT "A. Run the I/O Test Program" 320 PRINT "B. Run the CX/372/2100 Program" 325 PRINT "e. Stop the Program" (display options) 330 IF N1=0 THEN 350 (include EEPROM if any) 340 PRINT "D. Run a Stored Program" 345 PRINT "E. Search memory for a Stored Program":PRINT 350 A=GET:IF A=O THEN 350 (wait for keystroke) 360 IF A=65 THEN CALL 50 (test for A key) 370 IF A=66 THEN CALL 51 (test for B key) 375 IF A=67 THEN PRINT:PRINT:STOP (test for C key) 380 IF Nl=O THEN PRINT CHR(7),:GOTO 350 (beep, wrong key) 385 IF A=68 THEN 400 (test for D key) 390 IF A=69 THEN 100 (test for E key) 395 PRINT CHR(7),:GOTO 350 (beep, wrong key)

400 PRINT:PRINT "Enter the Program Number (10 max)" 410 INPUT "(enter 0 to start over)".ll (select program) 420 IF I1>Nl THEN PRINT CHR(7).:GOTO 400 430 IF 11<=0 THEN 20 (test for valid no.) 435 IF 11>10 THEN PRINT CHR(7),:GOTO 400 440 ON 11 GOTO 1,450.451,452,453.454,455,456,457,458,459 450 RROMl 451 RROM2 452 RROM3 453 RROM4 454 RROM5 (branch to run selected EEPROM program) 455 RROM6 456 RROM7 457 RROM8 458 RROM9 459 RROM10

Notable features of the above program include the use of the 8052's start-of-program and end-of-program characters (55 hex and 01 hex, respectively). To give any stored program a title, the first line must be a REM statement with the title. CALL 35 loads a program from EPROM to RAM and runs it.

113

Page 118: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Yl) 8/86

5.4 The Test and Demonstration Program

The following program is stored permanently in the B52's 'permanent EPROM memory. This program is especially useful in

troubleshooting situations when a B52 is installed and mysterious malfunctions occur. I/O function can be tested in many cases by connecting inputs to outputs.

This program allows testing the various I/O functions without loading any other diagnostic programs. It is accessible through the Directory program above by issuing the LOAD instruction while in the Direct command mode.

5.4.1 PROGRAM DESCRIPTION

The program has several menus of I/O operations to execise the various B52 I/O devices. Messages displayed by this program are explained below, followed by the program listing.

Opening message:

** Model 52 Test and Demonstration **

READfWRITE .MEMORY SIZE PROGRAM SIZE MEMORY AVAILABLE

STRIKE A KEY TO PROCEED

15770 BYTES 6735 BYTES 8523 BYTES

(More memory is available when programs are run from EEPROM)

Main Menu:

PRESS A LETTER KEY TO SELECT A FUNCTION

A. ANALOG I/O TEST E. ENCODER TEST I. ISOLATED I/O TEST M. MOTOR OUTPUT TEST P. PARALLEL I/O TEST R. RS-232 COMMUNICATIONS TEST

For this and subsequent menus, it is only necessary to press a key once. Do not press RE~~.

Capital letters are required for this program; press the CAPS LOCK key if required. It is easy to get out of any menu chosen.

114

Page 119: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8/86

Pressing "A" results in the Analog test menu:

ANALOG I/O TEST

PRESS S TO SET THE OUTPUT VOLTAGE PRESS R TO READ THE INPUTS PRESS A FOR AUTOMATIC CYCLE PRESS + OR - TO INCREMENT THE OUTPUT PRESS I TO CHANGE THE INCREMENT PRESS Space TO EXIT ANALOG TESTING

This section of the program allows setting the output voltage, and displaying the input voltage on all four channels.

The "+" and "_If keys will increase or decrease the output voltage by a fixed increment. This increment can be adjusted by pressing "I".

The "A" key allows either repetitive incrementing of the output from minimum to maximum voltage, or a running display of input voltage on all four channels, or both. The output increment is adjustable with the "I" option.

Pressing the Space Bar returns the program to the Main Menu. If "E" is then pressed, the following display appears:

ENCODER TEST

PRESS A KEY TO RESTART THE COUNT PRESS Space TO EXIT ENCODER TESTING

TOTAL QUADRATURE COUNT: o

Once an incremental encoder is powered up and connected to the ENCODER inputs, the program will display any change in the position of the encoder.

115

Page 120: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8/86

If the Main Menu "I" option is selected, the following menu is displayed:

ISOLATED I/O TEST ___________________________ 4 _________ __

PRESS 0 TO INVERT AN OUPUT PRESS I TO CHECK THE INPUTS PRESS A FOR OUTPUT CYCLE PRESS Space TO EXIT ISOLATED I/O TEST

This is actually the only program option that has any visible results when no I/O is connected. The four output indicators will turn on when their associated output is turned on. ·The "I" option displays the state of all four ISOLATED inputs. The "A" option cycles through all four outputs in sequence, and displays the state of all four ISOLATED inputs each time.

STEP OUTPUT TEST --------------------------------,--------, PRESS R TO REVERSE MOTOR DIRECTION PRESS F FOR FREQUENCY OUTPUT PRESS M FOR MOTOR CYCLE PRESS Space TO EXIT

The Main Menu "M" option results in the above display. If a Compumotor motor drive is connected to the STEP and DIR outputs, either the "F" or "M" options will move the motor.

PARALLEL I/O TEST

PRESS 0 TO INVERT AN OUTPUT PRESS F TO CHANGE INPUT FORMAT PRESS I TO CHECK THE INPUTS PRESS A FOR AUTOMATIC CYCLE PRESS Space TO EXIT PARALLEL TESTING

The Main Menu "P" option results in this display. Any of the 24 outputs (0 though 23) on the PARALLEL OUTPUT connector can be turned on or off using the "0" key. "I" results in a display of all 24 discrete inputs.

The "F" option provides several format display options for the 24 PARALLEL INPUTs. The inputs may be displayed in 6 digit BCD format, or the lower 16 inputs may be displayed as a binary number. Input state can be inverted.

116

Page 121: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Opera~ors Manual (88-005548-01 Rev. Y1) 8/86

The "A" option results in a cycle of all the outputs with the inputs displayed for each output change. Connecting outputs to inputs provides a function test of both input and output. RS232 PORT TEST

CURRENT RS232 PARAMETERS: BAUD RATE: PARITY: CHARACTER LENGTH: NO. OF STOP BITS:

9600 NONE 8 BITS 1

MODE: FULL DUPLEX CURRENT COMMUNICATIONS PORT= 0

PRESS C TO CHANGE PORTS PRESS P TO CHANGE PARAMETERS PRESS A FOR AUTO STRING TRANSMISSION PRESS K FOR KEYBOARD TRANSMISSION PRESS Space TO EXIT PORT TEST

This display follows selection of the "R" option from the Main Menu. Ei ther port, RS292#O or RS292#1, may be chosen for communications.

Communications protocol can be set using the "P" option. For communicating with devices that do not echo what they receive, use the "E" option when setting protocol.

The "A" option will automatically transmit a string of 93 ASCII characters out at a high rate. The "K" option sends CONSOLE keyboard characters out the port, and sends any characters coming into the port to the CONSOLE display.

This is the mode to use for testing interactive remote devices.

5.4.2 PROGRAM LISTING

Opening Message

10 PRINT ,,** Model 52 Test and Demonstration ** " 20 CALL 0:010 E (outputs off, enabled) 30 STRING 82,79:Xl=0 (reserve string space) 40 PRINT "READ/WRITE MEMORY SIZE =",MTOP+l," BYTES" 50 PRINT "PROGRAM SIZE =",LEN," BYTES" 60 PRINT "MEMORY AVAILABLE =",FREE," BYTES" 70 PRINT:PRINT "STRIKE A KEY TO PROCEED" 80 A=GET:IF A=O THEN 80 (wait for Console input)

ll7

Page 122: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Main Menu

90 GOSUB 260 100 PRINT "PRESS A LETTER KEY TO SELECT A FUNCTION" 110 PRINT:PRINT "A. ANALOG I/O TEST" 120 PRINT "E. ENCODER TEST" 130 PRINT "I. ISOLATED I/O TEST" 140 PRINT "M. MOTOR OUTPUT TEST" 150 PRINT "P. PARALLEL I/O TEST" 160 PRINT "R. RS-232 COMMUNICATIONS TEST" 170 A=GET:IF A=O THEN 170 180 IF A=65 THEN GOSUB 500:GOTO 90 (test for A key) 190 IF A=69 THEN GOSUB 1000:GOTO 90 (test for E key) 200 IF A=77 THEN GOSUB 1200:GOTO 90 (test for M key) 210 IF A=73 THEN GOSUB 1600:GOTO 90 (test for I key) 220 IF A=80 THEN GOSUB 2100:GOTO 90 (test for P key) 230 IF A=82 THEN GOSUB 2600:GOTO 90 (test for R key) 240 IF A>96 THEN IF A<123 THEN PRINT "UPPER CASE, PLEASE" 250 PRINT CHR(7),:GOTO 170 (beep, wrong key)

260 FOR 1=0 TO 5:PRINT:NEXT I:RETURN

270 FOR 1=0 TO 38:PRINT "-",:NEXT I 280 PRINT:RETURN

Analog I/O Section

500 GOSUB 260:Nl=.3125 510 PRINT "ANALOG I/O TEST":GOSUB 270 520 PRINT:PRINT "PRESS S TO SET THE OUTPUT VOLTAGE" 530 PRINT "PRESS R TO READ THE INPUTS" 540 PRINT "PRESS A FOR AUTOMATIC CYCLE" 550 PRINT "PRESS + OR - TO INCREMENT THE OUTPUT" 560 PRINT "PRESS I TO CHANGE THE INCREMENT" 570 PRINT "PRESS Space TO EXIT ANALOG TESTING":PRINT 580 A=GET:IF A=O THEN 580 590 IF A=32 THEN PRINT USING(O):GOTO 90 (if space, exit) 600 IF A=43 THEN GOSUB 670 (test for n+n) 610 IF A=45 THEN GOSUB 690 (test for n+n)

620 IF A=65 THEN 710 (test for II - ")

630 IF A=73 THEN 820 (test for "1") 640 IF A=82 THEN GOSUB 840:PRINT:GOTO 520 (test for "R") 650 IF A=83 THEN GOSUB 900:GOTO 520 (test for "S") 660 PRINT CHR(7),:GOTO 580

ll8

..

Page 123: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operator3 Manual (88-005548-0l Rev. Yl) 8/86

Output Increment Routine

670 V1=V1+N1:IF V1>10 THEN V1=10 680 GOTO 930 690 V1=V1-N1:IF V1<-10 THEN V1=-10 700 GOTO 930

Automatic Cycle Routine

(increment voltage) (output voltage) (decrement voltage) (output voltage)

710 V1=0:PRINT "PRESS 0 FOR OUTPUT ONLY" 720 PRINT "PRESS I FOR INPUT ONLY" 730 PRINT "OR PRESS Space FOR BOTH" 740 B=GET:IF 8=0 THEN 740 750 PRINT:PRINT "PRESS ANY KEY TO STOP":PRINT 760 M=O:IF B=79 THEN M=2:GOTO 780 (test for output only) 770 GOSUB 840:PRINT CR,:IF B=73 THEN M=1 (set up for input) 780 ON M GOSUB 800,810,950 (branch to I/O routine) 790 A=GET:IF A=O THEN 780 ELSE 510 (test for exit) 800 GOSUB 950 (increment output) 810 GOSUB 860:RETURN (display inputs)

820 PRINT:PRINT "VOLTAGE INCREMENT=",N1 830 INPUT "NEW INCREMENT? ",N1:GOTO 520

Input Display Routine

840 PRINT "INPUT VOLTAGE:" 850 PRINT "CHANNEL 1 2 860 PRINT SPC (7), : FOR 1=1 TO 4 870 ANLG I,V,Xl,1 880 PRINT USING(##.##),X1, 890 NEXT:RETURN

Set Output Routine

3 4"

(read channel volts) (format display)

900 INPUT "OUTPUT VOLTAGE? (-10 TO +10) ",V1 910 IF V1<=10 THEN IF V1>=-10 THEN 930 (test for valid range) 920 PRINT CHR(7),:GOTO 900 930 ANLG O,V,V1 (set output voltage) 940 RETURN

Output Cycle Routine

950 V1=V1+N1 960 IF V1>10 THEN V1=-10 980 GOTO 930

119

Page 124: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Opera~ors Manual (88-005548-01 Rev. Y1) 8/86

Encoder Section

1000 GOSUB 260:PRINT "ENCODER TEST" 1010 GOSUB 270:PRINT "PRESS A KEY TO RESTART THE COUNT" 1020 PRINT:PRINT "PRESS Space TO EXIT ENCODER TEST" 1030 PRINT:PRINT "TOTAL QUADRATURE COUNT:" 1040 PRINT SPC (5),"0", SPC (10), CR , 1050 QUAD C (start counting) 1060 QUAD R,Xl (read the count) 1070 IF Xl=X2 THEN 1100 (ignore if no change) 1080 PRINT SPC (5),Xl, CR , (display new count) 1090 X2=Xl 1100 A=GET:IF A=O THEN 1060 (repeat if no Console) 1110 IF A=32 THEN 90 (exit if Space) 1120 GOTO 1010 (else restart)

Motor Control Section

1200 GOSUB 260:PRINT "STEP OUTPUT TEST" 1210 GOSUB 270 1220 PRINT "PRESS F FOR FREQUENCY OUTPUT" 1230 PRINT "PRESS M FOR MOTOR CYCLE" 1240 PRINT "PRESS Space TO EXITII 1250 A=GET:IF A=O THEN 1250 1260 IF A=70 THEN 1400 (branch on F) 1270 IF A=77 THEN 1280 ELSE RETURN (test for M) 1280 PRINT:PRINT "PRESS ANY KEY TO STOP" 1290 A=5120:B=16 (set initial values) 1300 DO:PWM 20,A,B (output B pulses) 1310 A=A/2:B=B*2 (reduce pulse width, increase freq.) 1320 UNTIL A=20 (loop) 1330 PWM 20,20,10000 (output 10,000 pulses a max rate) 1340 DO:PWM 20,A,B 1350 A=A*2:B=B/2 (increase pulse width, reduce freq.) 1360 UNTIL A>=5120 (loop) 1370 A=GET:IF A<>O THEN 1390 (exit if Console) 1380 010 I,E:GOTO 1290 (invert DIR) 1390 RETURN

120

Page 125: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8/86

Frequency Output Routine

1400 1410 1420 1430 1440 1450 1460 1470 1480 1490 1500 1505 1510 1520 1530

PRINT:INPUT "ENTER FREQUENCY (10HZ-20KHZ) "IF1 IF Fl<O THEN 1400 ELSE IF F1>20000 THEN 1400 N =1 NT (1000/ (Fl * .001085) /2) ( calculate pulse width) PRINT "ACTUAL FREQUENCY WILL BE "11/(N*2*.000001085) PRINT "ENTER NUMBER OF PULSES (651535 MAX)" INPUT "(0 FOR REPEAT) "IP IF P<O THEN 1450 (limit no. pulses) IF P>65535 THEN 1450 IF P<>O THEN Fl=P PWM NINIFl (p=o repeats every second) IF P>O THEN 1510 A=GET:IF A=O THEN 1490 ELSE 1210 (stop on Console) PRINT "PRESS Space TO REPEAT" A=GET:IF A=O THEN 1520 IF A=32 THEN 1490 ELSE 1210

Isolated 1/0 Section

1600 F=l:GOSUB 260 1610 PRINT "ISOLATED I/O TEST":GOSUB 270 1620 PRINT:PRINT "PRESS 0 TO INVERT AN OUPUT" 1630 PRINT "PRESS I TO CHECK THE INPUTS" 1640 PRINT "PRESS A FOR OUTPUT CYCLE" 1650 PRINT "PRESS Space TO EXIT ISOLATED I/O TEST":PRINT 1660 A=GET:IF A=O THEN 1660 1670 IF A=65 THEN GOSUB 1830:GOTO 1620 (test for A) 1680 IF A=73 THEN GOSUB 1720:PRINT:GOTO 1620 (test for I) 1690 IF A=79 THEN GOSUB 1780:GOTO 1620 (test for 0) 1700 IF A=32 THEN RETURN (exit on Space) 1710 GOTO 1660

Input Display Routine

1720 1730 1740 1750 1760 1770

PRINT "OPTICAL INPUTS: A B PRINT SPC (15), FOR 11=65 TO 68 010 R,ll,Xl PRINT X1,:NEXT RETURN

C 0"

(65 to 68 are ASCII A to D) (read input to Xl)

(display)

121

Page 126: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Yl) 8/86

Output Set Routine

1780 PRINT "SELECT OUTPUT (A-D)" 1790 X1=GET:IF X1=O THEN 1790 (wait for Console) 1800 IF X1<65 THEN 1790 ELSE IF X1>68 THEN 1790 (test for A to D) 1810 010 I,X1 (invert output) 1820 RETURN

Automatic Cycle Routine

1830 1840 1850 1860 1870 1880 1890 1900 1910

PRINT "PRESS ANY KEY TO STOP:" GOSUB 1720:X2=65:PRINT CR, 010 S,X2 FOR 1=0 TO 10:NEXT GOSUB 1730:PRINT CR, 010 C,X2 X2=X2+1:IF X2>68 THEN X2=65 A=GET: IF A=O THEN 1850 GOTO 1600

Parallel Input Format subroutine

(set up input display) (output On)

(wait)

(output Off) (next output)

(exit on Console)

1920 PRINT:PRINT "SELECT INPUT FORMAT:" 1930 PRINT "PRESS B FOR BINARY (16 BIT)" 1940 PRINT "PRESS C FOR BCD" 1950 PRINT "PRESS 0 FOR DISCRETE" 1960 PRINT "PRESS I TO INVERT" 1970 A=GET:IF A=O THEN 1970 1980 IF A=66 THEN F1=O:PRINT "INPUT FORMAT: BINARY" 1990 IF A=67 THEN F1=2:PRINT "INPUT FORMAT: BCD" 2000 IF A=68 THEN F1=1:PRINT "INPUT FORMAT: DISCRETE" 2010 IF A<>73 THEN RETURN 2020 PRINT "INPUT FORMAT: INVERT" 2030 CALL 14:F1=-F1:GOTO 1970

122

Page 127: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8/86

Parallel 1/0 Section

2100 F1=1:GOSUB 260 2110 PRINT "PARALLEL I/O TEST" 2120 GOSUB 270 2130 PRINT "PRESS 0 TO INVERT AN OUTPUT" 2140 PRINT "PRESS F TO CHANGE INPUT FORMAT" 2150 PRINT "PRESS I TO CHECK THE INPUTS" 2160 PRINT "PRESS A FOR AUTOMATIC CYCLE" 2170 PRINT "PRESS Space TO EXIT PARALLEL TESTING" 2180 A=GET:IF A=O THEN 2180 2190 PRINT:IF A=65 THEN GOSUB 2440:GOTO 2130 2200 IF A=70 THEN GOSUB 1920:GOTO 2180 (test for F) 2210 IF A=73 THEN GOSUB 2240:PRINT:GOTO 2130 (test for I) 2220 IF A=79 THEN GOSUB 2340:GOTO 2180 (test for 0) 2230 IF A<>32 THEN 2180 ELSE RETURN (exit on Space)

Discrete Inuut Display Routine

2240 2250 2260 2270 2280 2290 2300 2310 2320 2330

PRINT "PARALLEL INPUTS:" IF ABS(F1)<>1 THEN 2390 PRINT" 0-7 8-15

(branch if not discrete format) 15-23"

FOR 1=0 TO 2 FOR 12=0 TO 7 13=11*8+12 010 R,13,X1 PRINT CHR(X1+48), NEXT:PRINT " ",:NEXT:PRINT RETURN

Output Set Routine

(loop 3 ports) (loop 8 inputs each)

(read input) (display state, 0 or 1) CR ,

2340 INPUT "SELECT OUTPUT (0-23) ",C1 2350 IF C1<0 THEN 2340 2360 IF C1>23 THEN 2340 2370 010 I,C1 (invert output, 0 to 23) 2380 GOTO 2240

Numerical Input Display Routine

2390 PRINT "THE NUMBER ON THE INPUTS IS:" 2400 ON ABS(F1) GOTO 2410,2410,2430 2410 CALL 12:POP X1 2420 PRINT X1," BINARY (", (display 16 inputs as binary no.) 2425 PHO. X1,:PRINT ")", CR ,:RETURN (and Hex) 2430 CALL 8:POP X1 2435 PRINT X1," BCD" ,CR ,:RETURN (display 24 inputs as BCD no.)

123

Page 128: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Yl) 8186

Automatic Cvcle Routine

2440 PRINT "PRESS ANY KEY TO STOP" 2450 GOSUB 2240:X2=0 (set up input display) 2460 B=GET:IF B<>O THEN RETURN (exit on Console) 2470 010 S,X2 (turn On output) 2480 GOSUB 2270 (display inputs) 2490 010 C,X2 (turn Off output) 2500 X2=X2+1 (next output) 2510 IF X2>23 THEN X2=0 2520 GOTO 2460

RS-232 Communications Test

2600 2610 2620 2630

GOSUB 260:PRINT "RS232 .PORT TEST" GOSUB 270:A1=OFAOOH P2=0:B1=4:S1=0:C1=0:P1=0:Ml=0 GOSUB 3390:GOSUB 3690

Protocol Displav Routine

(set Port 0 address) (set protocol variables)

(enable communications)

2635 PRINT "CURRENT RS232 PARAMETERS:" 2640 PRINT "BAUD RATE:",TAB(25),2**(9-B1)*300 (Bl is Baud rate) 2650 PRINT "PARITY:",TAB(25), 2660 IF P1=1 THEN PRINT "ODD" (PI is Parity) 2670 IF P1=2 THEN PRINT "EVEN" 2680 IF P1=0 THEN PRINT "NONE" 2690 PRINT "CHARACTER LENGTH:", TAB (25), (el is Data bi ts) 2700 IF C1=0 THEN PRINT "8 BITS" ELSE PRINT "7 BITS" 2710 PRINT "NO. OF STOP BITS:",TAB(25), (Sl is Stop bits) 2720 IF Sl=O THEN PRINT "1" ELSE PRINT "2" 2730 PRINT "MODE:",TAB(25), (Ml is Mode) 2740 IF M1=0 THEN PRINT "FULL DUPLEX", ELSE PRINT "HALF DUPLEX", 2750 IF M1=2 THEN PRINT " WITH ECHO" ELSE PRINT 2760 FOR 1=1 TO 1000:NEXT I

124

Page 129: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Yl) 8/86

Execution Menu

2770 PRINT "CURRENT COMMUNICATIONS PORT= ",P2 2780 PRINT:PRINT "PRESS C TO CHANGE PORTS" 2790 PRINT "PRESS P TO CHANGE PARAMETERS" 2800 PRINT "PRESS A FOR AUTO STRING TRANSMISSION" 2810 PRINT "PRESS K FOR KEYBOARD TRANSMISSION" 2820 PRINT "PRESS Space TO EXIT RS-232 TEST" 2830 A=GET:IF A=O THEN 2830 2840 PRINT 2850 IF A=65 THEN 3050 (test for A) 2860 IF A=75 THEN 2980 (test for K) 2870 IF A=67 THEN 2910 (test for C) 2880 IF A=80 THEN 3160 (test for P) 2890 IF A<>32 THEN 2900 ELSE RETURN (exit on Space) 2900 PRINT CHR(7),:GOTO 2830

Port Change Routine

2910 PRINT "NEW COMMUNICATIONS PORT (lOR 0) " 2920 A=GET:IF A=O THEN 2920 2930 IF A<48 THEN 2910 2940 IF A>49 THEN 2910 (test for 1 or 0) 2950 P2=A-48 (P2 identifies Port) 2960 A1=OFAOOH+P2*200H 2970 GOTO 2630

Interactive Console Routine

2980 PRINT:PRINT "ALL KEYSTROKES WILL BE TRANSMITTED" 2990 PRINT" (PRESS ESC TO EXIT)" 3000 IF M1=0 THEN PRINT "RECEIVED ECHO:", 3010 A=GET:IF A=O THEN GOSUB 3110:GOTO 3010 (check Console) 3020 IF A=27 THEN PRINT:GOTO 2770 (exit if Escape) 3030 GOSUB 3080 (transmit char.) 3040 GOTO 3010

Automatic String Routine

3050 FOR A=20H TO 70H 3060 GOSUB 3080 (transmit 93 ASCII characters) 3070 NEXT APRINT:GOTO 2770

125

Page 130: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operaeors Manual (88-005548-01 Rev. Y1) 8/86

Transmit and Receive Routines

3080 IF P2=0 THEN XMT O,SA, (transmit char. with code A) 3090 IF P2=1 THEN XMT 1,SA, 3100 IF Ml=O THEN 3110 ELSE PRINT CHR(A),(display if half duplex) 3110 IF P2=1 THEN 3120 3120 CALL 31:POP C1 (test for received chars) 3130 IF Cl<>O THEN RCV 0,0,C1:PRINT $(0), (display if any) 3135 RETURN 3140 CALL 32:POP C1 (test for received chars) 3150 IF Cl<>O THEN RCV 1,0,C1:PRINT S(O), (display if any) 3155 RETURN

Set Baud Rate Routine

3160 INPUT" NEW BAUD RATE (300-19200)" ,Bl 3170 Bl=INT(Bl/300) (Baud rate is encoded) 3180 1=0:00:Bl=Bl/2:1=l+l (and written to UART registers) 3190 UNTIL Bl<1:Bl=10-I:PRINT (Bl is the code, see 3690)

Set Parity Routine

3200 PRINT "PRESS A LETTER KEY TO SET PARITY" 3210 PRINT" (E FOR EVEN, 0 FOR ODD, N FOR NONE)" 3220 A=GET:IF A=O THEN 3220 3230 Pl=0:C1=40H (set 7 data bits) 3240 IF A=69 THEN Pl=2:GOTO 3300 (skip data bits if Even) 3250 IF A=79 THEN Pl=l:GOTO 3300 (skip data bits if Odd)

Set Data Bits Routine

3260 PRINT "PRESS A NUMBER KEY FOR CHARACTER LENGTH" 3270 PRINT" (7 OR 8 BITS)" (no. of Data bits is encoded) 3280 A=GET:IF A=O THEN 3280 (and written to UART registers) 3290 IF A<>55 THEN (1=0 (Cl is the code, see 3690)

Set Stop Bits Routine

3300 PRINT:PRINT "PRESS A NUMBER KEY FOR STOP BITS" 3310 PRINT" (lOR 2)":PRINT (no. of Stop bits is encoded) 3320 A=GET:IF A=O THEN 3320 (and written to UART registers) 3330 IF A=50 THEN Sl=20H ELSE Sl=O (51 is the code, see 3690)

126

Page 131: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operae~rs Manual (88-005548-01 Rev. Y1) 8/86

Set Mode Routine

3340 PRINT "PRESS F FOR FULL, H FOR HALF DUPLEX" 3350 PRINT "PRESS E TO ECHO RECEIVED CHARACTERS" 3355 A=GET:IF A=O THEN 3355 3360 Ml=O:IF A=69 THEN Ml=2 (test for E) 3370 IF A=72 THEN Ml=l (test for H) 3380 GOTO 2630

Confi~ure Receiver/Transmitter Routine

3390 3400 3410 3420 3430 3440 3450 3460 3470 3480 3490 3500 3510 3520 3530 3540 3550 3560 3570 3580 3590 3600 3610 3620 3630 3640 3650 3660 3670 3680

The following portion of the Test and Demonstration Program works out the various permutations of possible port and protocol combinations selected above. This is necessary because the COM instruction does not allow variable parameters. Subroutine 3690 below reduces the huge number of permutations by directly writing Stop bits, Data bits, and Baud rate information directly to the 8256 UART control registers.

ON P2 GOTO 3400,3540 ON Ml GOTO 3410,3410,3480 ON PI GOTO 3420,3440,3460 COM 0" N, , , R RETURN COM 0" 0, , , R RETURN COM 0" E, , , R RETURN COM 0" N , , , E RETURN COM 0, , 0, , , E RETURN COM 0, , E, , , E RETURN ON Ml GOTO 3550,3550,3620 ON PI GOTO 3560,3580,3600 COM 1" N , , , R RETURN COM 1" 0, , , R RETURN COM 1" E, , , R RETURN ON PI GOTO 3630,3650,3670 COM 1, , N , , , E RE~T>.1

COM 1, , 0, , , E RETURN COM 1" E, , , E RETURN

127

(select Port 0 or 1) (select Echo or not) (select Parity)

Page 132: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Opera~ors Manual (88-005548-01 Rev. Y1) 8186

Direct UART Control Routine

3690 3700 3710 3720 3730 3740 3750 3755 3760 3770 3780

PRINT A=XBY(A1) A=A.AND.OFH A=A.OR.C1 A=A.OR.S1 XBY(Al)=A A=XBY(A1+1) A=A.AN D.OFOH A=A.OR.Bl XBY(Al+1)=A RETURN

(read 1st UART register) (erase 4 upper bits)

(set # Data bits) (set # Stop bits) (write to UART) (read 2nd UART register) (erase 4 lower bits)

(set Baud rate) (write to UART)

128

Page 133: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operaeors Manual (88-005548-01 Rev. Y1) 8/86

5.5 The CX/372/2100 Control Program

This program allows the testing and control of Compumotor RS-232 indexing equipment from Auxiliary RS-232 port RS292#O.

The program allows control of Compumotor models CX, 372, and 2100. Menu help is provided for those unfamiliar with indexer commands, as well as interactive hands on control.

Pro~ram Initialization

10 CALL O:STRING 106,20 (reserve string space) 20 COM 0 (enable communications) 30 Al=10:V1=5:Dl=1:Pl=25000:A9=1 (set default parameters) 35 $(3)=" Preset":$(4)="Continuous" 40 PRINT "CX/372/2100 Indexer Control Program":PRINT 50 PRINT "Press the Space bar for the CX," 60 PRINT "Press RETURN for the 372 or 2100" 70 A=GET:IF A=O THEN 70 80 IF A=32 THEN 90 (branch if CX) 85 XBY(OFAOOH)=XBY(OFAOOH).OR.20H:GOTO 100 (set 2 stop bits) 90 P1=12800:A9=8:C2=1 (set CX parameters) 95 $(0)=" LD3 MPI SCA3 ":XMT O,O:RCV 0,0 (CX initialization) 100 $(0)=" E MN ":XMT O,O:RCV 0,0 (2100 initialization) 110 GOSUB 540:GOSUB 590:GOSUB 640 (download parameters) 115 PRINT:GOSUB 900 (display parameters)

Main Menu

120 PRINT:PRINT "Press a key to select a command option:" 125 PRINT" A: change device Address" 130 PRINT" C: send an execution command" 140 PRINT" K: select direct keyboard control" 160 PRINT" P: change motion parameters" 175 PRINT" 5: Stop the Program" 180 A=GET:IF A=O THEN 180 190 IF A=67 THEN 1500 (test for C) 200 IF A=75 THEN 1000 (test for K) 210 IF A=80 THEN GOSUB 300:GOTO 120 (test for P) 220 IF A<>83 THEN 240 (test for S) 230 PRINT:PRINT:PRINT "Enter 'LOAD' for the Directory":STOP 240 IF A<>65 THEN PRINT CHR(7),:GOTO 180 (test for A) 250 INPUT "New Address? ",A9 260 IF A9>0 THEN IF A9<9 THEN 120 270 GOTO 250

129

Page 134: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Opera~ors Manual (88-005548-01 Rev. Yl) 8/86

Parameter Change Routine

300 GOSUB 900 305 PRINT Press a key to select a parameter:" 310 PRINT A: change Acceleration" 320 PRINT V: change Velocity" 330 PRINT P: change Position (Distance)" 340 PRINT D: change Direction" 350 PRINT M: select the ",$(4)," mode" 360 PRINT X: exit" 370 A=GET:IF A=O THEN 370 380 IF A=65 THEN GOSUB 500:GOTO 300 390 IF A=68 THEN GOSUB 650:GOTO 300 400 IF A=77 THEN GOSUB 700:GOTO 300 410 IF A=80 THEN GOSUB 600:GOTO 300 420 IF A=86 THEN GOSUB 550:GOTO 300 430 IF A=88 THEN RETURN 440 PRINT CHR(7),:GOTO 370

(test for A) (test for D) (test for M) (test for P) (test for V)

(test for X)

500 PRINT:PRINT "Current Acceleration: ",Al," rev /sec.sq" 510 INPUT "Enter new Acceleration (.01 to 999) ",Al 520 IF Al>=.Ol THEN IF Al<=999 THEN 540 530 PRINT CHR(7),:GOTO 510 540 Nl=Ai:ASC($(0),1)=65:GOTO ·850 (transmit new accel)

550 PRINT:PRINT "Current Velocity: '''Vl, " rev/sec" 560 INPUT "Enter new Velocity (.001 to 50) ",vi 570 IF Vl>=.OOl THEN IF V1<=50 THEN 590 580 PRINT CHR(7),:GOTO 560 590 Ni=V1:ASC($(0),1)=86:GOTO 850 (transmit new velocity)

600 PRINT:PRINT "Current Parameter: ",Pl," steps" 610 INPUT "Enter new Distance? (1 to 9,999,999) ",Pl 620 IF Al>=-99999999 THEN IF Al<=99999999 THEN 640 630 PRINT CHR(7),:GOTO 610 640 Ni=P1:ASC($(0),1)=68:GOTO 850 (transmit new distance)

650 PRINT:PRINT "Current Direction: ", 660 IF Dl=O THEN PRINT "CCW" ELSE PRINT "CW" 670 PRINT "Press '+' or '-' for CW or CCW rotation" 680 A=GET:IF A=O THEN 680 685 IF A=43 THEN Dl=l:$(O)="H+":GOTO 800 690 IF A=45 THEN D1=0:$(0)="H-":GOTO 800 (transmit direction) 695 PRINT CHR(7),:GOTO 680

700 IF ASC($(3),1)=80 THEN 730 710 $13j=" Preset":$ (4)="Continuous" 720 $ a ="MN":GOTO 800 730 $ 3 ="Continuous":$(4)="Preset" 740 $ 0 ="MC":GOTO 800

(transmit new mode)

(transmit new mode)

130

Page 135: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8/86

Command Transmit Routine

800 XMT 0,0" (transmit string $(0» 810 XMT 0,$32, (then a space) 830 PRINT:PRINT "Command transmitted: ", 840 GOSUB 1120:PRINT:RETURN (display echo)

Numerical Parameter Conversion Routine

850 STR Nl,O,2 860 GOTO 800

(convert Nl to string. add on to $(0» (transmit)

Current Parameter Display Routine

900 PRINT:PRINT "Current Parameters:" 910 PRINT "Acceleration: ",Al, 920 PRINT TAB (20), "Velocity: ",Vl 930 PRINT "Direction: ", 945 IF 01=1 THEN PRINT "CW", ELSE PRINT "CCW", 940 PRINT TAB(20), "Distance: ",P1 950 PRINT "Mode: ",$(3), 960 PRINT TAB(20),"Device address: ",A9 970 FOR 1=0 TO 1000:NEXT 980 RETURN

Interactive Control Routine

1000 PRINT "All keystrokes are transmitted," 1010 PRINT" only echoes are displayed" 1005 PRINT "Press CEsc' to exit":PRINT 1010 A=GET:IF A=O THEN GOSUB 1120:GOTO 1010 (test receiver) 1020 IF A=27 THEN PRINT:GOTO 120 (exit on Escape) 1030 GOSUB 1100 (transmi t key) 1040 IF A=13 THEN PRINT CHR(10), (add LF to CR) 1050 GOTO 1010

Transmit/Receive Routine

XMT O,$A, CALL 31:POP C1 IF Cl=O THEN RETURN RCV 0,O,C1 FOR 1=1 TO C1

(transmit keystroke) (test receiver)

(exit if no characters) (else receive to $(0»

1100 1120 1130 1140 1150 1160 1170 1180 1190

IF ASC($(0),1)=13 THEN PRINT CHR(10), PRINT CHR($(O),I), (display characters) NEXT:$(O)="" RETURN

131

Page 136: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operacor3 Manual (88-005548-01 Rev. Y1) 8/86

Execution Options Routine

1500 PRINT:PRINT "Press a key to select a command option:" 1510 PRINT 5: Stop the Motor" 1520 PRINT G: Start the Motor (Go)" 1530 PRINT H: Go Home (reverse direction)" 1540 PRINT 0: reverse Direction" 1550 PRINT P: change Parameters" 1560 PRINT R: Report Parameters and Status" 1580 PRINT X: Exit", 1590 A=GET:IF A=O THEN 1590 1600 IF A=B3 THEN $(O)="S":GOSUB BOO:GOTO 1500 (stop) 1610 IF A=71 THEN $(O)="G":GOSUB BOO:GOTO 1500 (go) 1620 IF A<>72 THEN 1650 1630 IF 01=1 THEN $(O)="GH-l" ELSE $(0)="GH1" (go home) 1640 GOSUB 800:IF C2=0 THEN $(O)="XO" GOSUB BOO 1645 GOTO 1500 1650 IF A<>68 THEN 16BO 1660 $(O)="H":GOSUB 800:IF 01=1 THEN 01=0 ELSE 01=1 (reverse) 1670 GOTO 1500 1680 IF A=BO THEN GOSUB 300:GOTO 1500 1690 IF A=B2 THEN GOSUB 2000:GOTO 1500 1740 IF A=8B THEN 120 1750 PRINT CHR(7),:GOTO 1590

Status Report Routine

(change parameters) (report parameters)

(exit)

2000 GOSUB 900:F1=0:PRINT (display parameters) 2005 CALL 31:POP C1:RCV O,O,C1 (clear receiver) 2010 ASC~$(0),1)=A9+48 (set transmit address) 2020 ASC $(0),2)=82 (set R command) 2030 Nl= :N2=3:GOSUB 3000 (send 2, receive 3) 2035 IF ASC($(l),l)=O THEN PRINT "NO ECHO!":RETURN 2040 PRINT "Status: ", 2050 IF ASC($(1),2)=B2 THEN PRINT "Ready" ,:GOTO 2060 2055 F1=1:PRINT "Busy", (82-R=Ready) 2060 ASC($(0),2)=B2 2070 ASC($(0),3)=65 (set RA command) 2080 Nl=3:GOSUB 3000 (send 3. receive 3) 2090 PRINT TAB(17)," Limit: ", 2100 IF ASC($(1},2)=64 THEN PRINT "None":GOTO 2110 2105 PRINT "Active" (64=@=No Limits) 2110 ASC($(0),2)=B4 2120 ASC($(0),3)=B3 (set T5 command) 2130 GOSUB 3000 2140 PRINT "Inputs: " 2150 PRINT $(1). (print response)

132

Page 137: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Yl) 8{86

2210 IF F1=1 THEN 1500 2220 PRINT TAB (17), "Position: ", 2230 IF C2=1 THEN 2260 2240 N2=10:ASC($(0),2)=88 2250 ASC($(0),3)=49:GOTO 2280 2260 N2=12:ASC($(0),2)=80 2270 ASC($(0)'3)=82 2280 GOSUB 3000 2290 PRINT $(1) 2300 GOTO 1500

Status Transmit/Receive Routine

3000 XMT O,O,N1, 3010 XMT 0,$32,

(skip if busy)

(branch if eX)

(set Xl command)

(set PR command) (send command)

(print response)

(transmit N1 characters) (transmit Space)

(stall) 3020 FOR 1=1 TO 100:NEXT 3030 RCV O,1,N1+1 3040 RCV O,1,N2

(receive transmitted characters) (receive subsequent response)

3050 RETURN

133

Page 138: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operator5 Manual (88-005548-01 Rev. Y1) 8/86

APPENDIX A: PARALLEL I/0 CONNECTIONS

Input connector Remote I/O Port Register 12in no. module Address bit

47 0 FxOO 0 45 1 1 43 2 2 41 3 3 39 4 4 37 5 5 35 6 6 33 7 7

31 8 Fx01 0 29 9 1 27 10 2 25 11 3 23 12 4 21 13 5 19 14 6 17 15 7

15 16 Fx02 0 13 17 1 11 18 2

9 19 3 7 20 4 5 21 5 3 22 6 1 23 7

All even numbered pins on both PARALLEL connectors are connected to ground. Pin 49 carries the Model 52's +5 VDC supply.

Note: FxOO refers either to address F600 for output or address F800 for input. Ouput port F600 may be programmed for input

Page 139: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-0l Rev. Yl) 8/86

APPENDIX B: THE MEMORY MAP

The following list describes where memory and peripheral devices are located in the addressing scheme of the Model 52. Devices include RAM and EEPROM memory as well as the I/O devices. The list begins at the top of the 64K memory space and proceeds down to zero.

Permanent EEPROM memory is not included.

FEOO-FFFF, Not Used

FCOO-FCOF, U8, 8256AH Multi-function Peripheral

FCOO - Command Reg. 1 (DATA, STOP BITS) FCOl - Command Reg. 2 (PARITY, BAUD RATE) FC02 - Command Reg. 3 (INTERRUPT MODE) FC03 - Mode Register (COUNTER/TIMER CONFIG.) FC04 - Portl Control Register FCOS - Interrupt Enable Register (EXT, COUNTERS, RS232) FC06 - Interrupt Address/Disable Register FC07 Receive/Transmit Buffer FC08 - Port 1 (GH A, CH B, GH Z IN, DIR OUT) FC09 - Port 2 (ISOLA TED OUTPUTS ) FCOA - Timer 1 (not used) FCOB - Timer 2 (CHA B COUNTER (1) LOW BYTE) FCOC - Timer 3 (STEP COUNTER (2) LOW BYTE) FCOD - Timer 4 (CH B COUNTER (1) MSBYTE) FCOE - Timer 5 (STEP OUTPUT COUNTER (2) LOW BYTE) FCOF - Status Reg. (RECEIVER, TRANSMITTER STATUS)

FAOO-FAOF, U9, 8256 Multi-function Peripheral

FAOO - Command Reg. 1 (DATA, STOP BITS) FAOl - Command Reg. 2 (PARITY, BAUD RATE) FA02 - Command Reg. 3 (INTERRUPT MODE) FA03 - Mode Register (COUNTER/TIMER. CONFIGURATION) FA04 - Portl Control Register (7 in, lout) FAOS - Interrupt Enable Register FA06 - Interrupt Address/Disable Register FA07 - Receive/Transmit Buffer . FA08 - Port 1 (QUADRATURE, ISOLATED INPUTS) FA09 - Port 2 (PARALLEL I/O CONTROL) FAOA - Timer 1 FAOB - Timer 2 (+QUADRATURE COUNTER LOW BYTE) FAOC - Timer 3 (-QUADRATURE COUNTER LOW BYTE) FAOD - Timer 4 (+QUADRATURE COUNTER HIGH BYTE) FAOE - Timer S (-QUADRATURE COUNTER HIGH BYTE) FAOF - Status Reg. (RECEIVER, TRANSMITTER STATUS)

B-1

Page 140: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8/86

F800-F9FF, U16, 8255 PARALLEL INPUT Controller

F803 - Control Register F802 - Port C Data Register F80l - Port B Data Register F800 - Port A Data Register

(inputs 16-23) (inputs 8-15) (inputs 0-7)

F600-F603, U17, 8255 PARALLEL OUTPUT Controller

F603 - Control Register F602 - Port C Data Register F60l - Port B Data Register F600 - Port A Data Register

(outputs 16-23) (outputs 8-15) (outputs 0-7)

F400, - U26, AD7524 Digital to Analog converter

ANALOG Output Data Register

F200-F203, - U35, ADC0809 Analog to Digital converter

F203 - ADC channel 3 - IN 4 F202 - ADC channel 2 - IN 9 F20l - ADC channel 1 - IN 2 F200 - ADC channel 0 - IN 1

COOO-EFFF, Not Used

AOOO-BFFF, U4, X2864 EEPROM

Non-volatile Read/Write Memory (8k X 8)

8000-9FFF, U3, X2864 EEPROM

Non-volatile Read/Write Memory (8k X 8)

location 8000H stores power up Baud rate and auto-run codes location 80l0H stores the start-of-program character for the first stored program.

4000-SFFF, Not Used

B-2

Page 141: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

Model 52 Operators Manual (88-005548-01 Rev. Y1) 8/86

2000-3FFF, U2, 6264 RAM

ReadfWrite Memory O-lFFF, Ul, 6264

ReadfWrite Memory

(8k X 8) RAM

(8k X 8)

Use of RAM memory. from the top:

Top to MTOP: Model 52 receive buffers and operating variables

MTOP to VARTOP: declared program String space

VARTOP down: numerical program variables (6 bytes each)

DIMUSE up: dimensioned array variables

512 to DIMUSE: BASIC program, if any

o to 512: BASIC operating variables and Argument Stack

(see MCS BASIC-52 USERS MANUAL Appendix 1.7)

B-3

Page 142: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

APPENDIX C: SAMPLE I/O CONNECTIONS

C-l SIGNAL CONDITIONING CIRCUIT

This drawing shows a partial circuit of the Model 52 Parallel Output, configured for bi-directional operation, and connected to a 16 or 24 channel module rack, with AC input and DC output modules plugged in at locations 0 (input) and 8 (output) .

- PFFlFLLEl.. QJTPUT a:N£CTCI'l

0: ClJT RC IN (JJ. DII~:m (J.L c(Jn G.IlA TI (Jll

16 17 2 1 + ---.. 1:'0. --..

!'1D..l.£ ~ ~ ~ HODEL 52 I=lFCK

J +5 50 ._--.-

,Q D .~ 49 1 CH1

D ~

3.::t< 3.31< 4S II'I"UT -100-

H

46

ClJTPUT -S-31

GO 3D

I~>f<: l¢ ~ :ceo 14K

-v

~~

0: ClJTPUT R: IN PUT I"CO.LE 0 !'1D..l.£

B

I/O 51 GNA L CONDI T1 ON1 NG

C-l

Page 143: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

C-3 OPTICALLY ISOLATED OUTPUT CIRCUIT

DJT At

DJT A-

DJT B+

DJT B-

C-3

LThE

J20 ,A:

l.CJ'O

,

Page 144: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

C-4 OPTICALLY ISOLATED MULTIPLEXED THUMBWHEEL SWITCHES

\ I +~ v~ I

f'rlDEL 52 -EO) TH.HM-£El.

5W'lTOi *1 " IN At

~: _ 1

IN R-~2

~: 4 1 IN 8+

~B IN e-.... CO"! IN C+

EO)T~ IN C-

SVITD-I .,.2 IN D+

r-o"""c . .- 1 IN 0-~c :2

\.

~c ~4 ~c '::B

,

A OJT At i CO"! I

!

~nrr~ I

OJT B+

~ OJTB-, I

I :1

tmCALLY lSOLATD 111M'S

Readin£ thUlD.bwheel .....-itch

input us:iD.& lXlultiplexed BCD

. switches driven by opticia.ny ..

isolated outputs

C-4

Page 145: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

C-5 DRIVING A SPEAKER YITH THE STEP OUTPUT

The following circuit shows how to connect a speaker to either the STEP+ or STEP- output. Refer to the BASIC 52 OPERATOR'S MANUAL for details on producing tones with the PWM instruction.

+1 STEP ~~--------~

10 uf OR MORE

GND

SPEAKER

c-s

.--

Page 146: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

C-6 DRIVING A TRANSLATOR VITH THE STEP OUTPUT

The following circuit shows how to connect various translator input circuits to the Model 52 STEP+ and STEP- outputs. Refer to the BASIC 52 OPERATOR'S MANUAL for details on producing desired pulse rates with the PWM instruction. The STEP and OIR outputs will directly drive TTL level translator inputs having step and direction type inputs. External transistors are required for higher voltage or CW and COW type inputs.

. ISOLATED STEP AND DIRECTION INPUTS

. ~·····-···-T·RANSLATOR/O·R·iVE···-········1

:::::f-------~::O~c

ACTIVE LOW CLOCKWISE AND COUNTERCLOCKWISE ___ .... _ •• _ •••• _ ••• ____ ............... _ ... __ ... u __

· . · . ~ __ --.......... .-I:=-t'r-7 r.--7 CW STEP

STEP + "

L-..--t.:py--r----7~ CCW STEP

· TRANSLATOR/DRIVE l. __ ._ .... __ •• ....... ····_··_-.. _······· .. _···· __ • .. ··_--

DIR-

DIR+

C-6

Page 147: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

o

-

r-i Q.J

'" o :z , I

Page 148: o · All RS232C ports have selectable baud rates from 300 to 19200. A real-time clock function is built in. Interrupts are available on elapsed time, or from two external inputs,

i:

~ ,

!

e Q

: ~~® ::ffiB: '" '"

CD d

" ... 0 Ii

I 0

~®Cs

... ;, ..

.. I~

':=

[J

~C::I i =:=J .. ... a ;:;11

.. .,

l:l

"0 ...... ~ -=-~_-..l

;;:

~ 0

D

If" ..,

• ..,

.... ..,


Recommended