Bird
Raised Fist0
PLC Programmingscripting~5 mins

Output addressing scheme in PLC Programming - Time & Space Complexity

Choose your learning style10 modes available
Time Complexity: Output addressing scheme
O(n)
Understanding Time Complexity

When working with output addressing in PLC programming, it's important to understand how the program accesses and controls outputs.

We want to know how the time to set outputs grows as the number of outputs increases.

Scenario Under Consideration

Analyze the time complexity of the following output addressing code snippet.

FOR i := 0 TO n-1 DO
  Output[i] := TRUE;
END_FOR;

This code turns on each output from 0 up to n-1 one by one.

Identify Repeating Operations

Identify the loops, recursion, array traversals that repeat.

  • Primary operation: Setting each output bit to TRUE inside a loop.
  • How many times: The loop runs exactly n times, once for each output.
How Execution Grows With Input

As the number of outputs (n) increases, the program sets more outputs one by one.

Input Size (n)Approx. Operations
1010 output sets
100100 output sets
10001000 output sets

Pattern observation: The number of operations grows directly with the number of outputs.

Final Time Complexity

Time Complexity: O(n)

This means the time to set outputs grows in a straight line as the number of outputs increases.

Common Mistake

[X] Wrong: "Setting multiple outputs at once takes the same time as setting one output."

[OK] Correct: Each output must be addressed and set individually, so more outputs mean more time.

Interview Connect

Understanding how output addressing scales helps you explain how PLC programs handle many outputs efficiently and shows your grasp of program performance.

Self-Check

"What if we used a batch command to set all outputs at once? How would the time complexity change?"

Practice

(1/5)
1. What does the output addressing scheme in a PLC primarily specify?
easy
A. Which physical output device the PLC controls
B. The input device connected to the PLC
C. The programming language used in the PLC
D. The power supply voltage for the PLC

Solution

  1. Step 1: Understand output addressing purpose

    Output addressing tells the PLC which output device to activate or control.
  2. Step 2: Differentiate from inputs and other settings

    It does not specify inputs, programming language, or power supply.
  3. Final Answer:

    Which physical output device the PLC controls -> Option A
  4. Quick Check:

    Output addressing = physical output device [OK]
Hint: Output addressing points to the device PLC controls [OK]
Common Mistakes:
  • Confusing output with input addressing
  • Thinking it defines programming language
  • Mixing it with power supply details
2. Which of the following is a correct format for output addressing in a PLC?
easy
A. I:3/7
B. O:2/5
C. M:1/0
D. T:4/2

Solution

  1. Step 1: Identify output address format

    Output addresses usually start with 'O' followed by module and point numbers, e.g., O:2/5.
  2. Step 2: Recognize other prefixes

    'I' is for inputs, 'M' for memory bits, 'T' for timers, so they are incorrect for output addressing.
  3. Final Answer:

    O:2/5 -> Option B
  4. Quick Check:

    Output address starts with 'O' [OK]
Hint: Output addresses start with 'O:' followed by module/point [OK]
Common Mistakes:
  • Choosing input or memory addresses as output
  • Mixing timer addresses with outputs
  • Ignoring the prefix letter
3. Given the output address O:1/3, which physical output does it refer to?
medium
A. Module 1, output point 3
B. Module 3, output point 1
C. Input module 1, point 3
D. Memory bit 1, point 3

Solution

  1. Step 1: Parse the output address format

    O:1/3 means output module 1, point 3 (the third output on module 1).
  2. Step 2: Exclude other interpretations

    It is not a memory bit, not an input module, and the format is module/point (not point/module).
  3. Final Answer:

    Module 1, output point 3 -> Option A
  4. Quick Check:

    O:1/3 = module 1, point 3 [OK]
Hint: Format is O:module/point, read left to right [OK]
Common Mistakes:
  • Swapping module and point numbers
  • Confusing output with input addresses
  • Ignoring the prefix 'O:'
4. Identify the error in this output address: O:2-4
medium
A. Output point cannot be 4
B. Module number cannot be 2
C. Incorrect separator; should use '/' instead of '-'
D. Prefix 'O' is invalid

Solution

  1. Step 1: Check the separator in the address

    Output addresses use a slash '/' to separate module and point, not a dash '-'.
  2. Step 2: Validate other parts

    Module 2 and point 4 are valid numbers, and 'O' prefix is correct for output.
  3. Final Answer:

    Incorrect separator; should use '/' instead of '-' -> Option C
  4. Quick Check:

    Use '/' between module and point [OK]
Hint: Use '/' not '-' between module and point [OK]
Common Mistakes:
  • Using dash instead of slash
  • Thinking module or point numbers are invalid
  • Misunderstanding the prefix letter
5. You have a PLC with 3 output modules. Module 0 has 8 points, module 1 has 8 points, and module 2 has 4 points. Which output address correctly refers to the last output point of module 2?
hard
A. O:1/7
B. O:2/4
C. O:3/0
D. O:2/3

Solution

  1. Step 1: Understand module points numbering

    Points start at 0, so module 2 with 4 points has points 0,1,2,3.
  2. Step 2: Identify last point of module 2

    The last point is 3, so address is O:2/3. O:2/4 is invalid (point 4 does not exist).
  3. Step 3: Exclude other options

    O:3/0 is invalid (module 3 does not exist). O:1/7 is last point of module 1, not module 2.
  4. Final Answer:

    O:2/3 -> Option D
  5. Quick Check:

    Last point = points - 1 = 3 [OK]
Hint: Last point = total points minus one [OK]
Common Mistakes:
  • Counting points starting at 1 instead of 0
  • Using invalid module numbers
  • Confusing module and point numbers
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