IMDTouchKnowledge BaseShop main store

How-to

Reading a PLC clock word as hour and minute bytes

HMI and touchscreens Published 7 min read By IMDTouch engineering team

Short answer

Read the clock register %MW33 as one raw unsigned 16-bit word: the upper byte is the hour, the lower byte the minute. A single reading taken while the clock shows a minute above nine tells you whether the bytes are straight binary or packed BCD, and that result decides both the display conversion and how you rebuild the word for a time write.

On this page
  1. Which registers hold the Zelio clock, and how do you reach them?
  2. How do you split %MW33 into hour and minute bytes?
  3. How do you prove whether the clock byte is binary or packed BCD?
  4. What do you do with the two date words?
  5. How do you write a corrected time without corrupting the word?
  6. How do you commission the read end to end?
  7. Questions asked

A supervisory system never receives the Zelio clock as a time value; it receives packed words. The fix is to read %MW33 raw as an unsigned 16-bit integer, split it into its upper and lower bytes, and run one encoding test at a minute above nine before you format anything or enable a write. This article gives the register map, the byte-extraction offsets and masks, the arithmetic that separates straight binary from packed BCD, the treatment of the two date words, and a staged procedure for writing a corrected time back.

Which registers hold the Zelio clock, and how do you reach them? #

Schneider's published FAQ for the SR3MBU01BD communications module places the clock and calendar in registers %MW32 through %MW35; the hour and the minute share %MW33, the hour in the upper byte and the minute in the lower byte. Reach them over Modbus through the module's Ethernet extension.

Create one raw tag per clock word as an unsigned 16-bit integer, with no scaling and no conversion to a date or time type at the driver. Confirm the link first on a register you already know reads correctly, and keep a diagnostic page showing the raw words in both decimal and hexadecimal while you commission. A wrong register can return a plausible-looking integer, so compare the raw value against the controller's own clock display before you build any derived fields on top of it.

How do you split %MW33 into hour and minute bytes? #

Define two tags on the same word as binary bit-fields: the hour at bit offset 8 with width 8, the minute at bit offset 0 with width 8. Without a bit-field tag type, compute the hour as the raw word divided by 256 and the minute as the remainder.

Field Source word Bit offset Width Extraction
Hour %MW33 8 8 bits upper byte
Minute %MW33 0 8 bits lower byte

In arithmetic terms, the minute equals the word AND 255, and the hour equals the word divided by 256, masked with AND 255 again. That second mask matters when the runtime stores the word in a wider or signed container and would otherwise carry stray high bits into the hour. Both approaches come from the eight-bit widths: the field implementation is the same offset-and-width split shown in the guide to splitting Modbus register bytes in Operator Terminal Expert, just pointed at a clock word instead of a process value. On Logix controllers, the equivalent is the documented pattern for extracting the upper and lower byte from an INT to SINT.

Word order and bit position are different problems. Let the driver assemble the register into a word first, then extract the bytes from that word. Add a byte swap only if the raw comparison against the controller clock shows the bytes arriving reversed.

How do you prove whether the clock byte is binary or packed BCD? #

Watch the raw decimal value while the controller clock shows a minute above nine: at 14:47 a straight-binary word reads 3631, packed BCD of the same time reads 5191, and whichever number %MW33 returns at that moment is your encoding.

Packed BCD stores each byte as two decimal digits, one per nibble, which costs roughly 20 percent more bits than binary for the same range and is exactly why many controller clocks use it. The worked example shows both encodings of the same minute:

  • Straight binary at 14:47: 14 x 256 + 47 = 3584 + 47 = 3631, shown in hexadecimal as 0E2F.
  • Packed BCD at 14:47: the hour pair 14 stores as 0x14, decimal 20, and the minute 47 stores as 0x47, decimal 71, so the word is 20 x 256 + 71 = 5120 + 71 = 5191.
  • Cross-check at 14:07: binary gives 14 x 256 + 7 = 3591, while BCD gives 0x1407, decimal 5127. Minutes from 0 through 9 alone do not distinguish the encodings, which is why the test uses a minute above nine.

The decision follows directly: if the register reads 3631, the bytes are straight binary and you display them unchanged; if it reads 5191, decode each byte with value = (byte divided by 16) x 10 + (byte remainder 16), so minute byte 0x47 becomes 4 x 10 + 7 = 47.

Format the decoded fields as two digits each with a separator between them, and validate against the documented ranges: hours 0 through 23, minutes 0 through 59, rejecting a decoded field that falls outside instead of dressing it up with formatting. Confirm the display against the controller clock, never against the supervisory computer, and watch several minute changes before trusting the page; the same source-the-controller discipline applies in the walkthrough on sending M221 PLC time to an HMI clock. Include one change that crosses a digit boundary, such as 09 to 10, because that is where a BCD misread first shows up.

What do you do with the two date words? #

