UD70
Issue code: 70nu2
Serial communications
6-11
The message will be:
Control
Address
Control
Parameter
Data
Control
BCC
EOT
1
1
2
2
STX
0
1
2
1
–
3
4
.
5
ETX
0
Not included in the calculation
Included in the calculation
Result
The first character of the
BCC
calculation is 0
0 (00110000 in binary), the value
of which is taken as a starting or result value. The next character is 1
1
(00110001 in binary), which now has the exclusive
OR
(
XOR
) operator act
upon it. With the previous result value, a new result occurs of 00000001 in
binary.
The complete calculation is show in the table below:
Character
Binary Value
XOR result
0
0011 0000
–
1
0011 0001
0000 0001
2
0011 0010
0011 0011
1
0011 0001
0000 0010
–
0010 1101
0010 1111
3
0011 0011
0001 1100
4
0011 0100
0010 1000
.
0010 1110
0000 0110
5
0011 0101
0011 0011
ETX
0000 0011
0011 0000
The final value is the
BCC,
provided that its equivalent decimal value exceeds
31 (
ASCII
characters from 00 to 31 are used as control codes).
When the final
XOR
result produces a decimal value less than 32, 32 is added.
In this example, 0011 0000 is 48 decimal which is above 31, so this is the final
BCC
value. 48 decimal is the character 0. The complete message will be:
EOT
1
1
2
2
STX 0
1
2
1
-
3
4
.
5
ETX 0
Example
QuickBasic program to calculate
BCC
mess$ = CHR$(4)+”1122”+CHR$(2)+”0125”+”-34.5”+CHR$(3)
bcc% = 0
FOR n% = 7 to LEN(mess$)‘start at the character after ‘chr$(2).
bcc% = bcc% XOR ASC(MID$(mess$, n%, 1))
NEXT
IF bcc% < 32 THEN bcc% = bcc% + 32
mess$ = mess$ + CHR$(bcc%)
PRINT mess$
In
DPL
, the
ANSIREAD
and
ANSIWRITE
functions automatically calculate
the
BCC
.
Summary of Contents for UD70
Page 6: ......
Page 14: ...UD70 Issue code 70nu2 2 6 Installation...
Page 42: ...UD70 Issue code 70nu2 4 20 DPL programming...
Page 98: ...UD70 Issue code 70nu2 7 22 Reference...