beautypg.com

4 sample program, 1 example of basic program for send and receive, Sample program -17 4.4.1 – Yokogawa PR300 Power and Energy Meter User Manual

Page 78: Example of basic program for send and receive -17

background image

<4. PC Link Communication Protocol>

4-17

IM 77C01E01-10E

4.4

Sample Program

4.4.1

Example of BASIC Program for Send and Receive

This section shows an example of a command sending and response receiving program
created with F-BASIC*

2

for PC/AT*

1

(or compatible machines).

*1 PC/AT is the product of IBM Ltd.
*2 F-BASIC is the product of Fujitsu Ltd.

Example of the Program Created Using F-BASIC Version 6.3

Communication Conditions

Baud rate:

9600bps

Parity:

None

Data length:

8 bits

Stop bit:

1 bit

Protocol:

PC link (without checksum)

STX$=CHR$(2)

‘Define

ETX$=CHR$(3)

‘Define

CR$=CHR$(13)

‘Define

LF$=chr$(10)

‘Define

RCVCHR$=””

‘Initialize receive character string

STOPFLAG=0

‘Initialize end flag

SEND$=STX$+”01010WRDD0001,02"+ETX$

‘Create character string for send

BAUD 0,9600

‘Set a communication baud rate

open “COM0:(F8N1N7)” as #1

‘Open a communication port

interval 5

‘Set timeout timer

on com(0) gosub *RECEIVECHR

‘Specify interruption processing
during receiving

on interval gosub *TIMEOUT

‘Specify interruption processing
at timeout

print #1,SEND$

‘Send

com(0) on

‘Permit interruption during receiving

interval on

‘Start timer

while STOPFLAG=0

‘Wait for receive end or timeout

waiti

wend

com(0) off

‘Permit interruption during receiving

close #1

‘Close the port

print “>”+SEND$

‘Display sent character string
on screen

print “<“+RCVCHR$

‘Display received character
string on screen

end