How-to
S5TIME to TIME conversion for HMI display and preset entry
Short answer
Convert the Siemens S5TIME timer value to a 32-bit TIME in milliseconds inside the PLC and expose that tag to the panel, which scales it by 1,000 for seconds or 60,000 for minutes. For preset entry, write whole minutes to a setpoint tag and convert back in the PLC. Bits 12-13 of the S5TIME word carry the time base, bits 0-11 the BCD value 0-999, and bits 14-15 stay zero.

On this page
The timer value your PLC hands you is not a number a panel can display: S5TIME packs a time base and a BCD value into 16 bits, so reading the word as an integer shows 12432 where you expect 15 minutes. Keep the conversion in the PLC. Decode the S5TIME word into a 32-bit TIME value in milliseconds, give the panel that tag, and let the panel's scaling show seconds or minutes. For preset entry, run it the other way: the panel writes whole minutes to a setpoint tag and the PLC converts that to TIME and then to S5TIME before it reaches the timer.
What the S5TIME word actually holds #
Per the STEP 7 data type documentation, S5TIME stores a duration as the product of a time value in the range 0 to 999 and a time base, and the value part is BCD, not binary:
| Bits | Contents | Encoding |
|---|---|---|
| 14-15 | Reserved | Zero when writing a preset |
| 12-13 | Time base | 00 = 10 ms, 01 = 100 ms, 10 = 1 s, 11 = 10 s |
| 0-11 | Time value | BCD, 0 to 999 |
BCD means each group of four bits is one decimal digit: bits 8-11 are the hundreds, bits 4-7 the tens, bits 0-3 the units. A binary count dropped into those twelve bits corrupts the preset, because a binary 90 and a BCD 90 are different bit patterns.
Read elapsed time: decode the word in the PLC #
- Take the timer's current-time output as a 16-bit word.
- Isolate the base with word AND 16#3000, shift it right twelve places, and read 0, 1, 2 or 3.
- Convert that to the multiplier: 0 gives 10 ms, 1 gives 100 ms, 2 gives 1 s, 3 gives the largest multiplier.
- Isolate the value with word AND 16#0FFF and decode each nibble as a decimal digit: hundreds, tens, units.
- Multiply the decoded value by the multiplier into a DINT. That DINT is your TIME tag in milliseconds, and it is what the panel reads.
Your programming environment may ship ready-made blocks for this: in TIA Portal, T_CONV converts a TIME value to S5TIME, and the same block family covers the reverse direction. If you use a block, verify it against your exact tool version and target family before you trust it.
Scale the millisecond tag on the panel #
Create a signed 32-bit integer tag mapped to the converted DINT, then attach the display scaling: divide by 1,000 to show seconds, divide by 60,000 to show minutes. If your panel implements scaling as gain times PLC value instead of a division, the minutes gain is 1/60000, and short gain fields round it badly enough to shift the displayed value. Before you pick the gain digits, read Why an HMI gain of 0.0166667 rounds your minutes-to-seconds input (article:why-an-hmi-gain-of-0-0166667-rounds-your-minutes-to-seconds-input). Label the screen after you know what the tag means: decide whether the timer word you decoded is elapsed or remaining time, and write that on the object. The conversion changes representation only; it does not change the timer's counting direction.
Write a preset from the panel #
- Give the operator a numeric entry in whole minutes, on a plain signed integer setpoint tag.
- In the PLC, convert that integer to DINT and multiply by 60,000 to get the TIME value in milliseconds.
- Validate it: reject negative entries and reject anything the S5TIME word cannot encode, using the limits in the next section.
- Convert the TIME value to S5TIME with the tool's conversion block, such as T_CONV in TIA Portal, and feed the result to the timer's preset input.
If your project is in TIA Portal and you need the panel-side mechanics of the entry field and data format, they are covered in Enter S5TIME timer presets from an HMI in TIA Portal (article:enter-s5time-timer-presets-from-an-hmi-in-tia-portal). Build the preset through the conversion block rather than writing the raw word; if you ever assemble the word yourself, keep the two reserved bits at zero and put only BCD digits in the value field. Other controller families sidestep this encoding entirely because their timer presets are plain millisecond values from the start; the way entered time in milliseconds maps onto such presets is described in RSLogix 5000 timer preset values entered in milliseconds.
Worked example: 15 minutes on the screen, 10 minutes into the preset #
Display path. The timer's current-time word reads 16#3090, which is 12432 as an integer. Base bits: 16#3090 AND 16#3000 gives 16#3000, shifted right twelve places that is 3, so the multiplier is 10 s. Value bits: 16#3090 AND 16#0FFF gives 16#090, whose nibbles decode as the digits 0, 9 and 0, so the value is 90. Elapsed time: 90 x 10 s = 900 s = 900,000 ms. The panel divides 900,000 / 60,000 and shows 15 minutes, or 900,000 / 1,000 = 900 seconds.
Entry path. The operator types 10 on the minutes field. The PLC computes 10 x 60,000 = 600,000 ms. T_CONV encodes that as value 60 at the 10 s base, since 60 x 10 s = 600 s = 10 min, producing the word 16#3060: base bits 3, BCD digits 060. The timer counts down from ten minutes, and the same decode path from the display section returns its running value to the screen.
The limits that decide #
One S5TIME word tops out at 999 multiplied by the largest time base, giving 9,990 s, about 2 h 46 min 30 s. The millisecond TIME tag carries far more, because a signed 32-bit DINT reaches 2,147,483,647 ms, roughly 24.8 days, but the timer preset still caps at what the word can encode, so longer durations need the program to chain timer intervals. BCD nibbles hold only the digits 0 through 9, and the two reserved bits must stay zero in any preset you assemble by hand.
The decision, for both cases: decode and convert in the PLC for display, scale at the panel; take minutes at the panel, convert in the PLC for the preset. Never map the raw S5TIME word to a panel integer tag and treat it as minutes or milliseconds. Run the full read-decode-enter loop on a bench against a known preset before you rely on it where the timed delay guards an interlock.
Questions asked
Why does my panel show a strange number when I point it at the timer word?
The word is not a plain count. Bits 12-13 select the time base and bits 0-11 hold a BCD value, so a preset of 15 minutes stored as 90 at the largest time base reads as 12432 when the panel treats it as an integer. Decode the word in the PLC and hand the panel a millisecond TIME tag instead.
What is the longest duration one S5TIME word can hold?
The BCD field stops at 999 and the largest time base is 10 s, so one word reaches 9990 s, which is 2 hours 46 minutes 30 seconds. The millisecond TIME tag itself carries far more, roughly 24.8 days, but the timer preset still caps at what the S5TIME word can encode.
How should the operator enter a duration longer than that word limit?
Let the panel accept minutes and have the PLC multiply by 60,000 into the millisecond tag before converting. If the preset exceeds the S5TIME word capacity, the program has to split the duration into a counted number of timer intervals, because the timer input cannot take the extra length in one preset.
Which side should do the conversion, the panel or the PLC?
The PLC, in both directions. The PLC decodes S5TIME to a millisecond tag for display and converts the entered minutes back to S5TIME for the preset. The panel only divides milliseconds into the unit on screen. Mapping the raw timer word straight to a panel integer tag is the mistake behind most wrong timer screens.


