A trend plots values against time or sample order, so it cannot draw X against Y. Check the panel's object list for a scatter object first; if there is none, animate one line segment per gap between pairs, map each value into the plot rectangle with a linear formula, gate the read on a PLC done flag, and prove the mapping with four fixed test points.
A trend object plots values against time or sample order, so it can never draw X against Y. A true X-Y plot uses each X sample as the horizontal coordinate and its paired Y sample as the vertical coordinate, both read from the same array index. Most HMI packages carry no ready-made object for that. The build that works on a small touch panel is a set of line segments, one per gap between consecutive points, with each endpoint driven from PLC registers through the line object's animation settings and each engineering value mapped into the plot rectangle's pixels. Check the panel's object list for a scatter object first; if there is none, the steps below build the plot and prove it with four fixed test points.
Check for a scatter object first
Some HMI software includes a scatter or X-Y chart object that plots paired values on two value axes. If yours has one, configure it with the two arrays and an axis range per side and stop there; one walk-through of an X-Y scatter plot configured for position data shows what that object does when it exists. A trend object is the wrong tool for the rest: its horizontal axis is sample order or time, so two arrays plotted on it stay two curves and never become a path through paired points.
What you need
- Your HMI project software connected to the panel, with a blank test screen.
- Two arrays in the PLC, one of X values and one of Y values, in consecutive registers of the same length. If you build them as a rolling set, the register-shift layout in shift a block of PLC integers to keep a 24-second sensor trace keeps oldest-out, newest-in order.
- The engineering range for each axis in the units the sensors report, for example 0 to 100 mm and 0 to 500 N. If the PLC hands you raw register counts, scale them to engineering units first; that is the same job a trend needs, and setting raw and engineering units on an HMI trend walks through it.
- A done flag or handshake bit in the PLC that marks a complete set of pairs as ready.
- The plot rectangle on the test screen in pixels: its left, right, top and bottom edges.
Build the plot
- Pair the arrays. X element n plots with Y element n, always. If the PLC writes the two arrays at different moments, one read can catch a new X with the previous Y, and the plot draws a point no sensor ever reported. Gate the panel's read on the done flag, or copy both arrays into a second register block within one scan and point the panel at the copy; hold the drawing until the copy is complete.
- Fix the axis ranges. Write down the engineering minimum and maximum for each axis and keep them fixed. Give each axis a nonzero span even if a value can sit at one end, so the mapping never divides by zero.
- Decide out-of-range behaviour. Clamp values beyond a range to the plot edge, skip them, or widen the range. Clamping is the usual choice for a live curve; skipping hides real motion.
- Map values to pixels. For each axis, pixel position = edge_min + (value − value_min) × (edge_max − edge_min) ÷ (value_max − value_min). Screen pixels count downward while a plotted axis counts upward, so bind the value maximum to the top edge and the value minimum to the bottom edge.
- Animate the segments. Add one line object per gap between consecutive pairs. Open its settings and the animation area behind the check box marked
Advanced, then bind the start point to pair n and the end point to pair n + 1, X and Y each from their mapped registers. The last segment ends at the last pair; add a closing segment only when the data really forms a closed loop. If your version'sAdvancedarea exposes no endpoint binding, stop and use the vendor's supported plotting method. - Load a test set first. Four or five known pairs with distinct coordinates, as in the example below, before any live data.
Example: a 5-pair press curve in a 400 x 300 pixel plot
Inputs, and where each comes from: the paired arrays in the PLC and a line object whose Advanced animation area binds endpoints come from the documented method; the press numbers, plot rectangle and ranges are an illustrative setup you replace with your own. Plot rectangle: 400 pixels wide and 300 pixels tall, left edge at screen x 100, top edge at screen y 80, so the bottom edge sits at y 380. X axis: slide position 0 to 100 mm. Y axis: press force 0 to 500 N. Five pairs from the arrays: (0, 0), (25, 60), (50, 140), (75, 300), (100, 480).
The rule: a value maps to a pixel by first edge + (value − value_min) × pixels per unit, where pixels per unit = edge span ÷ value span, with the vertical map inverted.
Arithmetic. Horizontal: 400 ÷ 100 = 4 pixels per mm, so pixel_x = 100 + 4 × X. Vertical: 300 ÷ 500 = 0.6 pixels per N, so pixel_y = 380 − 0.6 × Y.
- Pair (0, 0): pixel_x = 100 + 4 × 0 = 100; pixel_y = 380 − 0.6 × 0 = 380.
- Pair (25, 60): pixel_x = 100 + 100 = 200; pixel_y = 380 − 36 = 344.
- Pair (50, 140): pixel_x = 100 + 200 = 300; pixel_y = 380 − 84 = 296.
- Pair (75, 300): pixel_x = 100 + 300 = 400; pixel_y = 380 − 180 = 200.
- Pair (100, 480): pixel_x = 100 + 400 = 500; pixel_y = 380 − 288 = 92.
| Pair | X (mm) | Y (N) | pixel_x | pixel_y |
|---|---|---|---|---|
| 0 | 0 | 0 | 100 | 380 |
| 1 | 25 | 60 | 200 | 344 |
| 2 | 50 | 140 | 300 | 296 |
| 3 | 75 | 300 | 400 | 200 |
| 4 | 100 | 480 | 500 | 92 |
Result: five screen points and four segments, from (100, 380) up to (500, 92), each segment running from pair n to pair n + 1. The decision: five pairs need four line objects, and in general N pairs need N - 1 segments. Count what your screen will hold before you choose a sample count. If 48 samples will not fit, plot every 6th pair, which leaves 8 points and 7 segments, or move to software that ships a scatter object.
Check it worked
Run the test screen and drive the mapped registers to four fixed values with the other axis held at its midpoint:
- X at its maximum moves the point to the right edge; X at its minimum moves it to the left edge.
- Y at its maximum moves the point to the top edge and Y at its minimum to the bottom edge, because the vertical map is inverted.
Then check the midpoint and one out-of-range value. In the example, X 50 mm with Y 250 N gives pixel_x = 100 + 4 × 50 = 300 and pixel_y = 380 − 0.6 × 250 = 230, the exact centre of the rectangle spanning x 100 to 500 and y 80 to 380. A value past the maximum should land clamped on the edge you chose. Read the failures directly: the point moving down when Y rises means the inversion is missing, sideways motion when only one axis changed means the X and Y bindings are swapped, and a point that never moves means the read is not gated on the done flag, so the panel still holds the first pair it ever saw.
If the endpoints will not bind
If the Advanced area on the line object offers only color, visibility or size animation and no endpoint coordinates, stop before building a screen around it and ask the vendor for the supported plotting method. If endpoints bind but the path is wrong, check in this order: the values the panel actually reads, the mapping arithmetic, the array indexing, then the done flag.
Recommendation: Use the panel's built-in scatter object when it has one. When it has none, animate one line object per gap between pairs through the Advanced animation settings, map values with the linear formula and the vertical map inverted, gate the panel's read on the PLC done flag, and run the four fixed test points before any live data. Size the sample count to the screen first, N pairs to N - 1 segments, and decimate the arrays when the segment count will not fit.
Questions
How many line segments does an X-Y plot need?
One per gap between consecutive pairs: five plotted pairs need four segments, and twenty-one pairs need twenty. Count the line objects your screen will hold before you choose a sample count, because two gaps cannot share one object without dropping a point. If the segment count will not fit, plot every k-th pair of the arrays or move to software that ships a scatter object.
Why does increasing Y move the plotted point down the screen?
Screen pixels usually count downward from the top-left corner, while a plotted engineering axis counts upward, so the vertical map runs in reverse: the axis maximum binds to the plot area's top edge and the minimum to the bottom edge. If the four-point test still shows the wrong direction, check whether the X and Y registers are swapped in the segment bindings, which also moves the point sideways when only one value changes.
The line object has no endpoint animation controls. What now?
Stop before building a screen around it. If the animation area behind the Advanced check box offers only color, visibility or size changes, that object cannot plot coordinates on this software version. Send the vendor the software version, the panel model, the array layout in the PLC and the object settings you tried, and ask for the supported plotting method; a trend is no substitute because its horizontal axis is sample order or time.
Planning information, not legal or engineering advice. Rules differ by place: check codes and permits with your local authority and your licensed trades.