LD UDFB Guided Learning Q16: – How can a UDFB's fault status string be used with an HMI?

This article is part of a guided learning series on building and analyzing User-Defined Function Blocks (UDFBs).

:pushpin: Canonical Article: Building a User-Defined Function Block (UDFB) Using Siemens TIA Portal
:blue_book: Learning Companion (Q&A): Explore All Questions

You are reading: Question 16

How can a UDFB’s fault status string be used with an HMI?

Clarification

The featured code provides an output string describing the reason for the fault. How can these strings be captured and used as part of a smart diagnostics tool?

Answer

This is left as a design exercise for advanced students.

Tech Tip: The techniques described in this note are considered standard for embedded microcontroller programming. However, not all PLCs are capable of performing the indexed memory operations. See this article for a brief introduction to array indexing.

  • The featured code reports the status as a 50-character string. For example, “Failed to close”. These are useful as-is for a technician who has access to the program and is actively monitoring the instantiation of the motor starter UDFB. Unfortunately, not all technicians will have access to the PLC program. Instead, it may be beneficial to capture and preserve the strings as part of a larger error reporting procedure.

Assuming a modular system with multiple UDFBs we could perform the following steps:

  1. Prepend: It is first necessary to prepend a unique identifier to the string. For instance, we could modify the UDFB to accept a string modifier. An example would be printed as “Pump 1: failed to close.”

  2. Date-time stamp: Add a date-time stamp so that we know precisely when the fault occurred. This is an essential step especially for a system where cascade failures occur. The timestamp allows us to determine the order of the failures which can greatly simplify the troubleshooting process.

  3. Store: Next, the individual strings should be collected and moved to an array of strings. With clever use of pointers, we should be able to store each string in the next available slot.

  4. Retrieve: The final step is to retrieve the message strings from a purpose-built HMI diagnostics screen. Once again, pointers are the key to retrieve array elements.

Tech Tip: Remember to use the most appropriate language for the task at hand. The previous description with indexing into arrays of strings could be described as intermediate to advanced PLC programming. The technique along with ring buffers would be better known to programmers from the computer science side of the house. It may be appropriate to lean into a Structured Text (ST) implementation.

:writing_hand: Article by Aaron Dahlen, LCDR USCG (Ret.), Application Engineer at DigiKey