Back to top

Extended KAS PipeNetwork Template with Two AKD Drives


The KAS extended template shows the use of different basic functionality, when using the pipe network motion engine. It’s based on the standard two axis pipe network example and includes some of the most common use cases. It covers the following topics

  • PipeNetwork motion blocs (Master, Gear, Comparator, Cam, Phaser, Converter, Axis)
  • Programming languages (SFC, LD, ST)
  • Subprograms (Functions, UDFB)
  • Control Panel
  • Variable structures
  • Defines

For each of this topic there is a short help in this manual. More information can be found in the KAS help.


The pipe network setup is extended to give an idea on what can be done with the different motion blocks. Not all pipe network motion blocs are used in this example.


Figure 1 PipeNetwork


The master bloc is used as a virtual master axis for the machine. Its output is calculated every motion cycle. The position is scaled in 360 per revolution, which can be interpreted as 360 degrees being one machine cycle, or one product.


The gear block is used as a multiplier of axis cycle versus machine cycles. The default ratio is set to one, so the axis is doing the same number of cycle as the virtual master. The ratio and offset slops are set to 100°/sec. This allows changing of ratio or slope with smooth ramping.


The comparator block is used to detect the zero crossing of the virtual axis position. This flag is needed to perform actions at a defined pipe position. With cams for example this allows the switching of profiles at identical positions on old and new profile.


The cam block is used to perform a cam following, intermittent motion. The used profile is waiting for 90°, accelerating for 90°, running on constant speed for 90° and then decelerating for the last 90° to a full stop again. The total slave move distance is also 360°, corresponding with one full revolution.


The phaser block is used to shift the axis position. The phaser has a slop of 100°/sec and a modulo of 360°. This allows the user to shift the position of the cam stop position around the axis position.


The converter block is used to prepare the pipe values to be sent to the axis as position values.


The axis block is setup to interpreted 360° as one full revolution, with modulo.

Programming language

The three programming language used, all have different advantage. There is no right or wrong in using one over the other.


Sequential function chart is a programming tool to adapt flow chart. The template uses this for the Main routine and its child MachineLogic.

In the main routine the motion engine is started and the stop function is performed.

In the machine logic all motion commands are sequenced. This includes waiting for the user to enable to drives. There are two modes in which the drive can be enabled.

In manual mode the drives are just powered and any manual mode motion can be performed.

In automatic mode the axis are first homed and synchronized before any automatic motion can be performed. In the example this includes a home move for axis one if not done before and a synchronization move. Axis two immediately performs a synchronization move. Only after these moves are completed the automatic mode is started.

The machine logic is only executed if the main logic is in the state Running.


Free form ladder diagram is a graphical programming tool making input and output connection easily visible. The template uses this in the actual mode inside the SFC to allow input changes form the control panel take place.


Structured text is a text only programming tool allowing compact code for even complex algorithm. The template uses this in the subprograms, to allow a short straight forward programming, for parts which won’t be touched by a user too much.


The subprograms are used to define reusable code. This code is not executed by default, but needs to be called in the program. There are two different types: functions and user defined functions (UDFB). While a function can be called right away and has no storage, UDFB’s are instantiated in the variable list, have internal memory, and can be executed over multiple cycles.


A Kollmorgen predefined UDFB which is used in the project. There is a help about this block available in the KAS help. Hit F1 on the function in the libraries or search the name in the help.


A template specific UDFB programmed to ease the axis handling. This block can be reused for each axis and just needs to be controlled according to the actual axis needs.


iAxisName     DINT               Axis name in the pipe network

iAxisCmd       tAxisCmd       Axis command values, see defines for bit usage


oAxisIface     tAxisIface       Actual axis state data, see defines for bit usage

The code reads back actual value of the axis including position, speed, torque, alarm codes and status. It allows the execution of fault reset, home moves and synchronization to pipe position. RESET, HOME, DOSYNC is raising edge triggered


A Kollmorgen predefined function which is used in the project. This module returns the full AKD specific alarm code.

Control Panel

The extended control panel includes status information from the axis and control for the additional commands.


Figure 2 Control Panel

Machine state

Chooses the axis mode. If set to off the axes are not powered, in manual mode all manual mode function can be used, in auto mode all automatic mode functions can be used. If switched to auto mode the axis are first moving to the pipe position before going into auto mode. This can lead to movement, even with no auto mode function motion active!

image  image  image

Figure 3 Machine state             Figure 4 E-Stop      Figure 5 Led indication


If E-Stop is set to stop all motion halts, the drives are disabled and the mode is switched back to off. To enable any mode the e-stop has first to be switched back to run. With Reset drive faults can reset.

LED indication

If Initialised is lit, the pipe motion engine is ready.

If Power is lit, the drives are powered.

If Running is lit, the axes are moving in automatic mode according to the virtual master.

If FAULT is lit, the e-stop is switched or any axis has a drive fault.

Manual mode function

In manual mode the master can be moved at a fixed speed by setting Travel Speed to any value.

With Abs Move the master can be moved to a fix position.

With Rel Move the master can be moved by a fix distance.

image         image

Figure 6 Manual mode function                       Figure 7 Automatic mode function

Automatic mode function

In automatic mode the master can be moved at a fixed speed by setting Machine Speed to any value.

With Axis1 master shift the GEAR1 gets an offset. This leads to a delay on the axis position. With this function the timing of the virtual master and axis can be adjusted.

With Axis1 position shift the PHASER1 gets an offset. This is leading to a position shift on the axis. With this function the cam can moved on the mechanical position.

With Axis1 gear ratio the GEAR1 multiplier is adjusted. With this the axis can be speeded up or down in relation to the virtual master.

Axis status

The axis status values are updated as soon as the pipe motion engine is running. Axis Position is scaled in degrees, Axis Velocity in degrees per second. The Axis Home Offset allows a shift between the virtual master zero position and the axis zero position, at the homing procedure. The Axis Following Error is the actual following error in degrees. With the Fault LED any drive fault is indicated, right next to the text the actual fault text is displayed. The Warning LED indicates any drive warning and the Enabled LED indicates if the axis is powered.


Figure 8 Axis status

Variable structures (structs)

In the dictionary all variable are defined. This goes from global, retain (stored value over power down) to local variable. It is also possible to define variable structures for variables at any level. The example uses two user defined variable structs.



Axis command word as double integer, bit coded by defines.


Home offset used in the homing routine as long real in axis unit.



Axis status word as double integer, bit coded by defines.


Actual axis position as long real, read by MLAxisReadActPos.


Actual axis speed as long real, read with MLAxisReadVel and low pass filtered by the last 20 values with avarageL.


Actual axis torque as long real, read with MLAxisReadTq.


Actual axis following error as long real, read with MLAxisReadFEUU.


Actual axis fault text as string, read from the function uMCFB_AKDFaultLookup with the fault number from PDO 0x2001.


The defines allows the definition of constants which can be used at any position in the programming. In the template all bit access in the axis command and status word are done via a keyword from defines. This way a change in bit order or function extension can be achieved with changes at only one place.

As a screen shot, an example of how a bit access works, in the double integer .dwAxisCmd a reset can be performed if bit RESET is set to true. Defines lists RESET with the value two. So if bit two in dwAxisCmd is true a reset is performed. (Which will lead to dwAxisState bit three (ERROR) be set to false.)


Figure 9 Defines


Figure 10 Use of defines in program