PROFINET - Using Records with Siemens PLCs

Read and Write Record Commands

PROFINET supports a second, alternative way of communicating with an In-Sight vision system, using the Read and Write Record commands. These commands explicitly write to a specific area in memory on an In-Sight vision system; the Read and Write Record commands are sent to a specific device and that device always responds with a reply to that message. As a result, the Read and Write Record commands are better suited for less frequently occurring operations.

The following Record commands are support by an In-Sight vision system:

Index Description
1 Job Name
10 Inspection ID + Inspection Result Code + Inspection Result Bytes 0 - 995
11 Inspection Result Bytes 996 - 1995
12 Inspection Result Bytes 1996 - 2995
13 Inspection Result Bytes 2996 - 3995
14 Inspection Result Bytes 3996 - 3999
30 User Data Bytes 0 - 999
31 User Data Bytes 1000 - 1999
32 User Data Bytes 2000 - 2999
33 User Data Bytes 3000 - 3999
Note:
  • Records 10-13 are read-only records. This data has the same format as the Inspection Results module, including the Inspection ID, Inspection Result Code, and the Inspection Results data. An attempt to write to these records will result in error code 0xB6 indicating access denied.
  • Records 30-33 are read/write records. When writing User Data records using “WRREC” (SFB53), you also need to use the Inspection Control module, Set User Data bit (bit 2) in order to signal the writing of the data from the User Data holding buffer to the spreadsheet ReadUserData function. Write the User Data record first and then set the Set User Data bit.

    In the event the PLC attempts to write to this record range while a Cyclic connection is established which includes the User Data module, an error code 0xB5 will be generated indicating that a state conflict has occurred. An application which requires transferring large amounts of data should use either the User Data module in the cyclic connection, or the User Data write record command. The use of both simultaneously is not supported.

  • When the Siemens CP 343-1 module is acting as a PROFINET I/O controller and reading or writing data records using FB52 – PNIO READ OR WRITE RECORD, only the first 480 bytes of data in each record read/write are transferred.
  • When an In-Sight vision system is configured to communicate over a PROFINET IO network, writing user data to records 30 through 33 is successful, while attempting to read user data records 30 through 33 will return inconsistent results.

Changing a Job on an In-Sight Vision System

The most common operation performed between an In-Sight vision system and a Siemens PLC using the Read and Write Record commands is changing a job. Within the Siemens PLC, these commands are sent using the "WRREC" (SFB 53) and "RDREC" (SFB 52) blocks.

The following steps illustrate how to add a "WRREC" block to change the current job on an In-Sight vision system:

  1. Open the symbol table in the PLC project (this can be found in the Simatic Manager project, under the S7 Program tree node).
  2. Add the following symbols to the project:

    Symbol Address Data Type Description

    LoadJob

    M 124.1

    BOOL

    Triggers the LoadJob command.

    LoadJobBusy

    M 124.2

    BOOL

    True while the LoadJob command is running.

    LoadJobDone

    M 124.3

    BOOL

    True if the LoadJob command succeeded.

    LoadJobErr

    M 124.4

    BOOL

    True if the LoadJob command failed.

  3. Open the OB1 main program block and set the editor into Ladder mode by selecting LAD from the View menu.
  4. Add a WRREC call to your ladder network by dragging the block from the function tree. This block can be found in the Libraries > Standard Library > System Function Blocks > DP node.
  5. Complete the rung by adding the ladder logic as illustrated below:

  6. The ID parameter in the function block must be set to the hexadecimal equivalent of the diagnostic address of the In-Sight module to send the command to; this can be found in the HW Config tool in the module list. In this example, the diagnostic address is 2044 (hex 7FC).
  7. Download the project to the PLC and put the PLC into Run mode.
  8. Open the Variable Table for the PLC project. Add the following entries to the Variable Table:

    Address Symbol Data Type

    M 124.1

    LoadJob

    BOOL

    M 124.2

    LoadJobBusy

    BOOL

    M 124.3

    LoadJobDone

    BOOL

    M 124.4

    LoadJobErr

    BOOL

    MD 128

     

    CHARACTER

    MD 132

     

    CHARACTER

    MD 136

     

    CHARACTER

    MD 140

     

    CHARACTER

    MD 144

     

    CHARACTER

  9. Enable monitoring by selecting Monitor from the Variable menu.
  10. Using In-Sight Explorer, place the vision system Offline.
  11. In the MD 128 - MD 147 entries of the Variable Table, enter the name of a job to be loaded; a null character ($0) must be entered after the last character of the job name.

  12. After the job name has been entered, in the Modify value column, enter "true" of the "LoadJob" row.
  13. Next, commit the values to the PLC's memory by selecting Activate Modify Values from the Variable menu.
  14. The specified job should load and be displayed in In-Sight Explorer, and the LoadJobDone variable should display "true".

Error Information Returned From Write/Read Record Messages in the STATUS Output of DWord (ERROR Bit Set to 1)

The STATUS output parameter contains useful error diagnostic information. The following tables provide descriptions of the values returned in the STATUS parameters, which are interpreted as ARRAY[1...4] OF BYTE.

The error information has the following structure:

Field element: Name: Description

STATUS[1]

Function_Num

  • B#16#00, if no error.
  • Function ID from DPV1-PDU: In error case B#16#80 is OR linked; if no DPV1 protocol element is used: B#16#C0.

STATUS[2]

Error_Decode

Location of the error ID.

STATUS[3]

Error_Code_1

Error ID

STATUS[4]

Error_Code_2

Manufacturer specific error ID, expansion.

