Content: Обработка строк и текстовых данных_парсинг и форматирование в Structured Text.pdf (2.05 MB)
Uploaded: 07.08.2026

Positive responses: -1
Negative responses: 0

Sold: -1
Refunds: -1

~ $3.58
The exact amount is on the payment page
This training manual addresses one of the most underestimated yet critically important topics in PLC programming — text data processing in Structured Text (ST) according to the IEC 61131‑3 standard. Unlike scattered articles and forum tips, this book provides a holistic, industry‑oriented system for working with strings: from buffer declaration and basic functions to parsing operator commands, interpreting process commands, validation, generating correct CSV reports, event logging with a circular buffer, and even EAN‑13 barcode generation with checksum calculation.

The book is built around real engineering challenges: HMI commands, protocol exchange, reporting, and product marking. Every example includes complete ST code, test tables with boundary and error cases, and lab assignments for practice. Special emphasis is placed on overflow protection, handling non‑numeric values, empty strings, and incorrect delimiters — exactly what causes line stops and scrap in real operation.

Key features:

Fully functional code of all functions and function blocks with comments in Russian.

10 thematic chapters and 8 lab assignments covering the complete cycle from syntax to industrial application.

Adapted for CoDeSys V3.5 and TwinCAT 3 (with notes on file‑system dependencies).

Verified for compliance with IEC 61131‑3 syntax, with clear notes on platform differences.

Consistent naming conventions and engineering discipline, making the code reusable as a template for real projects.

A comprehensive end‑to‑end example — a product barcoding system — that ties together all techniques learned.

Ideal for PLC engineers, technical students, and automation instructors. The manual turns strings from a source of errors into a manageable, verifiable interface of an industrial system.
Chapter 1: Introduction to Industrial Text Data Processing — Five use cases (HMI commands, protocols, reports, barcodes, logs). STRING specifics: fixed length, null terminator, 255‑character limit. Overview of LEN, LEFT, RIGHT, MID, CONCAT, FIND, INSERT, DELETE, REPLACE. Common mistakes and how to avoid them.

Chapter 2: Basic String Operations — Buffer declaration and memory allocation. Concatenation with CONCAT (nested calls and intermediate variables). Extracting substrings (LEFT, RIGHT, MID) with position numbering (starts at 1). FIND and mandatory zero check. In‑place editing (INSERT, DELETE, REPLACE). String comparison and lack of built‑in TRIM. Lab: F_TrimSpaces.

Chapter 3: Tokenization and String Parsing — Tokenization using WHILE + FIND + LEFT/RIGHT. Handling empty tokens, repeated delimiters, delimiters at edges. Predicate F_IsDigit. Key‑value pair parsing with a validity flag. From tokens to data structures. Lab: F_GetNthToken.

Chapter 4: Parsing Operator Commands from HMI — Key‑value format separated by commas. ST_ProcessRecipe with Valid and ErrorCode. Sequential pass algorithm, format error handling (missing ´:´, unknown key, non‑numeric value, incomplete set). Execute/Busy/Done pattern. Full FB_RecipeParser with tests. Lab: adding PRESSURE parameter and backward compatibility analysis.

Chapter 5: Process Command Interpreter — Imperative commands vs. data. Why CASE doesn´t work with strings — IF/ELSIF chain. E_CmdResult enumeration. FB_ProcessCommandInterpreter with mutually exclusive output protection. Integration with HMI (buffer, handshake). Lab: multi‑parameter command (MODE:AUTO,SP:75).

Chapter 6: Number‑to‑String and Back — Limitations of built‑in STRING_TO_* (undefined behavior). Custom F_StrToUDInt and F_StrToDInt with bOK flag and overflow protection via pre‑check. Formatting REAL with fixed decimals (rounding, zero padding, avoiding "‑0.00"). F_SecondsToHMS. Lab: thousand separator for integers.

Chapter 7: Input Data Validation — Four levels: length, characters/format, type conversion, technological range. E_RecipeValidation error classes. Range checks for REAL/DINT/UDINT. Forbidden character check. Validation pipeline and FB_RecipeValidator. Lab: integration with parser and blocking start.

Chapter 8: Message Formatting and CSV for Reports — Building CSV with field escaping (delimiter, quotes, CR/LF, doubling quotes). Building a line from an array of fields. Length and overflow control. Production report example. Lab: semicolon delimiter and handling fields containing semicolon.

Chapter 9: Event Logging to Text Files — Log structure (timestamp, severity, message). Edge detection for unique entries. Circular buffer in memory (FB_EventLogger) with record and lost counters. Reading buffer chronologically. Non‑blocking architecture: file adapter, states, rotation. Lab: implementing logging core.

Chapter 10: Comprehensive Example — Product Barcoding System — Building internal product number (line, shift, day, counter). EAN‑13 checksum calculation (GS1 algorithm). Assembling full 13‑digit barcode. FB_BarcodeSystem with edge protection and error codes. CSV report and log entry. Limitations and industrial requirements (persistent counter, uniqueness, GS1).

Appendices — Summary table of string functions, position conventions, what to check after FIND. Diagnostic data types (E_OperationResult, ST_Diagnostic, bit masks). Project structure. Portability notes for CODESYS, TwinCAT, Siemens SCL, Rockwell, OpenPLC. String code checklist. Minimal test set. How to document industrial code.
No feedback yet