Manage PLC Channels

 

In this Topic Hide

About PLC Channels

Create a PLC Channel

Rack and slot

Add or Edit a Channel Message

PLC addresses

Siemens S7

Supported S7 Elementary data types

Obtaining a TimeStamp

Example 1

Example 2

About PLC Channels

The OT PLC channel communicates with PLC’s via a TCP/IP connection without the need for an OPC Server. The channel currently supports the Siemens S7 protocol that supports the following Siemens PLC’s:

       S7-200 (equipped with a CP243), S7-300, S7-400, S7-1200, S7-1500 and Logo 8 (Only DB and M memory areas),

Create a PLC Channel

1.     Select the OT Bus Stop tab.

2.     Click PLC Client.

A list of the existing PLC channels is shown.

3.     Click Add.

A new window opens.

4.     Enter the following information:

The PLC channel has the following configuration parameters to connect to the PLC:

o       Name: A unique name for the channel.

o       Descriptions: Enter a description in the default language and any other required languages.

o       Comm, Protocol: The PLC protocol to use. The S7 Protocol is the only available option.

o       Host: The IP address or FQDN of the PLC

o       Port: The port number at which the PLC protocol is listening. 102 is used by the S7 protocol.

o       Use TSAP: Place a tick in this check box to configure a connection with a Siemens Logo 8 or Siemens S7-200 equipped with a CP243.

o       Rack: The PLC rack number that holds the S7 CPU. (Available if Use TSAP is not ticked.)

o       Slot: The slot number in the rack that holds the S7 CPU. (Available if Use TSAP is not ticked.)

o       Local TSAP: A hexadecimal value that can be found in the Siemens manual for the PLC. (Available if Use TSAP is ticked).

o       Remote TSAP: A hexadecimal value that can be found in the Siemens manual for the PLC. (Available if Use TSAP is ticked).

Rack and slot

The following table shows the rack and slot settings for the supported Siemens PLC’s:

  Rack Slot  
S7-300 0 2 Always
S7-400 0..7 1..31 Follow the hardware configuration
S7-1200 0 0..1  
S7-1500 0 0..1  

Add or Edit a Channel Message

1.     While editing a channel select the Channel Messages tab.

All existing channel messages contained in the channel are listed. The table shows the name of the channel message, the direction in which the message is going and whether or not the message is currently active.

2.     Click Add (or Edit to modify an existing message).

3.     Enter a name for the channel message.

4.     Select a Message Definition. Message definitions act as templates when adding messages to a Channel. They specify whether the message is being uploaded or downloaded and also lists the different data fields that will be available in the message. The Tags control opens.

5.     Link the tags to data fields as described here.

6.     Select the Acquisition type and its settings as follows:

Upload

o       Interval acquisition: Acquisition defined in seconds. The interval must be provided. You can also enable Message filtering and click to decide whether a channel message should be processed. The message filter requires 2 operands and an operator to create a condition. The channel message is processed when the condition evaluates to ‘true’.

The Data type specifies the type of data (Boolean, Integer) that the operands will use. The left and right operand can use the following data sources:

        The actual value from the PLC

        Constant value

        Data translation table

        Function evaluation

        Bus stop variable

The operator can be:

        Less than ‘<’

        Less than or equal ‘<=’

        Equals ‘==’

        Not equal ‘<>’

        Greater than or equal ‘>=’

        Greater than ‘>’

o       Trigger Tag Acquisition: The values of the tags are read when the selected trigger tag changes value. The trigger tags can be specified using the ‘Acquisition settings’.

§        Simple handshake upload: Apply a simple handshake using a trigger tag.

§        Double handshake upload: Apply a double handshake using a trigger tag and acknowledge tag.

§        Rising edge: Start message exchange when the trigger tag goes from zero to non-zero.

§        Falling edge: Start message exchange when the trigger tag goes from non-zero to zero.

o       On Change Acquisition: The values of the tags are read when one of the tags in the channel message changes value. This acquisition type does not have additional configuration settings.

Download

o       Trigger Tag Acquisition: The values of the tags are downloaded to the PLC using a handshake. The handshake prevents the channel from downloading new values to the PLC if the trigger is not in an idle state. The trigger tags can be specified using the ‘Acquisition settings’.

§        Value download: This downloads the channel message directly to the PLC without using a handshake.

§        Simple handshake download: Apply a single handshake when downloading the data to the PLC.

§        Double handshake download: Apply a double handshake when downloading to the PLC using a trigger tag and acknowledge tag.

7.     Enable Handshake only if the message is used for keep-alive purposes.

Add and Modify Tags

The tags provide the link to the location of the data on the server.

8.     Click Add below the Tags pane (or Edit to modify an existing tag).

A new window opens.

9.     Enter the name of the tag in the Description field.

10.  Select a Data Type. This is the format in which the data will be received (e.g. Integer, Char).

