Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to define the sensor type as PNP.
PLC Programming
sensor_type = "[1]"
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing NPN and PNP sensor types.
Using an invalid sensor type string.
✗ Incorrect
The sensor_type variable should be set to "PNP" to indicate a PNP sensor.
2fill in blank
mediumComplete the code to set the input wiring for an NPN sensor.
PLC Programming
input_wiring = "[1]"
Attempts:
3 left
💡 Hint
Common Mistakes
Selecting sourcing instead of sinking for NPN.
Confusing analog with digital wiring.
✗ Incorrect
NPN sensors use sinking input wiring, where the sensor sinks current to ground.
3fill in blank
hardFix the error in the code to correctly read a PNP sensor input.
PLC Programming
if sensor_input == [1]: activate_output()
Attempts:
3 left
💡 Hint
Common Mistakes
Checking for 0 instead of 1 for PNP sensors.
Using None or True which are not valid digital input values.
✗ Incorrect
PNP sensors output a high signal (1) when active, so the condition should check for 1.
4fill in blank
hardFill both blanks to complete the wiring logic for an NPN sensor input.
PLC Programming
if input_signal [1] [2]: start_process()
Attempts:
3 left
💡 Hint
Common Mistakes
Using != instead of == in the condition.
Checking for 1 instead of 0 for NPN sensor activation.
✗ Incorrect
NPN sensors pull the input low (0) when active, so the code checks if input_signal == 0.
5fill in blank
hardFill all three blanks to create a dictionary mapping sensor types to their wiring modes.
PLC Programming
wiring_modes = {
"PNP": "[1]",
"NPN": "[2]",
"Analog": "[3]"
}Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up sourcing and sinking for PNP and NPN.
Using digital instead of variable for analog wiring.
✗ Incorrect
PNP sensors use sourcing wiring, NPN use sinking, and analog signals are variable.
