B-2
5975636 ACTAS 2 170297
Appendix B : Serial communication
There are two formats of data transfers :
u
A short one : called “record”
u
A long one
: called “block” (this format is currently
not used for ACTAS purposes)
A record of the short format consists of 7 bytes :
ADR
Slave address
CMD
Command
DAT1
Data byte 1
DAT2
Data byte 2
DAT3
Data byte 3
DAT4
Data byte 4
CHKS
Check sum
CMD
is the command given to the slave with the address
ADR
.
DAT1-4
can contain additional information (ex-
plained later in this text), however, this information is not
always used. It is advised to set all non-used data bytes
to 0 (zero).
CHKS
is:
(
ADR+CMD+DAT1+DAT2+DAT3+DAT4) MOD 256
The transmission of the record on the serial line will be:
STX OFFS ADRe CMDe DAT1e DAT2e DAT3e DAT4e CHKSe
The long format 'block' consists of a record of 9 bytes
followed by either 208, 224, 240 or other data bytes plus
their checksum.
Slave type
Block length
800, 801,1100, 1101, 1600, 500
208
701
224
808, 1208, 1209
240
ACTAS
- (reserved for
future use)
The transmission will be :
STX OFFS ADRe CMDe DAT1e DAT2e DAT3e DAT4e CHKSe
D0e D1e ... D207e CHKSBe
with
Die
=
Di
+
OFFS
CHKSBe
= (
CHKSB
+
OFFS
)
MOD
256
CHKSB
= (
SUM
(i = 0 to 207)
Di
)
MOD
256
Bytes expected back from slave
Two Main types of slave response are possible :
u
No answer data bytes required;
u
Answer data bytes required.
In any case, at least a handshake byte has to be
returned.
Note that the slave only transmits upon request from the
master.
Handshake byte :
Because only the signals
RxD
and
TxD
are used for the
communication, there is no way to detect if there is a
slave listening or if there is one listening whether it
receives the data correctly. Therefore, the communica-
tion protocol expects a standard ASCII byte
ACK(
06H)
or
NAK
(15H) from the slave.
ACK
acknowledge
NCK
not acknowledge
It is very important that when the master asks the slave
for information that the master is ready to receive
immediately the data from the slave. Otherwise, data
loss or overruns could occur, or after a “time out”, the
master could think that there is no slave responding.
Data bytes :
If answer data is required, this can be either just a record,
or a record followed by a block.
No answer data from slave required
For the record format
For the record format (short) the slave returns an
ACK
byte if it has received the data correctly or a
NAK
byte if
the received data is not correct. If there is no slave
responding, then no byte is returned.
Master to slave :
RECORD
Slave to master :
ACK or NAK
For the block format
For the block format (long) the slave returns an
ACK
(or
NAK
) after the first part (the record) and a second
ACK
(or
NAK
) after the second part.
Master to slave :
RECORD
BLOCK
Slave to master :
ACK or NAK
ACK or NAK
Answer data from slave required
For the record format
Suppose the master asks for information to the slave
and the slave returns the information in the record
format, the bytes transmitted through the RS232 com-
munication will be :
u
Record from master to slave :
STX OFFS ADRPe CMDe Dat1e Dat2e Dat3e Dat4e CHKSe
u
Record from slave to master :
ADRP CMD Dat1b Dat2b Dat3b Dat4b CHKSb
where
ADRP = ADRPe - OFFS
CMD = CMDe - OFFS