Table of Contents
MPINO STUDIO 2 Phase 2 · Understand Memory
This page explains the differences between P, M, D, C, T, and R memory, address notation, memory-region settings, where memory is used in a project, and special-bit memory.
About screenshots: Screenshots use the English user interface.
1. PLC Memory Basics
Unlike Arduino programs, PLC programs use P, M, D, C, T, and R memory. Arduino code can allocate variables from the remaining SRAM after the PLC memory regions have been allocated.
Memory holds input states, internal conditions, calculation results, timer values, and other data while the program runs. Ladder logic and Arduino C code in MPINO Studio 2 can share and use this memory.
A basic address consists of a region letter followed by a zero-based number. For example, M10 is the eleventh address in the M region, and D0 is the first address in the D region.
| Region | Unit | Storage form | Value range |
|---|---|---|---|
P | BIT | Digital input or output state on the board | 0 or 1 |
M | BIT | Internal BIT memory | 0 or 1 |
D | WORD | Signed internal WORD memory | -32,768 to 32,767 |
C | WORD | Counter value (signed internal WORD memory) | -32,768 to 32,767 |
T | WORD | Current timer value (signed internal WORD memory) | -32,768 to 32,767 |
R | Floating Point (32 bits) | Internal Floating Point memory (real-number memory) | Approximately -3.4028235E38 to +3.4028235E38 |
Sharing Memory Between Arduino Code and Ladder Logic
Ladder logic and Arduino code use the same storage for P, M, D, C, T, and R memory. A value written on one side can be read from the same address on the other side.
In Arduino code, use the ladder address name directly or write it in array form. Both forms refer to the same memory.
- Ladder
M0↔ Arduino codeM0orM[0] - Ladder
D0↔ Arduino codeD0orD[0] - Ladder
R0↔ Arduino codeR0orR[0]
void loop() { M0 = true; // Sets the M0 bit contact in the ladder to ON. D0 = 120; // Shares the D0 integer between ladder and Arduino code. R0 = 23.5f; // Shares the R0 floating-point value between both sides. ladderLoop(); // Runs the ladder logic with the values stored above. }
A value changed by ladder logic can be read in Arduino code after ladderLoop() finishes. Within one scan, read and write order follows the position of the ladderLoop() call inside loop().
I/O mapping caution: The P region and C addresses mapped to board functions are synchronized with physical I/O during a ladder scan. Before sharing these regions with Arduino code, check the address and I/O direction under Settings → Ladder Pin Map Settings.
P address caution: P addresses can be reviewed and changed in Board Pin Editing. Their I/O directions and physical terminals follow the definition of the board selected for the project.
R value error caution: Because of the limits of 32-bit floating-point arithmetic,0.1 + 0.2may be stored as approximately0.30000001instead of exactly0.3. This characteristic must be considered on controllers that use IEEE 754 32-bit floating point.
Use Arduino Variables in Ladder
Global variables declared outside functions in a .ino code file can be entered by name in ladder contacts, coils, comparison contacts, and box-function arguments. The variable name must match the Arduino code exactly, including letter case.
bool motorOn = false; // Used as motorOn in contacts and coils. uint16_t flags = 0; // Used in contacts and coils with a bit number, such as flags.3. int speed = 0; // Used in comparison contacts such as speed > 100, or as a box-function argument.
| Class | Supported C types | Use in contacts and coils |
|---|---|---|
| Bit | bool, boolean | Enter the name as is |
| Byte | char, signed char, unsigned char, int8_t, uint8_t, byte | Add a bit number from .0 to .7 |
| Word | int, unsigned int, short, unsigned short, int16_t, uint16_t, word | Add a bit number from .0 to .15 |
| Double-word | long, unsigned long, int32_t, uint32_t | Add a bit number from .0 to .31 |
| Floating-point | float, double | Not available (use a comparison contact such as temp > 30.5) |
Variables of every class can be used in comparison contacts and box-function arguments. They cannot be used in the following cases.
- A
constvariable is read-only, so it cannot be used as a coil or as a box-function argument that is written. - Arrays, structures,
String, pointers,staticvariables, variables declared together on one line, variables inside an#ifblock, and variables in.cppor.hfiles cannot be used. - A name shaped like a ladder address, such as
M0,WM0, orD200, is always read as a ladder address. - Arduino variables cannot be timer or counter targets or presets, and they cannot be used in the
SHL,SHR,ROL,ROR,WNOT,INV,H2D,D2H,GMOV,FMOV,SCALE,FLOOR, andSQRTcommands.
In the candidate list of the cell editor, an Arduino variable appears as “Variable · code file name”. A symbol name spelled exactly like an Arduino variable is an error, and the project cannot be built. If the names differ only in letter case (for example, symbol Speed and variable speed), a warning appears in the Problems tab when you build. In that case, cells that take a single address, such as contacts and coils, and argument fields that take an address in a structured box function use the symbol even if you enter the variable name. Comparison contacts and free-form box-function expressions use the Arduino variable. If you enter a variable that cannot be used, the reason appears in the Problems tab when you build.
Ladder monitoring does not receive Arduino variable values, so variable cells are not shown as ON or OFF, and hovering over such a cell shows “Arduino variable values are not monitored”. Values cannot be written to Arduino variables with the Write Value to Arduino popup or with Ctrl + 1 / Ctrl + 0.
2. Memory Regions
The MPINO-8A4R(T)-S board uses these default memory counts:
You can change the number of addresses used under Settings → Memory Area Settings. (Shortcut: Ctrl + Shift + M)
| Region | Default count | Default address range |
|---|---|---|
P | 64 | P0 to P63 |
M | 1,024 | M0 to M1023 |
D | 200 | D0 to D199 |
C | 100 | C0 to C99 |
T | 128 | T0 to T127 |
R | 50 | R0 to R49 |
Memory Area Settings: Blank P, M, D, C, T, and R fields use the board defaults. Entering a value changes the count for that project. The bottom of the dialog shows estimated SRAM use together with total SRAM.
In Timer units at the bottom of the dialog, you can also select the length of one timer tick (1 ms or 10 ms for T* timers; 10 ms, 100 ms, or 1000 ms for TA* timers). The selected values are saved in the project. See Phase 4-1 · Timer Unit Settings for details.
Do not confuse a count with the last address. Numbering begins at zero, so 200 D addresses run from D0 through D199.
C Region and Board Pin Mapping
On MPINO-8A4R(T)-S, analog inputs, NTC temperature inputs, and PWM are connected to C0 through C10 memory.
You can change the mapped memory under Settings → Ladder Pin Map Settings.
Analog/PWM output caution: When memory is mapped to an analog or PWM output, the value at the mapped address drives that output. You therefore cannot useanalogWrite-related functions for the same output in Arduino code. To use ananalogWrite-related function, clear Use for that output under Settings → Ladder Pin Map Settings.
| C address | Board function | MCU pin |
|---|---|---|
C0 to C5 | Analog inputs | A0 to A5 |
C6 to C7 | NTC temperature inputs | A6 to A7 |
C8 to C10 | PWM outputs | D21 to D23 |
C11 to C99 | Remaining C region not directly assigned above | Confirm the intended use before selecting an address |
Critical check: If you chooseC0throughC10as ordinary counter addresses on this board, their data can overlap with the board functions that use the same addresses. Before assigning a counter, check Settings → Ladder Pin Map Settings and Settings → Used Memory.
Mapped addresses vary by board and can also be changed by the user. Check them under Settings → Ladder Pin Map Settings.
3. Data Types
Data width is the number of bits read or stored at one time. It determines the available value range and memory use.
| Width | Size | Signed range | Typical use |
|---|---|---|---|
| BIT | 1 bit | 0 or 1 | Contacts, coils, and ON/OFF states |
| BYTE | 8 bits | -128 to 127 | Small integers |
| WORD | 16 bits | -32,768 to 32,767 | General integers and the basic values of D, C, and T |
| DWORD | 32 bits | -2,147,483,648 to 2,147,483,647 | Large integers beyond the WORD range |
The R region also uses 32 bits, but it stores a floating-point value, not a DWORD integer. Do not treat R memory as DWORD access simply because both use 32 bits.
When selecting a width, consider the largest value after calculations. A value incremented every 1 ms for one day reaches 86,400,000 and therefore exceeds the WORD range.
4. Read Memory Addresses
Read memory addresses by starting with the simplest form and adding the required elements one at a time.
M0: BIT address 0 in the M region.D0: WORD address 0 in the D region.D0.1: the second bit in the D0 WORD. Bit numbering starts at zero.WM1.2: the third bit inWM1, the WORD view of the M region. It refers to the same bit asM18.
Memory Structure
This diagram shows the memory structure for bits, bytes, words, double words, and floating-point values.
The P and M regions group individual BIT addresses in sets of 8, 16, or 32 for BYTE, WORD, and DWORD views. The lowest address is the least significant bit, so WM0.0 refers to M0, and WM1.3 refers to M19.
Each D, C, or T address is one WORD. Two consecutive WORDs form a DWORD: DD0 combines D0 and D1, while DD1 combines D2 and D3. C and T use the same rule through forms such as DC0 and DT0.
5. Find Memory Used by the Project
Select Settings → Used Memory, or press Ctrl+Shift+L.
| Marker | Item | Action |
|---|---|---|
| ① | Area tabs | Switches among the P, M, D, C, T, and R areas. P and M show 16 bits per row; D, C, T, and R show one address per row. |
| ② | Ladder and Code | Show or hide the addresses used by the ladder and by Arduino code. |
| ③ | Search address | Enter an address such as D5 and press Enter to switch to its area tab and highlight its row. |
| ④ | Used cells | Blue cells are used by the ladder, green cells by Arduino code, and purple cells by both. Select a cell to open the usage dialog. |
If a ladder cell is selected when you open this dialog, the tab and row for that cell's address appear immediately.
| Marker | Item | Action |
|---|---|---|
| ① | Usage locations | For the ladder, shows the ladder name and cell position (R row number, C column number); for Arduino code, shows the file name and line number. |
| ② | Go to | Moves to that ladder cell or code file and closes the Used Memory dialog. |
Inspecting this map before reassigning an address or reducing a memory-region size helps prevent duplicate use and out-of-range references.
6. Special-Bit Memory
Special-bit memory beginning with @ is updated automatically by MPINO Studio 2. It can be used in ladder bit contacts.
| Format | Operation | Example |
|---|---|---|
@ON | Always ON | Keeps a bit contact true |
@OFF | Always OFF | Keeps a bit contact false |
@<ms> | Turns ON for one scan once each specified time boundary | @100 is ON for one scan every 100 ms |
@F<ms> | Repeats ON for the specified duration, then OFF for the same duration | @F1000 repeats 1 second ON and 1 second OFF |
@ON and @OFF are case-insensitive, so @on and @off are also valid.
@100 still produces one ON scan when the program scan crosses a 100 ms boundary without landing exactly on it. It can start an operation or increment a value at regular intervals.
@F1000 provides a repeating one-second condition without code that manually toggles a state.
Follow these input rules:
- The time unit for
@<ms>and@F<ms>is milliseconds (ms). - Do not use parentheses. Enter
@F1000, not@F(1000). - Use special-bit memory only in bit contacts.
- Do not enter it as an output-coil address.
Troubleshooting
| Symptom | What to check |
|---|---|
| An entered address is rejected. | Check the region letter, address range, B/W/D prefix support, and .n bit-access support. |
| Memory Area Settings cannot be saved. | Check whether estimated SRAM use exceeds total SRAM and is shown in red. |
| An address does not appear in Used Memory. | Select the correct region tab and ladder/code filters, enter the address, and press Enter. |
| A C counter value is unexpected. | First check for overlap with the C0 through C10 board pin mapping on MPINO-8A4R(T)-S. |
@F1000 cannot be entered. | Confirm that the selected cell is a bit contact and that no parentheses are present. |



