IMDTouchKnowledge BaseShop main store

Troubleshooting

Why a String Change Trigger Misses HMI Logout

HMI and touchscreens Published 6 min read

Short answer

A String Change trigger on the HMI user name fires when someone logs in but not when logout clears the name, because the runtime ends the session instead of editing text. Detect logout with an Express Condition comparing $Logout_Time with 0, which covers manual logout and automatic expiry alike, and attach the login macro to the OK key of the User Login (40003) keyboard.

On this page
  1. Why the string-change trigger misses logout
  2. Read the panel across three session states
  3. Testing the zero comparison on a G2100E at DTools Pro 1.10
  4. Configure the logout condition and its macro
  5. Run the login macro from the keyboard OK key
  6. Test on the panel and remove the overlapping trigger
  7. Questions asked

On a Kinco panel at DTools Pro 1.10, a Global Control String Change trigger on $User_Name fires the macro every time someone logs in and never at logout. Logout ends the session instead of editing the text, and the clear-to-empty transition does not fire the trigger. Stop asking one text event to represent both directions. Detect logout with an Express Condition that compares $Logout_Time with 0: that comparison is true on a manual logout and on automatic expiry alike, and false while a session is open. Run the login side from the OK key of the User Login (40003) keyboard. Below are the readings that confirm the diagnosis, the worked comparison, and the panel tests to run before you trust it in production.

Why the string-change trigger misses logout #

A String Change trigger watches the content of a string. At login the content changes from empty to a name, the trigger sees a text change, and the macro runs — which is why the login direction looked solved. At logout the runtime ends the authenticated session and clears the variable, and on this build that clear-to-empty transition raises no text-change event.

Nothing is wrong with the macro or with Global Control; the login path proves both work. The failing branch is the assumption that a text event also covers the session-state change. A string event reports what the text says, a logout needs a report that authentication status changed, and those are different conditions. Split the two directions so each has an execution point that fires on the transition you actually care about.

Read the panel across three session states #

Before changing any trigger, record what the panel actually does in each state. Give the macro an observable output, for example a tag it increments, so a missing execution is distinguishable from an execution whose effect you overlooked.

  • Logged in: $User_Name shows the active account and $Logout_Time holds the running session value. Read that value and write it down; never infer its units or countdown behavior from the name, because the fix below never needs them.
  • Manual logout: after the operator logs out, $User_Name is empty, the string-triggered macro has not executed, and $Logout_Time reads 0.
  • Automatic expiry: log in again and let the configured login period run out. The session ends and $Logout_Time reads 0, matching the manual path.
  • Macro executes but its action fails: the trigger fired and the fault is downstream, so inspect the macro's own actions and destinations.
  • $User_Name never changes during a login test: the test exercised no text transition. Repeat with a different authorized account before concluding anything.

Testing the zero comparison on a G2100E at DTools Pro 1.10 #

Inputs, each with its source:

  • Panel and build: Kinco G2100E at DTools Pro 1.10, the case behind this article.
  • $User_Name: the string system variable, filled at login and cleared at logout.
  • $Logout_Time: the session system variable, which on this panel returns to 0 when the session ends. Read the running value on your own panel and record it; the comparison never needs its units.
  • The condition: one Express Condition in Global Control, an equality test of $Logout_Time against 0, written in the expression editor's own comparison syntax.

The rule in words: the condition is true when $Logout_Time reads 0, a true result means no session is open and the logout macro runs, and anything other than 0 means a session is open and the macro stays idle.

The arithmetic, evaluated at each readback:

  • Logged in: readback = the recorded running value, nonzero on this case. Does the running value equal 0? No, so the condition is false and the logout macro stays idle.
  • Manual logout: readback = 0. Does 0 equal 0? Yes, so the condition is true and the logout macro runs.
  • Login period expires: readback = 0. Does 0 equal 0? Yes, so the condition is again true and the logout macro runs on the expiry path too.

Result: one comparison covers both logout paths the string trigger missed and stays false the whole time a user is working.

Decision and its threshold: true — a readback of 0 — means logged out, so run the cleanup and the screen change; any other readback means a session is open, so leave the macro alone. Two checks before you trust it. At power-up with nobody logged in the comparison is already true, which identifies a logged-out panel rather than a logout event, so decide whether startup should run the same cleanup. And confirm your own model and build actually return to 0 at logout; this worked case confirms it on the G2100E at DTools Pro 1.10, so treat other firmware as untested until you read it.

