Connections

Section 4-4

Using the TXD(––) Instruction

The TXD(––) instruction can be used to transmit data from the PC’s data area to the host computer. There is no response from the host computer. The TXD(––) instruction will be executed after the response has been transmitted if TXD(––) is executed while a response to a Host Link command is being returned to the host computer.

Host

No response

computer

 

PC

4-4-2 Example Programs

@Unit No. Header code

Text

FCS

Terminator

Command Transmission The following type of program must be prepared in the host computer to receive the data. This program allows the computer to read and display the data re- ceived from the PC while a Host Link read command is being executed to read data from the PC.

Example Program for

FCS

10

’CQM1H

SAMPLE PROGRAM FOR EXCEPTION

 

20

CLOSE 1

 

 

30

CLS

 

 

40

OPEN ”COM:E73” AS #1

 

50

KEYIN

 

 

60

INPUT ”DATA ––––––––”,S$

 

70

IF S$=” ” THEN GOTO 190

 

80

PRINT ”SEND DATA = ”;S$

 

90

ST$=S$

 

 

100 INPUT

”SEND OK? Y or N?=”,B$

 

110 IF B$=”Y” THEN GOTO 130 ELSE GOTO KEYIN

120 S$=ST$

 

 

130 PRINT

#1,S$

Sends command to PC

140 INPUT

#1,R$

Receives response from PC

150 PRINT

”RECV DATA = ”;R$

 

160IF MID$(R$,4,2)=”EX” THEN GOTO 210 ’Identifies command from PC

170IF RIGHT$(R$,1)<>”” THEN S$=” ”:GOTO 130

180GOTO KEYIN

190CLOSE 1

200END

210PRINT ”EXCEPTION!! DATA”

220GOTO 140

This example shows a BASIC subroutine program for executing an FCS check on a frame received by the host computer.

400 *FCSCHECK

410L=LEN(RESPONSE$)

420Q=0:FCSCK$=” ”

430A$=RIGHT$(RESPONSE$,1)

440PRINT RESPONSE$,A$,L

450IF A$=”*” THEN LENGS=LEN(RESPONSE$)-3

ELSE LENGS=LEN(RESPONSE$)-2

460FCSP$=MID$(RESPONSE$,LENGS+1,2) ’ . ... FCS data received

470FOR I=1 TO LENGS ’ . .......... Number of characters in FCS

48

Page 60
Image 60
Omron CQM1H-SCB41 operation manual Example Programs, Using the TXD-- Instruction, Example Program for