7 - 1
7 PROGRAM EXAMPLES
Chapter 7 PROGRAM EXAMPLES
Examples of application programs for an IBM PC are shown below.
Environment
Computer used: IBM PC
Mode:
Character length = 8 bits, parity = none, stop bit = 1, baud rate =
1200 bps
Handshake:
None
The file name used for writing to and reading from the floppy disk is TEST.DAT.
7.1 Program to Read Parameter Settings from VR200, Display Them
on Screen and Write Them to Disk
100
‘************************************************************
110
‘** RS422A Example Program for IBM PC **
120
‘** **
130
‘** To input and save parameter settings **
140
‘** **
150
‘************************************************************
160
‘**
170
‘** Baud rate: 1200 Stop bit: 1 bit
180
‘** Parity: none Control: OFF/OFF
190
‘** Data length: 8 bits
Others: LF is sent automatically.
200
‘**
210
‘
220
OPEN “COM1:1200,N,8,1,LF” AS #1
230
OPEN “TEST.DAT” FOR OUTPUT AS #2
240
‘
250
LF$=CHR$(&HA)
:’ Line feed = 0AH
260
PRINT #1,CHR$(27)+”O 01"
270
PRINT #1,”TS1"
280
PRINT #1,CHR$(27)+”T”;
290
PRINT #1,”LF01,04"
300
LINE INPUT #1,D$
310
IF LEFT$(D$,1)=LF$ THEN D$=MID$(D$,2) :’ Remove “LF” of head string
320
PRINT D$
330
PRINT #2,D$
340
IF LEFT$(D$,2)<>”EN” THEN GOTO 300
350
‘
360
PRINT #1,CHR$(27)+”C 01"
370
CLOSE
380
END
7.1 Program to Read Parameter Setting from VR200, Display Them on Screen and Write Them to Disk