Sysmac Studio Β· NJ/NX Β· IEC 61131-3

The Robot Factory

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.

πŸ€– FUNCTION_BLOCK ~12 min
01 Β· The idea

A cookie cutter, not a cookie

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.

02 Β· Play

Stamp out the line

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.

Instances: 0 Line total: 0 parts
No robots yet β€” stamp one out β†’

πŸ‘† Click an individual robot to pulse only its Run β€” proof each instance's memory is completely separate.

03 Β· How it's wired

Declaring the instances

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.

04 Β· Check yourself

One quick question

You have Arm1 and Arm2, both of type FB_Robot. You call Arm1(Run := TRUE) five times. What is Arm2.PartsMade?