Write a machine once, stamp out as many copies as you need β each with its own private memory. That's a function block. Let's build a robot template and run a whole line of them.
The template (defined once)
FUNCTION_BLOCK FB_Robot VAR_INPUT Run : BOOL; // pulse to make a part END_VAR VAR_OUTPUT PartsMade : UINT; END_VAR VAR count : UINT; // private memory END_VAR
The body (runs every cycle)
IF Run THEN count := count + 1; END_IF; PartsMade := count;
π‘ Defining FB_Robot doesn't build anything yet β like a cookie cutter sitting in a drawer. You get a working robot only when you create an instance of it.
Each instance is a real robot with its own count. Add a few, then run cycles β watch every robot keep its own tally. Click one robot to cycle just that one.
π Click an individual robot to pulse only its Run β proof each instance's memory is completely separate.
In your program's variable table
// add a robot to see this grow
Calling Arm1(Run := TRUE) touches only Arm1's count. Arm2 is a different robot with a different drawer of memory β same blueprint, separate state. That independence is the whole reason function blocks scale across a machine.
You have Arm1 and Arm2, both of type FB_Robot. You call Arm1(Run := TRUE) five times. What is Arm2.PartsMade?