|
S5 AS511 (Programming port) protocol |
|
WangFeng 发表于 2007-4-18 18:17:00 |
------------------------------------------------------------------
SIEMENS SIMATIC S5 AS511 (Programming port) protocol description
Last reviewed: May 4, 1999
- corrected a DLE/ACK sequence in DBWrite function
- provided new informations on data synchronisation between AS511
interface and the CPU.
------------------------------------------------------------------
COM port setup
--------------
Siemens data frame is not usual, open your port with:
speed 9600 baud
data 8 bits
stop 1 bit
parity EVEN
DLE control character
---------------------
DLE (10hex) is a control character, used to inform the receiver that the
following byte 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.
Communication breaks
--------------------
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)
Data addressing
---------------
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 when the datablock is rewritten in CPU (or after a program
compression), its address in PLC memory changes.
Therefore when communicating with double-port CPUs (or H1 networked CPUs) you
must take care of it, since the PLC program may be unexpectedly modified by
somebody else via other interfaces.
MOTOROLA and INTEL byte order conversion
----------------------------------------
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 on INTEL processors, the user
must therefore:
- swap the received bytes
and
- swap the bytes before sending them to the PLC
Data synchronisation
--------------------
The AS511 protocol is NOT synchronized with the CPU scan cycle.
This means that data transmitted by a computer can drop in the PLC
memory at any time during the PLC program scan..
If the program is reading some data (such as a recipe), there is
no guarantee that all data is "fresh received".
The best solution is to send recipe data in two steps:
a) send all the recipe data, then
b) send a "data ready" code in a further DataWord.
The PLC program, when receives the "data ready" code, will read all the
recipe data and clear the "data ready" info.
In this way you are sure to accept the recipe data only when it has been
completely transmitted to the PLC memory.
//////////////////////////////////////////////////////////////////////////////
B_INFO
input: - block number
output: - initial address of DW0 in AG
PG AS
(hex) (hex)
---------------------- function start --------
02 ----> STX
B_INFO function code = 1Ah
DLE
06 ----> ACK
DLE
06 ----> ACK
---------------------- header info --------
01 ----> ID=01h for Datablock
XX ----> DB number (0..255)
10 ----> DLE
04 ----> EOT
DLE
06 ----> ACK
DLE
06 ----> ACK
---------------------- terminate --------
DLE
06 ----> ACK
DLE
06 ----> ACK
//////////////////////////////////////////////////////////////////////////////
DB_READ
input: - initial address in AG
- final address in AG
output: - contents of datawords
PG AS
(hex) (hex)
---------------------- function start --------
02 ----> STX
DB_READ function code = 04h
DLE
06 ----> ACK
DLE
06 ----> ACK
---------------------- header info --------
XX ----> initial address in AG: XX XX
XX ---->
XX ----> final address in AG: XX XX
XX ---->
10 ----> DLE
04 ----> EOT
DLE
06 ----> ACK
DLE
06 ----> ACK
---------------------- terminate --------
DLE
06 ----> ACK
DLE
06 ----> ACK
//////////////////////////////////////////////////////////////////////////////
DB_WRITE
input: - initial address in AG
- contents of datawords
output: - none
PG AS
(hex) (hex)
---------------------- function start --------
02 ----> STX
DB_WRITE function code = 03h
DLE
06 ----> ACK
DLE
06 ----> ACK
---------------------- header info --------
XX ----> initial address in AG: XX XX
XX ---->
---------------------- data --------
XX ----> first byte of data
XX ---->
XX ---->
. . .
. . .
XX ---->
XX ---->
XX ----> last byte of data
10 ----> DLE
04 ----> EOT
DLE
06 ----> ACK
DLE
06 ----> ACK
//////////////////////////////////////////////////////////////////////////////
end of document | |
|
|
| Re:S5 AS511 (Programming port) protocol |
|
wangfeng发表评论于2008-4-19 19:47:00 |
| To: apple
不需要考虑硬件是TX还是RX。直接向串口发送数据,延时,接收即可。 最好有S5PLC试一下 | |
|
|
| Re:S5 AS511 (Programming port) protocol |
|
apple发表评论于2008-4-19 3:56:00 |
|
谢谢你提供这个协议的信息
想请教你一下关于接收传送方面的问题
当使用DB_READ时,是不是在PC端自订程序里将DB_READ的格式经由COM Port以RS232转TTY的方式(Tx),将数据送到PLC,然后PLC就会经由在Rx线路将资料传回呢?? 因此只要在自订程序里从Rx接收数据即可呢??
如有误解之处,还烦请你指教。谢谢!!
| |
|
|
| Re:S5 AS511 (Programming port) protocol |
|
wangfeng发表评论于2007-4-20 17:51:00 |
| 2005年. 使用VB6.0 ,按上述协议,与S5-95U PG口进行连接,测试完全正确。使用中VB6.0 + 三个串口 + Win2000 + S5编辑电缆(15米) + 三台S5-95U。
使用中,一定要注意 DLE(10Hex),如果写数据中出现10Hex,必须连发两次;同理 读上来的数据也是。
压缩S5 CPU内存后,上位机一定要重新读取S5地址首列表.
使用此协议(AS511),可完成与Step5相同功能的大部功能。 | |
|
|
发表评论:
|
|
|