Sample Programs
FP2 Serial Data Unit
8 − 7
8.1 Sample Programs
8.1.1.3 Received Program with BCC Check
The BCC (block check code) in the data received from the external device is checked.
In this program, a BCC check of the number of received data bytes is carried out ahead
of time, so the BCC check can be carried out regardless of the data length.
For this program, the serial data unit should be installed in slot 0.
X1
DF
R0
R0
,K0
, K1005 , K1 , DT49
F150 READ
R0
(CALL 0)
X1 Y11
R101 Y20
R102 Y21
R101
R102
R
R101
R
R102
TMX 0, K 10
(ED )
(SUB 0)
The content of 1−word of shared
memory address 1005
is read to the data register DT49.
Auxiliary relay (R0) is turned on at
the timing of the reception com-
pleted flag(X1).
Data is read from address 1005 of
the shared memory (number of bytes
received on CH1) at the timing of the
reception completed flag(X1) (includ-
ing the end code).
BCC monitoring routine call
When data has been received and
read, Y11 is turned on, and the re-
ceived buffer is cleared.
BCC OK display
BCC NG display
Display is reset.
Display is reset.
Specifies the FP2 serial data unit in
slot no.0.
,DT49 ,K1
F27 —
,DT50
R9010
,DT50 ,K1
F22 +
,DT51
,DT51 ,K2
F32 %
,DT52
, K 0 , DT 100
F11 COPY
, DT 149
,DT52 ,I0
F0 MV
Number of received bytes is calcu-
lated (not including the end code).
Result is converted to a number of
received words.
Preparation for data reading
− DT100 to DT149 are set to 0.
− Number of converted received
words is stored in I0.
next page