Omron SYSMAC C200H-ASC02 Operation Manual page 101

Ascii unit
Hide thumbs Also See for SYSMAC C200H-ASC02:
Table of Contents

Advertisement

Example Programs
Example 17
PC Program
Start
ASCII busy
1, 2, 3... 1.
92
Purpose:
To direct processing using different interrupts
MOV
#0010
100
10001
WRITE flag
Remarks:
In this example, a terminal is connected to port 1 and an RS-232C communi-
cation device is connected to port 2. Initially, all the interrupts are disabled.
The program will wait for one of two inputs from the keyboard -- KEY 1 or
KEY 2, each of which will direct the program to process subsequent inter-
rupts in a unique way.
If key 1 is pressed, the COM2 and PC interrupts will be enabled. When
COM2 interrupts the ASCII Unit, a character is read from the communi-
cation device and assigned to the variable A$. When the PC subse-
quently interrupts the ASCII Unit, the character will be written to the PC.
2.
If key 2 is pressed, only the COM 2 interrupt is enabled. When COM 2
interrupts the ASCII Unit, the data is read and written directly to the PC.
ASCII Unit Program
10
OPEN #1,"TERM:(42)"
20
OPEN #2,"COMU:(42)"
30
ON KEY 1 GOTO 100
40
ON KEY 2 GOTO 200
50
ON PC GOSUB 300
60
ON COM2 GOSUB 400
70
KEY ON:COM2 STOP
80
GOTO 80
100
'KEY 1 PROCESSING
110
COM2 ON:PC ON
120
GOTO 120
200
'KEY 2 PROCESSING
210
COM2 ON
220
IF A = 1 THEN GOSUB 300
230
GOTO 220
300
'PC INTERRUPT PROCESSING
310
B$ = MID$(STR$(LEN(A$)),2)
320
PC WRITE"@D,0,"+B$+","+B$+"A3";A$
330
A = 0
340
RETURN
400
'COM INTERRUPT PROCESSING
410
IF EOF(2) THEN RETURN
420
A$ = INPUT$ (LOC(2),#2)
430
A = 1
440
RETURN
Section 6-1

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents