Explainer
Why your wrapper's axis input must match control_atv.axis type
Short answer
The wrapper's axis input takes the exact type and parameter class that the installed GMC independent Altivar library declares for the axis input of control_atv, copied verbatim from the declaration; a type named axis_ref is not proven by its name. At the call site, pass the axis named after the Altivar drive in the CANopen Performance tree, then prove the wrapper with a clean build and one online move.

On this page
- What type does the axis input of control_atv require?
- Where do I read the exact type in the installed library?
- Should the wrapper input be VAR_INPUT or VAR_IN_OUT?
- Is axis_ref acceptable just because the name fits?
- What does the finished wrapper look like in code?
- Which axis variable goes in at the call site?
- How do I prove the wrapper drives the right axis?
- Questions asked
Your personal function block needs one input for the axis, and its type is not a judgment call: it is the exact type the installed GMC independent Altivar library prints on the axis input of control_atv in your Machine Expert project, with the same parameter class. Inside the wrapper you wire that input straight to the block. At the call site you pass the axis object named after your Altivar drive in the CANopen Performance tree. A name such as axis_ref looks like the answer but proves nothing on its own: under IEC 61131-3, two separately declared types stay distinct even when their layouts match. What follows shows where to read the declaration, why the class must match, and the two checks that prove the finished wrapper drives the intended axis.
What type does the axis input of control_atv require? #
Your wrapper's axis input takes exactly the type that the installed GMC independent Altivar library declares for the axis input of control_atv — copy that declaration verbatim, because the IEC 61131-3 compiler accepts only an actual that is assignment-compatible with it. IEC 61131-3 gives every declared type its own identity: two structures with identical fields declared under different names, or shipped by different libraries, are two types, and a formal parameter accepts only its own type or one the standard derives from it. So the choice of input type is a lookup, not a design decision — whatever the declaration prints is the type, and anything else is a compile error. The axis pin is special only in where its type lives: a command pin is an elementary type such as BOOL in every project, while the axis type exists only inside the motion library you installed, which is why guessing from the pin name fails and copying succeeds.
Where do I read the exact type in the installed library? #
It is on the declaration of control_atv itself: open the block's declaration with the editor's input-help or go-to-declaration command and read the type name and the parameter class printed on the axis line. Place the cursor on a placed control_atv instance and use that command; the declaration part shows the axis formal parameter, its type name and the variable section it sits in. That declaration is authoritative because it belongs to the version in your Library Manager, and the compiler enforces exactly it; the printed documentation describes the same block — the SoMachine functions and libraries guide refers GMC independent Altivar to the Motion Control Library Guide — but the installed declaration wins any disagreement. Keep the GMC libraries at one consistent version while you work: a documented case reports a version mismatch of the GMC Independent Base Device library, version 1.2.9.0, when a SoMachine v4.3 project is built. A library that will not resolve at all is a different fault from a wrong wrapper type; its package side is covered in Why CODESYS package libraries will not import into SoMachine.
Should the wrapper input be VAR_INPUT or VAR_IN_OUT? #
Give your wrapper the same parameter class the library gives axis on control_atv: if the declaration line sits under VAR_IN_OUT, declare yours VAR_IN_OUT too, and only declare a plain VAR_INPUT where the library does. The class is not a style preference; it changes what the call does. IEC 61131-3 defines a variable declared VAR_IN_OUT as a reference to the caller's variable: the actual must be a variable — never a literal or a constant — and whatever the block writes through it is visible to the caller. A VAR_INPUT copies its value at the call and stays read-only inside the block. An axis object is live state that the motion block reads and updates through, exactly the situation the reference class exists for; if the library declares axis as VAR_IN_OUT, a wrapper input declared VAR_INPUT cannot forward it, because there is no variable of yours for the reference to bind to, only a copy. So copy the variable section heading along with the type name — both stand on the same declaration line.
Is axis_ref acceptable just because the name fits? #
Only if axis_ref is literally the type printed on the control_atv axis declaration; a type with that name from another library is a distinct type under IEC 61131-3, and the name alone proves nothing about compatibility. Two libraries can each ship a type called axis_ref with field-for-field identical layouts, and the compiler still treats them as unrelated; strict type identity is what makes the copy rule reliable. If your project already uses axis_ref successfully with some other block, that proves the other block declares axis_ref — it proves nothing about control_atv. Do not rebuild a lookalike type by hand or rename a variable to satisfy the call either: the compiler compares type identity, not layout, so a lookalike fails the build like any other wrong type. The decision stays binary: the declaration prints axis_ref, use axis_ref; it prints something else, use that.
What does the finished wrapper look like in code? #
The finished shape is a pass-through: the wrapper declares one axis input with the copied type and class, holds an instance of control_atv as a static variable, and wires the input straight to the block's axis pin. All names below except control_atv are illustrative choices of this article: FB_ConveyorDrive, axBelt, fbDrive, fbBeltDrive and the device name ATV_Belt1 are examples, not library identifiers. The wrapper declaration:
FUNCTION_BLOCK FB_ConveyorDrive
VAR_IN_OUT // section heading copied from the control_atv declaration
axBelt : <the type the control_atv declaration prints for axis>;
END_VAR
VAR
fbDrive : control_atv; // instance of the library block
END_VAR
The implementation hands the input over unchanged; control_atv inputs the wrapper does not forward keep their library behavior:
fbDrive(axis := axBelt);
The calling program declares an instance of the wrapper and passes the generated axis object, here the one named after the example drive in the CANopen Performance tree:
PROGRAM PRG_Conveyor
VAR
fbBeltDrive : FB_ConveyorDrive; // wrapper instance
END_VAR
fbBeltDrive(axBelt := ATV_Belt1);
The test that proves the interface half is the build: with the copied type and class on the axBelt line, these lines compile clean; with any other type — including a lookalike axis_ref — the compiler stops on the assignment before download, at no risk to the machine.
Which axis variable goes in at the call site? #
Pass the axis object the device configuration generated under the drive's own name: the axis name equals the Altivar device name in the CANopen Performance tree, so a drive named ATV_Belt1 produces the axis variable ATV_Belt1. That generated object is the one bound to the drive's CANopen communication; an instance of the axis type that you declare yourself carries the right type and no binding, so the build passes and the drive never moves. When a name you find in code disagrees with the tree, go back to the device configuration and settle which generated axis belongs to which drive before anything is commanded — do not rename variables to paper over the difference. Renaming the device in the tree changes the axis name the configuration generates, so revisit the call site after any rename.
How do I prove the wrapper drives the right axis? #
Two checks settle it, in this order: a clean build with no error on the wrapper's assignment lines proves the type contract, and one online move proves the binding — enable the drive through the wrapper and command a low-speed reference. The build check runs before any hardware is connected and it is strict about exactly what this article is about: type identity and parameter class. The online check answers the only question the build cannot — whether the axis you passed is the drive you meant. Log in, enable through the wrapper, command a low-speed reference, and watch the drive's own display or the online axis view: the drive that responds should be the one named in the tree, and the shaft that turns the one you expect. Run this first move with the machine cleared and the mechanics free to travel, because a wrapper accidentally bound to the wrong axis announces itself through whatever that axis moves. If the enable never produces a ready state online, the fault-finding from there is worked through in Troubleshooting missing Drive Ready on a V60 axis retrofit.
Questions asked
Does the axis type come from GMC independent Altivar or from GMC Independent Base Device?
From the library that owns the block you call: control_atv belongs to GMC independent Altivar, so its axis declaration is the one to copy. GMC Independent Base Device is a sibling library of the same family, and a type name found there does not transfer, because type identity belongs to the declaring library. Copy the control_atv declaration and nothing else.
What happens to the wrapper when the motion library is updated?
The copied type is version-scoped. An update can rename the declared axis type or move axis to another parameter class, and the compiler then stops on the wrapper's assignment line at the next build. That error is the signal to reopen the control_atv declaration and copy it again; the rest of the wrapper does not change.
Can two wrappers receive the same axis variable?
They can both receive it, but only one may command it. Keep a single control_atv instance per axis and give one wrapper exclusive use of that axis; a second commanding block competes with the first for the same drive. Code that only needs axis status should read it through the library's monitoring functions rather than through a second control block.
Do the other inputs I forward from control_atv follow the same rule?
Yes, one rule covers every forwarded pin: the wrapper input takes the type and the parameter class the declaration prints for that pin. The axis is merely the one that fails first, because its type exists only inside the motion library, while command and status pins are often elementary types such as BOOL. Copy each declaration instead of retyping from memory.


