Section 5
Page 5 - 48
HA243821
Issue 5 Mar 98
MODEL 346 INSTALLATION AND OPERATION MANUAL
5.7.8 BASIC PROGRAM
This section includes a simple basic program to run on IBM® compatible PCs. Unmodified, the program writes a
‘random’ number to the recorder, and then reads it back to ensure that the link is operating correctly. The program
itself is not intended for use as it stands, but is included to give guidance, especially in the reading and writing
routines.
Notes...
1. This section is included to give an example of the sort of program which may be used. The manufacturer does
not guarantee that the program will run successfully with every version of BASIC, nor with every type of
personal computer (PC)
2. It is assumed that the user is familiar with the PC to the extent that text files and simple programs can be
entered.
3. Before any writing of PVs can take place, the relevant channel’s ‘Function’ must be set to ‘comms’.
PROGRAM LISTING
10
REM This program uses EIBISYNC protocol to read and write a channel
20
REM By changing the variables, any of the recorder’s parameters
30
REM can be written to or read, if permitted.
40
G$=”2"
:REM Set up group address
50
U$=”1"
:REM Set up Unit address
60
C$=”1"
:REM Set up Channel address
70
M$=”PV”
:REM Set up parameter mnemonic
80
V$=” 99.999
:REM Set up value to be written to parameter
90
ANSWER$=””
:REM Read from 34X
100
WRITE$=””
:REM Write to 34X
110
On error GOTO 340
:REM Use “REM” to disable this whilst de-bugging
120
CLS
130
CLOSE
140
OPEN “COM1:9600,e,7,1” AS #1
:REM Set comms parameters
150
OPEN “SCRN:” FOR OUTPUT AS #2
:REM Change for file later
160
If LOC(1) THEN ANSWER$=INPUT$(LOC(1),#1)
:REM Clear input buffer
170
Z=TIMER+1
:REM 1 second delay between readings
180
WHILE TIMER<Z : WEND
190
200
PRINT “WROTE,,”REC’D”,”ENQUIRED”,”REC’D”
210
GOSUB 3010:
:REM Make up write string to send
220
PRINT #1,Write$:
:REM Send string to 34X
230
PRINT #2,MID$(WRITE$,2,LEN(WRITE$)-3),
:REM Write string to file
240
GOSUB 1020
:REM Get reply
250
PRINT #2,ANSWER$,
:REM Write reply to file
260
GOSUB 2010
:REM Make up string to send
270
PRINT #1,WRITE$;
:REM Send enquire to 34X
280
PRINT #2,WRITE$
:REM Print enquiry to file
290
GOSUB 1020:
:REM Get reply
300
PRINT #2,MID$(ANSWER$,2,LEN(ANSWER$)-3)
:REM Write reply to file
310
V$=STR$(100*RND(1)):
:REM Change the PV
320
V$=MID$(V$,1,7):
:REM Get in correct form
330
GOTO 160
340
Print “error No “;ERR:RESUME 130
:REM Catch errors, print error
350
REM number and resume