Code examples PLCcom for S7

The integration of PLCcom for S7 is very easy and user-friendly.
In the following examples will show you the most important functionality.

You will find other documentations with more code examples in our example application in the download package or online.

Some of the code examples differ depending on whether you have selected the classic Put/Get access type or symbolic access via Secure Communication .

picture: PLCcom S7 C# Java Code Beispiele

Example: Connecting an application to a PLC

Example: Connecting an application to a PLC

Example: Close the PLC connection

Example: The connection is opened automatically when it is needed. If after the expiry of the given period, no more requests are sent, the connection is automatically closed.

Example: The connection is opened automatically when it is needed. If after the expiry of the given period, no more requests are sent, the connection is automatically closed.

Example:
Read data from PLC. Read raw data from PLC buffer.

Further examples for reading certain data types (string, DINT, etc.) can be found in the documentation or the sample application from the download package!

Example:
Read data from PLC. Read raw data from PLC buffer.

Further examples for reading certain data types (string, DINT, etc.) can be found in the documentation or the sample application from the download package!

Example:
Writing raw data to PLC.

You will find more 'write' examples of specific data types (String, DINT, etc.) in our documentation or in our example application!

Example:
Writing raw data to PLC.

You will find more 'write' examples of specific data types (String, DINT, etc.) in our documentation or in our example application!

Example:
Subscribing data of symbolically addressed variables for event-controlled reading

Further examples for reading certain data types (string, DINT, etc.) can be found in the documentation or the sample application from the download package!

Example:
Optimized reading and writing of data from several different areas of a PLC in a common access. A ReadWriteRequestSet is created for this purpose and transferred to the device for reading / writing. The necessary read accesses are automatically reduced to the bare essentials and optimized.

Further examples for reading certain data types (string, DINT, etc.) can be found in the documentation or the sample application from the download package!

Example:
Reading basic PLC informations like order number, model, firmware, etc.

Example:
Reading PLC operating mode and status (run, stop, key position, etc.)

Example:
Get / set PLC time

Example:
read data from system state list (if existing)

Example:
read diagnostic data from PLC

Example:
send password to unlock connection of password-protected PLCs

Example:
Start / Stop PLC (RUN >> STOP or STOP >> RUN)

Example:
Read a list of created PLC objects. This example reads blocks. Additionally you can choose a specific block type (OB, DB, etc.)

Example:
Read lenght of a specific block.

Example:
Read a specific block in MC7-format and save to a select file.

Among other things you can find block informations (language, author, etc.(plain text)) in the ReadPLCBlockResult's subobject 'BlockInfo'.

Example:
Restore block data from a selectable MC7-file.

It is possible to modify the target informations. E.g. save DB100 to DB200.

Example:
Delete a specific block.