Set the HMI field to BCD with two decimal places so 5.10% lands in the PLC register as 510. Apply it with one rung: multiply the source by the register, divide by 10,000, and add 5000 before the divide when you want rounding instead of truncation. A four-digit BCD word tops out at 9999, so the field ceiling is 99.99%.
Set the HMI numeric entry to BCD with two decimal places, and treat the register it writes as an integer of hundredths of a percent. Enter 5.10 on the panel and the register holds 510. One short rung of PLC math then applies it: multiply the source value by the percent register, divide by 10000, and store the result. Add 5000 to the product just before the divide when the result should round to the nearest unit; leave that add out and the divide truncates. The ceiling comes from the word itself: four BCD digits stop at 9999, so the field accepts up to 99.99%, and 100.00 needs a different decimal setting. The steps below take the field, the rung and the tests in order, with the arithmetic carried through.
What the register holds
A BCD field with two decimal places stores the digits and draws the point. Enter 5.10 and the word holds 510; the point lives in the field's format, not in the data. The stored integer counts hundredths of a percent, so 510 stands for 510 ÷ 10000 = 0.051 as a multiplier.
That scaling also sets the ceiling. 100.00% would need the word to hold 10000, and four BCD digits stop at 9999. The field therefore tops out at 99.99%, stored as 9999. If the process needs a true 100.0, the field's decimal setting changes and the divisor moves with it; the numbers sit in the questions at the foot of this page.
What you need
- Three registers with one role each: the percent entry, the source value, the result. The example uses V3000 for the percent, V3001 for the source and V3002 for the result; substitute the addresses your program already has and keep the roles apart, so the HMI entry can never overwrite the value it is meant to scale.
- An HMI numeric entry set to BCD format, two decimal places, writing to the percent register.
- Ladder instructions your software names something like load, multiply, add a constant to the wide accumulator, divide the wide accumulator by a constant, store. The mnemonics below come from one instruction set; map each line to its equivalent in yours.
Steps
-
Set the field and read it back. Point the numeric entry at V3000, formatted BCD with two decimal places. Enter 5.10 on the panel, then read V3000 in the programming software: it must read 510. If it reads anything else, fix the field's format or address before touching the ladder, because a wrong raw value makes every number after it wrong.
-
Write the rung in this order.
LD V3001loads the source value.MUL V3000multiplies by the percent register. The example's product, 510,000, spans more than one four-digit word, and adding a 16-bit BCD value to a 32-bit BCD total covers that wide-word handling.ADDD K5000adds half of the divisor to the product. Include this line when the result should round to the nearest unit; omit it when truncation is acceptable. It applies to the nonnegative numbers a BCD word holds.DIVD K10000divides by 10000. The constant 10000 is five digits and cannot sit in a single BCD word, which is why this divide runs in its double-word form.OUT V3002stores the result.
The order carries the math: the add lands on the product, so it sits between the multiply and the divide.
-
Check the range before anything runs. The wide accumulator holds eight BCD digits, so the product ceiling is 99,999,999; a page on BCD double-word math in analog scaling walks that layout digit by digit. Hand-calculate the largest source the process will see, times 9999, and confirm the product fits. A product that outgrows the words the divide works on loses digits off the top and the quotient comes out quietly wrong; the walkthrough of BCD conversion losing digits in division shows where they go. Some CPUs raise a math-error flag on that overflow and the rung stops; the hand calculation catches either outcome before it reaches production.
Worked example: 5.10% of a count of 1000
The line has counted 1000 pieces into V3001, and the operator enters 5.10 in the HMI field, so V3000 reads 510.
Truncating rung. 1000 × 510 = 510,000, and 510,000 ÷ 10000 = 51 exactly, so V3002 holds 51. The true value is 1000 × 0.051 = 51.0, and nothing was lost.
A count that separates the two choices. At 1010 pieces the true value is 1010 × 0.051 = 51.51. The product is 1010 × 510 = 515,100. Truncation gives 515,100 ÷ 10000 = 51. With the add-half line, 515,100 + 5000 = 520,100, and 520,100 ÷ 10000 = 52 with 100 left over, so V3002 holds 52. Truncation reported 51 where the true value rounds to 52.
The ceiling. The operator enters 99.99 and V3000 reads 9999. 1000 × 9999 = 9,999,000. Truncation gives 9,999,000 ÷ 10000 = 999; the add-half line gives (9,999,000 + 5000) ÷ 10000 = 1000, and the true value of 999.9 rounds to 1000. An entry of 100.00 is refused, because 9999 is all the word holds.
With the add-half line in place every result is the nearest whole unit; without it, results sit up to 1 low.
How to check it worked
Run these on a test value before the rung controls anything real:
- Enter 0.01: V3000 reads 1, the smallest step the field expresses. With 1000 in the source the result reads 0, and that is correct: 0.01% of 1000 is 0.1 and the divide truncates it.
- Enter 5.10: V3000 reads 510, and with 1000 in V3001 the result register reads 51.
- Enter 99.99: V3000 reads 9999, and the field rejects 100.00. That rejection is the word limit doing its job.
- Hand-calculate one value as source × register ÷ 10000 and compare it with the result register, allowing for the rounding choice you made.
- Change the entry while watching the registers: only the percent register follows the field. If the source or result moves too, two tags point at one address.
- A result off by 10 or 100 almost always means the two sides stopped agreeing on scale; the article on an HMI value ten times too small runs that diagnosis for analog scaling, and the questions below carry the 100-times case.
Recommendation
Recommendation: Store the percent as hundredths in its own register and run load, multiply, ADDD K5000, DIVD K10000, store, accepting 99.99% as the ceiling. Keep the add-half line whenever the result feeds a count or a reading someone acts on; drop it only where a result leaning less than 1 low does no harm. If the panel truly needs 100.0, move the field to one decimal place and divide by 1000. Before the rung is enabled, hand-check the largest expected source times 9999 against the CPU's documented double-word range.
Questions
My source values run into the tens of thousands. What is the limit?
The dividend path is a double word, which holds eight BCD digits, so source × register must stay at or below 99,999,999. With 9999 in the percent register that allows a source up to 10,001, because 10,001 × 9999 = 99,999,999 exactly, while 10,002 × 9999 = 100,009,998 overflows it. Above that, scale the source down first or split the math into two passes, and confirm the double-word range your CPU documents for the multiply and the divide.
The process really needs 100.00%. What can I change?
Drop the field to one decimal place. 5.1% then stores as 51, the rung divides by 1000 instead of 10000, and 100.0 stores as 1000, which fits a four-digit word. The cost is resolution: the smallest step becomes 0.1% instead of 0.01%. The arithmetic lands in the same place: at 5.1% of a source of 1000, 1000 × 51 = 51,000 and 51,000 ÷ 1000 = 51.
The result comes out 100 times too big. Where do I look?
Read the raw percent register first. If it shows 5 where you entered 5.10, the field was set to whole percent or one decimal place while the rung still divides by 10000; align the field's decimal places with the divisor. If the register reads 510 and the result still comes out 100 times high, the rung divides by 100, so change that constant to 10000 and repeat the 5.10 and 1000 test, which must return 51.
Planning information, not legal or engineering advice. Rules differ by place: check codes and permits with your local authority and your licensed trades.