A panel's live line graph samples one tag while its screen is open and starts a fresh drawing at every screen view, so the 24 samples must live in PLC registers. On a one-second pulse, block-copy the 23 older samples through a scratch row one address toward the end of a 24-register buffer, then write the newest reading into position 1.
A line graph driven from one live address starts a fresh drawing every time its screen opens, so 24 seconds of sensor history has to live somewhere that ignores screen changes: PLC registers. Reserve 24 contiguous integer registers for the trace plus a scratch row of 23. On a one-second pulse, copy the 23 older samples one address toward the end of the buffer, then write the newest reading into the first register. Point the graph at the stored range instead of a live tag, and the trace survives every screen change, including the seconds when no screen was open. The steps below cover the pulse, the copy order, the graph source, and the checks that prove each part.
Why the trace forgets
Nothing on the panel was storing those samples. A line trend object's documented job is to sample the single tag assigned to it while its screen is open; the object's help file describes it as a digital version of a chart recorder. Drawing is the job, storage is not, so the samples die with the screen. Data registers in the PLC ignore which screen is open, which is why the 24 samples belong there. The storage question in general is covered in why HMI trend graphs need PLC memory history; this page does the shifting.
What you need
- A controller with a block-copy instruction and a single-register move. The block-copy facts and the SC43 error code below are documented for the CLICK series; the pattern runs on any PLC with those two instructions.
- 47 integer registers: 24 for the buffer, positions 1 to 24 with position 1 holding the newest sample, and 23 for the scratch row.
- A one-second pulse built in PLC logic. A one-second clock built in rung logic shows one construction; a self-resetting on-delay timer with a 1-second preset works too.
- A display object that plots a stored range of registers. The live line trend cannot show the block, since it samples one tag; look through the panel's object list for a history or real-time graph type and confirm from its documentation that it reads a range.
- A work register for the captured reading and a counter to prove the pulse rate.
Build the one-second pulse
- Build the pulse in the PLC, not on the panel. A self-resetting on-delay timer with a 1-second preset feeding a one-shot edge contact works; many platforms name that edge instruction ONS. The pulse must be true for exactly one scan, once per second.
- Hang a counter on the pulse before any buffer logic exists. It should read 60 after 60 seconds. Fix the rate first if it counts faster or slower; every check later on this page assumes a correct pulse.
- Never drive the copy branch straight from the timer's done contact. The done contact stays true for the whole second, and the PLC executes that second as hundreds of scans: at a 2 ms scan time the copy would run about 500 times, leaving the buffer as 24 copies of a single reading. Put the one-shot contact between the done contact and the copy branch.
- On the pulse, copy the scaled sensor value into the work register once. Each interval then uses exactly one reading even if the analog channel changes between scans.
Move the block through a scratch row
- Copy one: block copy, 23 elements, source buffer positions 1 to 23, destination scratch positions 1 to 23.
- Copy two: block copy, 23 elements, source scratch positions 1 to 23, destination buffer positions 2 to 24.
- Last rung: move the work register into buffer position 1.
Rungs 5 to 7 sit in the same pulse branch and run in scan order once per second. When they finish, position 1 holds the newest reading and position 24 holds the reading from 23 seconds earlier; anything older has been shifted out and is gone.
The detour through scratch is deliberate. A single block copy from positions 1 to 23 directly into positions 2 to 24 overlaps source and destination on 23 of 24 addresses, and the block-copy documentation does not state which end such a copy moves first, so the surviving values would be unknown. Scratch copies never overlap, so they are correct under either direction, at the cost of one extra rung. An alternative that also avoids overlap is 23 single moves taken from the top down, position 23 into 24 first and position 1 into 2 last, then the new reading into position 1.
Keep the element counts at 23. A copy aimed at positions 2 to 24 with 24 elements reaches position 25 and stops with error SC43, which the copy instruction's help file lists as Out of Range for single, block and pack copy modes. The same shift-through-a-buffer pattern is standard practice on other controllers: a STEP 7 STL example that stores 100 four-bit samples for a trend display works the same way.
Working example: a spike crossing a 24-register, one-second buffer
The inputs:
| Input | Value | Where it comes from |
|---|---|---|
| Buffer | 24 integer registers, position 1 newest | the job: 24 seconds of history at one sample per second |
| Sample period | 1 second | the job's resolution |
| Scratch row | 23 registers | this page's setup, one register per copied element |
| Test values | 100, 100, 100, 900, 300 at pulses 1 to 5 | forced test values written into the scaled input |
The rule: every pulse moves positions 1 to 23 up one position through the scratch row, then the new reading lands in position 1.
The arithmetic, showing positions 1 to 5 after each pulse:
- Pulse 3: 100, 100, 100, 0, 0. The input held 100 for the first three pulses.
- Pulse 4: 900, 100, 100, 100, 0. The 900 entered at position 1.
- Pulse 5: 300, 900, 100, 100, 100. The 900 moved to position 2 and the new reading took position 1.
From pulse 4 the 900 advances one position per pulse: at pulse n it sits in position n minus 3. It reaches position 24 at pulse 27, and at pulse 28 it would need position 25, which does not exist, so pulse 27 is the last time the spike appears.
The result: the spike stays on screen for 24 samples, and 24 samples at 1 second is 24 seconds, exactly buffer size multiplied by sample period. The decision that falls out: size the buffer as window seconds divided by sample period, and copy one element fewer than the buffer holds. Twenty-four registers with 23-element copies give the 24-second trace; 60 registers with 59-element copies give a 60-second window if an event must stay visible longer. The rest of the logic is unchanged, and the cost stays at 48 register writes per second: 23 elements in each of two copies, plus the capture and the position 1 write.
Point the graph at the stored range
Set the graph object's data source to the 24 buffer registers as one block, so it plots stored values instead of sampling a tag. With the PLC owning the samples, the panel's refresh interval only decides how often the drawing repaints; opening and closing screens loses nothing.
Set the direction before an operator reads it on the floor. Position 1 holds the newest sample, so on a chart that runs left to right the newest point belongs at the right edge. If the object plots the first address of the range at the left edge, the trace runs backwards: flip the plot order in the object's settings if that setting exists, otherwise reverse the buffer convention, with the newest reading written into position 24 and the copies moving positions 2 to 24 down into 1 to 23 through the scratch row.
If the panel turns out to have no object that reads a stored range, keep the buffer anyway: the samples sit in known registers, and the panel's object list or manual is the place to find what can plot them.
How to check it worked
Work down the list in order; each step isolates one part.
- Counter: 60 counts after 60 seconds proves the pulse.
- March: force 900 into the input for exactly one pulse, then watch the buffer online. The 900 advances one position per second and drops off after position 24, 23 pulses after it entered.
- Screen: open the graph, leave it for at least 24 seconds, come back. The drawing must include the samples taken while the screen was closed, with the spike where the march puts it. This is the acceptance test for the whole job.
- Range: a fault reading SC43 on a copy rung means an element count or start address stepped outside its block; recheck 23 elements into positions 2 to 24.
- Power: cycle controller power only if the trace must survive that too. Without a retentive range the registers start at zero and the window rebuilds over the next 24 seconds; with the buffer block placed in the controller's retentive memory range, the samples return as they were.
Recommendation
Recommendation: Build the history in the PLC: 24 integer registers for a 24-second trace at one-second steps, a 23-register scratch row, and on each one-second pulse two non-overlapping block copies of 23 elements followed by one move into position 1. Point the graph object that reads a stored register range at the block. Pick the panel's own trend storage only where its documentation states that samples survive screen changes, and place the buffer block in the controller's retentive memory range when the trace must also come back after a power cycle.
Questions
How do I change the trace to a different window or sample rate?
Change two pairs of numbers. The buffer grows to 60 registers, the two copies move 59 elements through a 59-register scratch row, and the timer preset drops to 500 ms for a half-second step. The window is always registers multiplied by sample period, so 60 registers at 0.5 seconds gives a 30-second trace. Update the graph object's range to the new first and last addresses and rerun the counter check, which should read 120 counts in 60 seconds.
What happens to the trace when the PLC loses power?
Ordinary data registers start at zero after a cold start, so the window rebuilds over the next 24 seconds. Most controllers publish which register ranges are retentive and let you place a block there in the memory configuration; put the buffer and scratch rows in a retentive range and the samples return with the values held before the power was cut. The panel stored nothing, so its side needs no change.
Can I use the shift register instruction for this?
The shift register instruction moves control bits: each OFF-to-ON transition of its clock input steps the bit range one position. Sensor readings are integer values in data registers, so bits are the wrong container. Keep the shift register for on and off histories such as a row of station sensors, and use block copy plus a single-register move for an analog trace.
When can the panel's own trend storage replace the buffer?
When its object documentation states that the trend stores samples while no screen is showing them. Test before relying on it: open the trend, step the value, close the screen for 30 seconds, reopen, and look for the gap. A drawing that restarts at the current value stored nothing, and the PLC buffer stays the fix.
Planning information, not legal or engineering advice. Rules differ by place: check codes and permits with your local authority and your licensed trades.