TIA Portal Examples

This section gives some examples of using the DataMan with a Siemens S7-1200 PLC, assuming that you are familiar with the S7-1200 and TIA Portal.

  1. In TIA Portal, either create a new project, or open an existing one.
  2. In Project View, click Options and click Manage general station description files (GSD).

  1. Browse to the installation folder of the GSD file (or the location where you saved the GSD file if you downloaded it from the web).
  1. Select the GSD file you wish to install and follow the displayed instructions to complete the installation.
Note: If there is more than one GSD file in the list and you are unsure which to install, choose the one with the most recent date.

  1. Go to Device Configuration and add your device in the Network View tab.
  2. The Hardware catalog is displayed on the right. Expand the “PROFINET IO” tree to the “Cognex ID Readers” node.
  3. Press and hold the left mouse button to drag the DataMan reader and drop it on the PROFINET IO network symbol in the left pane.

The HW Config tool automatically maps the DataMan I/O modules into the memory space.

Note: By default, the 64 byte User Data and 64 byte Result Data Modules are inserted. There are multiple sizes available for both of these modules. To optimize performance, use the module size that most closely matches the actual data requirements of your application. You can change the module by deleting the one in the table and inserting the appropriate sized module from the catalog.
  1. Right-click the DataMan icon and select Properties….

  2. Give the reader a name. This must match the name of your actual DataMan reader. The name must be unique and follow DNS naming conventions. For details, see the TIA Portal help documentation.
  3. If your DataMan reader is configured to use its own static IP, select the IP address is set directly at the device radio button. As an alternative, if you wish the PLC to assign an IP address, select the Ethernet button and configure the appropriate address.
  1. Check the checkbox next to the device image and connect the selected device with the PLC by drawing a line with your mouse.
  2. By default, the SIMATIC software maps the User Data and Result Data Modules to offset 256. This is outside of the default process image area size of 128. That is, data in these modules are inaccessible by some SFCs such as BLKMOV. As a solution, either remap the modules to lower offsets within the process image area or expand the process image area to include these modules.

If you choose to expand the process image area, make the size large enough for the module size plus the default 256 offset.

Note: Expanding the process image can have a performance impact on the PLC scan cycle time. If your scan time is critical, use the minimal acceptable module sizes and manually remap them down lower in the process image.

Symbol Table

It is recommended that you define symbols for the DataMan I/O module elements to make the code much easier to read and reduce mistakes. This sample table shows symbols defined for a typical instance of a DataMan reader. It is possible that DataMan I/O modules are at different addresses in your project. Make sure to adjust your symbol definitions based on the specific offsets of the I/O modules. For more information, see the TIA Portal Integration Guide for In-Sight and DataMan at https://support.cognex.com/en/downloads/detail/in-sight/3687/1033.

Trigger and Get Results

Open the sample program “Cognex-Dataman” for the complete example program.

Note: This sample can be used with any PROFINET enabled DataMan reader.

Perform the following steps to install the program:

  1. Start TIA Portal.
  2. Browse to find the sample file on your PC.

  1. Save the project on your PC. TIA Portal extracts the sample archive and makes it available.

Reduced to the basics, the process of reading and retrieving results consists of the following:

  1. Define an area in your application to save read results. There are many options regarding how and where result data can be stored. In this example, a temporary tag is defined containing the fields of the Result Data module that are relevant for our application.

  1. Enable the reader.

  1. Set the trigger signal and set coil to indicate a read is pending.

  1. As soon as the results are available, clear the trigger signal and save a copy of the result data and set the results acknowledge signal.

  1. When the reader sees the result acknowledge signal, clear result acknowledge, clear the read pending coil, and signal that the read process is complete.
Note: The reader clears “Results Available” as soon as it sees the PLC’s “Results Ack” signal.


Using SoftEvents

SoftEvents are a means of invoking an activity by manipulating a single control bit. The activity for each bit is predefined. For more details, see section SoftEvents. With the exception of “Execute DMCC” and “Set Match String” all SoftEvents may be invoked in the same way. “Execute DMCC” and “Set Match String” require the added step of loading the User Data module with application data before invoking the event.

Reduced to the basics, the process of invoking a SoftEvent consists of the following:

Executing DMCC Commands

Refer to sample program “Cognex-Dataman” for the complete example program. For information on how to install it, see section Using SoftEvents.

Note: This sample can be used with any PROFINET enabled DataMan reader.

“Execute DMCC” is a SoftEvent which requires the added step of loading the User Data module with the desired DMCC command string before invoking the event. Note that the SoftEvent mechanism does not provide a means of returning DMCC response data (other than a failure indication). So this mechanism cannot be used for DMCC “||>GET…” commands.

The process of executing a DMCC command is the same for all other SoftEvents (see example above) except the step of invoking the SoftEvent also includes copying the command string to the User Data Module. In this example the command string is exists in a Data Block. This example can be expanded to utilize a Data Block with an array of command strings that the copy function can reference by an index value. This allows the user to pre-define all DMCC commands that are required by the application and invoke them by index.