The S7 TCP-IP interface is providing a direct connection to Siemens Hardware Controllers including the S7-300,400,1200,1500 as well as Simotion and Sinumerik controllers.

The S7 Interface is running in a separate thread to achieve maximum performance.

The S7 TCP-IP interface is based on Snap7 from Davide Nardella, for more information see http://snap7.sourceforge.net/. Thanks to Davide for providing us Snap7 under special license conditions.

Here is a short Youtube Tutorial showing you the interface in action:

Configuring the PLC

For allowing the access of the PLC, you will need to set the TIA portal property, under the CPU project, in the left pane under Properties the item Protection to Full access. You also need to check permit access with PUT/GET …

Interface configuration

The S7 interface is added to the Scene by selecting Tools > game4automation > Add Component > Interface > S7 or by adding the script S7interface to an empty GameObject.

You will get an inspector window like this:

For the PLC you need to configure the IP-Adress under Adress and the Rack and Slot number.
For importing symbols, a path to a symbol table (.sdf-format) needs to be added.

By pushing the Check Connection button you can check if the PLC is reachable. If everything is OK you will get an OK in the Connection Status as well as a Running in the PLC Status

Importing Signals

With Import symbol table all symbols that are in the table are imported and GameObjects with the any Game4Automation signal objects (PLCInput…, PLCOutput…) are created.

The name of the GameObject will be the Symbol name. The name of the Signal Script (PLCInput.. and PLCOutput..) will be the absolute plc address. This address is the basic id for the interface signal.

It is also possible to manually add signals and to configure the address (in the Name property of the Signal script) yourself.

After the interface configuration is done and after you have checked if the PLC is reachable, you can start the simulation. You will see, that all signals are updated automatically.

Adding Signals manually

It is possible to add signals manually. In this case you must make sure that the Signal adress is proided in the Signal as name and that the Data type (see table below) of the signal is provided as property in Origin Data Type:

These data types are supported:

Datatype Description
BOOL Boolean, one Bit
BYTE Byte, 8 Bit
WORD Word, 16 Bit
DWORD Double Word with 32 Bit
SINT Signed Int with 8 Bit
INT Signed Int with 16 Bit
DINT Signed Int with 32 Bit
USINT Unsigned Int with 8 Bit
UINT Unsigned Int with 16 Bit
UDINT Unsigned Int with 32 Bit
REAL Real with 32 Bit
Please check the Game4Automation Class Reference for more information about the properties and methods of this component.

Reading and Writing DBs

It is also possible to read and write Data Blocks (DBs) on a PLC. DB variables are not part of the signal table and you need to configure the access to the DB values manually based on their physical address in the PLC.

To be able to access the DB values Optimized Block Access needs to be turned off in the DB properties:

Here is an example how to access a Byte inside the DB. The Name of the PLCOutput or Input needs to be the absolute adress of the DB value:

This is an example how to access a Real inside the DB:

© 2019 in2Sight GmbH https://game4automation.com - All rights reserved. No part of this publication may be reproduced, distributed, or transmitted in any form or by any means, including printing, saving, photocopying, recording, or other electronic or mechanical methods, without the prior written permission of the publisher.