IMDTouchKnowledge BaseShop main store

How-to

Enter S5TIME timer presets from an HMI in TIA Portal

HMI and touchscreens Published 7 min read

Short answer

The panel cannot enter S5TIME directly: it is a packed 16-bit BCD word with a time-base code, not a number. Declare a TIME tag (a DInt of milliseconds) in a global DB, let the HMI write that tag, and convert it to S5TIME with T_CONV before the timer's preset input. S5TIME needs a word address such as MW20, not MD20.

On this page
  1. Why won't the HMI accept an S5TIME entry?
  2. How is an S5TIME value stored in the CPU?
  3. Which tags do I create in the PLC program?
  4. How do I convert the entry to S5TIME with T_CONV?
  5. What does the HMI side of the entry field need?
  6. Why does the compiler reject my S5TIME tag address?
  7. How long can an entered timer preset be?
  8. How do I test the entry before startup?
  9. Questions asked

A panel field cannot hold an S7-300 S5TIME value and still show the operator a readable time, because S5TIME is a packed word: twelve bits of BCD count plus a two-bit time-base code, not a plain number. The working route takes three moves. Put a TIME tag — a 32-bit DInt counted in milliseconds — in a global data block, let the HMI write that tag, and convert it to S5TIME with T_CONV in the PLC before the timer's preset input. The S5TIME tag must sit on a word address, not a double-word, and the encoding caps how long a single preset can be. The sections below give the bit layout, the tags, the conversion network, the panel field and the limits.

Why won't the HMI accept an S5TIME entry? #

You can force a raw word through, but the operator then types the packed internal code instead of a time, so the working answer is to let the panel write a TIME tag in milliseconds and convert it to S5TIME in the PLC with T_CONV.

An I/O field on a WinCC panel writes a plain binary integer, and no panel data format fills twelve BCD bits plus a two-bit base code in one keystroke. Point the field at the timer word anyway and one of two things happens: the compiler rejects the data type, or the write lands and the timer counts a nonsense duration. Both come from the same root cause, so fix the structure, not the field — the panel owns a readable number, the PLC owns the encoding.

How is an S5TIME value stored in the CPU? #

S5TIME is a 16-bit word whose lowest twelve bits hold the count as BCD digits from 0 to 999 and whose bits 12 and 13 hold the time base, one of 10 ms, 100 ms, 1 s or 10 s.

Bits 14 and 15 stay zero. The base codes read 00 for 10 ms, 01 for 100 ms, 10 for 1 s and 11 for 10 s. Worked by hand, a 25 s preset on the 1 s base stores BCD digits 2 and 5 — 0x25 in bits 0 to 11 — under base code 10 in bits 12 and 13, which makes the word 16#2025. Read as an unsigned decimal, that word is 8229, which is why nobody should type it on a keypad. The gap between the digits the operator means and the word the CPU holds is the same trap that makes an HMI counter display jump from 9 to 16 when a BCD value is shown as binary.

Which tags do I create in the PLC program? #

Create a global data block with two tags: Preset_TIME of type TIME for the panel entry and Preset_S5T of type S5TIME for the conversion result, then wire Preset_S5T to the timer's preset input.

In a block such as DB10, Preset_TIME takes four bytes because TIME is a 32-bit DInt counted in milliseconds, and Preset_S5T takes two. Keep both out of the M area: M0.0 sits inside MB0, MW0 and MD0, so a bit written for one purpose silently rewrites the byte, word and double-word views of the same memory, while DB tags give every value its own bytes. If the entered preset has to survive a power-down, the retention setup is its own task, and how to keep HMI-entered timer presets in PLC memory covers it.

How do I convert the entry to S5TIME with T_CONV? #

Place T_CONV in a network that runs every scan, connect the TIME tag to its input, set the output data type to S5TIME and pass the result tag to the timer call, so the conversion tracks each new panel value.

  1. Add a network to OB1, or to a block that OB1 calls every scan.
  2. Insert T_CONV from the conversion group of the instruction palette.
  3. Wire Preset_TIME to the input, choose S5TIME as the output type and assign Preset_S5T.
  4. In the timer network — an S_ODT on T150, for example — connect Preset_S5T to the TV input, the timer's time value.
  5. Go online and confirm Preset_S5T changes whenever the panel writes a new value.

T_CONV does the packing itself: it selects the time base and builds the BCD digits, so the base is never set by hand. Because the entry tag is already TIME, the older Int → DInt → Time detour that raw integer entries force never appears in this structure.

What does the HMI side of the entry field need? #

Bind an I/O field on the screen to the TIME tag so the operator's entry lands in DB10 as milliseconds, and label the field with its unit so the number on the keypad is the number in the PLC.

