ProSoft Technology MVI56-BAS User Manual
Page 75

MVI56-BAS ♦ ControlLogix Platform
Using ASCII Communications
BASIC Module (DB/BAS Compatible)
User Manual
ProSoft Technology, Inc.
Page 75 of 234
December 13, 2011
6.2
ASCII Data Transfer from MVI56-BAS Serial Port to CLX
The MVI56-BAS can interface serial devices such as printers and code bar
readers to the ControlLogix processor. This section shows how to receive data
from an ASCII device and transmit it to the CLX processor.
In order to transfer data from the MVI56-BAS serial port to the ControlLogix
processor, CALL 22 is required to set up the transfer parameters. The following
shows a CALL 22 example:
1 REM CALL 22 reads data from the MVIBAS to the CLX
2 REM BASIC Example Program
10 REM MAIN BODY
20 PUSH 1: REM PORT NUMBER
30 PUSH 10: REM RECEIVES 10 BYTES MAXIMUM
40 PUSH 13: REM <CR> IS THERE TERMINATION CHARACTER
50 PUSH 1: REM DESTINATION IS MSG INSTRUCTION
55 PUSH 0: REM DESTINATION FILE OFFSET
60 PUSH 0: REM STRING NUMBER (NOT USED HERE)
65 PUSH 0: REM BYTE SWAP
70 CALL 22
80 POP S:
90 IF ( S <> 0) THEN PRINT "error", S
99 GOTO 99
or
10 PUSH 1,10,13,1,0,0,0: CALL 22: POP S
20 IF ( S <> 0) THEN PRINT "error", S
30 IF ( S <> 0) THEN STOP
40 GOTO 40
After CALL 22 is executed, the serial port (PRT1 or PRT2) continues receiving
data until the maximum number of characters is reached, or the character
delimiter is received.
Both parameters are configurable when using CALL 22 (refer to "BASIC CALLs
Syntax" section). The maximum number of characters transmitted depends on
the destination file used:
CLX Input Image File => 60 characters maximum
MSG Instruction => 198 characters maximum
Internal String => 251 characters maximum
If using CLX input image file the destination file offset parameter in CALL 22
should be no less than 1 otherwise a CALL error will be returned.