发表于:2006-01-05 15:47:00
楼主
SIEMENS SIMATIC S5 AS511 编程口协议描述
------------------------------------------------------------------
串口参数设置:
speed 9600
data 8 bits
stop 1 bit
parity EVEN
DLE (10hex) is a control character, used to inform the receiver that the
following char is to be considered a control character and not a data byte.
In other words, DLE is a software switch within the AS511 protocol to divide
control and data bytes.
Whenever a DATA byte containing the value 10hex is to be sent, the sender must
DOUBLE the char. This means that to send a data byte 10hex, the sender must
send 10hex 10hex (DLE DLE).
The receiver must consider the thing, so a single DLE will mean a protocol
signal, while two consecutive DLE are to be interpreted as a SINGLE data byte
containing the 10hex value. This is a little tricky, since the receiver NEVER
knows exactly how many bytes to expect.
Take also note that the AG can answer DLE NAK instead of DLE ACK if the
requested operation can not be carried out.
In this case, the PG must abort the communication and wait for 500ms before
attempting a new communication.
The value of 500mS is also applied as timeout value in case of missing response
from the partner.This also means that no "holes" of 500mS (or more) are allowed
during a communication (e.g. within a DB_READ function)
To read or write a datablock value, you need to know its address in PLC memory.
Therefore you must invoke B_INFO function to know the address, then you can
call DB_READ or DB_WRITE by giving the initial and final address of the area to
be read or written.
Be aware that in SIMATIC the LSB/MSB bytes order is reversed:
SIMATIC:
15..............0
BYTE 0 BYTE 1
INTEL:
15..............0
BYTE 1 BYTE 0
To obtain the correct integer value of a dataword, the user
must therefore:
- swap the received bytes
and
- swap the bytes before sending the