Back to Blog
Applications and How-Tos

Configuring CiA 402 Drive Profile on TIA Portal and a Siemens PLC to Program KEB VFDs

Conner Glaser | February 25th, 2025

This article provides a step-by-step guide on programming a Siemens PLC using TIA Portal software to establish communication with a KEB S6/F6 Drive. It builds upon a previous communication setup tutorials – Comprehensive Guide to CiA 402 and PROFINET Communication Setup with a KEB Drive.

This blog will focus on integrating Profinet to control KEB drives through a state machine to rotate a motor. We will demonstrate how to manage KEB drives using the CiA 402 state machine over PROFINET.

 

 
Below is the equipment that is used for this setup:

 

Step 1 – Setup Profinet

This sample project was established using the standard process data setup, with the addition of ru18 in the Transmit PDOs. To configure this, first disable the Transmit PDOs, then drag ru18 from the available parameters and re-enable process data. For further setup instructions, please refer to the Profinet Communication Setup FAQ provided by KEB America.

 

Selecting Profinet Combivis Fieldbus configuration
Figure 1: Selecting Profinet in KEB’s COMBIVIS Fieldbus configuration

 

Step 2 – KEB Drive Control Data Block

An organization block has been created to demonstrate how to control the KEB drive using the CiA402 state machine. The most common controlword and statusword bits are implemented in the block. After defining a data block instance of KEB_Cia402_DriveControl, bits of the data type can be written-to and read.

 

Siemens TIA Portal Controlword function block type - KEB CiA402 Drive Control
Figure 2: Drive Control Program Block

 
In the sample project an instance of the KEB_Cia402_DriveControl FB is created as Drive1. We will now discuss the various states utilized to control the drive.

 

Step 3 – State Machine

The drive’s internal state machine is controlled via the co00 (CiA 0x6040) controlword and internal events (from errors). The actual state is displayed via st00 (CiA 0x6041) statusword. The actual state can be determined additionally via st12 state machine display. The main path through the state machine that will be covered is 1 to 2, 2 to 3, 3 to 4, and 4 to 17.

 

CiA402 State Machine flowchart for drive control in plc programming
Figure 3: CiA402 State Machine Diagram

 

Startup OB100

The startup organization block contains a single function called “IO2MOD,” which sets the HardwareID of the drive. The HardwareID serves as a crucial identifier within Siemens programming.

 

PLC_PRG OB123

This program cycle organization block contains the state machine. The state machine is controlled by three digital inputs outlined below.
Digital Input I1: HIGH = single step through
Digital Input I2: HIGH = STOP
Digital Input I6: LOW = velocity mode active, HIGH = positioning mode active

 

State 0: Pre-Init

State 0 is the pre-initialization state and includes several examples of acyclic communication writes. Acyclic communication writes are utilized in this state to define drive configuration parameters that do not need to be updated during every PLC cycle. In this example, the brake control mode and the maximum velocity limit are specified.

 

TIA Portal tutorial screen showing how to configure State 0, the pre-init state as an example of acyclic communication.
Figure 4: State 0

 
The first step is to create a variable in the “Read/Write Param Values” PLC tag group. Once the variable is created, you can then establish an instance of Acyclic Communication. Each input for this instance must be completed. The test, status, and error variables are created within the “temp” variables in PLC_PRG. You can enter the name of the parameter in the address field. In the “KEB Parameter to Address” PLC tag table, there is a string table that contains the address associated with the KEB drive.

For the subindex, enter the subindex of the drive parameter. The device is using the constant “Hardware ID” found in the Startup organization block. The “cmd” input determines if its a write or a read. For a write, enter #writing,” if a read, enter “#reading.”

Finally, enter the variable that the value will be written to/from. To proceed to the next state, initiate a rising edge of I1. To proceed to the stop state, initiate a rising edge of I2.

 

State 1: Init

State 1 is the init state, and sets the main controlword bits to false. St14, the active controlword, is being read to verify that there is no controlword bits active. If none are active, the user is allowed to initiate a state step. In every state, there is a check for a fault or a stop and changes the state accordingly.

 

This screenshot in TIA Portal shows State 1, the init state, which sets the main controlword bits to false
Figure 5: State 1

 

State 2: Switch On, Enable Voltage, No Quick Stop, Select Mode