Two entry styles both work. Without scaling, the field carries milliseconds and the operator types 25000 for a 25 s preset — exact, but unfriendly. With linear scaling in the tag's properties, the operator types seconds and the tag multiplies the entry by 1000 on the way to the PLC, so an entry of 25 arrives as 25000; check the scaling direction on the tag before the first real write. Either way, set the tag to a cyclic acquisition mode so the field tracks the PLC value instead of a snapshot taken once. Storing milliseconds in the controller while the operator works in friendly units is a pattern other controller families use too — the article on BRX timer presets using milliseconds for hour-based entry shows the same idea on a different platform.

Why does the compiler reject my S5TIME tag address? #

The compiler flags an S5TIME tag parked on a double-word address because S5TIME is a word: it needs a two-byte location such as MW20, not a four-byte MD20.

The same width rule puts Preset_TIME on a four-byte offset and Preset_S5T on the next two-byte offset in DB10. If the S5TIME line shows a width error, move the tag to the next free word boundary and recompile. A mismatch that slips past the compiler is quieter and worse — the panel writes happily and the value inside the PLC is wrong. That silent failure class is exactly what why an HMI writes the wrong PLC value above 9 documents on a live project, so match the panel tag's type and width to the PLC declaration every time.

How long can an entered timer preset be? #

Whatever the panel lets the operator type, the converted preset cannot exceed 9990 s, because the largest BCD count of 999 on the largest 10 s base gives 999 × 10 s = 9990 s, roughly 2 h 46 min 30 s.

A 4 h hold is 14400 s, which no single S5TIME word carries, so the structure changes: run the first timer at the full 9990 s and let its done bit start a second timer preset for the remaining 4410 s. Limit the entry field's range so no operator can ask for more than the encoding holds, and keep longer recipes in chained timers rather than in a bigger number.

How do I test the entry before startup? #

Prove the chain on the bench before the machine sees it: enter a known value such as 5 s, confirm the TIME tag holds 5000, watch the S5TIME tag change to its converted code, and time the output with a stopwatch.

Simulate the PLC and the panel together, write the value from the field, and check three things in order: the TIME tag matches the entry, the S5TIME tag follows through T_CONV, and the timer output closes for the set duration when you trigger the start condition. Keep the machine's outputs disabled during the bench run so a mistyped preset cannot move real equipment. Then stop the timer mid-run, enter a shorter value, and confirm the running timer picks up the new preset on its next call. Repeat the same three checks against the real panel over the real connection before sign-off, since a simulation proves the logic but not the panel's write path.

Questions asked

Can one entered preset feed more than one timer?

Yes. The converted S5TIME tag is an ordinary word in a DB, so several timer boxes can take it as their preset input and all of them start with the same duration. When timers need different durations, create one TIME tag and one S5TIME tag for each duration instead of rescaling a shared tag.

Can I skip the conversion and write the S5TIME word straight from the panel?

Only as a diagnostic. A Word tag will carry the raw value, but the operator would be typing the packed internal code, and the 25 s preset from the worked example reads as 8229 on a decimal keypad. Keep the TIME tag plus T_CONV for anything an operator touches, and reserve a raw word view for troubleshooting screens.

Which timer instructions does the converted preset feed?

All five classic S7-300 timer boxes, meaning pulse, extended pulse, on-delay, latched on-delay and off-delay, take S5TIME at their preset input, so the converted tag wires to any of them. The IEC timer instructions that accept TIME directly are not offered on S7-300 CPUs, which is why the conversion step cannot be skipped.

Which TIA Portal versions does this work in?

T_CONV is documented in the STEP 7 Professional V13.1 instruction help and is present in V15-class projects, which is what this procedure targets. STEP 7 classic projects use the identical S5TIME format, so the tag layout and the word-address rule carry over unchanged; only the palette and the project tree differ.

Keep reading

  • Troubleshooting

    Why a WinCC flexible 2008 I/O field rejects fractional timer values

    In WinCC flexible 2008 SP3 an I/O field formats a raw word; it does not convert a typed 2.5 or 0.1 into an S5Time duration, which is a time-base code plus three BCD digits. Connect the field to an integer preset in tenths of a second, encode S5Time in the PLC, and verify by reading the word back.

    HMI and touchscreens

  • How-to

    How to Display a Time-Until-Closed Countdown on an HMI

    Display time until closed by computing the timer preset minus the accumulated value (.PRE - .ACC) in the PLC and binding the numeric display to that result. Clamp the value to zero when the done bit sets, keep the operator's duration in its own tag, and let the timer-done rung in the controller close the valve - never the panel.

    HMI and touchscreens

  • How-to

    PLC timer value on an HMI: start, stop and show after a win

    Time the run in the PLC, not on the panel. A TONR accumulator runs while Sensor 1's run-active bit is high, Sensor 2 copies the elapsed value into a result tag and sets the win bit, and the KTP600 shows that one tag on an I/O field while the PLC-driven screen change opens the winning screen.

    HMI and touchscreens