Use six numeric entry boxes, one per 16-bit clock field, and let one button request the documented Set Date/Time instruction. A single text field works only after PLC logic parses a fixed format and validates all six values. Build the six boxes first and keep them as the fallback.
Six numeric entry boxes is the commissioning answer. The controller exposes the date and time as separate 16-bit integers, one of them the set field, and its help file documents a Set Date/Time instruction whose application example writes a single field, the day, from a panel. The same instruction takes year, month, day, hour, minute and second. So the direct screen is one entry box per field plus one button that requests the change, and nothing anywhere has to parse a string. A single text field is an upgrade you earn later: the panel writes a string, the clock fields are integers, and ladder logic has to split that string, check every value and block the set until the whole date is legal. Build the six-box screen first.
Why six boxes wins first
| Clock screen style | What the panel does | What the PLC does | First thing to break |
|---|---|---|---|
| Six numeric boxes | six entry objects writing six integer tags | validity rungs, then the set instruction | one mistyped value, visible in its own box |
| One text field | one entry object writing one string | parse, validate, copy, set | the format: one wrong character stops the set |
Each numeric box binds to one integer tag, so a wrong value sits in the field where the operator typed it and the ladder can flag that box. The set instruction reads integers, so six boxes feed it with no translation step. A text field hides six values inside one string, and every format you accept is a new way to fail.
The same screen serves the daylight-saving clock change twice a year: edit the hour field, press the same button. And if your controller keeps its clock in one packed value, setting it from an HMI without breaking the packed format is a separate job with its own checks.
What you need
- A panel-to-controller link that already passes a test write to a scratch tag.
- Six integer tags named year, month, day, hour, minute and second, with the panel objects carrying the same names.
- The controller help file open at the Set Date/Time instruction, topic P182, for the operand assignments and the trigger its example uses.
- One momentary button object for the set request.
- A digital clock display built from the PLC real-time clock values on the same screen, so the readback stays in view.
Build the six-box screen
- Create the six integer tags. Name the panel objects to match, so a month entry cannot land on the day tag.
- Put one labeled numeric entry object on the system screen per tag. Set each object's input range: month 1 to 12, day 1 to 31, hour 0 to 23, minute 0 to 59, second 0 to 59. Take the year range from the instruction documentation.
- Add the momentary Set clock button, wired the way the instruction's example shows. If a held button re-fires the instruction, put a rising-edge contact in the rung so one press is one set.
- Add the validity rungs below, ahead of the set instruction.
- Gate the set instruction on request AND valid, so an illegal date is blocked before the clock.
- Preload the six boxes from the current clock when the screen opens, so the operator edits from a legal starting point instead of six zeros.
The validity rungs
The input ranges stop single-field errors such as month 13 or hour 25. Calendar errors pass those ranges, so the ladder has to catch them:
- Month in 1 to 12; hour in 0 to 23; minute and second in 0 to 59.
- Day at most the month's length: 31 days for months 1, 3, 5, 7, 8, 10 and 12; 30 days for months 4, 6, 9 and 11; 28 or 29 days for month 2.
- February rung: day 29 passes only when the year divides by 4, and a century year must divide by 400.
- Every field loaded before the set runs.
This is the same discipline as entry limits enforced in PLC ladder: the panel's range is a convenience for the operator; the rung is what the set instruction sees.
Example: leap year accepted, common year rejected
Scenario: commissioning test after the controller loses its clock to a battery swap. The operator types year 2028, month 2, day 29, hour 14, minute 35, second 0 and presses Set clock once.
Range checks: month 2 sits in 1 to 12, hour 14 in 0 to 23, minute 35 and second 0 in 0 to 59. Calendar check: February carries 29 days only in a leap year. 2028 divided by 4 gives 507 remainder 0, and 2028 is no century year, so day 29 passes. The set instruction runs once, and the readback shows 2028-02-29 14:35:00 with the seconds advancing.
Rejection pass: the operator changes one value, year to 2027, and leaves month 2, day 29. 2027 divided by 4 gives 506 remainder 3, so February 2027 has 28 days. The February rung is false, the set instruction stays off, the day box carries the error, and the readback holds its old value. The whole difference between the two outcomes is one year digit.
If one text field has to happen
Fix the format before anything else and print it beside the field. The easiest format for the ladder is fixed-position digits with no separators, YYYYMMDDhhmmss, 14 characters: every component sits at a known offset, so parsing is six substring reads and six conversions. For readability, 2028-02-29 14:35:00 runs 19 characters, and the parser skips two dashes, one space and two colons.
Then in ladder:
- Parse into temporary values, never straight into the clock tags.
- Run every check from the six-box design on those temporaries, leap-year rung included.
- Copy to the six integer tags and fire the set only when all checks pass.
- On any failure, leave the clock alone and show one message naming the bad field.
A string in string memory changes nothing until that ladder runs, because the set instruction reads integers. That gap between string memory and integer words is the same one behind displaying ASCII from integer words when a panel cannot map the PLC string file, in the display direction. Keep the six-box screen one page away as the fallback.
Check that it worked
- Watch the six tags online and type into each box: one box moves one tag. A box that moves the wrong tag is a naming slip; fix the binding.
- Press Set clock once and read the clock back: all six values match, then the seconds advance.
- Change a different field and set again. Two successful sets on different fields show the mapping is real.
- Enter 31 April and press Set clock: the rung blocks it and the readback holds.
- Hold the button down: one press, one set. If the clock re-sets while held, add the rising-edge contact.
If this program schedules outputs by day and time, set the clock with the machine in a safe state: a clock jump can bring a scheduled output due at once.
Recommendation: commission with the six numeric entry boxes, the ladder validity rungs and the readback test, in that order. Add the single text field only after the six-box screen has set the clock correctly twice, and only when the parse rung has passed a test with a malformed string. If the clock is wrong today and the line is waiting on it, stay on the six boxes; the text field is interface polish and it can wait.
Questions
How many entry objects does a PLC clock screen need?
Six numeric entry boxes, one each for year, month, day, hour, minute and second, plus a seventh object: the momentary button that requests the set. The button is what makes the change deliberate, because the integer fields themselves accept writes at any time. If you add a text field later, keep the button; the parsed values still need a trigger.
Why will a single text field not set the clock on its own?
The clock fields are 16-bit integers and the set instruction reads those integers. A text entry lands in string memory, where the instruction never looks. Until ladder logic extracts six numeric values from the string, validates them and writes the integer fields, the string changes nothing. That extraction logic is the real cost of the one-field design.
What text format is easiest for the PLC to parse?
Fixed-position digits with no separators: YYYYMMDDhhmmss, 14 characters. Every component sits at a known offset, so parsing is six substring reads and six conversions with no delimiter hunting. Reject any string whose length differs before parsing anything.
How do I test the clock screen before it can affect the machine?
Disable the logic that schedules outputs by day and time, or do the test with the machine in a safe state. Run two sets with a different field changed each time, read the clock back after both, and try one invalid date such as 31 April to check the set stays blocked. Restore the scheduled logic only after the readback matches twice.
Does the set request need a rising edge?
Give it one. A button held for a second looks like many requests to a fast scan, and a clock re-set on every scan reads as frozen. Wire the request through a one-shot contact so one press is one set, then watch the readback: seconds advancing after the write show the instruction fired once.
Planning information, not legal or engineering advice. Rules differ by place: check codes and permits with your local authority and your licensed trades.