Bird
Raised Fist0
PLC Programmingscripting~15 mins

Internal relay (memory bit) addressing in PLC Programming - Deep Dive

Choose your learning style10 modes available
Overview - Internal relay (memory bit) addressing
What is it?
Internal relay addressing refers to using special memory bits inside a PLC (Programmable Logic Controller) to store and control internal states. These bits act like invisible switches inside the PLC that can be turned on or off by the program. They do not connect to physical devices but help the program remember conditions or control logic steps. This allows the PLC to perform complex tasks by keeping track of internal information.
Why it matters
Without internal relay addressing, PLC programs would struggle to remember past events or control sequences without physical inputs or outputs. This would make automation systems less flexible and more complicated. Internal relays let the PLC act like a brain with memory, enabling it to handle tasks like timers, counters, and step sequences smoothly. This makes machines smarter and more reliable in real life.
Where it fits
Before learning internal relay addressing, you should understand basic PLC programming concepts like inputs, outputs, and ladder logic. After mastering internal relays, you can learn advanced topics like timers, counters, and state machines that rely on these memory bits to function.
Mental Model
Core Idea
Internal relay addressing is like using invisible switches inside the PLC to remember and control program states without physical devices.
Think of it like...
Imagine a light switch panel with many switches, but some switches control lights in another room you can't see. These hidden switches let you control things indirectly and remember which lights should be on or off, even if you can't see them directly.
┌─────────────────────────────┐
│        PLC Program          │
│ ┌───────────────┐          │
│ │ Physical I/O  │          │
│ │ (Inputs/Outs) │          │
│ └──────┬────────┘          │
│        │                   │
│ ┌──────▼────────┐          │
│ │ Internal      │          │
│ │ Relays (Bits) │◄─────────┤
│ └───────────────┘          │
│                             │
└─────────────────────────────┘
Build-Up - 7 Steps
1
FoundationWhat are Internal Relays
🤔
Concept: Internal relays are memory bits inside the PLC used to store on/off states.
In PLCs, internal relays are special bits that do not connect to physical devices. They act like tiny switches inside the PLC's memory. You can turn them on or off with your program to remember conditions or control logic steps. For example, if a sensor input turns on, you might set an internal relay to remember that event.
Result
You can store and recall on/off states inside the PLC without physical inputs or outputs.
Understanding internal relays as memory bits helps you see how PLCs can keep track of information beyond just reacting to physical signals.
2
FoundationHow Internal Relays are Addressed
🤔
Concept: Each internal relay has a unique address or number used to control it in the program.
PLCs assign addresses to internal relays, often called memory bits or flags. These addresses look like M0, M1, M2, etc., depending on the PLC brand. When programming, you use these addresses to turn the relay on or off. For example, setting M0 ON means the internal relay at address 0 is active.
Result
You can control specific internal relays by referring to their unique addresses in your code.
Knowing that internal relays have addresses lets you organize and control many memory bits systematically.
3
IntermediateUsing Internal Relays in Ladder Logic
🤔Before reading on: do you think internal relays behave exactly like physical inputs in ladder logic? Commit to your answer.
Concept: Internal relays can be used as contacts and coils in ladder logic just like physical inputs and outputs.
In ladder logic, internal relays can appear as contacts (conditions) or coils (actions). For example, you can use M0 as a contact to check if it is ON, or as a coil to turn it ON or OFF. This lets you build complex logic by combining physical inputs with internal memory bits.
Result
You can create logic that depends on both real-world signals and internal memory states.
Understanding internal relays as both inputs and outputs in logic lets you build flexible and reusable control sequences.
4
IntermediateCommon Naming and Addressing Conventions
🤔Before reading on: do you think all PLC brands use the same internal relay addresses? Commit to your answer.
Concept: Different PLC brands use different naming and address formats for internal relays.
For example, Mitsubishi PLCs use M bits (M0, M1...), Siemens uses flags like M or Q, Allen-Bradley uses B3:0/0 style bits. Knowing your PLC's addressing scheme is important to write correct programs. Sometimes internal relays are grouped in bytes or words for efficient use.
Result
You can correctly address internal relays according to your PLC's standards.
Recognizing address differences prevents errors and helps you read and maintain programs across different PLC systems.
5
IntermediateInternal Relays for Temporary Storage
🤔
Concept: Internal relays can temporarily store states during program execution cycles.
PLCs scan programs repeatedly in cycles. Internal relays can hold states between scans. For example, if a condition is met, you set an internal relay ON, and it stays ON until reset. This temporary storage is essential for timers, counters, and step sequences.
Result
Your program can remember events and control sequences over time.
Knowing internal relays hold states between scans explains how PLCs manage time-based and sequential operations.
6
AdvancedMemory Bit Addressing Limits and Overlaps
🤔Before reading on: do you think internal relay addresses can overlap with physical I/O addresses? Commit to your answer.
Concept: Internal relay addresses are separate from physical I/O but can have addressing limits and overlaps within memory areas.
PLCs have limited memory bits for internal relays. Some bits may be reserved or shared with special functions. Addressing beyond limits can cause unexpected behavior. Also, some PLCs map internal relays in memory areas that overlap with other data types, requiring careful management.
Result
You avoid memory conflicts and program errors by respecting addressing limits.
Understanding memory layout and limits prevents subtle bugs and system crashes in complex programs.
7
ExpertOptimizing Internal Relay Usage in Large Programs
🤔Before reading on: do you think using many internal relays always improves program clarity? Commit to your answer.
Concept: Efficient internal relay use involves grouping, naming, and minimizing to optimize memory and readability.
In large PLC programs, using too many internal relays can waste memory and confuse maintenance. Experts group related bits into bytes or words, use meaningful names, and reuse bits carefully. Some PLCs support symbolic addressing to improve clarity. Also, internal relays can be used for interlocking, fault flags, and complex state machines.
Result
Your programs become more efficient, maintainable, and less error-prone.
Knowing how to manage internal relays at scale is key to professional PLC programming and system reliability.
Under the Hood
Internally, the PLC allocates a block of memory bits reserved as internal relays. Each bit corresponds to a single memory location that can be set or reset by the program. During each scan cycle, the PLC reads inputs, executes logic, and updates outputs and internal relays. The internal relay bits retain their state between cycles unless explicitly changed. This memory is separate from physical I/O memory and often faster to access.
Why designed this way?
Internal relays were designed to provide flexible, fast, and reusable memory inside PLCs without needing extra hardware. Early PLCs had limited physical I/O, so internal relays allowed programmers to build complex logic without adding physical devices. This design balances hardware simplicity with software power, enabling scalable automation solutions.
┌───────────────┐ Scan Cycle Start
│ Physical Inputs│
└──────┬────────┘
       │ Read Inputs
