Two letters apart, two halves of reuse. A DDT (Derived Data Type) is a structure you design once and stamp everywhere โ change the type, every copy follows. A DFB (Derived Function Block) is your own reusable logic block with private memory โ call it ten times and each call remembers its own state. Play with both.
Left is the DDT T_Valve. Right are three valves stamped from it in a DB. Click โ add a field to the type and watch all three instances gain it at once โ one edit, zero drift. That's why a DDT beats a pile of loose valve1_open, valve2_open tags.
Here's the DFB FB_PumpHours โ it counts a pump's run-hours, holding the total in its private instance data. It's instanced twice: Pump_1 and Pump_2. Run one and only its meter climbs โ same code, separate memory. An EFB or a plain section couldn't do this; the DFB's per-instance storage is the point.
FUNCTION_BLOCK FB_PumpHours // PRIVATE (retained per instance): runHours : REAL; // runs each scan: IF Running THEN runHours := runHours + dt; END_IF;
Fix a bug in FB_PumpHours once and both pumps inherit it โ yet Pump_1's hours never leak into Pump_2's. DDT for the shape of data, DFB for reusable behaviour with state: together they're how a Modicon project scales without copy-paste.
You need a reusable conveyor controller that holds its own state machine and a timer, dropped onto 8 conveyors. What do you build?