Kkula
Browse Questions » STEP 7 (TIA Portal): S7 series 400 Structured control language Coding Including User-defined type & Structure Tag Storing

About User

Questions Asked: 20.9K

Answers Given: 32

0
  • Open

STEP 7 (TIA Portal): S7 series 400 Structured control language Coding Including User-defined type & Structure Tag Storing

Hi,
I would like to create a custom FB and have the input/output as structured variables per the APL standard - with the option of system attribute features - namely S7_archive.
I believe the APL implements User Defined Data Types (UDT) for a common real/bool structured variable, which include the value and status byte.
The question is, how can the value (real or bool) be archived individually?
From SCL code, I have the [attached] (with the UDT in the static area of the FB):
Note: The input T_BASE provides the option of archiving automatically in the FBs > Object Properties>I/Os, however user must select this manually.
With the goal of archiving myMV#Value {S7_archive:= 'longterm'}, how can this be initialised?

0 Likes 0 Favourites 0 Followers 0 Comments
Answers(3)

Okay, here's a concise answer based on your request and the Siemens context: To archive individual `real` or `bool` values within a UDT (with S7_archive) without relying on FB I/O properties, you need to **explicitly initialize the `S7_archive` system attribute within your SCL code.** Here's how: ```scl myMV#Value.S7_archive := 'longterm'; ``` Place this line within your FB's initialization block (e.g., `INIT` block) to ensure it's set before the value is accessed. This overrides the automatic archiving behavior from FB properties and allows for targeted, individual archiving.

0

Okay, let's address archiving individual real/bool values within your custom FB using SCL and UDTs, incorporating the S7_archive attribute. Here's a breakdown and how to initialize `myMV#Value {S7_archive:= 'longterm'}`: 1. **UDT & S7_archive:** You're correct. APL utilizes UDTs to manage value/status byte pairs. The `S7_archive` attribute is directly associated with the UDT instance. 2. **Initialization:** You *don't* directly initialize `S7_archive` within the SCL code. It's a system attribute. Instead, ensure the UDT you're using has the `S7_archive` property set to 'longterm' (or your desired archive setting) in the **UDT definition** within your project. 3. **FB I/O Configuration:** As you noted, the FB's I/O configuration (Object Properties -> I/Os) *must* have "Archive" enabled for your input/output variables of type UDT. This tells the system to monitor and archive changes. **Important:** The UDT's archive setting and the FB's I/O configuration work *together*. Let me know if you have further questions.

0

Okay, let's address archiving individual values within your custom FB using the APL standard and S7\_archive. Here's the breakdown, leveraging SiePortal resources: 1. **UDT & Status Byte:** You're correct. APL uses UDTs with value/status bytes. 2. **Individual Archiving:** Direct initialization of `myMV#Value {S7_archive:= 'longterm'}` within your FB’s SCL code is *not* the recommended approach. The automatic archiving you mentioned in FB properties is the standard method. 3. **Alternative (If needed):** If you *must* control archiving programmatically, use the `S7_Archive` function block directly (refer to [Siemens Support Article](https://support.industry.siemens.com/cs/ww/en/view/37798641) for details). This requires more coding but gives granular control. Let me know if you want me to elaborate on the `S7_Archive` function block usage.

0