Problem Overview
An operator on a PanelView Plus terminal must enter a single 8-digit decimal value (e.g., 34567890) and have the HMI software distribute each digit to a separate integer file word in a PLC-5/40E controller. The target is integer file N70 with elements N70:0 through N70:7, where the most significant digit lands in N70:0 and the least significant digit (ones place) lands in N70:7.
This is a classic PLC-5/40E sizing limitation. A PLC-5 integer file element is a 16-bit signed word with a maximum positive value of 32767. An 8-digit number such as 99999999 exceeds this by a factor of ~3,050 and cannot be stored in a single N word. FactoryTalk View Machine Edition User's Guide (VIEWME-UM004) does not provide a direct single-tag-to-array digit splatter, so the conversion must be performed either:
- In an HMI-side macro (VBScript) using integer division and the
Modoperator, or - In PLC-5 ladder logic using the
AEX(String Extract) andACI(ASCII Convert to Integer) instructions against a string tag such asST10:0.
The HMI-macro approach is the most portable and the one that ships out of the box on a stock FactoryTalk View ME runtime; the string approach is fragile because the AEX/ACI combination requires precise mid-string index handling and is sensitive to leading-zero padding.
PLC-5 Integer Constraints and Address Mapping
| Item | Specification |
|---|---|
| Controller | PLC-5/40E (1771-40E) on DH+ or EtherNet/IP |
| Target integer file | N70 (integer file 70) |
| Target words | N70:0 through N70:7 (8 consecutive words) |
| Word width | 16-bit signed integer |
| Per-word range | -32,768 to 32,767 (single digit 0-9 always fits) |
| Max 8-digit input | 99,999,999 (cannot fit in a single N word) |
| Digits per word | 1 (forced split required) |
| Byte order within word | Single decimal digit 0-9, no packed BCD required |
Because every target word holds a single decimal digit (range 0-9), the only required math is a base-10 decomposition. There is no need for BCD (D-file) handling, hexadecimal conversion, or 32-bit long-integer support inside the PLC-5 scan.
Prerequisites
- FactoryTalk View Studio v5.0 or later (catalog 9701-VWMx), with the runtime image deployed to a PanelView Plus 6, 7, or PanelView 5500 terminal.
- RSLogix 5 (or Studio 5000 with PLC-5 add-on profile) to confirm the
N70:0throughN70:7addresses exist in the data table. - RSLinx Enterprise / RSLinx Classic with an active topic to the PLC-5/40E.
- A working numeric input cursor configured in the HMI display that writes to an HMI memory tag of type
LongorDINTwith a 0-99,999,999 range. - A second HMI button or
DisplaySettingshutdown trigger to fire the split macro.
Solution 1: HMI-Side Modulus Macro (Recommended)
The most reliable method is a single VBScript macro fired on the shutdown of the numeric-entry pop-up display (or from a dedicated Transfer button). The macro reads the 32-bit HMI tag, applies integer division and modulus 10 to extract each decimal place, and writes one digit per N70:x word.
Macro Code
Sub SplitToN70
Dim v As Long
v = BigInput.Value ' 32-bit HMI tag, range 0..99999999
' Int() forces truncation so 9.999 does not round up to 10
N70_0 = Int(v / 10000000) Mod 10 ' ten-millions digit (MSB)
N70_1 = Int(v / 1000000) Mod 10 ' millions digit
N70_2 = Int(v / 100000) Mod 10 ' hundred-thousands digit
N70_3 = Int(v / 10000) Mod 10 ' ten-thousands digit
N70_4 = Int(v / 1000) Mod 10 ' thousands digit
N70_5 = Int(v / 100) Mod 10 ' hundreds digit
N70_6 = Int(v / 10) Mod 10 ' tens digit
N70_7 = v Mod 10 ' ones digit (LSB)
End Sub
Why Int() instead of the -0.5 trick
The original (value % 100)/10 - 0.5 approach used a subtraction to defeat implicit rounding when the HMI runtime converted a real to an integer word. That workaround silently corrupts legitimate zeros. A pure Int(value / divisor) expression always truncates toward zero, so a ones digit of 0 is written as 0, not as a negative stub. VIEWME-UM004 documents the Int, Fix, and Mod built-ins in the VBScript reference appendix.
Sample Verification (input 34567890)
| Word | Expression | Result | Digit position |
|---|---|---|---|
| N70:0 | Int(34567890/10000000) Mod 10 | 3 | Ten-millions (MSB) |
| N70:1 | Int(34567890/1000000) Mod 10 | 4 | Millions |
| N70:2 | Int(34567890/100000) Mod 10 | 5 | Hundred-thousands |
| N70:3 | Int(34567890/10000) Mod 10 | 6 | Ten-thousands |
| N70:4 | Int(34567890/1000) Mod 10 | 7 | Thousands |
| N70:5 | Int(34567890/100) Mod 10 | 8 | Hundreds |
| N70:6 | Int(34567890/10) Mod 10 | 9 | Tens |
| N70:7 | 34567890 Mod 10 | 0 | Ones (LSB) |
Solution 2: PLC-5 Ladder String Method (AEX + ACI)
Rockwell's FactoryTalk View ME documentation set cross-references PLC-5 string instructions. If you would rather do the split inside the PLC scan, the operator enters the value as a string (e.g., ST10:0 = "34567890") and the ladder pulls each character out.
PLC-5 Ladder Snippet (Rung Description)
-
Rung 1:
AEX ST10:0 ST10:1 0 1extracts the first character of the entry intoST10:1(string of length 1). -
Rung 2:
ACI ST10:1 N70:0converts the ASCII'3'(hex0x33) to the integer value3and stores it inN70:0. - Repeat for indexes
1..7, writing the converted values toN70:1throughN70:7in order. - Add an
EQUcompare onST10:0.LENequal to 8 to enable the conversion; otherwise left-justified short entries will leave trailing words stale.
03456789) and the HMI string tag drops it on write. Use the HMI macro approach (Solution 1) whenever zero anywhere in the 8-digit entry is a valid input.Solution 3: Pure PLC-5 Divide-and-Subtract Ladder (CompactLogix Heritage)
The pattern of divide-then-multiply-then-subtract in ladder logic works in CompactLogix but is not native to PLC-5 because PLC-5 has no 32-bit integer data type. Skip this approach on a PLC-5/40E.
HMI Tag Configuration
| Tag name | Type | Source | Range / scaling | Purpose |
|---|---|---|---|---|
| BigInput | HMI memory, Long (32-bit signed) | Internal | 0 to 99,999,999 | Captures the 8-digit operator entry from the numeric input cursor |
| N70_0 ... N70_7 | HMI tag alias to PLC device tag | PLC-5 N70:0..N70:7 | 0 to 9 (scaled 1:1) | Destination per-digit words; one tag per integer file element |
Numeric Input Cursor Settings
-
Tag:
BigInput - Minimum: 0
- Maximum: 99999999
- Input style: Decimal, no thousands separator
-
Display on shutdown: Run
SplitToN70macro (so the operator only touches one key, not two)
Step-by-Step Implementation
- Open the FactoryTalk View Studio project that targets your PanelView Plus terminal.
- In the project tree, expand HMI Tags and create an HMI memory tag named
BigInputwith data type Long (or DINT) and initial value0. - For each of
N70:0throughN70:7, browse to the PLC-5 device and add a tag alias. If you prefer one continuous block, addN70as an array of eight Int tags and referenceN70[0]throughN70[7]in the macro. - Open the display where the operator enters the 8-digit value. Insert a Numeric Input Cursor Point bound to
BigInput. Set Min = 0, Max = 99999999. - Click the cursor, go to Properties → Behavior → On Shutdown, and attach the
SplitToN70macro. (If you prefer an explicit button, drop a Command button on the display and set its Press - Run Macro action toSplitToN70.) - Paste the macro from the Macro Code section above into the project's Macros folder. Compile and save.
- Create eight Numeric Display objects on the same screen bound to
N70_0throughN70_7so the operator can see the split values immediately. - Download the runtime image to the PanelView Plus terminal and cycle power.
- In RSLogix 5, place the data monitor on
N70:0..N70:7to verify the writes.
Verification and Commissioning
Use the following test matrix. Each row exercises a different combination of leading-zero, mid-zero, and trailing-zero positions to prove that the Int-based macro does not lose zeros.
| Test # | Operator entry | Expected N70:0 | Expected N70:1 | Expected N70:2 | Expected N70:3 | Expected N70:4 | Expected N70:5 | Expected N70:6 | Expected N70:7 |
|---|---|---|---|---|---|---|---|---|---|
| 1 | 34567890 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 |
| 2 | 12000000 | 1 | 2 | 0 | 0 | 0 | 0 | 0 | 0 |
| 3 | 10000001 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
| 4 | 00000001 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
| 5 | 99999999 | 9 | 9 | 9 | 9 | 9 | 9 | 9 | 9 |
| 6 | 00000000 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
For each test, perform the entry, dismiss the pop-up, and confirm in RSLogix 5 that the eight N70:x values match. If a value is off by one, suspect a rounding error and re-check that you used Int(...) rather than implicit conversion.
Troubleshooting Matrix
| Symptom | Likely cause | Fix |
|---|---|---|
| All N70:x read -1 instead of the digit | VBA implicit rounding converted a value 0.999 to 1 after a -0.5 offset, leaving negatives |
Remove the -0.5 offset; use Int(v / divisor) Mod 10 for every line |
| Mid-string zeros become garbage | Operator typed a leading zero and the HMI tag dropped it (HMI tag is Integer not Long) | Change the HMI tag to Long/DINT and re-test |
| Values flicker on every PLC scan | PLC program overwrites N70 every scan with the wrong math | Use the HMI macro, not ladder |
| Macro runs but values never change | Wrong tag name or wrong HMI tag scope (project-level vs local) | Re-link tags under HMI Tags → Project and confirm the device shortcut is live in RSLinx Enterprise |
| Negative number appears in N70:0 | Operator entered a value > 99,999,999 and Int truncated to a negative 32-bit value | Clamp the numeric input Maximum to 99,999,999 |
| Macro error "Type mismatch: BigInput" | Tag type is Real or String, not Long | Re-create BigInput as Long (32-bit signed integer) |
Field-Proven Caveats and Edge Cases
-
Leading-zero handling. The PLC-5 integer file has no notion of "leading zero." An entry of
00000042is stored asN70:0..N70:6 = 0andN70:7 = 42only if you treatN70:7as the ones place and the rest as zero. Decide the digit-to-word mapping up front; do not flip it after commissioning. -
Sign. Never use this pattern to store a signed value. The HMI
BigInputmust be declared unsigned-equivalent by clamping the range to 0-99,999,999 in the numeric input. - Endianness. PLC-5 stores integers little-endian, but you are writing one digit per word, so the question is moot at the bit level. It is a real concern only if you later pack two digits per word using BCD.
- Performance. The macro runs once per pop-up shutdown; even a 400-MHz PanelView Plus 6 executes it in under 5 ms. No scan-time impact on the PLC-5.
-
Multilingual numeric formats. Some locales display
34,567,890with a thousands separator. Set the numeric input cursor to No Separator to prevent the runtime from rejecting the comma.
Related PLC-5 Instructions (For Reference)
| Mnemonic | File | Purpose |
|---|---|---|
| AEX | String | String Extract - pulls a substring of N characters from a source string |
| ACI | String | ASCII Convert to Integer - converts an ASCII character to its integer value |
| MOV | Integer | Move source to destination - useful for clearing all eight N70 words before the split |
| CLR | Integer | Clear a word to 0 |
| EQU | Integer | Equal compare - check ST10:0.LEN = 8 before triggering ACI |
FAQ
Why won't a single PLC-5 integer file element hold an 8-digit number?
A PLC-5 integer file element is a 16-bit signed word with a maximum positive value of 32,767. An 8-digit entry such as 99,999,999 cannot fit, so the value must be decomposed into at least eight 0-9 digit words before being written to N70:0 through N70:7.
Do I need a 32-bit HMI tag to capture the 8-digit entry?
Yes. The numeric input cursor must be bound to a 32-bit HMI memory tag (Long or DINT) ranging 0 to 99,999,999. A 16-bit HMI tag tops out at 32,767 and will reject any larger entry.
Will the macro lose zeros anywhere in the entry?
No, as long as you use Int(value / divisor) Mod 10 for every line. The legacy -0.5 offset trick used to defeat implicit rounding and silently corrupted legitimate zeros. The Int-based form always truncates toward zero and preserves zeros.
Can I do the split in PLC-5 ladder instead of an HMI macro?
Yes, using AEX (String Extract) and ACI (ASCII Convert to Integer) against a string tag. Field testing shows this approach is fragile when the operator enters leading zeros, because the HMI string write can drop them. The HMI macro method is preferred for zero-safe operation.
What tag should the numeric input cursor write to?
Bind the numeric input cursor to an HMI memory tag of type Long or DINT, with a minimum of 0 and a maximum of 99,999,999. Attach the SplitToN70 macro to the cursor's On Shutdown event so the operator only performs one entry step.