Collapse
CollapsingX
  • - or -

Procedure for communicating with controllers


The following steps provide a basic methodology for communicating with a PLC using the PROFINET or EtherNet/IP protocol:

  1. Using an appropriate configuration software package, configure your PLC to recognize your runtime platform as a slave device (scanner). Refer to the sections on setting up for PROFINET and EtherNet/IP, later in this chapter, for more information.

  2. Use the MILConfig utility to enable the protocol service for your runtime platform.

  3. In Matrox Design Assistant, enable the protocol for your project.

  4. Read data from the PLC using Quick Comm, the ProfinetReader step, or the EthernetIPReader step.

  5. Perform some inspection and analysis operations.

  6. Write data back to the PLC using Quick Comm, the ProfinetWriter step, or the EthernetIPWriter step.

The diagram below displays an overview of the PROFINET and EtherNet/IP industrial protocols in Matrox Design Assistant.

Enabling the PROFINET and EtherNet/IP protocol service

To communicate with a PLC using the PROFINET or EtherNet/IP protocol on your runtime platform, you must enable the protocol service by opening the MILConfig utility on the runtime platform, expanding the Communication item, selecting the EtherNet/IP or PROFINET page, and adding, removing, or modifying protocol instances (instance names are case sensitive). If your runtime platform has multiple network adapters (NICs), you can select which one to use from the Interface dropdown list.

If you are using a remote PC or a smart camera as your runtime platform, opening the MILConfig utility on it might require remote desktop or VNC access. On a Matrox Iris GTR smart camera, you can create, enable, and modify protocol instances directly from its COMMUNICATION portal pages, accessible using the Administration button ().

Once the protocol instance has been created on your runtime platform using the MILConfig utility, you need to enable the protocol for your project by selecting the Configure EtherNet/IP or Configure Profinet menu item from the Project menu. This will open the Platform Configuration dialog to the relevant page, and you can enable the protocol by clicking on the EtherNet/IP or Profinet slider. Make sure to verify the name of the instance needed for your project. The slider will turn green, indicating that the protocol is now enabled for your project. By default, this also enables the Quick Comm feature. To disable it, click on the Quick Comm slider in the same dialog.

Alternatively, you can enable the protocol instance in the Communications dropdown panel, accessible from the Matrox Design Assistant platform toolbar. Note that, when using this method, you cannot select a different instance of the protocol.

You cannot enable both the PROFINET and EtherNet/IP protocols in the same project. Matrox Design Assistant will automatically disable one when you enable the other.

For information about running multiple projects simultaneously, and the restrictions for projects that use industrial protocols, see the Communication protocols subsection of the Considerations when running multiple projects simultaneously section in Chapter 60: Running multiple projects on a runtime platform.

Quick Comm with PROFINET and EtherNet/IP

Matrox Design Assistant's Quick Comm feature is implemented as a combination of predefined data fields in data tables and action points in the flowchart. These data fields are waited for, read, set, and reset in the background. The handshake, including overall pass and fail status, is done without the need to add any steps in the flowchart. Event-triggered actions allow Quick Comm to perform the handshake between the runtime platform and the PLC. For information on actions and events, see the Events and actions section in Chapter 2: Building a project.

You can enable or disable Quick Comm at any time during the development of a project either in the Platform Configuration dialog or in the Communications dropdown panel.

Status and control handshake

The standard data fields set by the PLC indicate that the camera should be triggered, and that the results of the analysis have been acknowledged. Data fields sent to the PLC indicate if the project is ready or busy, and indicate an OverallPass and OverallFail status based on the results in the Status step. There are also Quick Comm data fields that are dedicated to triggering image acquisition for up to 8 cameras. The images below illustrate the standard handshake.

If you are not using Quick Comm, see the Using a PLC trigger without Quick Comm subsection of the Triggering section in Chapter 28: Acquisition for information.

At runtime, a wait banner appears in the operator view if a running project is waiting for a handshake from the PLC. At design-time, the Wait notification bar blinks at the bottom of the flowchart and offers the option to skip the wait or see which bit is being waited for.

