S7 ReadMe
S7 ReadMe
only. No warrantee is expressed or implied. You should test your code and
completely understand the implications of writing to or reading from an operating
PLC.
PLCs are often used to control hazardous processes and/or equipment. Writing to or
reading from a PLC in active control of equipment or process can result in the
disruption of the PLC program or data areas, potentially causing economic loss,
property damage, generation or release of hazardous substances and/or personal
injury up to and including death. Test your software in a controlled environment
and qualify it before using it on active equipment or processes.
To my knowledge, Siemens has never released the details of the S7 protocol. Much
of what is publicly available on S7 is based on observations of the protocol by
others. There is an open source S7 data exchange package available at
http://libnodave.sourceforge.net/ that documents many S7 features.
The Address Area parameter determines which PLC memory area is the target for the
reads and writes. I have only tested reads and writes to the Data Block (DB) Area.
Your application should read and write to separate read and write DBs dedicated for
transfer only. By confining reads and writes to dedicated Data Blocks, the risk of
unintended overwrites may be reduced.
S7Com_Once.vi performs one read or write per execution. It writes to the target
PLC from an array of I32, it reads from the target PLC into an array of I32. The
number of bytes written is proportional to the number of elements in the array to
be written and the transport size parameter.
S7Com_W+R_Loop.vi regularly writes to and reads from a pair of DBs in the target
PLC. In order to use it, your Step7 PLC project should provide two Data Blocks,
DB11 and DB12. See the screen capture image db11&12.PNG for their layout. After
downloading the DBs to your PLC, monitor and change DB VAlues with a VAT. As can
be seen in the VI, the transfer size is DWORD.
This is not finished. Needed are better error checking, cleaner S7 Response
decoding, and stress testing with malformed data.