Rockwell Automation 1203 Serial Communications Module Series B User Manual
Page 45

4–11
Configuring and Interfacing
1203–5.5 September 1995
DF1 Messaging with a 1746–BAS Module Example
This example accepts a parameter number and a value from a user
terminal and writes the data out to a SCANport–compatible device.
100 REM _____________________________________________________________
101 REM __ This program inputs a parameter number and a value
102 rem __ from a user terminal and writes it out to a scanport
103 rem __ compatible device.
104 rem __ for 1746–BAS and 1203–GD2 modules
105 rem _____________________________________________________________
110 STRING 512,127
140 REM
150 REM ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
160 REM Setup port 1 to 9600 baud, no parity, 8 bits, 1 stop bit,
170 REM software handshaking, and battery backed ram data storage.
180 REM !!!!REMEMBER TO SET TERMINAL TO MATCH!!!!
190 REM ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
200 MODE (PRT1,9600,N,8,1,S,R)
210 REM ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
220 REM
230 REM Setup port 2 to 300 baud, no parity, 8 bits, 1 stop bit,
240 REM software handshaking, and battery backed ram data storage.
250 REM
260 REM ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
270 MODE (PRT2,300,N,8,1,S,R)
280 REM ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
290 REM
300 REM Enable DF1 driver
310 REM (20 = Setup for Full Duplex, Auto–Detect Embedded Responses,
320 REM Disable Duplicate Packet Detection, BCC error checking)
330 REM (200 = Wait 1 second for polling by Master)
340 REM (2 = 2 retries)
350 REM (0= No RTS on delay)
360 REM (0 = No RTS off delay)
370 REM (8 = 1746–BAS module address)
380 REM ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
390 PUSH 20
400 PUSH 200
410 PUSH 2
420 PUSH 0
430 PUSH 0
440 PUSH 8
450 CALL 108
460 REM __________________ end df1 config _____________________________
461 Print: print ”A negative parameter number exits the program ”
470 INPUT ”Offset (Parameter Number)? ”,PAR_NUM
475 IF (PAR_NUM<0) THEN GOTO 530
480 INPUT ”Control (parameter value)? ”,PAR_VALUE
481 REM encode the value as an ASCII hex string in order of LOW, HIGH
490 ASC($(1),1)=PAR_VALUE–(INT(PAR_VALUE/256)*256)
500 ASC($(1),2)=INT(PAR_VALUE/256)
510 GOSUB 550 : REM fire off the write instruction
520 GOTO 460
530 CALL 113
540 END