Optionally, applications can make use of additional data fields (such as PLCReset, and PLC event fields). You must set the address of each data table to match the expected address in your PLC's data map. More sophisticated multiple-camera applications can also use per camera trigger and per camera pass/fail fields for up to 8 cameras. By default, the PROFINET and EthernetIP pages in the Platform Configuration dialog only display data fields associated with events, but all fields in the data tables can be seen by toggling the Only show fields with events option.

The table below lists the predefined data fields, when Quick Comm is enabled. Their exact addresses are protocol dependent.

Data fields

Data table

Bit 0

Bit 1

Bit 2

Bit 3

Bit 4

Bit 5

Bit 6

Bit 7

Control

(Reserved)

PLCReset

PLCACK

(Reserved)

(Reserved)

PLCSoftEvent1

PLCSoftEvent2

(Reserved)

Status

ProjectReady

Busy

OverallPass

OverallFail

(Reserved)

SoftEvent1ACK

SoftEvent2ACK

Online

Camera1

(Reserved)

(Reserved)

Camera1Pass

Camera1Fail

(Reserved)

Camera1SoftEvent1ACK

Camera1SoftEvent2ACK

(Reserved)

PLCCamera1Trigger

(Reserved)

(Reserved)

(Reserved)

(Reserved)

PLCCamera1SoftEvent1

PLCCamera1SoftEvent2

(Reserved)

.

Up to 8 Camera data tables

.

DataToPLC

16, 32, 64, 128, 256, 512, 1024 bytes of user-defined fields (Bit, Byte, Word, DWord, Float, String)

DataFromPLC

16, 32, 64, 128, 256, 512, 1024 bytes of user-defined fields (Bit, Byte, Word, DWord, Float, String)

Inputs: Written to the PLC

Outputs: Read from the PLC

Matrox Design Assistant allows you to define custom actions and events, for some data fields, in the Actions page of the Platform Configuration dialog. For more information, see the Configuring actions and events section later in this chapter.

Set Quick Comm to trigger acquisition automatically

When Quick Comm is enabled, a CameraN data table is added for each camera added to your project. You can use up to 8 cameras for your project. Each CameraN data table includes dedicated Quick Comm data fields for triggering image acquisition. In the PROFINET and EthernetIP pages (with Quick Comm enabled) of the Platform Configuration dialog, you can select a trigger target (for example, PhysicalCamera1) for the PLC CameraN trigger bit field of each CameraN data table. The physical camera's corresponding page in the Cameras page of the Platform Configuration dialog will show that the camera trigger is enabled. A note will appear underneath the Trigger settings, stating that the camera is triggered by the protocol.

Sending and receiving data

Using Quick Comm, projects can be configured so that data is automatically sent to the PLC when the Inspection End Action point is reached. You can configure application-specific data fields to be automatically updated with data to be sent to the PLC in the DataToPLC page of the Platform Configuration dialog. Application-specific data for input to the runtime platform from the PLC is configured in the DataFromPLC page of the Platform Configuration dialog, but does not have the option to update automatically.

If you load a project that was created prior to Matrox Design Assistant 5.0, it will not be automatically upgraded to use the Quick Comm feature, because its data mapping does not match that defined by Quick Comm. All the fields in the project are added to the DataToPLC and DataFromPLC tables. Consequently, reader and writer steps are also provided in Matrox Design Assistant X Version 1905 for legacy projects to communicate with a PLC.

DataToPLC and DataFromPLC data tables

DataToPLC and DataFromPLC data tables contain the application-specific data fields that are read from and written to the PLC, respectively. When using the EtherNet/IP protocol, the first 32 bytes of each data table (assembly) are reserved for predefined Quick Comm data fields, meaning the first valid address for EtherNet/IP fields starts at 32. When using PROFINET these tables are in separate modules and addresses start at 0. For more information on specific address mapping, refer to the data tables sub-sections found in the sections for either PROFINET or EtherNet/IP.

