BCD and S5TIME (Siemens)
Two tools in one: BCD, where each decimal digit takes 4 bits, and S5TIME, the Siemens timer format that combines a time base with three BCD digits. Type a value or paste a hex word.
BCD: each digit in 4 bits
| BCD | 16#1234 |
|---|
S5TIME: time base + 3 BCD digits
| S5TIME | W#16#2150 |
|---|
| bit 13–12 | Time base | Resolution | max |
|---|---|---|---|
00 | 10 ms | 10 ms | 9.99 s |
01 | 100 ms | 100 ms | 1 min 39.9 s |
10 | 1 s | 1 s | 16 min 39 s |
11 | 10 s | 10 s | 2 h 46 min 30 s |
Indicative results: always verify with a qualified technician and the applicable standards. Legal notice
BCD: one digit every 4 bits
In BCD (Binary Coded Decimal) every decimal digit takes one nibble: 1234 becomes 0001 0010 0011 0100 = 16#1234, while in plain binary it is 16#04D2. The combinations A to F are invalid. BCD is found in thumbwheel switches, 7-segment displays, the CPU clock, the S5TIME and DT formats and some encoders.
BCD in Siemens instructions
The BTI/ITB instructions and CONVERT with BCD16 use only 3 digits and put the sign in the top 4 bits (0000 = positive, 1111 = negative): range −999 to +999. BCD32 (BTD/DTB) uses 7 digits, −9999999 to +9999999. This tool shows the “plain” 4-digit BCD (0–9999) of thumbwheels and displays; if the word contains a digit above 9 the PLC raises a BCD error.
How S5TIME is built
S5TIME is a 16-bit word: bits 15–14 are unused, bits 13–12 are the time base and bits 11–0 three BCD digits. Bases: 00 = 10 ms (up to 9.99 s), 01 = 100 ms (up to 99.9 s), 10 = 1 s (up to 999 s), 11 = 10 s (up to 9990 s = 2h46m30s). Example: S5T#2M30S = 150 s, with base 1 s and digits 150, i.e. W#16#2150.
Which base the PLC picks
When you type S5T#… STEP 7 and TIA Portal pick the smallest base in which the value fits in 999, so the resolution is the best possible. The value is truncated to the base: 12345 ms becomes 12.3 s. On S7-1200/1500 CPUs prefer IEC timers (TON, TOF, TP) with TIME; S5TIME remains for programs migrated from S7-300/400.
Frequently asked questions
What is W#16#2127 as S5TIME?
Bits 13–12 are 10, i.e. time base 1 s; the three BCD digits are 127. The time is 127 × 1 s = 127 s = S5T#2M7S.
What is the maximum S5TIME?
S5T#2H46M30S, i.e. 999 × 10 s = 9990 s, stored as W#16#3999.
What is the difference between BCD and binary?
In binary 1234 is 16#04D2; in BCD each digit gets its own nibble and 1234 becomes 16#1234. BCD wastes combinations (A–F are invalid) but is handy for displays and thumbwheel switches.
Why does my S5TIME lose a few milliseconds?
With 3 digits not every time can be represented: 12345 ms needs the 100 ms base and becomes 123 × 100 ms = 12.3 s. The rest (45 ms) is truncated.
How do I convert S5TIME to TIME in TIA Portal?
With the S5TI_TIM (S5TIME to TIME) and TIM_S5TI (TIME to S5TIME) instructions. S7-1200 does not support S5TIME; S7-1500 does, for compatibility.