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.
- In TIA Portal, either create a new project, or open an existing one.
- In Project View, click Options and click Manage general station description files (GSD).
- 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).
- Select the GSD file you wish to install and follow the displayed instructions to complete the installation.
- Go to Device Configuration and add your device in the Network View tab.
- The Hardware catalog is displayed on the right. Expand the “PROFINET IO” tree to the “Cognex ID Readers” node.
- 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.
- Right-click the DataMan icon and select Properties….
- 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.
- 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.
- Check the checkbox next to the device image and connect the selected device with the PLC by drawing a line with your mouse.
- 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.
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.
Perform the following steps to install the program:
- Start TIA Portal.
- Browse to find the sample file on your PC.
- 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:
- 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.
- Enable the reader.
- Set the trigger signal and set coil to indicate a read is pending.
- 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.
- When the reader sees the result acknowledge signal, clear result acknowledge, clear the read pending coil, and signal that the read process is complete.
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.
“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.