How-to
How to Scale a PLC Integer Into an HMI Display Value
Short answer
Divide the raw integer by 100 in an expression on the HMI variable and set the numeric field format to two decimal places: a register value of 4998 then displays as 49.98. The scaling tab rounds because its result stays an integer, which cannot carry a fraction; the expression evaluates the division as a real value before the field renders it.
On this page
- Why the scaling tab rounds
- Confirm the divisor before touching the HMI
- Match the HMI variable type to the PLC data
- Apply the conversion once, in a variable expression
- Worked example: 4998 counts from a frequency meter displayed as 49.98
- Set the numeric field format
- Symptoms that look like scaling errors
- Which path to take
- Questions asked
Divide the raw integer by 100 in an expression on the HMI variable, then format the numeric field with two decimal places: a register holding 4998 displays as 49.98. The scaling tab on the variable rounds because its result stays in the integer type, and an integer cannot carry a fraction. No field setting restores a fraction lost before the display. The running case is a meter that transmits frequency as a four-digit integer in hundredths over a 16-bit register, but the method covers any register holding scaled counts. Work the sections in order: confirm the divisor, match the data type, apply one conversion, then format the field.
Why the scaling tab rounds #
A signed 16-bit integer stores whole counts only, from -32768 to +32767. Two's complement arithmetic gives 2^15 = 32768, hence the limit. Any division whose result is kept as an integer drops the fractional part; that is how integer arithmetic works, not a defect in the software. The scaling tab maps one range onto another and delivers its result in the variable's own type, so hundredths round to whole units before the field ever sees them. Decimal-place settings on a field position the separator; they do not create fractional data.
A floating-point value carries a fraction in 32 bits, the width of a double integer, so fractions survive only where the value is held or evaluated as a float. That leaves two routes: have the PLC program supply a REAL, or keep the register an integer and divide in the display path. A meter that sends a four-digit integer leaves you the second route.
Confirm the divisor before touching the HMI #
Read the device register description and state what one count means. Then verify it live: put the meter online and compare its own indication with the PLC register. A register reading 4998 while the meter indicates 49.98 confirms hundredths, so one count is 0.01 of the displayed unit. Choose the divisor from the documentation, not from trial and error, because the wrong divisor yields a plausible number with the decimal point in the wrong place.
| Device sends | Register example | Divisor | Field format |
|---|---|---|---|
| Hundredths | 4998 gives 49.98 | 100 | xx.xx |
| Tenths | 4998 gives 499.8 | 10 | xx.x |
| Whole units | 50 gives 50 | none | xx |
Match the HMI variable type to the PLC data #
Keep the mapping honest before scaling anything. An integer register gets an integer communication variable. A 32-bit REAL spans two consecutive 16-bit registers, so it needs a float variable addressed across the pair. An integer variable pointed at float data, or a float variable pointed at an integer register, decodes bits that were never meant as that type, and the HMI software accepts the mismatch without complaint. An accepted configuration is not a correct one, and the symptom is a wild or frozen number that no amount of formatting repairs. If the register never changes at all, the connection is the fault rather than the math; start with why HMI indicators stay off over Modbus RTU polling.
Apply the conversion once, in a variable expression #
- Remove every existing conversion first: check the PLC logic, the variable's scaling tab, and any display-level expression. Two chained divisions of 100 leave the value off by a factor of 100, and both readings look plausible.
- Open the variable in the HMI project and find its expression editor. Select the communication variable through the editor rather than typing its name by hand.
- Enter the division with the divisor from the table above: for hundredths, the expression value is the raw variable divided by 100.
- Force the evaluation to a floating-point result. If the result type stays integer, 4998 evaluates to 49 or 50, a whole number either way; use the editor's documented conversion to float inside the expression before the value reaches the field.
- Confirm the intermediate value before touching any field format: with 4998 in the register, the expression must evaluate to 49.98.
Worked example: 4998 counts from a frequency meter displayed as 49.98 #
Inputs:
- Raw register value: 4998 counts, an integer verified online against the meter's own indication of 49.98.
- Device convention: one count equals 0.01 of the displayed unit, taken from the register description.
- Register width: signed 16-bit, so the storable range is -32768 to +32767 counts, from 2^15 = 32768 in two's complement.
Rule in words: the engineering value equals the raw counts divided by 100, and the field shows two digits after the decimal separator.
Arithmetic, written out:
- Display value: 4998 / 100 = 49.98
- Resolution: 1 / 100 = 0.01, the smallest change this display can ever show
- Positive headroom: 32767 / 100 = 327.67, the largest value one signed register carries in hundredths
- Negative limit: -32768 / 100 = -327.68, the value the field's sign position must accommodate
- Write-back check: 49.98 * 100 = 4998, the counts an operator entry must produce
Result: the expression returns 49.98, and the integer screen field with xx.xx formatting renders 49.98.
Decision: whenever the display must show any digit to the right of the decimal point, use the expression with a floating-point result and format the field to the documented decimal count. Leave the scaling tab to whole-unit display, where its rounding of 4998 to 50 is acceptable. The moment the maximum engineering value exceeds 327.67, one signed 16-bit register cannot carry hundredths at all; the device must then send two registers or a REAL, and the variable mapping changes with it.
Set the numeric field format #
Format follows the calculation; it never compensates for one. The working configuration for hundredths is an integer screen field fed by the expression and formatted xx.xx. On the floating-point route, set the data display to accept float data as well, or the fraction dies at the field.
Size the field from the arithmetic above: at least five digits plus a sign to cover 327.67 and -327.68, or the value clips at the range limits. Run the screen and check the rendered number for value and decimal position, not just that two digits appear after the separator.
One boundary worth drawing: an expression on the read side does not define the inverse conversion. If the field is writable, the operator's entry must be multiplied back to counts, 49.98 entered becomes 4998 written, and that path is commissioned separately; see keeping HMI-entered timer presets in PLC memory for how retained operator values are handled.
Symptoms that look like scaling errors #
| Symptom | Real cause | Fix |
|---|---|---|
| Whole-number display, decimals wanted | Result kept as integer | Move the divide into the expression with a float result |
| Wild or frozen number before scaling | Type or register-span mismatch | Correct the variable type and addressing first |
| Plausible value, decimal point one place off | Divisor 10 applied to hundredths, or 100 to tenths | Reconfirm the device convention and change one divisor |
| Value off by a factor of 100 | Conversion applied twice | Delete one of the chained conversions |
Which path to take #
| Case | Configuration | Outcome |
|---|---|---|
| Integer register, decimals needed | Expression divide by 100, float result, xx.xx | 4998 shows 49.98 |
| Integer register, whole units acceptable | Scaling tab | 4998 shows 50 |
| PLC supplies a REAL | Float variable, float display | Fraction arrives already scaled |
Keep the three checks separate: storage type in the PLC, evaluation in the expression, presentation in the field. Held apart, the decimal lands where the device documentation says it should, every time.
Questions asked
The meter sends tenths, not hundredths. What changes?
Only the divisor and the format. Tenths means one count is 0.1 unit, so divide by 10 and format the field with one decimal place: 4998 becomes 499.8. Confirm the convention against the register description before choosing, because a divisor of 100 applied to tenths data shifts the decimal point one place and still produces a plausible-looking number.
How do I write an operator-entered value back to the integer register?
Configure the write conversion separately, because a read-side expression does not create its inverse. Multiply the entered engineering value by 100 before it reaches the register: an operator entry of 49.98 must be written as 4998 counts. Check that the product stays inside the register range, since the entered value times 100 must remain within the 16-bit integer limits of -32768 to +32767.
The field shows a huge or zero number before any scaling. Why?
That is a data-type mismatch, not a scaling fault. A 32-bit floating-point value occupies two consecutive 16-bit registers, so an integer variable reading one register of it decodes bits that were meant as part of an exponent and mantissa, while a float variable pointed at integer data misreads the count. The HMI accepts either mapping without complaint, so fix the variable type and register span first, then scale.
Do decimal places on the field add resolution?
No. Formatting only positions the decimal separator; it neither creates nor restores fractional data. Resolution is fixed where the fraction survives, and in this configuration one register count equals 0.01, so the display can never resolve finer than that. If you need steps smaller than 0.01, the meter or the PLC must send more counts for each displayed value or a floating-point value.