📖 Scenario: You work in a factory where machines are controlled by a Programmable Logic Controller (PLC). Sometimes, the machines stop working because of errors in the PLC program. Your job is to find and fix these errors by reading the PLC program and checking the status of inputs and outputs.
🎯 Goal: Build a simple PLC troubleshooting script that checks the status of inputs and outputs, identifies errors, and prints a clear message to help fix the problem.
📋 What You'll Learn
Create a dictionary called inputs with exact keys 'StartButton', 'StopButton', and 'EmergencyStop' and their boolean values
Create a dictionary called outputs with exact keys 'Motor' and 'Alarm' and their boolean values
Create a variable called error_detected set to False
Use a for loop with variables input_name and status to iterate over inputs.items()
Inside the loop, set error_detected to True if EmergencyStop is True
Print the final error status message exactly as specified
💡 Why This Matters
🌍 Real World
In factories, PLCs control machines. Troubleshooting scripts help quickly find problems to reduce downtime.
💼 Career
Technicians and engineers use similar scripts to monitor and fix industrial control systems efficiently.
Progress0 / 4 steps
1
Set up input and output status
Create a dictionary called inputs with these exact entries: 'StartButton': True, 'StopButton': False, 'EmergencyStop': False. Also create a dictionary called outputs with these exact entries: 'Motor': True, 'Alarm': False.
PLC Programming
Hint
Use curly braces {} to create dictionaries. Make sure the keys and values match exactly.
2
Add error detection variable
Create a variable called error_detected and set it to False.
PLC Programming
Hint
Use a simple assignment statement to create the variable.
3
Check inputs for emergency stop
Use a for loop with variables input_name and status to iterate over inputs.items(). Inside the loop, if input_name is 'EmergencyStop' and status is True, set error_detected to True.
PLC Programming
Hint
Use inputs.items() to get key-value pairs. Check if the key is 'EmergencyStop' and the value is True.
4
Print error status message
Write a print statement that prints exactly 'Error detected: Emergency Stop is active.' if error_detected is True. Otherwise, print 'No errors detected. System is running normally.'.
PLC Programming
Hint
Use an if statement to check error_detected and print the correct message.
Practice
(1/5)
1. What is the first step when troubleshooting a PLC system that is not starting?
easy
A. Reset the factory settings without checking
B. Rewrite the entire PLC program
C. Replace all wiring immediately
D. Check if the PLC has power and is turned on
Solution
Step 1: Verify power supply to the PLC
Without power, the PLC cannot operate, so checking power is the first logical step.
Step 2: Confirm PLC is turned on and indicators are normal
Indicators like LEDs show if the PLC is active or has faults.
Final Answer:
Check if the PLC has power and is turned on -> Option D
Quick Check:
Power check = first troubleshooting step [OK]
Hint: Always check power first before anything else [OK]
Common Mistakes:
Jumping to program changes without checking power
Replacing wiring without diagnosis
Resetting without understanding the problem
2. Which of the following is the correct syntax to read an input named I0.0 in a PLC ladder logic program?
easy
A. INPUT(I0.0)
B. READ I0.0
C. LD I0.0
D. GET I0.0
Solution
Step 1: Identify standard ladder logic instruction for input
LD (Load) is the common instruction to read an input bit in ladder logic.
Step 2: Compare options with standard syntax
Only 'LD I0.0' matches typical ladder logic syntax for reading input.
Final Answer:
LD I0.0 -> Option C
Quick Check:
LD = load input instruction [OK]
Hint: Use LD to load inputs in ladder logic [OK]
Common Mistakes:
Using non-standard commands like READ or GET
Adding parentheses incorrectly
Confusing input reading with output commands
3. Given this PLC ladder logic snippet:
LD I0.1
AND I0.2
OUT Q0.0
What will be the output Q0.0 if I0.1 is ON and I0.2 is OFF?
medium
A. Q0.0 will be ON
B. Q0.0 will be OFF
C. Q0.0 will toggle ON and OFF rapidly
D. The program will cause an error
Solution
Step 1: Evaluate the AND condition with inputs
AND requires both I0.1 and I0.2 to be ON. Here, I0.1 is ON but I0.2 is OFF.
Step 2: Determine output based on AND result
Since one input is OFF, the AND condition is false, so Q0.0 will be OFF.
Final Answer:
Q0.0 will be OFF -> Option B
Quick Check:
AND false = output OFF [OK]
Hint: AND needs all inputs ON for output ON [OK]
Common Mistakes:
Assuming output ON if any input is ON
Confusing AND with OR logic
Expecting errors from simple logic
4. A PLC program is not turning on an output Q0.1 even though the input I0.3 is ON. The code snippet is:
LD I0.3
OUT Q0.1
What is the most likely error?
medium
A. The output address Q0.1 is incorrect or not configured
B. The input I0.3 cannot be ON in PLC logic
C. The LD instruction is invalid syntax
D. The PLC program must use AND before OUT
Solution
Step 1: Check input and output addresses
Input I0.3 is ON, so the problem is likely with output Q0.1 address or configuration.
Step 2: Validate output wiring and PLC configuration
If Q0.1 is not configured or wired correctly, output won't activate despite correct logic.
Final Answer:
The output address Q0.1 is incorrect or not configured -> Option A
Quick Check:
Output config error = no output ON [OK]
Hint: Check output address and wiring if output stays OFF [OK]
Common Mistakes:
Assuming input cannot be ON
Thinking LD is wrong syntax
Believing AND is always needed before OUT
5. You have a PLC controlling a conveyor belt. The belt should run only if both sensors I0.0 and I0.1 detect objects. The current program uses:
LD I0.0
OR I0.1
OUT Q0.0
What change should you make to fix the logic so the belt runs only when both sensors detect objects?
hard
A. Change OR to AND in the program
B. Add a NOT instruction before I0.1
C. Replace OUT with IN instruction
D. Remove I0.0 from the program
Solution
Step 1: Understand the current logic
OR means the belt runs if either sensor detects an object, but requirement is both sensors must detect.
Step 2: Replace OR with AND to require both sensors ON
AND ensures output Q0.0 is ON only when both I0.0 and I0.1 are ON.
Final Answer:
Change OR to AND in the program -> Option A
Quick Check:
AND = both inputs ON for output ON [OK]
Hint: Use AND to require all conditions true [OK]
Common Mistakes:
Using OR when AND is needed
Adding NOT incorrectly
Confusing OUT with input instructions
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.