STATUS[2] can have the following values:

Error_Decode (B#16#...) Source Description

00 to 7F

CPU

No error or no warning.

80

DPV1

Error according to IEC 61158-6.

81 to 8F

CPU

B#16#8x shows an error in the nth call parameter of the SFB.

FE, FF

DP Profile

Profile-specific error.

STATUS[3] can have the following values:

Error_Decode (B#16#...) Error_Code_1(B#16#...) Explanation according to DVP1 Description

00

00

 

No error, no warning.

70

00

reserved, reject

Initial call; no active data record transfer.

 

01

reserved, reject

Initial call; data record transfer has started.

 

02

reserved, reject

Intermediate call; data record transfer already active.

80

90

reserved, pass

Invalid logical start address.

 

92

reserved, pass

Illegal type for ANY pointer.

 

93

reserved, pass

The DP component addressed via ID or F_ID is not configured.

 

95

 

Error in the H system when fetching additional interrupt information (when fetching additional interrupt information at the local or distributed I/O layer via an external DP interface, this error is output as "group error").

Note: When connecting or updating, the additional interrupt information may be temporarily unavailable.

 

96

 

A master-reserve switchover has occurred in an H system, and the previous master CPU has gone into STOP mode. At that time, an OB was being processed. SFB 54 cannot supply the OB start information, management information, header information or additional interrupt information. SFC 6 "RD_SINFO" will read out the OB start information. SFC 13 "DPNRM_DG" will synchronously read the current diagnostic frame of the affected DP slave for OBs 4x, 55, 56, 57, 82 and 83 (address information from the OB start information).

 

A0

read error

Negative acknowledgement while reading the module.

 

A1

writer error

Negative acknowledgement while writing the module.

 

A2

module failure

DP protocol error at layer 2.

 

A3

reserved, pass

 

 

A4

reserved, pass

Bus communication disrupted.

 

A5

reserved, pass

 

 

A7

reserved, pass

DP slave or modules are occupied (temporary error).

 

A8

version conflict

DP slave or modules report incompatible versions.

 

A9

feature not supported

Feature is not supported by the DP slave or module.

 

AA to AF

user specific

DP slave or module report a manufacturer-specific error in its application. Check the documentation of the DP slave or module manufacturer.

 

B0

invalid index

Data record not known in module. Illegal data record number 3256.

 

B1

write length error

Wrong length specified in RECORD parameter; with SFB54: length error in AINFO.

 

B2

invalid slot

Configured slot not occupied.

 

B3

type conflict

Actual module type not equal to specified module type.

 

B4

invalid area

DP slave or module report access to an invalid area.

 

B5

status conflict

DP slave or module not ready.

 

B6

access denied

DP slave or module deny access.

 

B7

invalid range

DP slave or module report an invalid range for a parameter or value.

 

B8

invalid parameter

DP slave or module report an invalid parameter.

 

B9

invalid type

DP slave or module report an invalid type.

 

BA to BF

user specific

DP slave or module report a manufacturer-specific error when accessing. Check the documentation of the DP slave or module manufacturer.

 

C0

read constrain conflict

The module has the data record, but there is no read data, yet.

 

C1

write constrain conflict

The previous write request to the module, for the same data record, has not yet been processed by the module.

 

C2

resource busy

The module is currently processing the maximum number of jobs for the CPU.

 

C3

resource unavailable

The required operating resources are currently occupied.

 

C4

 

Internal temporary error; the job could not be executed. Repeat the job. If this error occurs often, check the plant for sources of electrical interference.

 

C5

 

DP slave or module unavailable.

 

C6

 

Data record transfer was canceled due to priority class cancellation.

 

C7

 

Job canceled due to a warm or cold restart of the DP master.

 

C8 to CF

 

DP slave or module reports a manufacturer-specific resource error. Check the documentation of the DP slave or module manufacturer.

 

Dx

user specific

DP slave specific; refer to the DP slave description.

81

00 to FF

 

Error in the initial call parameter (with SFB54: MODE).

 

00

 

Illegal operating mode.

82

00 to FF

 

Error in the second call parameter.

:

:

 

:

88

00 to FF

 

Error in the eighth call parameter (with SFB54: TINFO).

 

01

 

Wrong ID syntax.

 

23

 

Quantity frame exceeded or target area too small.

 

24

 

Wrong ID range.

 

32

 

DB/DI number out of user range.

 

3A

 

DB/DI number is NULL for the ID area  DB/DI, or the specified DB/DI does not exist.

89

00 to FF

 

Error in ninth call parameter (with SFB54: AINFO).

 

01

 

Wrong ID syntax.

 

23

 

Quantity frame exceeded or target area too small.

 

24

 

Wrong ID range.

 

32

 

DB/DI number out of user range.

 

3A

 

DB/DI number is NULL for the ID area  DB/DI, or the specified DB/DI does not exist.

8A

00 to FF

 

Error in the tenth call parameter.

:

:

 

:

8F

00 to FF

 

Error in the fifteenth call parameter.

FE, FF

00 to FF

 

Profile-specific error.

With DPV1 errors, the DP Master passes on STATUS[4] data to both the CPU and SFB. Without the DPV1 error, this value is set to 0, with the following exceptions for the SFB52 (Read Record):

  • STATUS[4] contains the target area length from RECORD, if MLEN is greater than the target area length from RECORD.
  • STATUS[4] equals MLEN, if the actual data record length is less than MLEN, and MLEN is less than the target area length from RECORD.
  • STATUS[4] equals 0, if STATUS[4] is greater than 255, 255 would have to be set.