┌──────▼────────┐
│ Program Logic │
│ (Ladder Code) │
└──────┬────────┘
       │ Update
┌──────▼────────┐
│ Internal Bits │
│ (Relays M0..) │
└──────┬────────┘
       │ Update
┌──────▼────────┐
│ Physical Outs │
└───────────────┘

Cycle repeats continuously
Myth Busters - 4 Common Misconceptions
Quick: Do internal relays directly control physical devices? Commit to yes or no.
Common Belief:Internal relays are just like physical outputs and directly control devices.
Tap to reveal reality
Reality:Internal relays only exist inside the PLC memory and do not directly control physical devices.
Why it matters:Confusing internal relays with outputs can cause wrong wiring assumptions and program errors.
Quick: Can internal relay addresses be freely mixed with physical I/O addresses? Commit to yes or no.
Common Belief:You can use internal relay addresses interchangeably with physical input/output addresses.
Tap to reveal reality
Reality:Internal relay addresses are separate and must be used only for internal memory bits, not physical I/O.
Why it matters:Mixing addresses can cause unexpected behavior and hardware damage if outputs are misaddressed.
Quick: Do internal relays reset automatically after each scan cycle? Commit to yes or no.
Common Belief:Internal relays reset to OFF automatically every scan cycle.
Tap to reveal reality
Reality:Internal relays keep their state between scan cycles until changed by the program.
Why it matters:Assuming automatic reset leads to logic errors and unpredictable machine behavior.
Quick: Are internal relay address limits the same across all PLC brands? Commit to yes or no.
Common Belief:All PLCs have the same number and range of internal relay addresses.
Tap to reveal reality
Reality:Different PLC brands and models have different internal relay address ranges and limits.
Why it matters:Ignoring this causes programs to fail or behave incorrectly on different hardware.
Expert Zone
1
Some PLCs allow symbolic naming of internal relays, improving program readability and maintenance.
2
Internal relays can be grouped into bytes or words, enabling efficient batch operations and data handling.
3
Advanced PLCs use internal relays for inter-task communication and synchronization in multi-tasking environments.
When NOT to use
Internal relays should not be used to represent physical device states that require real-time hardware feedback. For such cases, use actual input/output addresses or specialized modules. Also, avoid overusing internal relays for large data storage; use data registers or arrays instead.
Production Patterns
In real-world PLC programs, internal relays are used for latching circuits, step sequence control, fault flags, and interlocking conditions. Professionals organize internal relays with clear naming conventions and groupings to simplify troubleshooting and updates. They also combine internal relays with timers and counters to build robust automation sequences.
Connections
Boolean Logic
Internal relays implement Boolean variables inside PLC programs.
Understanding internal relays as Boolean variables helps grasp how PLCs perform logical decisions and control flows.
Computer Memory Bits
Internal relays are a form of single-bit memory inside embedded systems.
Recognizing internal relays as memory bits connects PLC programming to general computer architecture concepts.
Human Working Memory
Internal relays function like short-term memory in human cognition, holding temporary information.
Seeing internal relays as memory bits similar to human working memory helps appreciate their role in managing sequences and decisions.
Common Pitfalls
#1Using internal relay addresses as if they control physical outputs.
Wrong approach:Set M0 ON expecting a motor to start without linking M0 to an output coil.
Correct approach:Use M0 as a condition and link it to an output coil like Y0 to control the motor.
Root cause:Misunderstanding that internal relays are memory bits, not physical outputs.
#2Assuming internal relays reset automatically each scan cycle.
Wrong approach:Program logic that sets M1 ON once, expecting it to turn OFF automatically next cycle.
Correct approach:Explicitly reset M1 OFF in the program when needed to change its state.
Root cause:Confusing internal relays with transient inputs that refresh every scan.
#3Mixing internal relay addresses with physical I/O addresses.
Wrong approach:Using M0 address to read a physical sensor input directly.
Correct approach:Use the correct input address (e.g., X0) for the sensor and M0 only for internal memory.
Root cause:Lack of understanding of separate memory areas for internal relays and physical I/O.
Key Takeaways
Internal relays are memory bits inside PLCs used to store and control program states without physical devices.
Each internal relay has a unique address used in programming to turn it ON or OFF and check its state.
They behave like invisible switches in ladder logic, acting as both contacts and coils to build complex control.
Understanding addressing limits and differences across PLC brands prevents errors and improves program reliability.
Efficient use of internal relays is essential for scalable, maintainable, and professional PLC automation programs.