11.  Enable the Active checkbox to ensure the tag is active.

12.  If required, enable Mandatory. If a message is received and a mandatory tag doesn't have a value then the message won't be processed.

The source and destination can now be selected. The source and destination will depend on whether it is an Upload or Download message definition and on the message format that's been selected.

13.  Select the Data source. This can be one of the following:

Name

Description

Required Information

PLC tag address

The value received from the tag address.

Address of the tag.

Constant value

The tag will always be the same value.

Enter the value to be used.

Data translation table

The value is read from a specific PLC address (upload) or message field (download) and then translated using a data translation table.

Select the translation table to use and the PLC address or message field for the source value.

Message Field (download only)

Value from specific message field.

Select the message field.

Function evaluation

The value is read from a specific PLC address (upload) or message field (download) and then modified using a function.

Enter the function to use and the PLC address or message field for the source value that will be modified by the function.

Reset counter evaluation (upload only)

Instead of sending the received value it sends the iteration. For example, if the last known value was 50 and it receives a value of 53 then the output will be 3.

No extra information required.

Rollover counter evaluation (upload only)

Instead of sending the received value it sends the iteration. As soon as a defined limit is reached the value is reset and the counter goes back to zero. For example, if the current value is 99, rollover is set to 100 and 5 is the incoming value then the result is 6. This is calculated as follows: (100 – 99 + 5 = 6)

Specify the rollover value set for the equipment the value is being received from.

Bus stop variable

A bus stop variable. Select a bus stop variable.

14.  Select the Destination. This will either be a message field or bus stop variable for upload or a PLC tag address or Bus stop variable for download:

15.  Click OK.

The tag is added to the channel message.

16.  Click OK.

The channel message is added to the channel.

17.  Click OK.

The channel is saved.

PLC addresses

Siemens S7

Siemens PLC addresses are provided in the following format:

      Data blocks: DB<n>.DB<memory_width><offset>[.<bit>|<S7_datatype[<length_or_size>]>]

       Markers: M<memory_width><offset>[,<bit>|<S7_datatype[<length_or_size>]>]

Where:

       <n> is the datablock number.

       <memory_width> is ‘X’ (bit, for DB only), ‘B’ (byte), ‘W’ (word) and ‘D’ (double word).

       <offset> is an offset starting from 1.

      .<bit> the bit index (range 0 to 7).

       <S7_datatype> is the Siemens S7 data type which is optional in the S7 address used by the PLC channel. The PLC channel only supports 1, 8, 16 and 32 bit data types. It supports the following values:

o       BOOL: 1 bit

o       BYTE: unsigned byte (8-bit)

o       CHAR: signed byte (8-bit)

o       WORD: unsigned word (16-bit)

o       DWORD: unsigned double word (32-bit)

o       SINT: signed short integer (8-bit)

o       INT: signed integer (16-bit)

o       DINT: signed double integer (32-bit)

o       REAL: IEEE float (32-bit)

o       TIME: Siemens S7 Date, stored as word in steps of one day since January 1, 1990

o       TOD: S7 Time of Day, milliseconds since midnight. Stored as DWORD.

o       DT: Siemens S7 Date and Time, stored as 64-bit value.

§        byte 0 = year

§        byte 1 = month

§        byte 2 = day

§        byte 3 = hours

§        byte 4 = minutes,

§        byte 5 = seconds

§        byte 6 = two most significant digits of millisecond

§        byte 7 (4MSB) two least significant digits of millisecond

§        byte 7 (4LSB) = day of week

o       STRING: S7 String. An S7 string requires 2 additional bytes to store the string in the PLC, the first byte indicates the maximum length and the second byte indicates the actual length.

       <length_or_size>: is the length specifier for an S7String or the size specifier for a character array. Arrays are not supported for other S7 data types.

The PLC channel applies the following default/raw data types when a specific S7 data type in the address string is omitted:

       Memory area: X --> S7 data type: BOOL.

       Memory area: B --> S7 data type: BYTE.

       Memory area: W --> S7 data type: WORD.

       Memory area: D --> S7 data type: DWORD.

S7 addressing examples:

       DB5.DBX10.1

       M10.1

       DB5.DBW10

       MW10

       DB5.DBB10|SINT

       DB5.DBB10|CHAR[10]

       MB10|CHAR[10]

       DB5.DBB10|STRING[10]

       MB10|STRING[10]

       DB5.DBD10|REAL

       MD10|REAL

Supported S7 Elementary data types

  Description

S7-300 / S7-400

S7-1200

S7-1500

Bit data type

BOOL

BYTE

WORD

DWORD

Yes

Yes

Yes

Character type CHAR (8-BIT)

Yes

Yes

Yes

Numerical data types

INT (16-bit)

DINT (32-bit)

REAL (32-bit)

Yes

Yes

Yes

 

SINT (8-bit)