Treat %MW32 and %MW34 as unmapped until the register description says otherwise: build a field map from the module documentation — component, source word, bit offset, width, encoding, permitted range — and never extend the %MW33 layout to them by analogy.

Record every reserved bit and any special write condition the documentation lists, because a date write that stomps an undocumented field corrupts the calendar. Keep the derived read fields separate from any operator entry values, and assemble a supervisory date-and-time type from decoded components rather than assigning the raw register to it; a correct local-time display does not by itself prove anything about timezone handling or daylight-saving behavior, so configure those only against the site's time policy. Leave date writes disabled until every field in both words, reserved bits included, has a defined treatment in your map.

How do you write a corrected time without corrupting the word? #

Rebuild the whole word from the two mapped fields and write it in one operation: for straight binary, hour 16 and minute 45 becomes 4145 decimal, and for packed BCD the same time becomes 5701. Verify with an immediate read-back.

For a BCD clock, encode each field into two nibbles before combining — hour 16 goes in as 0x16, minute 45 as 0x45 — then write the combined word. Never write only one byte of a register that the clock logic reads as a unit. Clock writes move every time-based schedule and timer on the controller, so stage the first write in an approved window with the process in a safe state. Do not touch the date words until their field map from the register description is complete.

How do you commission the read end to end? #

Run the checks in order and do not skip the encoding test: the read is not done until a minute above nine has fixed the encoding and several minute changes have confirmed both fields track the controller clock.

  1. Confirm the network link on a register you already trust, then add a raw %MW33 tag displayed in decimal and hexadecimal.
  2. Compare that raw value against the controller's own clock display before building anything on top of it.
  3. Split the word using the bit offsets and widths in the table above, or the divide-by-256 arithmetic, and confirm the upper field tracks hours while the lower field tracks minutes.
  4. Log the raw decimal at a minute above nine: 3631 means straight binary, 5191 means packed BCD.
  5. Apply the nibble decode only if the test showed BCD; leave a binary byte untouched.
  6. Watch several minute changes, including one crossing a digit boundary, on a bench or diagnostic page before the fields reach an operator-facing screen.
  7. Map %MW32 and %MW34 from the register documentation, and keep date writes disabled until the map is complete.
  8. Test the write path last, in an approved window, writing a rebuilt full word and confirming it with an immediate read-back.

The end state is a supervisor that reads the controller's clock as the source of truth, displays it with the correct encoding, and changes it only through a word you reconstructed yourself.

Questions asked

Which registers carry the SR3MBU01BD module's outputs?

The SR3MBU01BD module maps its outputs to %MW20 through %MW23, separate from the clock range of %MW32 through %MW35. Keeping the two ranges apart matters during commissioning, because a readable value from the wrong range still proves nothing about your clock tags except that the network link itself works.

Can a clock word ever read back negative?

No. A straight-binary word peaks at 23:59, which encodes as 23 x 256 + 59 = 5947, and packed BCD of the same time encodes as 9049. Both sit well inside the positive range of a signed 16-bit read, so sign handling never enters a plain clock read; it only matters if you reuse the same extraction technique on other process words.

Why does my hour value show up in the minute field?

Your driver assembled the register's two bytes in the opposite order from the one the clock layout expects. Fix the word order at the driver or tag level, not by swapping your extraction offsets: reversed offsets make the read look correct while guaranteeing that a reconstructed write value lands in the wrong bytes.

Should the hour and minute poll the clock word separately?

Polling %MW33 with two tags costs two transactions per refresh and can catch the word at two different instants. Read one raw internal tag and derive both fields from it with the division and the remainder: the traffic halves, and the hour and minute are guaranteed to come from the same snapshot.

Keep reading

  • Troubleshooting

    Why a WinCC Unified script cannot read an array of PLC UDTs

    A WinCC Unified script tag must resolve to one scalar leaf, so an HMI tag pointing at an array of PLC UDTs stays uninitialized and the debugger shows Object not properly initialized. The fix is one HMI tag per primitive member of each element the script reads, read by name, with the leaf bindings verified at the runtime debugger.

    HMI and touchscreens

  • Selection guide

    Choosing an External HMI Architecture for a Robot Controller

    Connect the HMI directly over Modbus TCP only when the controller's server option is enabled, the documented register map covers every needed value, and the panel has a matching client driver. Otherwise use a PLC gateway that exchanges fieldbus I/O or TCP messages with the robot and publishes normalized tags. Direct PROFINET fits only with the fieldbus board installed and a display side that consumes cyclic data.

    HMI and touchscreens

  • Explainer

    Reading raw PLC tags as diagnostics in WinCC over OPC

    No. An OPC server does not limit WinCC to slave diagnostics: WinCC reads every item the server publishes, process tags included. A raw tag is only an undecoded value — match its type to the server item, decode packed words at the tag level, and drive configured alarms and displays instead of C scripts in each graphic object.

    HMI and touchscreens

Setting hh and mm on an HMI week timer minutes word