PLCcheck

S5 AWL Constant Formats: KF, KH, KM, KC, KT, KZ, KY

Complete reference for all S5 AWL constant formats: KF (fixed-point), KH (hex), KM (bit mask), KC (character), KT (timer), KZ (counter), KY (two-byte). With S7 equivalents.

·5 min read
S5AWLconstantsKFKHKMKCKTKZKYBCDtimerhex

Diesen Artikel auf Deutsch lesen

S5 AWL Constant Formats: KF, KH, KM, KC, KT, KZ, KY

S5 AWL uses prefix letters to define constant types. Each format specifies how the 16-bit value is interpreted. Understanding these is essential for reading S5 code and converting to S7.

Complete Reference

KF — Fixed-Point Integer (Festpunktzahl)

L  KF +100         // Load integer 100
L  KF -32768       // Load minimum INT value
L  KF +32767       // Load maximum INT value

Range: -32768 to +32767 (16-bit signed integer) S7 equivalent: L 100 or L W#16#0064

KH — Hexadecimal (Hexadezimalzahl)

L  KH 00FF         // Load hex 00FF = decimal 255
L  KH FFFF         // Load hex FFFF = decimal 65535 (or -1 as INT)
L  KH 0001         // Load hex 0001 = decimal 1

Range: 0000 to FFFF (16-bit unsigned) S7 equivalent: L W#16#00FF Typical use: Bit masking, hardware register manipulation

KM — Bit Pattern (Bitmuster)

L  KM 11110000 00001111    // Load 16-bit mask: F00F hex
L  KM 00000000 00000001    // Load bit 0 set = 1

Format: 16 binary digits, space-separated into two bytes (high byte first) S7 equivalent: L 2#1111000000001111 Typical use: Bit manipulation with UW/OW/XOW operations

KC — Character (Zeichen)

L  KC AB            // Load ASCII characters 'A' and 'B'

Format: Exactly 2 ASCII characters. Stored as two bytes — first character in high byte, second in low byte. S7 equivalent: L 'AB' Note: Only 2 characters per constant. For longer strings, S5 uses multiple KC loads or data blocks.

KT — Timer Value (Zeitwert)

L  KT 030.2         // 30 × 1s = 30 seconds
L  KT 100.0         // 100 × 10ms = 1 second
L  KT 050.1         // 50 × 100ms = 5 seconds
L  KT 300.3         // 300 × 10s = 3000 seconds = 50 minutes

Format: KT value.timebase — value is BCD (000–999), timebase selects resolution.

TimebaseResolutionMax Duration
010 ms9.99 s
1100 ms99.9 s
21 s999 s ≈ 16.6 min
310 s9990 s ≈ 2.8 h

S7 equivalent: L S5T#30s or use IEC timer with T#30s See also: S5 Timer Conversion Guide

KZ — Counter Value (Zählwert)

L  KZ 050           // Counter preset value = 50
L  KZ 999           // Maximum counter value

Format: BCD value 000–999 S7 equivalent: L C#50

KY — Two-Byte Constant (Zwei-Byte-Konstante)

L  KY 10,20         // High byte = 10, low byte = 20
L  KY 0,5           // High byte = 0, low byte = 5

Format: Two decimal values 0–255, comma-separated. High byte first. S7 equivalent: L B#(10, 20) Typical use: Timer type/value combinations, parameter passing to function blocks

Quick Conversion Table

S5 ConstantS7 EquivalentExample
KF +100100Integer
KH 00FFW#16#00FFHex word
KM 11110000 000011112#1111000000001111Bit pattern
KC AB'AB'Characters
KT 030.2S5T#30sTimer value
KZ 050C#50Counter preset
KY 10,20B#(10, 20)Two bytes

Part of the S5 AWL Command Reference. Maintained by PLCcheck.ai.


Analyze Your S5 Code Automatically

PLCcheck Pro reads your complete S5 AWL program and explains every instruction — including this one — in plain language. Upload your code and get instant documentation, S7 equivalents, and migration guidance.

Upload S5 code for free analysis → | S5→S7 Migration Guide →

Related Articles

Analyze your PLC code with AI

PLCcheck Pro explains, documents, optimizes, and migrates PLC code — automatically.

Try PLCcheck Pro →
← Back to Blog

Not affiliated with Siemens AG. S5, S7, STEP 5, STEP 7, and TIA Portal are trademarks of Siemens AG.