State 2 is the 1 to 2 to 3 transition in the Cia402 state machine. By activating the switch on bit, enable voltage bit, and no quickstop bit, the Cia402 state machine is now at the “switched on” state. The drive is still waiting for the enable operation bit to be active for movement.

 

This TIA Portal screen shows the KEB Cia402 state machine now at the “switched on” state for drive control
Figure 6: State 2

 
It is necessary for the enable voltage and switch on bit to be activated before the enable operation bit is activated. The mode (velocity or positioning) is determined based off of the value of I6 (set to #PositioningModeActive). A rising edge of I1 will proceed to the corresponding state.

 

State 3: Set Velocity Mode and Command Speed

State 3 is separate from the Cia402 state machine, and sets the “mode of operation” and the “target velocity,” both members of the “Drive1” instance of KEB_Cia402_DriveControl. Once the “actual mode” (drive response) equals the set “mode,” the program state machine waits for a rising edge of I1.

 

This TIA Portal screenshot is from State 3 which sets the mode of operation and the target velocity.
Figure 7: State 3

 

State 4: Set Profile Positioning Mode and Profile Command Speed

State 4 is is the positioning mode jump from 3 to 4 to 17 in the Cia402 state machine, and sets the “mode of operation,” “profile velocity” (speed when positioning), “end velocity” (speed once target has been reached), and “target position,” all members of the “Drive1” instance of KEB_Cia402_DriveControl.

 

This is a screenshot of State 4, the positioning mode jump from 3 to 4 to 17 in the Cia402.
Figure 8: State 4

 
Once the “set point” has been acknowledged (drive response), the motor will start to spin. Different from velocity mode, the motor will only spin when the “new set point” bit is set, assuming the enable operation bit has already been set. Once the set point has been acknowledged within the drive, the “new set point” bit can be deactivated, and the program state machine will proceed to the positioningactive state.

 

State 5: Velocity Mode – Enable Operation and Open Brake

State 5 is the velocity mode jump from 3 to 4 to 17 in the Cia402 state machine. The “enable operation” bit is set, and as soon as that happens, the motor will spin at the given “target velocity.” The motor will spin until a rising edge of I1 or I2 (stop).

 

State 5 is the velocity mode jump from 3 to 4 to 17 in the Cia402 state machine
Figure 9: State 5

 

State 6: Profile Positioning Mode Active

It’s helpful to separate the positioning mode states into a set state and a positioning active state. State 6 is the positioning active state, and there is no change in the Cia402 state machine.

 

TIA Portal tutorial screenshot of State 6 which is used to separate the positioning mode states into a set state and a positioning activestate.
Figure 10: State 6

 
The PLC waits for a rising edge of the “target reached” bit from the “Drive1” instance of KEB_Cia402_DriveControl. As soon as that happens, the program state machine will proceed to the stop state.

 

State 99: Stop

State 99 is the stop state. At any point in the program state machine, the stop state can be triggered by a rising edge of I2. At entry of the stop state, the “enable operation” bit and brake bit are deactivated. This is equivalent to the “operation enabled” to “disable operation active” to “switched on” move in the Cia402 state machine.

 

State 99 in TIA Portal is equivalent to the Cia402 state machine in “switch on disabled" mode.
Figure 11: State 99 – The stop state

 
Once the stop state is left and the init state is re-entered, “switch on,” “enable voltage,” and “no quickstop” are all deactivated. Once that happens, the Cia402 state machine will be at “switch on disabled.”

 

State 100: Fault Reset

State 100 is functionally very similar to the stop state, except it requires that the drive be free from faults to return to the program init state. The “fault reset” bit is mapped to I5, and if the fault is resettable, it will reset.

 

Screenshot of TiA Portal code showing State 100 in the CiA 402 State machine. This state requires that the drive be free from faults to return to the program init state.
Figure 12: State 100 – The stop state

 
Once reset, a rising edge of I1 will return to the program init state. This state outlines path 14 and 15 in the Cia402 state machine, from “fault reaction active” to “fault” to “switch on disabled” on returning to the init state.

 

Need Additional Guidance?

With the successful completion of this tutorial, you’ve established communication between your KEB VFD and Siemens PLC via the CiA 402 profile. Should you encounter any further challenges or require advanced support, the application engineering team at KEB America is readily available.

 

Contact Us

Let's Work Together

Connect with us today to learn more about our industrial automation solutions—and how to commission them for your application.

"*" indicates required fields

This field is for validation purposes and should be left unchanged.