How-to
Display large PLC array history on an HMI with a buffer page
Short answer
Put a display buffer in the PLC sized to one visible page (10 rows here) and let the HMI show only that. On each page change the PLC clamps a start index and copies the requested slice of four 5000-entry test arrays plus a timestamp array into five 10-element buffers, so 1000 exposed entries become 100 pages and 50 HMI-facing values instead of one object per tag.
On this page
Mapping a 5000-entry history array one numeric display at a time is a project that never ends and a screen your editor struggles to open. Display it one page at a time instead: keep the history arrays in the PLC, give the HMI a fixed set of display buffers sized to one screen page — 10 rows here — and let the PLC copy the requested slice into those buffers whenever the operator changes pages. This screen draws its 50 values from five 10-element buffers, and the 5000-entry storage depth never reaches the HMI. The steps below size the page, build a clamped one-shot copy on a shared start index, wire the buttons, and verify that four test values and the timestamps stay aligned across the 100 pages that cover the first 1000 entries.
Why a buffer page beats one object per tag #
One display per tag scales with storage, and storage always wins. Exposing the first 1000 entries of five arrays means 5000 display objects and 5000 polled tags. The buffer page scales with what the operator sees instead: 10 rows of four value columns plus a timestamp column is 50 objects — 53 tags counting the page counter and the two buttons. Tag count is refresh rate: a screen carrying hundreds of extra polled objects is the classic recipe for a slow or frozen panel, especially over serial — the failure pattern behind why an HMI freezes or updates slowly over serial. One page of the values the operator actually decides from is also the instinct behind high-performance HMI practice (ISA-101).
Size the page and the buffers #
Three numbers decide the design. Rows per page is the row count one screen shows without clutter — 10 here. Exposed range is how far back the operator needs to read — the first 1000 of the 5000 stored entries, indices 0-999. Page count is exposed range divided by rows per page: 1000 ÷ 10 = 100 pages, numbered 0-99. Buffers follow the page, one per displayed column, each as long as the page: four value buffers plus one timestamp buffer at 10 elements each is 50 elements of HMI-facing data. Size buffers to visible rows, never to storage depth; that ratio is the whole point of the design.
| Item | Stored in the PLC | HMI-facing |
|---|---|---|
| Test values | four arrays, 5000 entries each | four buffers, 10 elements each |
| Timestamps | one array, 5000 entries | one buffer, 10 elements |
| Exposed range | first 1000 entries, indices 0-999 | 100 pages of 10 rows |
| Page navigation | page counter 0-99, clamped in the PLC | two buttons, one page per press |
Build the buffer page, step by step #
- Keep the history arrays in the PLC. Your logging logic keeps writing all 5000 entries; the HMI never addresses them directly.
- Create five display buffers of 10 elements each — one per test-value array and one for timestamps — with the same data types as their source arrays so the copy moves values without conversion.
- Add an integer page counter, initialized to 0, that the HMI buttons set: one press on 'older' adds 1, one press on 'newer' subtracts 1.
- Clamp the counter in the PLC to 0-99 before using it, then compute start index = page × 10. Clamping in the PLC means a stray or stale write from the HMI can never produce an out-of-range read.
- Copy on the button edge, once per press: for each visible row 0-9, read source index start + row from all five arrays into the matching buffer positions. Use the controller's block-copy instruction for the run of 10, or ten indexed moves per array — the loop shape is the same.
- Draw one numeric display for row 0 of the first column, format it, then duplicate the whole row — four values plus timestamp — until the page holds 10 rows: 50 objects configured once. Lay the columns out for a glance read; designing HMI screens for clear operator decisions applies to history pages as much as to control screens.
- Label the buttons by time direction — 'older', 'newer' — not by index arithmetic, so the labels stay truthful if the array order ever changes.
The copy logic with real numbers #
Check the arithmetic on the worst case first. Pages: 1000 exposed entries ÷ 10 rows = 100 pages, so the highest page number is 100 − 1 = 99. Highest start index: 99 × 10 = 990. Last element read: 990 + 9 = 999, the final exposed entry — nothing past it. The clamp earns its keep here: a glitch that writes 120 into the counter clamps to 99, start stays 990, and the operator sees the true final page instead of values from indices 1200-1209, which were never exposed.
The pseudocode below uses illustrative names and IEC-style types; use your project's own naming.
page_number : DINT := 0; (* set by the HMI buttons *)
start_index : DINT := 0;
row : DINT := 0;
(* sources: test_val_1..test_val_4, time_stamp : 5000-element arrays
buffers: value_buf_1..value_buf_4, stamp_buf : 10-element arrays *)
IF page_number < 0 THEN page_number := 0; END_IF;
IF page_number > 99 THEN page_number := 99; END_IF;
start_index := page_number * 10;
FOR row := 0 TO 9 DO
value_buf_1[row] := test_val_1[start_index + row];
value_buf_2[row] := test_val_2[start_index + row];
value_buf_3[row] := test_val_3[start_index + row];
value_buf_4[row] := test_val_4[start_index + row];
stamp_buf[row] := time_stamp[start_index + row];
END_FOR;
Run this on the rising edge of a page-change bit rather than every scan: one pass of five 10-element copies per press is the entire continuous load the screen adds to the controller.
Keep the pages bounded and aligned #
Alignment is free when every copy uses one shared index: all five buffer rows read the same start + row, so the four values and the timestamp on a row cannot drift apart. Two boundaries carry the proof. Page 0 must show entries 0-9 and clamp a negative counter to 0; page 99 must show entries 990-999 and clamp anything above 99. Fix the time direction once, in a project comment: this design stores the newest entry at index 0, so 'older' increments the page counter, and the button labels carry the time meaning rather than the arithmetic.
Verify the page before it goes on the machine #
Load test data that announces itself: write each element's index into the entry, so element 347 displays as 347 and any mispointed row shows a wrong number immediately. Then run three checks. Cross a page boundary — page 9 to page 10 — and confirm all four values and the timestamp jump together from 99 to 100. Touch both ends: page 0 shows 0-9 and page 99 shows 990-999. Attack the clamp: write 120 into the counter and confirm the screen stays on page 99 instead of showing stale data. Dry-run all of it in testing HMI simulation against a live PLC before you repeat the boundary checks on the panel itself.
When to log instead of scroll #
Scrolling serves the operator at the machine; retention is a different job. Records that must survive — quality holds, shift reports, incident reviews — need the HMI's data-logging function or a historian capturing each entry as the PLC writes it, whether or not anyone pages back later. Some HMI platforms document a script-side variant of this same design: the script copies the PLC array into an internal HMI array once at screen load, and the objects bind to that internal copy. It works, but the PLC-side buffer keeps one copy of the logic where the data lives and runs on any panel, so it stays the default here.
Decision: keep the four 5000-entry value arrays and the timestamp array in the PLC, expose the first 1000 entries as 100 clamped pages of 10 rows, and draw the screen from five 10-element buffers — 50 objects, one copy pass per button press. Build one display object per tag only when a page holds a handful of rows; never for 1000.
Questions asked
Can the HMI index the PLC array directly with a variable offset?
Some HMI platforms let a tag supply the array offset, so each display row reads element start plus row straight from the PLC. It works, but every row becomes its own polled request: fifty rows means fifty reads per refresh, and over serial the screen slows to a crawl. Keep indirect addressing for small pages on Ethernet; the PLC-side block copy stays the better default.
What changes when each history entry is a structure?
A raw block copy will not translate the fields of a structure one for one. Copy each field into its own buffer with the same shared start index, or use the controller's typed array copy if it offers one. The page math, the clamps and the screen objects stay exactly as they are; only the copy body changes.
My recorder stores the newest entry last - what breaks?
Reverse the button signs; nothing else moves. With newest-last storage, back toward older entries subtracts a page and forward adds one, while the 0-to-99 clamps and the copy math stay as designed. Choose the convention once, label the buttons by time direction rather than index arithmetic, and prove the direction at both ends during verification.
Should the page itself record what the operator viewed?
No - a page view is a snapshot, and a log that records only viewed pages has holes for every page nobody opened. Capture with the HMI's data-logging function or a historian at the rate the PLC writes entries, and keep the buffer page purely as the operator's window into what was already stored.