NOT logic with NC contact in PLC Programming - Time & Space Complexity
We want to understand how the time it takes to run a PLC program changes when using NOT logic with a Normally Closed (NC) contact.
Specifically, we ask: How does the program's execution time grow as the number of contacts increases?
Analyze the time complexity of the following PLC ladder logic snippet using NC contacts.
// Example PLC code using NOT logic with NC contact
IF NOT Input1 THEN
Output1 := TRUE;
ELSE
Output1 := FALSE;
END_IF;
IF NOT Input2 THEN
Output2 := TRUE;
ELSE
Output2 := FALSE;
END_IF;
// Repeat for n inputs
This code checks each input using NOT logic on NC contacts and sets outputs accordingly.
Look for repeated checks or loops in the code.
- Primary operation: Checking each input with NOT logic on NC contact.
- How many times: Once per input, repeated for n inputs.
Each input requires one NOT check and one output assignment.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 | About 10 NOT checks and 10 output sets |
| 100 | About 100 NOT checks and 100 output sets |
| 1000 | About 1000 NOT checks and 1000 output sets |
Pattern observation: The number of operations grows directly with the number of inputs.
Time Complexity: O(n)
This means the time to run the program grows in a straight line as the number of NC contacts increases.
[X] Wrong: "Using NOT logic with NC contacts makes the program run instantly regardless of input count."
[OK] Correct: Each contact still needs to be checked one by one, so more contacts mean more checks and longer execution time.
Understanding how simple logic like NOT with NC contacts scales helps you explain how PLC programs behave as they grow, a useful skill in real automation work.
What if we combined multiple NC contacts in series instead of checking them separately? How would the time complexity change?
Practice
Solution
Step 1: Understand NC contact behavior
An NC contact means the circuit is closed (ON) when the switch is not pressed.Step 2: Compare options with NC contact logic
Only The circuit is ON when the switch is NOT pressed correctly states the circuit is ON when the switch is NOT pressed.Final Answer:
The circuit is ON when the switch is NOT pressed -> Option AQuick Check:
NC contact = ON when NOT pressed [OK]
- Confusing NC with Normally Open (NO) contact
- Thinking circuit is ON when switch is pressed
- Assuming NC contact toggles automatically
Solution
Step 1: Recall PLC contact symbols
Normally Open (NO) contact is--| |--, Normally Closed (NC) contact is--|/|--.Step 2: Match symbol to NC contact
--|/|--shows--|/|--, which is the correct NC contact symbol.Final Answer:
--|/|-- -> Option CQuick Check:
NC contact symbol = --|/|-- [OK]
- Choosing NO contact symbol instead of NC
- Confusing symbols with AND/OR logic
- Using invalid or made-up symbols
Stop controlling output Motor:
--|/|--(Stop)----( )--(Motor)What happens to
Motor when the Stop button is pressed?Solution
Step 1: Understand NC contact effect when pressed
Pressing the NC contact opens the circuit, breaking the path.Step 2: Determine output state
Since the circuit is open, the Motor output coil is not energized and turns OFF.Final Answer:
Motor turns OFF -> Option AQuick Check:
Pressing NC contact = circuit open = output OFF [OK]
- Assuming pressing NC turns output ON
- Thinking output toggles automatically
- Ignoring NC contact behavior
EmergencyStop to stop a conveyor motor. The motor never stops when the emergency button is pressed. What is the most likely error?Solution
Step 1: Analyze symptom
Motor never stops when emergency button pressed means circuit does not open.Step 2: Identify wiring error
If NC contact is wired as NO, pressing button closes circuit instead of opening it, so motor stays ON.Final Answer:
The NC contact is wired as Normally Open (NO) -> Option BQuick Check:
Wrong contact type wiring = motor won't stop [OK]
- Blaming output coil without checking input wiring
- Assuming button press duration causes issue
- Ignoring PLC power status
SafetySwitch and an output coil MachineRun. Which ladder logic rung correctly implements the NOT logic with the NC contact to stop the machine when the switch is pressed?Solution
Step 1: Identify correct NC contact usage
Safety stop uses NC contact so circuit is closed (MachineRun ON) when switch NOT pressed.Step 2: Match ladder logic rung
--|/|--(SafetySwitch)----( )--(MachineRun)uses NC contact--|/|--controllingMachineRunoutput correctly.Final Answer:
--|/|--(SafetySwitch)----( )--(MachineRun) -> Option DQuick Check:
NC contact before output coil = safety stop logic [OK]
- Using NO contact instead of NC for safety stop
- Reversing contact and coil positions
- Confusing contact labels with output coil
Ready to prove it?
Pass the test and this pattern moves unknown