Practice

(1/5)
1. What is the main purpose of an internal relay (memory bit) in PLC programming?
easy
A. To store ON/OFF states inside the PLC without controlling physical devices
B. To directly control motors and actuators
C. To provide power to sensors
D. To display output on the PLC screen

Solution

  1. Step 1: Understand internal relay function

    Internal relays store ON/OFF states inside the PLC memory but do not control physical devices.
  2. Step 2: Compare options

    Only To store ON/OFF states inside the PLC without controlling physical devices correctly describes this purpose; others mention controlling devices or power, which is incorrect.
  3. Final Answer:

    To store ON/OFF states inside the PLC without controlling physical devices -> Option A
  4. Quick Check:

    Internal relay = memory bit for logic [OK]
Hint: Internal relays remember states, not control devices [OK]
Common Mistakes:
  • Confusing internal relays with output devices
  • Thinking internal relays supply power
  • Assuming internal relays display information
2. Which of the following is the correct syntax to address an internal relay (memory bit) named M10 in a PLC program?
easy
A. D10
B. X10
C. Y10
D. M10

Solution

  1. Step 1: Identify internal relay address format

    Internal relays are commonly addressed with the letter 'M' followed by a number, e.g., M10.
  2. Step 2: Match options to address format

    M10 uses 'M10', which is correct. Other options use letters for inputs (X), outputs (Y), or data registers (D).
  3. Final Answer:

    M10 -> Option D
  4. Quick Check:

    Internal relay = M + number [OK]
