E/A
Digitale Eingänge und Ausgänge sind die Schnittstelle zwischen der physischen Welt und der SPS. Druckknopf, Näherungsschalter, Sicherheitsrelais, Magnetventil — alle kommunizieren über digitale E/A-Kanäle. Das Verständnis dieser Signale — wie sie erzeugt, konditioniert, verdrahtet, gelesen und geschützt werden — ist die Grundlage jedes Automatisierungssystems.
Vor dieser Lektion sollten Sie kennen:
Ein digitales Signal hat genau zwei Zustände: EIN (Logik 1, WAHR, HIGH) oder AUS (Logik 0, FALSCH, LOW). In der industriellen Automatisierung ist der häufigste Standard 24V DC: ca. 0V steht für AUS und ca. 24V für EIN. Das Verständnis, wie diese beiden Zustände definiert, erkannt und sichergestellt werden, ist die Grundlage jeder zuverlässigen Maschinenkonstruktion.
Drag the voltage slider and watch which logic zone the signal falls into. Real-time visual of the IEC threshold bands.
Click the sensor to toggle its state. Watch current flow and PLC input state for both PNP and NPN configurations.
Reale industrielle Digitalsignale sind keine sauberen 0/1 aus dem Lehrbuch: Sie haben Anstiegszeiten, überlagerten Rauschen, Massepotentialverschiebungen und können in der undefinierten Zone zwischen den Schwellen liegen. IEC 61131-2 definiert exakt, welche Spannungen einen garantierten Logik-0- und Logik-1-Zustand für 24V-DC-Systeme darstellen. Jeder kompetente Automatisierungsingenieur kennt diese Werte auswendig.
// IEC 61131-2 — 24V DC digital signal thresholds
// Type 1 inputs (most common industrial standard)
//
// Voltage range │ Guaranteed state
// ─────────────────┼─────────────────────────────────
// −3V to +5V │ Logic 0 (OFF) — guaranteed
// +5V to +15V │ UNDEFINED — avoid this zone
// +15V to +30V │ Logic 1 (ON) — guaranteed
//
// Real sensor output voltages (good design):
// Sensor OFF: 0V to 1V (well within logic 0 zone)
// Sensor ON: 22V to 24V (well within logic 1 zone)
//
// Common problems that push into undefined zone:
// Long cable + high sensor current → voltage drop
// Shared 0V rail with heavy loads → ground lift
// Damaged sensor output transistor → partial conduction
// Missing termination on shielded cable
//
// Test procedure:
// Measure signal with multimeter (DC) at PLC input terminal
// Expected OFF: < 5V. Expected ON: > 15V
// Anything between 5–15V: INVESTIGATE before commissioning
Industrielle Sensoren und Aktoren verwenden vier Haupt-Ausgangstypen. PNP (sourcend): Der Transistor verbindet den Ausgang mit +24V — am häufigsten in Europa. NPN (sinkend): Der Transistor verbindet den Ausgang mit 0V — häufig in Asien und den USA. Push-Pull: Funktioniert mit beiden Polaritäten. Potenzialfreier Kontakt: Ein mechanischer Schalterkontakt ohne eigene Spannung — für Not-Halt-Taster und Sicherheitsgeräte.
// Signal type wiring examples — 24V DC system
//
// ── PNP (Sourcing) sensor → PLC input ──────────────────────
// +24V ──────────── Sensor Vcc
// Sensor OUT ──────── PLC Input +
// 0V ──────────── Sensor GND ──────── PLC Input − (Common)
//
// When sensor detects: OUT → +24V → PLC sees HIGH
// When sensor not det: OUT → floating/0V → PLC sees LOW
// Current path: +24V → Sensor → PLC input impedance → 0V
// ── NPN (Sinking) sensor → PLC input ───────────────────────
// +24V ──────────── Sensor Vcc ──── Pull-up resistor ──────┐
// Sensor OUT ──────────────────────── PLC Input
// 0V ──────────── Sensor GND ──── PLC Input − (Common)
//
// When sensor detects: OUT pulls to 0V → PLC sees LOW? No:
// NPN sinking means current flows INTO sensor OUT
// PLC input sees +24V when sensor OFF, 0V when sensor ON
// → Input logic is INVERTED for NPN with pull-up wiring
// ── DRY CONTACT (potential-free) → PLC input ───────────────
// +24V ──── PLC Input + supply ──── Contact A
// Contact B ──── PLC Input
// 0V ──── PLC Input − (Common)
//
// When contact closes: current flows through contact → PLC HIGH
// Galvanically isolated from any external voltage source
// Used for: E-Stop, safety relay contacts, manual switches
// ── PUSH-PULL sensor → PLC input ────────────────────────────
// Works with EITHER PNP or NPN wiring
// ON state: output drives to +24V (PNP transistor active)
// OFF state: output drives to 0V (NPN transistor active)
// No pull-up or pull-down needed — actively drives both states
Jede SPS-Eingangskarte hat einen spezifizierten Mindeststrom für eine zuverlässige Logik-1-Erkennung — typisch 2–6 mA. Jeder Sensor hat einen maximalen Laststrom. Jede Ausgangskarte hat einen maximalen Strom pro Kanal und pro Gruppe. Die Überprüfung dieser Anforderungen, einschließlich Einschaltstrom für kapazitive und induktive Lasten, ist für zuverlässigen Betrieb unerlässlich.
// Input/output current matching calculation
//
// Step 1: Check sensor vs PLC input
// Sensor max output current: 200 mA (typical PNP sensor)
// PLC input current draw: 6 mA at 24V (from datasheet)
// → OK: 6 mA << 200 mA
//
// Step 2: Check PLC output vs load
// PLC output max current: 0.5 A continuous
// Solenoid valve coil: P=4.8W, I=4.8/24=0.2A steady
// Solenoid inrush (pick-up): I_inrush = 5 × I_steady = 1.0A
// Duration: ~20 ms
// → 1.0A > 0.5A: OVERLOAD at inrush!
// → Solution: Use output rated ≥ 1A, or add external relay
// → OR: Use solenoid valve with electronic inrush limiter
// (modern ASCO/Festo valves: inrush = 1.2× steady)
//
// Step 3: Group fuse calculation
// 8 outputs per group, all solenoids 0.2A steady
// Simultaneous on: 8 × 0.2A = 1.6A
// Add 25% margin: 1.6 × 1.25 = 2.0A
// Select: 2A fast-blow fuse (or 2.5A slow-blow for inrush)
//
// Step 4: PSU total current
// All I/O current + PLC CPU + HMI + field devices
// Total: 12A estimated → use 15A / 360W PSU @ 24V
// Add UPS buffer capacitor: 15A × 20ms = 0.3 Ah
Digitale E/A-Hardware umfasst das gesamte Spektrum — von festen integrierten E/As an einer kompakten SPS bis zu großen dezentralen Peripheriestationen über PROFINET. Das Verständnis der internen Architektur einer E/A-Karte — Optokoppler, Filter, Schutzdiode, Strombegrenzungswiderstand — ermöglicht die Diagnose von Fehlern, die sonst unsichtbar wären.
Click any input channel to toggle it. Right-click to inject a fault. Watch LED states, group fuse current, and diagnostic messages update live.
Ein Standard-24V-DC-Digitaleingangskanal hat fünf Stufen: Klemmleiste → Überspannungsschutz (TVS-Diode und Polyfuse) → RC-Eingangsfilter (Entprellen) → Optokoppler (galvanische Trennung zwischen Feldverdrahtung und SPS-Rückwandbus) → Pegelanpasser auf 3,3V oder 5V für die CPU. Der Optokoppler bietet galvanische Trennung bis 500V–3kV.
// Digital input channel — internal signal path
//
// Field terminal (+) ─┬── [TVS diode to 0V] ← clamps spikes
// │
// └── [R_input ~3.3kΩ] ← current limiter
// │ I = 24V/3.3kΩ = 7.3mA
// ▼
// [C_filter ~1µF] ← RC debounce
// │ τ = 3.3kΩ × 1µF = 3.3ms
// ▼
// [Optocoupler LED] ← 5mA min to switch
// [Optocoupler photo-transistor]
// │ 3kV isolation barrier
// ▼
// [3.3V logic level] ← PLC CPU side
// │
// [Input register] ← Read each PLC scan
// Field terminal (−) ─── [0V common]
//
// Key parameters from datasheet:
// Input voltage range: −3V to +30V (continuous)
// Min. current for logic 1: 4 mA
// Max. current (continuous): 15 mA
// Default filter time: 3.2 ms
// Filter time programmable: 0.1–20 ms
// Isolation voltage: 500V (field to backplane)
// Input impedance at 24V: ~3.3 kΩ (= 7.3 mA → above 4mA min)
Transistorausgänge (statisch) verwenden MOSFETs — schnelle Schaltzeiten (<1 ms), kein Verschleiß, hohe Schaltfrequenzen, aber möglicher Kurzschlussausfall. Sie benötigen eine Freilaufdiode für induktive Lasten — die meisten Karten integrieren diese intern. Relaisausgänge verwenden physische Relaiskontakte — höhere Ströme (2–10 A), aber langsam (5–15 ms) und begrenzte Lebensdauer.
// Freewheeling diode — why it is MANDATORY for inductive DC loads
//
// When a transistor output switches OFF a coil:
// L × (dI/dt) = V_spike
// Coil inductance L = 0.1H, I = 200mA, turn-off time = 10µs
// V_spike = 0.1 × (0.2 / 0.00001) = 2000V !!!
//
// This 2000V spike appears across the output transistor:
// → Exceeds transistor V_DS rating (typically 50–60V)
// → Transistor avalanche breakdown → eventual failure
// → Also radiates EMI affecting nearby electronics
//
// Freewheeling diode solution:
// Diode placed: anode to 0V, cathode to +24V
// (i.e. reverse-biased during normal operation)
// When output turns OFF: inductor drives current through diode
// Coil energy dissipated safely: V_clamp = 0.7V (diode forward V)
// Spike: 0.7V instead of 2000V
//
// Practical notes:
// Most modern PLC output cards include internal freewheeling diodes
// External is still recommended for long cable runs (cable inductance)
// For faster coil release: Zener diode in series with freewheeling
// (e.g. 27V Zener): V_clamp = 27V, faster energy dissipation
// → Relay/valve opens in ~3ms vs ~50ms with simple diode
//
// Protection components per output channel (external):
// Inductive DC load: 1N4007 freewheeling diode across load
// Inductive AC load: RC snubber (47Ω + 47nF) across load
// Lamp load (inrush): Series NTC thermistor or current fuse
In großen Maschinen ist die Verlegung von Hunderten einzelner Kabel von Feldgeräten zu einem zentralen SPS-Schrank kostspielig und fehleranfällig. Dezentrale Peripherie platziert kleine E/A-Module direkt an der Maschine, verbunden über ein einziges PROFINET-Kabel. IO-Link (IEC 61131-9) überträgt E/A-Daten UND Geräteparameter UND Diagnosedaten über ein Standard-3-Draht-Kabel.
// IO-Link device data model (IEC 61131-9)
// Single 3-wire cable: L+ (24V), L− (0V), C/Q (data)
// Communication: 24V UART, 4800/38400/230400 baud
// Process Data (cyclic, every master cycle ~2ms):
// Bit 0: Switch state (ON/OFF) — same as digital I/O
// Bit 1–7: Extended status flags (output overload etc.)
// Device Parameters (acyclic, on demand):
// Index 1: Vendor name (e.g. 'SICK')
// Index 2: Device name (e.g. 'IME08-1B5NSZW2S')
// Index 5: Serial number ('AB12345678')
// Index 16: Switching distance (mm) — read/write!
// Index 17: Hysteresis (mm)
// Index 18: Output logic (NO/NC)
// Diagnostic Data (acyclic, on event):
// Temperature (°C, internal)
// Operating hours (h)
// Short-circuit count (events)
// Signal quality (0–100%)
// PLC code — read IO-Link device temperature:
VAR
iolink_master : IO_LINK_MASTER_REF;
sensor_temp : REAL;
read_done : BOOL;
END_VAR
iolink_master.ReadParameter(
port := 3, // Port 3 on master
index := 32, // Temperature object index
subindex:= 0,
data => sensor_temp,
done => read_done
);
// sensor_temp populated after read_done = TRUE
Das Lesen eines Digitaleingangs und das Setzen eines Digitalausgangs sind die einfachsten SPS-Operationen — aber die darum aufgebaute Logik kann komplex sein. Entprellen, Flankenerkennung, Zeitsteuerung, Zählen, Verriegeln und Zustandsmaschinen werden alle aus diesen primitiven Operationen aufgebaut.
Toggle each input condition. Watch the interlock word, the combined AND result, and which bit is blocking the output. This is how a real machine interlock matrix works.
Press the button below to simulate a button press with contact bounce. Watch how the raw signal, the debounced signal, and the edge detector outputs respond.
Ein Digitaleingang ist TRUE oder FALSE. Eine Flanke ist der Übergang zwischen Zuständen — steigende Flanke (FALSE→TRUE) oder fallende Flanke (TRUE→FALSE). Viele Operationen sollen genau einmal pro Übergang ausgelöst werden. In IEC 61131-3 Structured Text erkennen R_TRIG und F_TRIG diese Flanken. Fehlende Flankenerkennung ist einer der häufigsten SPS-Programmierfehler.
// Edge detection — all methods (IEC 61131-3)
// ── METHOD 1: R_TRIG / F_TRIG function blocks ─────────────
VAR
start_button : BOOL; // Direct input
rtrig_start : R_TRIG; // Rising edge detector
ftrig_start : F_TRIG; // Falling edge detector
start_pressed : BOOL; // Single-scan pulse on press
start_released : BOOL; // Single-scan pulse on release
END_VAR
rtrig_start(CLK := start_button);
ftrig_start(CLK := start_button);
start_pressed := rtrig_start.Q; // TRUE for exactly 1 scan
start_released := ftrig_start.Q;
// ── METHOD 2: Manual edge detection (no function blocks) ──
VAR
input_now : BOOL;
input_prev : BOOL := FALSE;
rising_now : BOOL;
fall_now : BOOL;
END_VAR
rising_now := input_now AND NOT input_prev; // 0→1 transition
fall_now := NOT input_now AND input_prev; // 1→0 transition
input_prev := input_now; // Store for next scan — MUST be last!
// ── METHOD 3: Pulse-stretching for very short inputs ──────
// Sensor pulse may be shorter than PLC scan time (e.g. 0.5ms pulse)
// Use hardware input filter OFF + software latch:
VAR
short_pulse : BOOL; // Hardware HSC captures, OR input filter=0
pulse_latch : BOOL;
pulse_timer : TON;
END_VAR
IF short_pulse THEN pulse_latch := TRUE; END_IF;
pulse_timer(IN := pulse_latch, PT := T#50ms);
IF pulse_timer.Q THEN pulse_latch := FALSE; END_IF;
// pulse_latch now stretches short input to 50ms — visible to slow scan
Industriemaschinen verwenden Verriegelungen, um gefährliche oder beschädigende Ausgangskombinationen zu verhindern. Gute Praxis: Alle Verriegelungsbedingungen in einem dedizierten BOOL-Array zentralisieren, alle Bedingungen einmal auswerten und das Ergebnis im Ausgangsrung verwenden. Dies macht die Logik prüfbar und das Elektrische Sicherheitsdokument bis zu den Codezeilen rückverfolgbar.
// Structured interlock pattern — machine axis enable
// All conditions must be TRUE for axis to enable
VAR
// Raw input signals
estop_ok : BOOL; // E-Stop chain healthy (TRUE = no estop)
guard_closed : BOOL; // Safety guard confirmed closed
home_done : BOOL; // Axis has completed homing
pneum_ok : BOOL; // Pneumatic pressure OK (> 5 bar)
no_fault : BOOL; // Drive has no active fault
mode_auto : BOOL; // Machine in AUTO mode
upstream_ready : BOOL; // Upstream station has released
// Interlock result
axis_interlock : BOOL; // Combined interlock — all must be TRUE
axis_enable : BOOL; // Final output to drive STO
// Diagnostic — which interlock is preventing enable?
interlock_word : WORD; // Bit-mapped diagnostic for HMI
END_VAR
// Evaluate all interlocks ONCE per scan
interlock_word.0 := estop_ok;
interlock_word.1 := guard_closed;
interlock_word.2 := home_done;
interlock_word.3 := pneum_ok;
interlock_word.4 := no_fault;
interlock_word.5 := mode_auto;
interlock_word.6 := upstream_ready;
// Single combined result
axis_interlock := estop_ok AND guard_closed AND home_done
AND pneum_ok AND no_fault
AND mode_auto AND upstream_ready;
// Output: only enable if all interlocks pass
axis_enable := axis_interlock;
// HMI shows interlock_word as bitfield:
// Bit 0 OFF → operator sees 'E-Stop active'
// Bit 1 OFF → 'Guard open'
// Bit 3 OFF → 'Low pneumatic pressure' etc.
// One word carries all diagnostic info — efficient and clear
Digitaleingänge speisen Zähler und Timer, die die Maschinenlogik implementieren. CTU (Aufwärtszähler) zählt steigende Flanken. TON (Einschaltverzögerung) startet, wenn ein Eingang TRUE wird. TOF (Ausschaltverzögerung) bleibt für eine definierte Zeit TRUE nach dem Abfall des Eingangs. TP (Impulszeit) erzeugt einen Impuls fester Breite unabhängig von der Eingangsdauer.
// Production counter with reset, preset, and HMI output
VAR
part_sensor : BOOL; // Photoelectric sensor — part detected
reset_button : BOOL; // Operator reset
rtrig_part : R_TRIG;
rtrig_reset : R_TRIG;
counter_CTU : CTU;
batch_size : INT := 500;
batch_complete : BOOL;
total_produced : DINT := 0; // Persistent across power cycles
END_VAR
rtrig_part(CLK := part_sensor);
rtrig_reset(CLK := reset_button);
counter_CTU(
CU := rtrig_part.Q, // Count on each part detection
R := rtrig_reset.Q, // Reset on button press
PV := batch_size,
Q => batch_complete, // TRUE when batch_size reached
CV => batch_count // Current count (0 to PV)
);
// Accumulate total (persist across resets)
IF rtrig_part.Q THEN total_produced := total_produced + 1; END_IF;
// Full machine cycle state machine — RDFD pattern
// (simplified to show DI/DO interaction)
CASE machine_state OF
0: // IDLE — waiting for start
IF start_button AND interlock_ok THEN
machine_state := 1;
END_IF;
1: // EXTEND cylinder
cylinder_extend := TRUE;
IF cylinder_fwd_sensor THEN // End of stroke confirmed
dwell_timer(IN:=TRUE, PT:=T#200ms);
IF dwell_timer.Q THEN
dwell_timer(IN:=FALSE);
machine_state := 2;
END_IF;
END_IF;
2: // RETRACT
cylinder_extend := FALSE;
cylinder_retract := TRUE;
IF cylinder_back_sensor THEN
cylinder_retract := FALSE;
machine_state := 0;
END_IF;
END_CASE;
Der Digitaleingang ist nur so zuverlässig wie der ihn speisende Sensor. Jede Erkennungstechnologie hat spezifische Anwendungseinschränkungen — Erkennungsreichweite, Zielmaterial, Umgebungsbeständigkeit, Ansprechzeit und Ausgangstyp. Die Wahl der falschen Technologie ist die häufigste Ursache für intermittierende Maschinenfehler.
Describe your target and environment. The tool computes which sensor technology fits and shows the expected sensing distance with correction factors.
Induktive Sensoren erkennen metallische Ziele durch Erzeugung eines Wechselmagnetfelds und Messung der Dämpfung durch Wirbelströme. Sie sind unempfindlich gegenüber Schmutz, Öl und Kühlmittel. Schlüsselparameter: Nennschaltabstand Sn (für Baustahl), Korrekturfaktor Cf (Edelstahl: 0,7; Aluminium: 0,45; Kupfer: 0,35). Den tatsächlichen Schaltabstand immer an der realen Maschine mit dem tatsächlichen Zielmaterial messen.
// Inductive sensor — correction factor calculation
// Sensor: Balluff BES 516-300-S272 Sn=5mm (mild steel)
//
// Target material correction factors:
// Mild steel (Fe360): 1.00 (reference)
// Stainless steel 304: 0.70 → Actual Sd = 5 × 0.70 = 3.5mm
// Stainless steel 316L: 0.65 → Sd = 3.25mm
// Cast iron: 1.10 → Sd = 5.5mm
// Aluminium: 0.45 → Sd = 2.25mm
// Brass: 0.40 → Sd = 2.0mm
// Copper: 0.35 → Sd = 1.75mm
//
// CRITICAL: Always verify actual switching distance on
// the real machine with the real target material!
// Spec sheet gives starting point, not final value.
//
// Mounting correction:
// Flush (shielded, embeddable): 100% Sn, can embed in metal
// Non-flush (unshielded): 100% Sn but needs 3Sn clearance
// around sensor body
//
// Temperature effect:
// Standard range: −25°C to +70°C (Sn varies ±10%)
// Extended range: −40°C to +85°C (Sn varies ±15%)
// At −25°C: switching distance may increase by 10%
// At +70°C: switching distance may decrease by 10%
// For tight applications: measure at actual operating temperature
//
// Output types available:
// NO (normally open): outputs HIGH when target present
// NC (normally closed): outputs LOW when target present
// NO+NC (dual output): both signals simultaneously
// IO-Link: digital + analog + diagnostics on one wire
Lichtschranken verwenden einen Lichtstrahl (Infrarot-LED, 850 nm) zur berührungslosen Objekterkennung. Drei Konfigurationen: Einweglichtschranke (separate Sender und Empfänger) hat die größte Reichweite (bis 60 m). Retroreflektive Lichtschranke nutzt einen Reflektor — Reichweite bis 10 m. Diffuse Lichtschranke — einfachste Installation, kürzeste Reichweite (0,1–2 m), stark abhängig von Farbe und Oberfläche des Ziels.
// Photoelectric sensor selection guide
//
// APPLICATION: Detect transparent bottles on conveyor
// Problem: diffuse mode cannot detect transparent objects
// (light passes through, no reflection back)
// Solution: Through-beam or retro-reflective with polarised filter
//
// APPLICATION: Detect shiny metal lids
// Problem: diffuse may false-trigger on ambient light
// retro-reflective: lid surface may reflect back
// Solution: Background suppression diffuse sensor (laser triangulation)
// or colour mark sensor if mark is present
//
// Excess gain concept:
// Excess gain = actual signal level / minimum detection level
// Excess gain = 1.0: sensor just barely switches — UNRELIABLE
// Excess gain = 5.0: sensor has 5× signal margin — GOOD
// Excess gain > 10: robust in dirty/foggy environments
// Rule: always mount sensor to achieve excess gain > 2.0
// after accounting for worst-case contamination
//
// Response time:
// Mechanical conveyor at 1.5 m/s, part width 10mm:
// Part passes sensor in: 10mm / 1500mm/s = 6.7 ms
// Sensor response time must be << 6.7ms
// Standard sensor: 1–3 ms response → OK
// High-speed sensor: < 0.1 ms → for small parts at high speed
//
// Beam diameter must be < part size:
// Min part size to reliably detect: 1.5 × beam_diameter
// Laser spot: 1–3 mm → detects parts > 1.5–4.5 mm
// LED spot: 5–20 mm → minimum part size 7.5–30 mm
Mechanische Endschalter verwenden einen physischen Aktor zum Öffnen/Schließen elektrischer Kontakte. Hohe Zuverlässigkeit bei der Positionsbestätigung. Reed-Kontakte verwenden ein Magnetfeld — außen an Pneumatikzylindern montiert, erkennen den Kolbenmagneten durch die Zylinderwand. Hall-Effekt-Sensoren sind das statische Äquivalent — keine beweglichen Teile, bessere Schwingungsfestigkeit.
// Limit switch selection — precision positioning
// Application: CNC axis end-of-travel limits
// Key parameters for precision limit switches:
// Repeatability: ±0.01mm (Omron D4C series)
// vs standard limit switch: ±0.5mm
// Operating force: 0.5–2N (low for delicate mechanisms)
// Pre-travel: 0.5–2mm (distance from free to operate)
// Over-travel: 5–10mm (mechanical stops beyond operate point)
//
// Reed switch inside pneumatic cylinder:
// Cylinder bore: 32mm, stroke: 100mm, piston has magnet
// Mount reed switch in T-slot on cylinder body
// Sensing range: 3–5mm through aluminium wall
// Response time: 1–3ms (contact bounce 2–5ms — use input filter)
// Max speed: 2m/s typical (piston must slow near end of stroke)
// Temperature: −20°C to +70°C standard
//
// Common problem: reed switch misalignment
// Symptom: sensor activates mid-stroke (magnet field misaligned)
// Fix: slide switch 5–10mm toward piston travel direction
//
// Hall-effect digital switch (solid-state reed replacement):
// No contact bounce → no input filter needed
// Faster response: < 0.1ms
// Vibration resistant: survives 30g shock vs 10g for reed
// IO-Link version: reports magnetic field strength
// If field_strength < threshold → 'magnet wear' alarm
// Service life: > 10^9 operations (effectively unlimited)
Sicherheitskritische Digital-E/As werden durch IEC 62061 (SIL) und ISO 13849 (PL) geregelt. Ein Standard-SPS-Ausgang, der einen Motorschütz abschaltet, ist KEINE Sicherheitsfunktion. Ein zertifizierter Sicherheits-E/A-Kanal mit Zwei-Kanal-Überwachung und Diagnose IST eine. Den Unterschied zu verstehen ist für Maschinenbauer in Europa gesetzlich vorgeschrieben.
Simulate an E-Stop dual-channel safety relay. Click button to trigger/release E-Stop. Inject individual channel faults. See relay state, channel monitoring, and machine output.
Kategorie B/1 (PLa/PLb): Einkanal, keine Fehlererkennung. Kategorie 3 (PLd): Zwei unabhängige Kanäle, jeder für sich ausreichend. Ein einzelner Fehler verhindert die Sicherheitsfunktion nicht, und der Fehler wird vor oder bei der nächsten Anforderung erkannt. Kategorie 4 (PLe): Zwei Kanäle mit sofortiger Fehlererkennung.
// Dual-channel safety input — wiring and monitoring
// Hardware: Pilz PNOZ m B0 safety relay
// Input: E-Stop button with 2× NC contacts
//
// Channel 1: +24V → button NC1 → terminal S11 of relay
// Channel 2: +24V → button NC2 → terminal S12 of relay
// Common: terminal S14 → 0V
//
// Safety relay internal monitoring:
// Continuously measures voltage on S11 and S12
// Both HIGH (button released, NC contacts closed): OK
// Both LOW simultaneously: E-Stop pressed → SAFE STATE
// One HIGH, one LOW: DISCREPANCY
// → If discrepancy < 500ms: temporary (acceptable)
// → If discrepancy > 500ms: FAULT → latched fault state
// → Requires manual reset after fault cleared
//
// Cross-circuit detection (short between channels):
// Relay sends diagnostic test pulse alternately on ch1/ch2
// If ch2 responds when ch1 is pulsed: short circuit detected
// → Relay locks out immediately
//
// Safety relay outputs (2× NO contacts):
// Contact K1 and K2 in series → drive contactor coil
// Even if K1 welds shut: K2 still opens safely
// Relay monitors K1/K2 feedback to detect welded contacts
// If welded contact detected: relay will not re-enable
// → Forces maintenance before machine can restart
// IEC 62061 PFH calculation (simplified):
// PFH = λ_D × DC where λ_D = dangerous failure rate, DC = diagnostic coverage
// For dual-channel (Cat.3): PFH ≈ λ_D² × T_proof / 2
// Typical result: PFH = 10^-8 /h → achieves SIL 2
Eine Sicherheits-SPS (Siemens S7-1500F, Beckhoff TwinSAFE, Pilz PSS 4000) verwendet F-Peripherie: F-DI und F-DO. Diese Module kommunizieren über PROFIsafe oder FSoE — eine Sicherheitsschicht über Standard-PROFINET/EtherCAT, die CRC, Sequenzzähler und Watchdog zu jeder Botschaft hinzufügt. Das F-Modul überwacht seine eigenen Kanäle: Kurzschluss, Drahtbruch, Diskrepanz.
// Safety PLC F-DI module — channel configuration (TIA Portal / Siemens)
// Module: SM 326 F-DI 8×24VDC (6ES7326-1BK02-0AB0)
// Channel configuration (per pair of channels):
// Channel mode: 2-channel equivalent evaluation
// Channel 0 + Channel 1 are one safety input (E-Stop button)
// Module monitors both channels and their agreement
// Discrepancy time: 100 ms
// Channels must agree within 100ms → otherwise safety fault
// Supply voltage: 24V DC
// Input filter: 3ms (adjustable 0.1–20ms)
//
// Safety integrity:
// SIL 3 / PL e capable (single module, dual channel)
// PFH: 1.0 × 10^-9 /h
// MTTFd: 474 years
// Proof test interval: 20 years
//
// PROFIsafe communication:
// F-Address: must be unique across all F-peripherals
// Watchdog time: 150ms (if no valid safety telegram in 150ms → fault)
// CRC: 4-byte checksum on every safety telegram
//
// Safety program (SCL / F-FBD):
// Access safety data ONLY through F-approved blocks
VAR
E_stop_F : BOOL; // Read from F-DI via ESTOP1 block
Muting_en : BOOL; // From standard program (muting request)
Safety_OK : BOOL; // Safety output to F-DO
END_VAR
// ESTOP1: standard emergency stop evaluation block (PLCopen Safety)
ESTOP1_instance(
E_STOP := NOT F_DI_channel_0, // NC contact → invert
RESET := reset_button_safe,
T_MUTING := T#500ms,
Q1 => Safety_OK,
Q2 => (* feedback monitoring output *)
);
Maschinenschutzverriegelungen verhindern den Zugang zu gefährlichen Bereichen während des Maschinenbetriebs. IEC 14119 klassifiziert Verriegelungen: Typ 1 (gefangener Schlüssel) — Schlüssel muss physisch im Schloss sein; Typ 4 (elektronisch codiert, RFID) — höchste Manipulationssicherheit. Muting ist das kontrollierte, temporäre Überbrücken einer Sicherheitsfunktion.
// Muting sequence for safety light curtain
// Application: product enters machine through curtain on conveyor
// Muting sensors: S_MUT_1 and S_MUT_2, spaced 200mm apart on conveyor
// Sequence: S_MUT_1 must trigger BEFORE S_MUT_2 (confirms product direction)
// Time window: S_MUT_2 must trigger within 5s of S_MUT_1
VAR
lc_beam_broken : BOOL; // Light curtain OSSD output (NC logic)
s_mut_1 : BOOL; // Upstream muting sensor
s_mut_2 : BOOL; // Downstream muting sensor
rtrig_mut1 : R_TRIG;
rtrig_mut2 : R_TRIG;
muting_window : TON; // 5-second muting window timer
muting_active : BOOL; // Muting state
safety_curtain : BOOL; // Final safety output (to F-CPU)
END_VAR
rtrig_mut1(CLK := s_mut_1);
rtrig_mut2(CLK := s_mut_2);
// Muting logic — strict sequence required
IF rtrig_mut1.Q AND NOT muting_active THEN
muting_window(IN:=FALSE); // Reset timer
muting_window(IN:=TRUE, PT:=T#5s);
END_IF;
// S_MUT_2 must follow S_MUT_1 within window
IF rtrig_mut2.Q AND muting_window.IN AND NOT muting_window.Q THEN
muting_active := TRUE;
END_IF;
// Deactivate muting when both sensors clear
IF NOT s_mut_1 AND NOT s_mut_2 THEN
muting_active := FALSE;
muting_window(IN:=FALSE);
END_IF;
// Timeout: no second sensor → cancel muting
IF muting_window.Q AND NOT muting_active THEN
muting_window(IN:=FALSE);
END_IF;
// Safety output: safe unless beam broken AND muting not active
safety_curtain := NOT lc_beam_broken OR muting_active;
// This runs in SAFETY PLC — standard PLC cannot modify safety_curtain
Die meisten E/A-Fehler in Industriemaschinen fallen in drei Kategorien: Verdrahtungsfehler (falsche Polarität, fehlende Verbindung, gebrochener Leiter), Komponentenausfälle (defekter Sensor, kurzgeschlossener Ausgang, durchgebrannte Sicherung) und Logikfehler (falsche Adresse, invertierte Logik, fehlendes Entprellen). Eine systematische, physikbasierte Diagnosemethode löst 95% der E/A-Fehler in wenigen Minuten.
A fault has been injected into the system. Use the virtual multimeter to probe different points. Deduce the root cause from your measurements. Click each probe point to measure.
Watch live digital signals with noise, contact bounce, and EMI. Adjust noise level and see how it affects PLC input reliability. Toggle EMI events.
Die Diagnosevorgehensweise ist immer dieselbe: Den Fehler in der Feldverdrahtung, im Sensor/Aktor oder in der SPS-Hardware lokalisieren — dann bis zur spezifischen Komponente eingrenzen. Niemals mit dem Austausch von Teilen beginnen. Mit dem Multimeter am SPS-Klemmenblock beginnen. Das dauert zwei Minuten und identifiziert 80% der Fehler sofort.
// Digital I/O fault diagnosis — systematic approach
//
// ── INPUT NOT READING CORRECTLY ──────────────────────────────
//
// Step 1: Check PLC status LEDs
// Input LED ON but PLC reads FALSE:
// → Wrong input address in program (check wiring diagram)
// → Input card failed (rare)
// Input LED OFF but device is activated:
// → No signal reaching PLC terminal → go to Step 2
//
// Step 2: Measure voltage at PLC input terminal (+ vs COM)
// Sensor claimed to be ON:
// Measure > 15V → signal OK → input card fault
// Measure 5–15V → signal in undefined zone → sensor or cable fault
// Measure < 5V → no signal → go to Step 3
//
// Step 3: Measure voltage at sensor output pin
// Sensor ON condition:
// > 20V → cable fault between sensor and PLC (check connector)
// < 1V → sensor output stage failed or not powered
// No supply voltage: check Vcc and 0V at sensor connector
//
// Step 4: Check sensor supply
// Measure Vcc at sensor: should be 18–30V DC
// < 18V: cable resistance drop (long cable + high current)
// or PSU overloaded (measure at PSU terminals)
// 0V: fuse blown, broken wire, wrong pin connection
//
// ── OUTPUT NOT ACTIVATING LOAD ──────────────────────────────
//
// Step 1: Is PLC commanding the output?
// Force output ON in PLC → output LED lights?
// NO → PLC output card fault or output disabled (safety?)
// YES → output card OK, problem is in wiring/load → Step 2
//
// Step 2: Measure voltage at output terminal (+ vs COM)
// Output commanded ON:
// > 20V: signal OK but load not working → check load
// < 15V: voltage drop → check fuse, check load resistance
// 0V: broken wire or blown output transistor
//
// Step 3: Check load
// Solenoid valve: measure coil resistance (Ω)
// Expected: P=4.8W → R = V²/P = 576/4.8 = 120Ω
// Measured 0Ω: coil short → replace valve
// Measured ∞Ω: coil open → replace valve
// Lamp: measure filament resistance
// Relay coil: measure coil resistance
Elektrisches Rauschen verursacht unbeabsichtigte Auslösungen von Digitaleingängen. Die drei Rauschkopplungsmechanismen: Leitungsgebundenes Rauschen (verhindert durch Filter und TVS-Dioden), kapazitive Kopplung (aus benachbarten Leitern — verhindert durch Trennung und Abschirmung) und induktive Kopplung (Magnetfeld aus Stromschleifen — verhindert durch verdrillte Leitungen).
// EMC noise diagnosis and prevention
//
// SYMPTOM: Input randomly toggles with no physical change
//
// Diagnosis sequence:
// 1. Check: does it correlate with any machine output?
// (motor start, solenoid fire, welding?) → Conducted/inductive EMI
// 2. Check: does it correlate with day/time? → Mains supply quality issue
// 3. Measure: voltage at PLC input terminal during false trigger
// > 5V transient? → Noise couple into cable
// < 5V: → Ground reference problem (ground loop)
//
// FIX 1: Increase input filter time
// Change filter from 3ms to 10ms
// Cost: slightly slower input response (acceptable for most sensors)
// Eliminates: short transients < 10ms
//
// FIX 2: Cable shielding and routing
// Signal cables: run in separate cable tray from power cables
// Minimum separation: 100mm (200mm near VFD output cables)
// Shield: connect at PLC end only (single-point ground)
// Cross at 90°: when signal and power cables must cross
//
// FIX 3: Ground loop elimination
// Problem: sensor and PLC have different local earth potentials
// e.g. sensor ground = 0.8V above PLC ground → 0.8V common mode
// Fix: ensure all 0V connections return to a single earth point
// Use star topology: ALL 0V wires back to same PSU 0V terminal
// Never: daisy-chain 0V through sensor connectors (adds resistance)
//
// FIX 4: Ferrite cores on cable
// Snap-on ferrite on cable: ~50Ω impedance at 25MHz
// Attenuates HF conducted noise
// Use: 3–5 turns through core for maximum impedance at target frequency
// Zero cost to system operation (no effect on DC/50Hz signals)
//
// FIX 5: Optical isolation (ultimate solution)
// If all else fails: use an isolating signal converter
// Input: 24V DC from field device
// Output: 24V DC to PLC, galvanically isolated
// Common mode rejection: > 1000V
// Cost: €15–50 per channel — use only where necessary
Moderne Systeme implementieren vorausschauende E/A-Diagnosen. Die SPS kann überwachen: Flankenanzahl (wie oft hat sich dieser Eingang pro Stunde geändert?), Zeit seit der letzten Flanke und Blockiererkennung (Eingang hat sich in N Minuten nicht geändert, obwohl er es sollte). Diese Daten identifizieren alternde Sensoren Wochen vor einem ungeplanten Stillstand.
// Digital I/O predictive diagnostics
// Monitor every input for anomalies
TYPE DigitalInputDiag :
STRUCT
raw_value : BOOL;
prev_value : BOOL;
transition_count: DWORD; // Total state changes
last_change_ms : DWORD; // Timestamp of last change (ms)
state_duration : DWORD; // How long in current state (ms)
expected_hz : REAL; // Expected change rate (for cyclic inputs)
actual_hz : REAL; // Measured change rate
stuck_timeout : TIME := T#30s; // Alarm if no change in this time
alarm_stuck : BOOL;
alarm_fast : BOOL; // Changing much faster than expected
alarm_slow : BOOL; // Changing much slower than expected
END_STRUCT
END_TYPE
// Update function (call every PLC scan)
PROCEDURE UpdateDiag
VAR_IN_OUT d : DigitalInputDiag; END_VAR
VAR
now_ms : DWORD; // System time in ms
dt_ms : DWORD;
END_VAR
now_ms := GetSystemTime_ms();
IF d.raw_value <> d.prev_value THEN
d.transition_count := d.transition_count + 1;
dt_ms := now_ms - d.last_change_ms;
d.actual_hz := 1000.0 / DWORD_TO_REAL(dt_ms + 1);
d.last_change_ms := now_ms;
d.alarm_stuck := FALSE; // Activity: clear stuck alarm
END_IF;
d.state_duration := now_ms - d.last_change_ms;
// Stuck-at detection: no change for too long
d.alarm_stuck := (d.state_duration > TIME_TO_DWORD(d.stuck_timeout))
AND (d.expected_hz > 0.0); // Only if cyclic expected
// Rate alarms (for cyclic inputs like cam-driven sensors)
IF d.expected_hz > 0.0 THEN
d.alarm_fast := d.actual_hz > d.expected_hz * 2.0; // >2× expected
d.alarm_slow := d.actual_hz < d.expected_hz * 0.5; // <50% expected
END_IF;
d.prev_value := d.raw_value;
END_PROCEDURE
Voltage thresholds, PNP/NPN wiring, safety architectures, noise diagnosis, and IO-Link — all tested with detailed technical explanations.
Eine SPS-Digitaleingangskarte spezifiziert «PNP (sourcend), 24 V DC, 4 mA Mindest». Ein Feldsensor liefert nur 2 mA bei 24 V. Was wird passieren?
Was ist der Unterschied zwischen einem «sourcenden» (PNP) Ausgang und einem «sinkenden» (NPN) Ausgang?
Ein Näherungsschalterausgang wird direkt an einen SPS-Eingang angeschlossen, der bereits an einen anderen Sensor verdrahtet ist (ODER-Verbindung). Beide Sensoren sind vom Typ NPN. Welcher Schutz ist erforderlich?
IEC 61131-2 definiert Eingangsspannungsschwellen für «Typ 1» 24V-DC-Eingänge. Was sind die Spannungsfenster für Logik 0 und Logik 1?
Eine Ausgangskarte treibt eine 24V-DC-Magnetventilspule mit 2W Nennleistung. Die Karte spezifiziert max. 0,5A pro Ausgang. Wie viele Kanäle kann die Karte gleichzeitig aus einer einzigen 2A-Sicherungsgruppe betreiben?
Was ist die «Eingangsfilterzeit» (Entprellung) an einem SPS-Digitaleingang, und wann muss sie sehr niedrig eingestellt werden?
Ein Sicherheitsrelais benötigt zwei NC-Kontakte (Öffner) von einem Not-Halt-Taster für IEC-62061-SIL-2-Konformität. Ihr Taster hat nur einen NC-Kontakt. Was ist die richtige Lösung?
Was verursacht «Spannungsabfall»-Probleme bei langen Kabeln zu Digitaleingängen, und wie wird er berechnet?
Was sind «Diagnosen pro Kanal» an einem modernen IO-Link- oder Sicherheits-E/A-Modul, und warum ist das wertvoll?
Ein SPS-Ausgang treibt eine Relaisspule. Nach monatelangem Betrieb nimmt die Spule zunehmend mehr Strom auf und wird heiß. Der Spulenwiderstand ist von 480Ω auf 200Ω gefallen. Was ist der Fehler und welches Risiko besteht?
Eine Maschine verwendet einen induktiven PNP-Sensor (Sn = 8 mm auf Baustahl, IP67) zur Erkennung von Aluminiumbügeln mit 1,5 m/s auf einem Förderband. Die Bügel sind 6 mm breit.
Ihre SPS-Eingangskarte benötigt mindestens 4 mA und hat eine Standard-Filterzeit von 3 ms.
1. Berechnen Sie den tatsächlichen Schaltabstand für Aluminium.
2. Prüfen Sie, ob die Durchlaufzeit des Bügels für Sensor und SPS-Filter ausreicht.
3. Geben Sie die richtige Eingangsfiltereinstellung an.
4. Beurteilen Sie, ob dieser Sensor eine gute Wahl ist — und schlagen Sie ggf. eine Alternative vor.
Das führt weiter zu: Sensor-Auswahlherausforderung · Digital-E/A-Verdrahtungsherausforderung
Die häufigsten Fehler an echten Maschinen — von Ingenieuren und Studenten gleichermaßen.