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.
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.
| Timebase | Resolution | Max Duration |
|---|---|---|
| 0 | 10 ms | 9.99 s |
| 1 | 100 ms | 99.9 s |
| 2 | 1 s | 999 s ≈ 16.6 min |
| 3 | 10 s | 9990 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 Constant | S7 Equivalent | Example |
|---|---|---|
| KF +100 | 100 | Integer |
| KH 00FF | W#16#00FF | Hex word |
| KM 11110000 00001111 | 2#1111000000001111 | Bit pattern |
| KC AB | 'AB' | Characters |
| KT 030.2 | S5T#30s | Timer value |
| KZ 050 | C#50 | Counter preset |
| KY 10,20 | B#(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
S5 Timer Conversion: KT Values to IEC Timers
Complete guide to converting Siemens S5 KT timer values to S7 IEC timers (TON, TOF, TP). Includes BCD format explanation, conversion table with 20+ examples, and behavior differences between S5 and IEC timers.
12 min read
migration-guideMigrating S5 Counter Programs (Z/ZV/ZR) to S7
How to migrate S5 counter programs to S7. Covers ZV (count up), ZR (count down), BCD format differences, S7 equivalents (S_CU, S_CD, CTU, CTD, CTUD), and common pitfalls.
10 min read
plc-documentationReading and Understanding S5 AWL Code: A Practical Guide
Learn to read Siemens S5 AWL (Instruction List) code from scratch. Covers the accumulator model, bit logic, load/transfer, timers, counters, jumps, and data blocks with real code examples and line-by-line explanations.
16 min read
Analyze your PLC code with AI
PLCcheck Pro explains, documents, optimizes, and migrates PLC code — automatically.
Try PLCcheck Pro →Not affiliated with Siemens AG. S5, S7, STEP 5, STEP 7, and TIA Portal are trademarks of Siemens AG.