Hint: Internal relays start with 'M' in address [OK]
Common Mistakes:
  • Using input (X) or output (Y) addresses for internal relays
  • Confusing data registers (D) with memory bits
  • Omitting the letter prefix
3. Given the following ladder logic snippet, what is the state of internal relay M5 after the rung executes?
--[ ]--[ ]--(M5)\n   I1   I2

Inputs: I1 = ON, I2 = OFF
medium
A. ON
B. OFF
C. Toggle
D. Undefined

Solution

  1. Step 1: Analyze input conditions

    The rung has two contacts in series: I1 and I2. I1 is ON, I2 is OFF.
  2. Step 2: Determine relay output state

    Both inputs must be ON for M5 to energize. Since I2 is OFF, M5 remains OFF.
  3. Final Answer:

    OFF -> Option B
  4. Quick Check:

    Series contacts require all ON for output ON [OK]
Hint: Series contacts need all ON to energize relay [OK]
Common Mistakes:
  • Assuming relay toggles automatically
  • Ignoring OFF input in series
  • Confusing parallel and series logic
4. In the following PLC code snippet, there is an error in addressing the internal relay. Identify the error:
LD X0\nAND M1\nOUT M2

What is the error?
medium
A. Using M1 as input in AND instruction is invalid
B. Incorrect internal relay address M2 in OUT instruction
C. No error, code is correct
D. Using input address X0 instead of internal relay

Solution

  1. Step 1: Review each instruction

    LD X0 loads input X0 state, AND M1 uses internal relay M1 as condition, OUT M2 sets internal relay M2.
  2. Step 2: Check addressing validity

    Inputs (X) and internal relays (M) are correctly used. M1 and M2 are valid internal relay addresses.
  3. Final Answer:

    No error, code is correct -> Option C
  4. Quick Check:

    Input and internal relay addresses used properly [OK]
Hint: Inputs use X, internal relays use M; both valid here [OK]
Common Mistakes:
  • Thinking internal relays can't be inputs
  • Assuming OUT can't target internal relays
  • Confusing input and output addresses
5. You want to use internal relays M10 and M11 to remember if two sensors S1 and S2 were ON at any time during a process. Which ladder logic sequence correctly sets M10 and M11 to ON when their respective sensors turn ON, and keeps them ON until reset?
hard
A. --[S1]--(M10)\n--[M10]--(M10)\n--[S2]--(M11)\n--[M11]--(M11)\n--[Reset]--(/M10)\n--[Reset]--(/M11)
B. --[S1]--(M10)\n--[S2]--(M11)\n--[Reset]--(/M10)\n--[Reset]--(/M11)
C. --[S1]--(M10)\n--[S2]--(M11)\n--[Reset]--(M10)\n--[Reset]--(M11)
D. --[S1]--(M10)\n--[S2]--(M11)\n--[Reset]--(M10)\n--[Reset]--(/M11)

Solution

  1. Step 1: Understand latch logic for memory bits

    To keep M10 and M11 ON after sensors turn ON, latch logic uses the internal relay itself in parallel with the sensor input.
  2. Step 2: Analyze options for latch and reset

    --[S1]--(M10)\n--[M10]--(M10)\n--[S2]--(M11)\n--[M11]--(M11)\n--[Reset]--(/M10)\n--[Reset]--(/M11) shows M10 and M11 set by sensors and latched by themselves, with reset contacts to turn them OFF. Others lack latching or proper reset.
  3. Final Answer:

    --[S1]--(M10)\n--[M10]--(M10)\n--[S2]--(M11)\n--[M11]--(M11)\n--[Reset]--(/M10)\n--[Reset]--(/M11) -> Option A
  4. Quick Check:

    Latching uses self-holding contact + reset to clear [OK]
Hint: Latch with self-contact to hold ON until reset [OK]
Common Mistakes:
  • Not using latch (self-holding) contacts
  • Resetting only one relay
  • Using reset coil instead of reset contact
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard