KEYENCE LS-5000 User Manual

Page 104

Advertising
background image

Chapter 8 RS-232C I/O

98

8

Sample Program (BASIC)

The following program can controll the LS using your computer’s keyboard.

100

OPEN"COM1:9600,N,8,1"FOR RANDOM AS #1

110

ON COM(1) GOSUB 180

120

COM(1) ON

130

A$=INKEY$

140

IF A$<>""THEN 150 ELSE 130

150

PRINT #1,A$;

160

PRINT A$

170

GOTO 130

180

N=LOC(1)

190

IF N=0 THEN RETURN

200

B$=B$+INPUT$ (N, #1)

210

IF RIGHT$(B$, 1)<>CHR$(13)THEN RETURN

220

PRINT CHR$(13):PRINT"RD=>";B$:B$=""

230

A$=INKEY$

240

IF A$<>""THEN PRINT #1,A$;

250

RETURN

To use this program, set the communication protocol of the LS-5000 series and
your personal computer to the “DIP switch 2: OFF” settings.

➮ See p. 88.

Troubleshooting for communication errors using the RS-232C.

Communication fails

Set the communication
protocol.
Refer to the external
equipment's
manual and
p. 88 of this manual.

Use a proper type
cable. Refer
to the figure on p. 89.

Check the program used.

End

Ensure

that the communication

protocol setup is the same between

the LS and external

equipment.

Ensure that the proper

connection cable is being used.

Normal operation

NO

NO

NO

YES

YES

Advertising