USINT (8-bit)

UINT (16-bit)

UDINT (32-bit)

No

Yes

Yes

Time types

TIME

DATE

TIME_OF_DAY

Yes

Yes

Yes

  DT

Yes

Yes

Yes

Obtaining a TimeStamp

Obtaining timestamp of a data change event in the OPC, MTConnect and PLC channel.

The PLC, MTConnect, OPC client and OPC server channels can expose a timestamp to specific message field class types that shows when the data on the device (or OPC Server) has changed:

o       Property attribute with its name set to “Timestamp” (case sensitive)

o       EquipmentCondition – EquipmentStateTimestamp.

o       EquipmentCondition – EquipmentModeTimestamp.

Example 1

An OPC channel message (direction = upload) is triggered on change and it is configured to obtain the data from multiple OPC tags (Tag1 and Tag2). The following message definition can be used to obtain the tag value and the time it changed its value:

Direction = Upload

o       A ‘Property’ with its name set to “MyTag1

o       A ‘PropertyAttribute’ with its name set to “Timestamp” (case sensitive) and its index set to “MyTag1

o       A ‘Property’ with its name set to “MyTag2

o       A ‘PropertyAttribute’ with its name set to “Timestamp” (case sensitive) and its index set to “MyTag2

The message definition should be used (linked) with an OPC channel message:

o       A tag named “Tag1” linked to message field ‘MyTag1’ and having access path ‘/my/OPC/Access/Path/To/Tag1’ will give the tag value.

o       A tag named “Tag1_Timestamp” linked to message field ‘Timestamp - MyTag1’ and having access path ‘/my/OPC/Access/Path/To/Tag1’ will give the timestamp of when the Tag1 changed its value.

o       A tag named “Tag2” linked to message field ‘MyTag2’ and having access path ‘/my/OPC/Access/Path/To/Tag2’ will give the tag value.

o       A tag named “Tag2_Timestamp” linked to message field ‘Timestamp - MyTag2’ and having access path ‘/my/OPC/Access/Path/To/Tag2’ will give the timestamp of when the Tag2 changed its value.

The channel message implementation reads the timestamp instead of the tag value when the classtype of the message field named ‘Timestamp’ is set to ‘PropertyAttribute’.

When published on the bus, the channel message data will translate to the following B2MML:

<SegmentData>

  <ID> Tag1</ID>

 <Value>

   <ValueString>tag value of Tag1</ValueString>

  </Value>

  <Value>

    <ValueString>The tag value of Tag1_Timestamp</ValueString>

    <Key>Tag1_Timestamp</Key>

  </Value>

</SegmentData>

<SegmentData>

  <ID> Tag2</ID>

 <Value>

   <ValueString>tag value of Tag2</ValueString>

  </Value>

  <Value>

    <ValueString>The tag value of Tag2_Timestamp</ValueString>

    <Key>Tag2_Timestamp</Key>

  </Value>

</SegmentData>

Example 2

An OPC channel message (direction = upload) is triggered on change and it provides the Equipment state. The following message definition can be used to obtain the equipment state (tag value) and the time the state changed (when the tag changed its value):

o       Direction = Upload

o       A ‘EquipmentContext’ with its name set to ‘EquipmentId’ and its index set to “state1

o       A ‘EquipmentCondition’ with its name set to ‘EquipmentState’ and its index set to “state1

o       A ‘EquipmentCondition’ with its name set to ‘EquipmentStateTimestamp’ and its index set to “state1

The message definition should be used (linked) with an OPC channel message:

o       A tag named “MyEquipmentId” linked to message field ‘EquipmentId – state1’ and having access path ‘/my/OPC/Access/Path/To/Tag3’ will give the tag value.

o       A tag named “MyEquipmentState” linked to message field ‘EquipmentState – state1’ and having access path ‘/my/OPC/Access/Path/To/Tag1’ will give the tag value.

o       A tag named “MyEquipmentState_Timestamp” linked to message field ‘EquipmentStateTimestamp – state1’ and having access path ‘/my/OPC/Access/Path/To/Tag1’ will give the timestamp of when the Tag1 changed its value.

The channel message implementation reads the timestamp instead of the tag value when the classtype of the message field named ‘EquipmentStateTimestamp’ is set to ‘EquipmentCondition’.

When published on the bus, the channel message data will translate to the following B2MML:

              <EquipmentActual>

                <EquipmentID>MyEquipmentId</EquipmentID>

                <Description>state1</Description>

               <EquipmentActualProperty>

                  <ID>EquipmentState</ID>

                  <Value>

                    <ValueString>Value of MyEquipmentState</ValueString>

                    <Key />

                  </Value>

                  <Value>

                    <ValueString>Value of MyEquipmentState_Timestamp</ValueString>

                    <Key>Timestamp</Key>

                  </Value>

                </EquipmentActualProperty>

              </EquipmentActual>