A keypad key can only send digits into the entry buffer, so it can never send a fraction. Store the dimension as an integer count of 32nds, enter the count on the panel's existing keypad, and convert to inches in the PLC: 3 1/4 in is 104 counts, 5/8 in is 20. Custom keys belong on a screen created with the keypad screen type.
A key on an HMI keypad does one thing when pressed: it sends a digit or a function into the entry buffer of the object that opened the keypad. It cannot send 5/8. So a keypad covered in fraction keys is not the fix. The fix is how the number is stored. Keep the dimension as an integer count of 32nds, let the operator type the count on the keypad the panel already has, and convert to inches where the machine needs them. Type 104 for 3 1/4 in. Type 20 for 5/8 in. Custom keys, where you really want them, work only from a screen created with the keypad screen type: a layout copied onto an ordinary screen never appears in the numeric entry object's keypad list.
Why a fraction key cannot work
Every numeric entry object holds a single number in its buffer while you type. A key injects one character into that buffer, a digit 0 through 9 or the decimal point, or runs one function: backspace, clear, enter, cancel. A key labeled 5/8 has nothing valid to write. The buffer can end up holding 0.625, but getting there takes three keystrokes and a key fires exactly one. The keypad is an input device for one number, so the fraction has to be built into the encoding of that number. Decide the encoding before you draw a single key.
Three ways to store 32nds
| Method | Operator enters | Stored value | Custom keypad |
|---|---|---|---|
| Count of 32nds | 104 for 3 1/4 in | one integer; inches = count ÷ 32 | no |
| Whole inches plus numerator | 3, then 8 | two integers; total = whole × 32 + numerator | helps, with a limited numerator |
| Increment buttons | taps that add or subtract steps | one integer; each press adds a fixed count | no, plain buttons work |
The count method is one entry, one register, one conversion. The whole-plus-numerator method matches how a drawing reads out, but it needs two entries and a hard limit of 0 to 31 on the numerator, because a numerator of 32 silently adds a whole inch. Increment buttons are the way to run tonight on a panel that offers no keypad customization.
What you need
- One integer tag for the count.
- Entry limits set at the machine's real travel: a 30 in stroke is 0 to 960 counts, because 960 ÷ 32 = 30.
- One conversion in the controller, written once, from counts to decimal inches.
- The panel programming software and its screen manager, only if you build a custom keypad.
- A data view in the controller, so you can read the tag after every test entry.
How to build it
- Add the integer tag to the controller and make it retentive, so the last dimension set survives a power cycle.
- Place the numeric entry object. Set its data type to integer, minimum 0, maximum at the machine's travel in counts. If the object caps the digits you can type before the range fits, the fix in enter 5 digits on an HMI numeric entry limited to 4 widens it.
- Leave the keypad assignment on the panel's built-in numeric keypad. A count needs no special keys.
- For the whole-plus-numerator method, build the keypad: in the screen manager, create a new screen and set its screen type to keypad as you create it. Copy the key objects from the built-in keypad template into that screen, delete the decimal point key, and check that every key left on it still carries a key function: digit, backspace, clear, enter, cancel. Give the screen its own name so the list entry is unambiguous. The assignment itself works the same way as when you link a user-defined keypad to an HMI numeric entry object.
- Select the screen in the numeric entry object's keypad list. That list offers the built-in keypads plus screens of keypad type only. Buttons pasted onto an ordinary base or popup screen never appear in it, which is why a copied keypad layout looks right in the editor and still cannot be called.
- Write the conversion in the controller: decimal inches = count × 0.03125, since one count is 1 ÷ 32 in. Keep the tag an integer and convert to floating point only where the machine needs decimal inches. The object writes the count on Enter; move an HMI numeric entry into PLC memory on Enter covers the write side when the value lands in the wrong register.
- Save and transfer the project to the panel.
Worked example: set a shaft to 3 1/4 in
The drawing calls the target out in 32nds: 3 1/4 in. The operator touches the entry object and types 104, because 3 × 32 + 8 = 104. On Enter the object writes 104 into the controller tag, and the conversion gives 104 ÷ 32 = 3.25 in. Check it backwards: 3.25 × 32 = 104. The next part on the job sheet reads 5/8 in, so the operator types 20 and the machine sees 20 × 0.03125 = 0.625 in. The display beside the entry splits the count back into drawing form: 104 ÷ 32 leaves 3 with a remainder of 8, shown as 3 and 8/32. On the 30 in stroke with the maximum at 960, a mistyped 1200 is refused at the object.
How to check it worked
- Touch the entry object. The keypad you assigned opens, not a different one.
- Type 20 and press Enter. The controller tag reads 20 and the conversion output reads 0.625 in.
- Type 961 on the 30 in stroke. The object refuses it, because the maximum is 960.
- Start an entry and press Cancel partway through. The tag keeps its old value.
- Cycle power on the panel and touch the object again. The same keypad opens, which proves the assignment survived the transfer.
For the decimal readout of the converted value, show decimal flow values on an HMI numeric display covers the scaling on the display side.
Mistakes that recur
- Storing decimal inches in a floating point tag and typing values like 3.25. Rounding on entry and display drifts the value by a full 32nd, and the parts come out long or short. Keep the integer and convert once, in the controller.
- A numerator field with no limit. On the two-field method, a numerator of 32 adds a whole inch to the total. Limit the field to 0 to 31 at the object.
- Editing the built-in keypad and expecting a save. The built-in keypads are templates; duplicate the layout into your own keypad-type screen and assign that screen in the object.
- Building the custom keypad on a copied screen. The screen type is set when the screen is created, so the copy has to be rebuilt with the keypad type, not patched in place.
The decision
Recommendation: Store every fractional dimension as one integer count of 32nds and let the operator type the count on the panel's existing keypad. Add a custom keypad only when entries must read as whole inches plus a numerator; build it on a screen created with the keypad screen type, delete the decimal point key, and limit the numerator to 0 to 31 at the object.
Questions
What integer range does a 32nds count need?
A 16-bit signed register tops out at 32,767, and 32,767 ÷ 32 is about 1023 in, so one register holds any dimension a machine stroke will need. An unsigned register doubles the ceiling to 65,535 counts, about 2047 in, which nothing here requires. Keep the entry limits at real travel anyway: a 30 in stroke is 0 to 960 counts, because 960 ÷ 32 = 30.
How do I show the stored count back as inches and 32nds?
Split the count with integer math. Whole inches are the count divided by 32 with the remainder dropped; the numerator is the remainder, the count modulo 32. A count of 104 gives 104 ÷ 32 = 3 with remainder 8, read as 3 and 8/32. Set the whole-inch display to truncate, because a display that rounds will turn a count of 112, which is 3 and 16/32, into 4 in on the screen.
What if the panel has no custom keypad option at all?
Use plain buttons. Give each one an add-constant action on the integer tag: 32 counts per whole inch, then 16, 8, 4, 2 and 1 for the fraction steps, so the 1/16 button adds 2 counts. Put a subtract button beside each step to undo a mis-tap, and a numeric display beside them so the operator sees the running total. No keypad screen is involved.
Planning information, not legal or engineering advice. Rules differ by place: check codes and permits with your local authority and your licensed trades.