Configure the logout condition and its macro #

  • Save the project, then record the current Global Control entries and keyboard actions before editing anything.
  • Create the Global Control entry with the Express Condition comparing $Logout_Time with 0 and attach the logout macro to it.
  • Give the macro two jobs: the cleanup your application needs, and a screen change to a page that is valid with nobody logged in. That keeps the display out of the setup screens once a user logs out or the login period expires.
  • Keep navigation and authorization separate: navigation decides which page is visible, permissions decide which operations are allowed, so configure both. Keep access rights in the HMI's authentication configuration — a macro that fired is not proof of authorization.
  • Decide the repeated-execution question deliberately: if the entry re-evaluates while the condition stays true, a logged-out panel re-runs the macro indefinitely. Use the transition behavior the entry offers, or keep the macro idempotent — a screen change to a screen it would select anyway leaves the same state when repeated.

Run the login macro from the keyboard OK key #

Login gets its own execution point instead of leaning on the string event. Add the login macro to the OK key of the User Login (40003) keyboard; the keyboard keeps performing the login and the OK action runs your macro alongside it.

An OK action means the login operation was submitted, and authentication completing is a separate moment. Verify that ordering before the macro reads the active user name or initializes account-dependent values. If the OK action runs first, move account-dependent work to a point that can see the resulting session state. This same hook is where login macros that send the active HMI user to the PLC belong.

Then test all three outcomes on the keyboard:

  • Valid credentials: authentication succeeds and the macro's actions occur with the correct active user.
  • Invalid credentials: no successful-login initialization happens, and failed attempts also feed the lockout behavior described in why invalid login attempts lock an HMI user as unauthorized.
  • Cancellation: close the login entry without accepting it and confirm no login action ran.

Test on the panel and remove the overlapping trigger #

Run the final logout and expiry tests on the target panel, not only in offline simulation, because user-management behavior can differ between the two — the split is described in when HMI user management works in simulation but not on the panel.

With the OK-key macro in place, login has two possible triggers: the OK action and the string change from empty to a name. Remove the String Change entry unless something else depends on it, or test the combined execution deliberately, because duplicate triggers cause repeated initialization and conflicting navigation.

Set the idle timer that causes automatic expiry to a deliberate value instead of leaving a default in place; configuring RSView32 idle detect control for auto logout walks through one platform's idle-detect setup.

Questions asked

What if $Logout_Time does not read 0 after logout on my panel?

The confirmed case is the G2100E at DTools Pro 1.10, so read the value on your own model after a manual logout before wiring the condition. If your build keeps a nonzero value after logout, test the comparison against the value your panel actually shows, and confirm the variable's logout behavior in the system-variable definitions for that model in the tool's manual.

How do I catch a trigger that keeps running while the panel sits logged out?

Point the macro at a tag it increments, log out once, and read that tag: one logout should add exactly one. If the count keeps climbing, the entry is level-triggered, so use its transition setting or keep the macro idempotent, for example a screen change to the screen it would select anyway. Then power-cycle with no user logged in and read the tag again to see whether startup also runs the macro.

Can one trigger still cover login and logout together?

On this build, not reliably: the login direction, empty to a name, fires the string event, while logout clears the name to empty without firing it. Split the directions instead — the OK key of the user login keyboard owns login, and the Express Condition comparing $Logout_Time with 0 owns logout. Two execution points that each fire on a real transition are easier to verify than one event that fires on only half of them.

Where should the logout screen change point?

To a screen that is valid with nobody signed in, for example the main screen or the login screen itself. That keeps the panel off the setup pages after a manual logout or after the login period expires. Navigation and permissions stay separate decisions: the screen change controls what is visible, and user management controls which operations are allowed, so set both.

Keep reading

  • Explainer

    How HMI Audit Trails Record Tag Changes With User and Time

    An HMI audit trail writes each operator tag change to a file with the logged-in user and a timestamp; a tag-value archive only shows what the value was. Enable the audit option on Comfort panels and RT Advanced, the Unified audit logging on Unified targets, and prove attribution with two accounts on a bench.

    HMI and touchscreens

  • How-to

    How to timestamp Weintek HMI alarm history

    Timestamp the history with the panel's own real-time clock: save every event in the Event (Alarm) Log, retrieve the records with an Event Display, and set the clock from the panel's date and time setup or the documented settable system registers. The S7-1200 supplies the trigger bits only; its clock is not needed.

    HMI and touchscreens

  • How-to

    Display a Previous-Day Historian Average on an HMI Screen

    Query the Historian in average retrieval mode with an explicit start and end one day apart, prove the query standalone in SQL Server Management Studio, then assign the single returned value to the display object's attribute by script. History Summary cannot select the prior-day range, so it is the wrong tool for this page.

    HMI and touchscreens