Concept Flow - Digital input wiring (NPN vs PNP sensors)
Sensor Type?
Connect to GND
PLC Input
Detect LOW
The flow shows choosing sensor type (NPN or PNP), wiring it to power or ground, then connecting to PLC input to detect signal level.
IF sensor_type == 'NPN' THEN
input_signal = read_input()
IF input_signal == LOW THEN
output = ON
ELSE
output = OFF
ENDIF
ENDIF| Step | sensor_type | input_signal | Condition (input_signal == LOW) | Action | Output |
|---|---|---|---|---|---|
| 1 | NPN | LOW | True | Set output ON | ON |
| 2 | NPN | HIGH | False | Set output OFF | OFF |
| 3 | PNP | HIGH | N/A | No action (different wiring) | No Change |
| Variable | Start | After Step 1 | After Step 2 | After Step 3 |
|---|---|---|---|---|
| sensor_type | NPN | NPN | NPN | PNP |
| input_signal | UNKNOWN | LOW | HIGH | HIGH |
| output | OFF | ON | OFF | No Change |
Digital input wiring: - NPN sensors switch to GND when active (output LOW) - PNP sensors switch to +V when active (output HIGH) - PLC input detects LOW for NPN active, HIGH for PNP active - Wiring must match sensor type for correct detection - Code logic depends on sensor wiring type
Sensor output connected to PLC input; sensor negative to 0V; sensor positive to +24V.Pass the test and this pattern moves unknown