- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
In this article we describe a solution used to integrate Kassow Robots RC with ctrlX PLC Engineering using the Profinet interface. We provide you with the setup and programming templates used in the CODESYS PLC environment to control elementary data exchange between the robot and ctrlX device.
Introduction
Profinet (usually styled as PROFINET, as a portmanteau for Process Field Net) is an industry technical standard for data communication over Industrial Ethernet. It is designed for collecting data from and controlling equipment in industrial systems, with a particular strength in delivering data under tight time constraints. The standard is maintained and supported by Profibus & Profinet International [de], an umbrella organization headquartered in Karlsruhe, Germany.
Kassow Robots RCs provide access to this real-time field bus by incorporating the specialized hardware extension (Hilscher cifX), which is not available with a standard KassowRobots RC. The Profinet extension handles all necessary real-time requirements for the fieldbus and allows the integration of KassowRobots robot controllers within existing Profinet infrastructures. Each robot equipped with the optional Profinet HW interface can act as an IO-Device. This means that such a robot can be monitored and controlled by any PROFINET IO-Controller (for example, PLC).
Requirements
- Kassow Robots RC (robot controller) supporting PROFINET fieldbus
- ctrlX PLC Engineering IDE
- CODESYS fieldbus communication drivers for Ethernet IP and PROFINET
- Some basic experience with the ctrlX PLC Engineering programming
Basic Access to Profinet Data Fieldbus
In the sections that follow, we outline the fundamental steps for setting up a project and system. This setup is specifically designed for Profinet communication between the ctrlX CORE and the KR Robot Controller (referred to as RC). We'll illustrate the process using user data fieldbus slots.
Step 1 - Initial Setup
Check the Wiring:
- The Kassow RC Profinet to PLC Ethernet cable should be inserted into the XF51 port on the PLC.
- Connect your PC running ctrlX WORKS with the XF10 port on the PLC.
Switch on the Kassow RC, ctrlX PLC, and a PC with ctrlX PLC Engineering installed. The PLC should be blinking blue. Connect to the ctrlX CORE using ctrlX WORKS. The PLC should start blinking red.
Step 2 - Initialize your ctrlX PLC Engineering tools
When establishing the initial connection of the Profinet fieldbus to the ctrlX CORE, it is essential to initialize the ctrlX as a fieldbus device. To accomplish this, update the PLC Engineering IDE with the necessary add-ons, particularly the Fieldbus Ethernet IP and PROFINET Codesys drivers:
- CODESYS Ethernet Adapter package (4.2.0 or higher)
- CODESYS NetX package (4.0.0 or higher)
- CODESYS PROFINET package (4.4.0 or higher)
For a comprehensive guide on downloading and installing these dependencies, please refer to the ctrlX support pages.
Once your PLC Engineering IDE is equipped with the required libraries and add-ons, proceed to open and deploy the "KR Profinet template v1.2.1.project" (included in the enclosed zip file).
Note: If you are not using the template and creating your own project, load the GSDML file "gsdml-v2.35-kassow_robots-axxx-20210602.xml" (included in the enclosed zip file).
Build the code and deploy it on the ctrlX PLC Engineering. The Profinet master (ctrlX) should now be active, allowing you to attempt connecting the Kassow RC as its IO Device counterpart.
Step 3 - Profinet Setup
Adjustments on ctrlX CORE
We use the Network Interface XF51 for the profinet connection as mentioned before. For this template, we use the IP address 192.168.0.10. You can set that in ctrlX CORE Settings > Network Interfaces
Choose XF51 and set the IP address this way.
Enabling Profinet on the Kassow
With the fieldbus successfully running on your master node, the next step involves setting it up on the robot controller as well. To achieve this, utilize the teach pendant UI. Navigate to the Workcell/Interfaces section and select the "profinet" item.
Note: If the Profinet interface is not available, it is likely that your robot is not equipped with the optional Profinet HW (please confirm with Kassow Robots tech support if you are uncertain).
Click "Enable" to activate the Profinet and wait until the status is changed to "Connected.
By now, the teachpendant should be showing connected in the top left corner, indicating that the teachpendant is communicating with the robot.
Step 4 - Simple PLC program from the KR Profinet template
Now, we return to the PLC Engineering IDE with the "KR Profinet template v1.2.1.project" project open.
Every KR template project contains all necessary types and functions for converting between the fieldbus and internal program representations. The primary user code is located within the PLC_PRG program, with pre-defined local variables reflecting 12 KR Profinet modules. In the "FETCHING INPUT VARIABLES" preamble, the input fieldbus variables are updated, followed by the "USER CODE" section. This is where your PLC code logic, combining fieldbus data reading and writing, should be placed. The final section, "FILLING OUT VARIABLES" provides the necessary conversion to the fieldbus structure.
The "USER CODE" section essentially establishes the boundaries for your PLC code. Here, you should access the RC Profinet data and call all your dedicated functions constituting your PLC program. Leave the preamble and final section intact.
For illustration purposes, you can easily modify user slots 10, 11, and 12 of the KR Profinet frame by accessing variables out64Bit, out24Int, out24Real as follows:
To access and use these values on the side of the RC and UI programming environment, you have to do the mapping of Profinet variables. Let's see how to do that in the following step.
Step 5 - Profinet Input/Output mapping
The KR PROFINET frame defines a space for several single-typed arrays of user data (Ints, Doubles, Bits). To access this data from the context of the user RC running program, it is necessary to create an array mapping.
To do this, navigate to the Workcell/Profinet option panel and inside that, click the 'Map Profinet Variable' button.This action opens up a variable map dialog where you can select the Profinet IO slot. Give it a name and click "Create". This will generate an outlet array within the RC user variable, providing access to the Profinet IO user slot for reading or writing:
There are six user slots defined in the KR PROFINET IO fieldbus specifically designated for user data exchange. For more details check the USER INPUTS AND OUTPUTS table in the Appendix of this article.
For more details regarding the KR PROFINET IO fieldbus contents and specifics, refer to the enclosed document KR_profinet_netfrm_desc_1.0.pdf.
Step 6 - First ctrlX PLC data exchange
Now, you can attempt to assign values to the KR PROFINET IO slots using predefined output variables (PLC -> RC). Utilize the same empty 'KR Profinet template v1.2.project' template and add the following lines into the "USER CODE" section of the PLC_PRG program:
// USER CODE
// set 64 plc output variables
out64Bit.DINT_1 := 255;
// 24x integer outputs
out24Int.in1 := 1;
// ...
out24Int.in24 := 24;
// 24x real outputs
out24Real.real_1 := 3.0;
// ...
out24Real.real_24 := 3.24;
In the RC user interface, create the mapping to provide access to the Profinet Float output array:
To observe the assigned outputs provided by the ctrlX PLC program, click "Login" at the top of the ctrlX PLC Engineering tool and use the "Play" button to execute the PLC code. This action will compile the code, load it into the PLC, and set it in motion. In the brief moment after ctrlX runs the code, the mapped Profinet array block (Float Outputs) will display transferred values:
Accessing Robot State and RC IOs
Except the user data, the KR PROFINET IO also defines slots for the main robot state and RC IO control. This part of the fieldbus data allow the PLC program to determine manipulator state (joint positions, speeds, TCP) or use evaluate robot error states.
System State
You can read the Robot status information simply by reading the inSystemState.Robot structure member values as illustrated in the following short sample ctrlX PLC program.
// USER CODE
// access the RobotState member value to evaluate the robot is moving
IF (inSystemState.Robot.RobotState = 3 OR inSystemState.Robot.RobotState = 4) THEN
// robot is moving
out24Int.int_1 := 1;
ELSE
// robot is not moving
out24Int.int_1 := 0;
END_IF
This simple code snippet keeps the user output variable updated based on the "moving" status of the robot.
Similar way it is possible to read RobotMode, Program or Buttons state. The System State inSystemState.Safety contains also several safety related fields as SafetyMode, EStopFlag, PStopFlag or SStopFlag.
For more details check the SYSTEM STATE table in the Appendix of this article.
Manipulator State
Dynamic state of the robot arm (joint positions, speeds, TCP coordinates) is also included in the KR PROFINET IO structure and is accessible through inJointsMonitor and inTCPMonitor structures.
To illustrate the use of inJointsMonitor member, check out the following PLC_PRG snippet evaluating the robot jointss robot is not moving:
// USER CODE
// define a local variable abs_speed and calculate it from the actual joint values
abs_speed := SQRT(EXPT(inJointsMonitor.Joint_1_velocity, 2) +
EXPT(inJointsMonitor.Joint_2_velocity, 2) +
EXPT(inJointsMonitor.Joint_3_velocity, 2) +
EXPT(inJointsMonitor.Joint_4_velocity, 2) +
EXPT(inJointsMonitor.Joint_5_velocity, 2) +
EXPT(inJointsMonitor.Joint_6_velocity, 2) +
EXPT(inJointsMonitor.Joint_7_velocity, 2));
IF (abs_speed > 0.0001) THEN
// robot seems to be moving
out24Int.int_1 := 1;
ELSE
// robot is not moving
out24Int.int_1 := 0;
END_IF
The manipulator state also contains access to the TCP (Tool Center Point) related variables, giving the references about the end of arm tool coordinates within the cartesian space.
// USER CODE
// set user output field based on the TCP position
IF (inTCPMonitor.TCP_position_X > 0.0 AND inTCPMonitor.TCP_position_Y > 0.0) THEN
// robot TCP is in front of X and Y axes
out24Int.int_1 := 1;
ELSE
// robot TCP is somwhere else
out24Int.int_1 := 0;
END_IF
For more details check the MANIPULATOR STATE table in the Appendix of this article.
Robot IOs
The KR PROFINET IO fieldbus provides access to digital/analog Inputs and Outputs available in physical slots on the KR RC (Cabinet) and Robot ToolIO (End of Arm Tool Flange). These IO slots are primarily accessible through the Teach Pendant UI and can be mapped for programming purposes.
The KR PLC template facilitates access to these variables using two modules: inIOMonitor for inputs and outIO for outputs.
To read specific digital inputs connected to the RC IOBoard, you can refer to the following code sample:
// USER CODE
// read the state of IOBoard input slots
IF (TO_BOOL(inIOMonitor.IOB_digital_inputs AND 2)) THEN
// IOBoard Digital Output slot 2 is ACTIVE
END_IF
IF (inIOMonitor.IOB_current_input_1 > 5.0) THEN
// IOBoard Current Analog Input slot 1 is more than 5 miliamps
END_IF
For changing digital/analog output values, you can use the following code:
// USER CODE
// set IOBoard Digital Outputs
// define a local variable digital_outputs
digital_outputs := 0;
// activate DIO01
digital_outputs := SHL(1, 0) OR dig_outputs;
// activate DIO03
digital_outputs := SHL(1, 2) OR dig_outputs;
// activate DIO05
digital_outputs := SHL(1, 4) OR dig_outputs;
// set values
outIO.IOB_digital_outputs := dig_outputs;
// mask target requests
outIO.IOB_digital_outputs_monitor := 255;
Changing all digital/analog output variables follows the same schema. It involves assigning the desired output to the API variable while setting the proper mask variable. The mask variable enables you to select output slots that must adhere to a value change request. If the output slot is not "demasked," the assigned value has no effect on its state.
The API also contains information about the previously requested value, which can be useful in some request state evaluations.
For more details check the ROBOT IOs table in the Appendix of this article.
Subroutine triggering framework
In addition to basic fieldbus access to Profinet modules defined by the KR PROFINET IO, the "KR Profinet template v1.2.1.project" also supports a mechanism that enables the remote execution of routines predefined in the RC. This extension is particularly useful for advanced applications where the ctrlX PLC can request the execution of predefined abstractions from the RC program, such as sequences of motions, robot state evaluations or peripheral control commands (e.g. Cbun methods).
To integrate this framework into your application, you should utilize a predefined KR program structure containing the necessary data handling. Open the enclosed KR template program “plc_routines_1_2_1.kr2” in your RC. It includes the infrastructure and placeholders for up to 8 subroutines (labeled ctrlx_routine_<N>) that will be triggered from the ctrlx PLC program. Your custom RC code should be coming there.
Please note the first sequence (Sequence_1) is fully engaged in communication control and subroutine triggering, so please refrain from modifying it. You can use the other empty KR sequences if you require concurrent user code running.
To handle subroutine triggering, the RC program needs to be running. In the following illustration, you can find a simple trigger of the RC routine ctrlx_routine_1
// USER CODE
// Check whether there is already some ctrlx_routine_<> running on the RC
IF KR_call_proc.ready = TRUE THEN
// Select to execute ctrlx_routine_1 here
KR_call_proc.in := 1;
ELSE
// Select nothing while the routine is still running
KR_call_proc.in := 0;
END_IF
// Subroutine handling
// this call has to be present right after the USER CODE section to evaluate and command subroutine data
KR_call_proc();
A few framework variables play a crucial role in controlling the state of routine triggers:
- KR_call_proc.in - Used to assign the index of the desired ctrl_routine_<n> that will be executed in the RC program. Placeholders for ctrlx routines 1-8 are already present within the current RC template.
-
KR_call_proc.ready - Provides the state of the actively running routine in the RC. It returns True while any ctrlx routine is running in the RC program; otherwise, it contains False (idle).
KR_call_proc() is the important part of this framework overhanding requests and updating its state from the underlying Profinet data fields. This call needs to be provided at each update of the PLC_PRG program.
Please be mindful that this framework relies on a few KR PROFINET IO user module integer variables for status exchange. Consequently, it is essential to refrain from using the output variables out24Int.int_22, out24Int.int_23, out24Int.int_24, as well as the input variables in24Int.int_23, in24Int.int_24.
Appendix
System State
Variable |
Description |
inSystemState.Robot.MajorVersion (USINT) inSystemState.Robot.MinorVersion (USINT) |
KR PROFINET IO frame content version. The present version is assuming Major = 1, Minor = 0. |
inSystemState.Robot.RobotMode (USINT) |
Contains the value about the manual/automatic mode actually present in the RC. Defined values: |
inSystemState.Robot.RobotState (USINT) |
Robot State information describing the main robot operational status. Defined values: |
inSystemState.Robot.ProgramState (USINT) |
Automatic Mode Status. Defined values: |
inSystemState.Robot.EStopButton (BIT) |
This flag reflects status of the ESTOP circuit. |
inSystemState.Robot.PStopButton (BIT) |
This flag reflects status of the PSTOP circuit. |
inSystemState.Robot.ToggleButton (BIT) |
State of the Toggle button (the pause button). True - Toggle button is pressed |
inSystemState.Robot.BackdriveButton (BIT) |
State of the Teach button (back of the teachpendant, or on the robot ToolIO). True - Teach button is pressed |
inSystemState.Safety.SafetyMode |
The actual Safety Mode being set for the controller. Defined values: |
inSystemState.Robot.EStopFlag |
The BIT value is set to True when the robot system enters the ESTOP state. Please note that this flag reflects a broader state compared to the EStopButton mentioned earlier, which only indicates the state of the physical circuit. |
inSystemState.Robot.PStopFlag |
The BIT value is set to True when the robot system enters the PSTOP state. Please note that this flag reflects a broader state compared to the PStopButton mentioned earlier, which only indicates the state of the physical circuit. |
inSystemState.Robot.SStopFlag |
The BIT value is set to True when the RC is in the Soft-Stop state. This state is exclusively triggered by the software controller and doesn't encompass other electronic/hardware or safety-defined signals from the system. |
Manipulator State
Variable |
Description |
inJointsMonitor.Joint_1_position,.. |
The member variables contain actual position of each robot joint stated in radians. |
inJointsMonitor.Joint_1_velocity,.. |
The member variables contain actual position of each robot joint stated in radians per second. |
inJointsMonitor.Joint_1_current,.. |
The member variables contain the actual currents running through each robot joint, expressed in milliamps. |
inJointsMonitor.Joint_1_temperature,.. |
The member variables contain the actual temperatures of each joint (JointBoard sensor), expressed in degrees Celsius. |
inTCPMonitor.TCP_position_X |
Actual TCP reference position with regards to the WF (world frame) of the robot. Value units are stated in meters. |
inTCPMonitor.TCP_position_OR |
Actual TCP reference orientation (RPY - roll, pitch, yaw) with regards to the WF (world frame) of the robot. Value units are stated in radians. |
inTCPMonitor.TCP_velocity_X |
Actual velocity of the TCP reference with regards to the WF (world frame) of the robot. Value units are stated in meters per second. |
inTCPMonitor.TCP_velocity_OR |
Actual rate of change in the TCP orientation (RPY) relative to the World Frame (WF) of the robot. It's important to note that these quantities do not represent a geometric angular vector. The value units are stated in radians per second. |
ROBOT IOs - Inputs
Variable |
Description |
inIOMonitor.IOB_digital_inputs |
DI01 - DI16 The variable encodes 16 physical input signals situated on the RC IOBoard. Each DIxx entry corresponds to a specific bit within the value, following the schema: (DI01 << 0) | (DI02 << 1) | ... (DI16 << 15) |
inIOMonitor.IOB_safe_inputs |
SDI01 - SDI04 The variable encodes the status of four combined input signals situated on the RC IOBoard. When Safe Inputs are enabled, they operate in pairs, relying on physical Digital Inputs. The ACTIVE signal is returned only when both connected inputs in a pair are ACTIVE. For detailed information on safe IOs, please refer to the KR instruction manuals. Each SDIxx entry is assigned to a specific bit within the value, following the schema: (SDI01 << 0) | (SDI02 << 1) | ... (SDI04 << 3) |
inIOMonitor.IOB_current_input_1 |
AI01, AI02 Two available current inputs on the RC IOBoard with a value range of 4-20mA. |
inIOMonitor.IOB_voltage_input_1 |
AI03, AI04 Two available voltage inputs on the RC IOBoard with a value range of 0-10V. |
inIOMonitor.TIO_current_input |
TAI05/TAIC05 One available Robot ToolIO current input with a value range of 4-20mA. |
inIOMonitor.TIO_voltage_input_1,.. |
TAI03, TAI04 (Gen1 Robots) Up to four Robot ToolIO voltage input values, ranging from 0 to 10V. Please note that the current KR Profinet 1.0 fieldbus definition only supports four of these inputs, as it has not been adapted to the newer KR generation 2 robots. |
ROBOT IOs - Outputs
Variable |
Description |
outIO.IOB_digital_outputs inIOMonitor.IOB_digital_outputs |
DO01 - DO08 These output variables command eight digital outputs on the IOBoard, with each slot represented by a corresponding bit value. To implement a change in the actual value of the i-th output slot, set the i-th bit of the outIO.IOB_digital_output_mask. Subsequently, the value encoded at the i-th bit of the outIO.IOB_digital_output is applied (1 - ACTIVE, 0 - INACTIVE). The mask variable enables you to select output slots that must adhere to a value change request. If the output slot is not "demasked," the assigned value has no effect on its state. Additionally, the inIOMonitor.IOB_digital_outputs provides the recent request value. |
outIO.IOB_relay_outputs inIOMonitor.IOB_relay_outputs
|
RO01 - RO04 These output variables command four relays on the IOBoard, with each slot represented by a corresponding bit value. To implement a change in the actual value of the i-th output slot, set the i-th bit of the outIO.IOB_relay_outputs_mask. Subsequently, the value encoded at the i-th bit of the outIO.IOB_relay_outputs is applied (1 - ON, 0 - OFF). The mask variable enables you to select output slots that must adhere to a value change request. If the output slot is not "demasked," the assigned value has no effect on its state. Additionally, the inIOMonitor.IOB_relay_outputs provides the recent request value. |
outIO.IOB_current_output_1, outIO.IOB_current_outputs_mask inIOMonitor.IOB_current_output_1
|
AO01, AO02 These output variables command two current output slots on the IOBoard. The accepted range is 4-20mA. To implement a change in the actual value of the current output slot, set the 1st or 2nd bit of the outIO.IOB_current_output_mask. Additionally, the inIOMonitor.IOB_current_output_<n> provides the recent request value. |
outIO.IOB_voltage_output_1, outIO.IOB_voltage_outputs_mask inIOMonitor.IOB_voltage_output_1 |
AO03, AO04 These output variables command two voltage output slots on the IOBoard. The accepted range is 0-10V. To implement a change in the actual value of the voltage output slot, set the 1st or 2nd bit of the outIO.IOB_voltage_outputs_mask. Additionally, the inIOMonitor.IOB_voltage_output_<n> provides the recent request value. |
outIO.TIO_digital_outputs inIOMonitor.TIO_digital_outputs
|
TDO01 - TDO04 (Gen1 Robots) These output variables command four digital outputs on the Robot ToolIO, with each slot represented by a corresponding bit value. To implement a change in the actual value of the i-th output, set the i-th bit of the outIO.TIO_digital_outputs_mask. Subsequently, the value encoded at the i-th bit of the outIO.TIO_digital_outputs is applied (1 - ACTIVE, 0 - INACTIVE). The mask variable allows you to select output slots that have to follow value change request. If the output slot is not "demasked", the assigned value has no effect on its state. Additionally, the inIOMonitor.TIO_digital_outputs provides the recent request value. Please note that for Gen1 Robots, also outIO.TIO_digital_outputs_range variable is required to specify the voltage configuration. Here the bit value of 0 assigns 0-12V range, while bit value of 1 specify the 0-24V range. |
outIO.TIO_power_supply inIOMonitor.TIO_power_supply
|
TPSU01 - TPSU3 (Gen1 Robots) Output variables controling 4 extra ToolIO digital outputs. Particular slot is represented by a relevant bit value (starting from bit 1). These output variables command four extra digital outputs on the Robot ToolIO. Particular slot is represented by a relevant bit value. To implement a change in the actual value of the i-th output, set the i-th bit of the outIO.TIO_power_supply_mask. Subsequently, the value encoded at the i-th bit of the outIO.TIO_power_supply is applied (1 - ACTIVE, 0 - INACTIVE). The mask variable allows you to select output slots that have to follow value change request. If the output slot is not "demasked", the assigned value has no effect on its state. Additionally, the inIOMonitor.TIO_power_supply provides the recent request value. Please note that for Gen1 Robots, also outIO.TIO_power_supply_range variable is required to specify the voltage configuration. Here the bit value of 0 assigns 0-12V range, while bit value of 1 specify the 0-24V range. |
outIO.TIO_analog_output_1, outIO.TIO_current_outputs_mask inIOMonitor.TIO_analog_output_1
|
TAO01, TAO02 These output variables command two configurable outputs on the Robot ToolIO. Each of them can be configured either as current or voltage. Accepted range is 4-20mA resp. 0-24V. Similarly as in case of previously described outputs, to implement a change in the actual value of one of the outputs, set 1st or 2nd bits in the outIO.TIO_current_outputs_mask. Use the outIO.TIO_current_outputs_TYPE variable to configure the output type. Bit value of 0 stands for the current mode, while 1 specifies the use voltage output. In addition to control variables the inIOMonitor.TIO_analog_output_<n> give you the recent current state requests for both output slots. |
User Data
Variable |
Description |
out64Bit |
PLC -> Robot (Profinet Bit Output) out64Bit.DINT_1 -> Profinet Bit Output [0-31] The mapped array represents bit values in the net order, i.e. the MSB of DINT_1 is stored at index 0, while the LSB of DINT_1 at 31. Similarly, the MSB of DINT_2 is at index 32 and LSB of DINT_1 at 63. |
out24Int |
PLC -> Robot (Profinet Int Output) out24Int.int_1 -> Profinet Int Output[0] |
out24Real |
PLC -> Robot (Profinet Float Output) out24Real.real_1 -> Profinet Float Output[0] |
in64Bit |
Robot -> PLC (Profinet Bit Input) Profinet Bit Input [0-31] -> in64Bit.DINT_1 The mapped array represents bit values in the net order, i.e. the MSB of DINT_1 is stored at index 0, while the LSB of DINT_1 at 31. Similarly, the MSB of DINT_2 is at index 32 and LSB of DINT_1 at 63. |
in24Int |
Robot -> PLC (Profinet Int Input) Profinet Int Input[0] -> in24Int.int_1 |
in24Real |
Robot -> PLC (Profinet Float Input) Profinet Float Input[0] -> in24Real.real_1 |
The Company
Kassow Robots is developing and manufacturing unique and efficient 7-axes lightweight robots for industrial applications.