10.6Communication programs
In this paragraph are illustrated two examples of communication programs between the CL526 and an IBM or IBM compatible PC.
Example A: (data transfer from CL526 to PC)
Set IDNAME=1 and BAUD RATE=9600 on CL526 (see chapter 8.6). Connect CL526 through adapter BB530001 (TTL- RS232 converter), to personal computer communication port COM1.
Set CL526 in mA measurement (IN). Run the program and you will see on the computer screen the actual reading value (once).
Example B: (PC instructions to CL526)
Set IDNAME=1 and BAUD RATE=9600 on CL526 (see chapter 8.6). Connect CL526 through adapter BB530001 (TTL- RS232 converter), to personal computer communication port COM1.
Set the CL526 for current OUT mode; run the program and CL526 will be set automatically to 20mA.
Example A:
1Ø CHAR = Ø
2Ø IDNAME = 1
3Ø INSTRUCTION = 24
35 OPEN "COM1: 96ØØ, N,8,1,CD,CS,DS,RS" FOR RANDOM AS # 1
4Ø PRINT #1, CHR$ (IDNAME);:REM TRANSMIT IDNAME TO CL526
5Ø WHILE LOC (1) = Ø: WEND: REM WAIT RECEIVING IDNAME FROM CL526
6Ø IDNAME = ASC (INPUT$ (1, 1)): REM READ RECEIVED IDNAME FROM CL526 7Ø PRINT #1, CHR$ (INSTRUCTION);
8Ø WHILE LOC (1) = Ø: WEND
9Ø INSTRUCTION = ASC (INPUT$ (1, 1)) 1ØØ PRINT #1, CHR$ (CHAR);
11Ø WHILE LOC (1) = Ø: WEND
12Ø DATA 1 = ASC (INPUT$ (1, 1)) 13Ø PRINT #1, CHR$ (CHAR); 14Ø WHILE LOC (1) = Ø: WEND 15Ø DATA 2 = ASC (INPUT$ (1, 1)) 16Ø PRINT #1, CHR$ (CHAR); 17Ø WHILE LOC (1) = Ø: WEND 18Ø DATA 3 = ASC (INPUT$ (1, 1)) 19Ø PRINT #1, CHR$ (CHAR); 2ØØ WHILE LOC (1) = Ø: WEND 21Ø DATA 4 = ASC (INPUT$ (1, 1)) 22Ø PRINT #1, CHR$ (CHAR); 231Ø WHILE LOC (1) = Ø: WEND 24Ø CHKSUM = ASC (INPUT$ (1, 1))
25Ø IF CHKSUM <> ((DATA1 + DATA2 + DATA3 + DATA4) AND &HFF) THEN PRINT "Error": END 26Ø VALUE = DATA3 * 256 + DATA4
27Ø IF VALUE > 32767 THEN VALUE =VALUE - 65536: REM 2'S COMPLEMENT
28Ø PRINT "VALUE: " ; VALUE / 1ØØ 29Ø END
Example B:
1Ø CHAR = Ø
2Ø IDNAME = 1
3Ø INSTRUCTION = 27 4Ø VALUE = 2ØØØ
5Ø VALUE$ = HEX$ (VALUE)
55WHILE LEN (VALUE$)<4: VALUE$ ="Ø"+VALUE$: WEND 6Ø IF LEN (VALUE$) > 4 THEN VALUE$ =RIGHT$ (VALUE$,4)
65DATA1 = VAL ("&H" + LEFT$ (VALUE$, 2)) 7Ø DATA2 = VAL ("&H" +RIGHT$ (VALUE$, 2))
75DATA3 = Ø 8Ø DATA4 = Ø
9Ø CHKSUM = (DATA1 + DATA2 + DATA3 + DATA4) AND &H7F
1ØØ REM MEMORY RELEASE PREVIOUS 4.xx1 (Example 4.ØØØ, 4.2ØØ) MUST USE 11Ø REM NEXT LINE INSTEAD LINE 9Ø OR PROGRAM DOES'NT WORK
12Ø REM CHKSUM =(DATA1 + DATA2 + DATA3 + DATA4) AND &HFF 13Ø OPEN "COM1: 96ØØ,N,8,1,CD,CS,DS,RS" FOR RANDOM AS #1 14Ø PRINT #1, CHR$ (IDNAME) ; : REM TRANSMIT IDNAME TO CL526
15Ø WHILE LOC (1) = Ø: WEND: REM WAIT RECEIVING IDNAME FROM CL526
44