The following steps describe how to add or edit data fields in the DataToPLC and DataFromPLC data tables, from the Platform Configuration dialog.

  1. Open the Platform Configuration dialog, navigate to the DataToPLC or DataFromPLC page, and enter the data table's base address in the PLC's data map.

  2. Click on the Add or Delete button to change the number of data fields. The address of data fields are automatically set to the base address plus an offset based on data type, but can also be set manually to another address. Click the Up or Down arrows to change the order of the fields.

  3. Assign a name to each field according to its use. For example, using the same name as the tag in the PLC.

  4. For each field, select the data type. The data type establishes the size of the field and will offset the address of the next data field by a fixed number of bytes. String type data has a default maximum string size of 10 bytes, but can be changed. The following table shows the different data types of each protocol and their sizes.

    Date type

    EtherNet/IP

    PROFINET

    Size

    BOOL

    Bit

    1-bit

    USINT

    Byte

    8-bit (unsigned)

    INT

    Int

    16-bit

    UINT

    Word

    16-bit (unsigned)

    DINT

    Dint

    32-bit

    REAL

    Float

    32-bit

    UDINT

    DWord

    32-bit (unsigned)

    LREAL

    Lreal

    64-bit

    SHORT_STRING

    --

    1 + Max string size

    NULL_TERMINATED_STRING

    --

    1 + Max string size

    --

    String

    2 + Max string size

    STRING

    --

    4 + Max string size

    STRING2

    --

    2 + (2 * Max string size)

  5. Change the default address of the data field if it does not match the address in your PLC's data map. This allows you to create a manual offset for the data fields if they are not contiguous in the PLC's memory.

If you need to specify a field linked to a value that will automatically update at inspection end, instead of performing the previous steps, go to the Quick Watch flyout panel of the required result element in a step's display, right-click on the result that you need to add, and choose Auto DataToPLC. This adds a new data field whose name is based on the result name and whose value is a link to the result that you clicked on. The Open DataToPLC button gives access to the corresponding page in the Platform Configuration dialog, where you can modify the name, address in the PLC's data mapping, and data type.

Application-specific values written to the DataToPLC data table

To send application-specific data to the PLC, you write values to the DataToPLC data tables using the ProfinetWriter step or EthernetIPWriter step, or by using the Auto DataToPLC option. Data fields found in the DataToPLC data tables can also be used for validation, for more information on validation see the Project Change Validator overview section in Chapter 62: Project Change Validator.

When the PLC writes a value to a data field associated with an event, the event will cause an associated action (for example, trigger, or reset) or subflowchart to execute when outside the active inspection zone, it is queued otherwise. For more information, see the Configuring actions and events section later in this chapter. You can also use actions to automatically send data, through the DataToPLC data tables, to the PLC. To do so:

  1. In the DataToPLCDataToPLC page, enable the Automatic option of a data field. This will automatically add the data field to the Actions page, and add Set and Clear actions at the Inspection End Action point.

  2. In the DataToPLC data table, once you have enabled the Automatic option, set the value to send for the selected field (of the correct data type) in the Value text box.

Alternatively, you can write to the DataToPLC data table using a ProfinetWriter step or an EthernetIPWriter step. The procedure for both PROFINET and EtherNet/IP is the same, to do so:

  1. Add a writer step to the flowchart, or select it if you already have one added.

  2. Click on the Manage Fields button in the Configuration pane to open the Platform Configuration dialog. Ensure that the DataToPLC page is selected, from there you can add or edit data fields in the DataToPLC data table.

  3. In the Configuration pane, enable the data field to which the step should write. To specify a linked or advanced value, click on the right-arrow button and select the appropriate option, or you can drag and drop a link from the Quick Watch flyout panel or the Quick Evaluate pane.

Application-specific values read from the DataFromPLC data table

To receive application-specific data from the PLC, you read from the DataFromPLC data tables using the ProfinetReader step or EthernetIPReader step. Data in the DataFromPLC data table will be the data that the PLC has written to the table during its last write cycle. The procedure for reading from both PROFINET and EtherNet/IP is the same, to do so:

  1. Add a Readers step, or select it if you already have one added.

  2. Click on the Manage Fields button in the Configuration pane to open the Platform Configuration dialog. Ensure that the DataFromPLC page is selected, from there you can add or edit data fields in the DataFromPLC data table.

    The value of a data field in the DataFromPLC data table is accessible using the outputs of the ProfinetReader step and EthernetIPReader step. Use the value element to access the data (For example, ProfinetReader.Fields("SerialNumber").Value).