Decoupling PROFINET devices via KRL
Use KRL IOCTL commands to decouple PROFINET devices so they can be alternately used on different robots or isolated for other reasons.
IOCTL command 1060
- Use when a device must be run alternately on different robots. It can also be used if the device runs on only one robot.
- After decoupling, the device outputs are immediately set to zero. If the device is briefly powered off and then powered on again, the outputs will not be restored.
IOCTL command 60
- Only use this command if the device runs on a single robot. It is retained only for compatibility.
- When decoupled with this command, the device outputs remain unchanged. If the device is briefly powered off and then powered on again, the outputs will be restored.
Option: Always available
When enabled, the robot controller expects the device to be active at startup and reports an error if it is not. When disabled, the controller does not check device activation at startup.
Attributes of decoupled devices
- Separating a decoupled device from the bus or power does not trigger a fault.
- All I/O operations on a decoupled device remain invalid.
- A decoupled device cannot handle read/write faults.
- When decoupled, device inputs are set to zero.
Syntax examples
When the device is used on a single robot:
RET = IOCTL("PNIO-CTRL",60,user ID)
When the device can be used on one or more robots:
RET = IOCTL("PNIO-CTRL",1060,user ID)
Example: decouple device with ID 3 depending on the selected tool:
... IF (NEXT_TOOL == GRIPPER_1) THEN RET = IOCTL("PNIO-CTRL",1060,3) ENDIF ...
Coupling PROFINET devices via KRL
Two IOCTL commands are available for coupling with different behaviors and intended use cases.
- IOCTL command 1050: Use to couple a device so it can be alternately run on different robots. It can also be used if the device runs on only one robot.
- IOCTL command 50: Only use this command if the device runs on a single robot. It is retained only for compatibility.
Syntax examples
When the device is used on a single robot:
RET = IOCTL("PNIO-CTRL",50,user ID)
When the device can be used on one or more robots:
RET = IOCTL("PNIO-CTRL",1050,user ID)
Example: couple device with ID 5 depending on the selected tool:
... IF (NEXT_TOOL == GRIPPER_2) THEN RET = IOCTL("PNIO-CTRL",1050,5) ENDIF ...
Change coupling timeout via KRL
Some devices require longer coupling times than others. The controller waits a configurable timeout before reporting an error. The default timeout is 10 s. You can change it at runtime with IOCTL.
Syntax:
RET = IOCTL("PNIO-CTRL",32776,timeout)
Parameters
- RET: Variable to store the return value of the KRL IOCTL function. Must be declared as INT before use.
- IOCTL: KRL function to send commands to the bus driver.
- PNIO-CTRL: Bus driver name.
- 32776: IOCTL command for changing the timeout.
- timeout: Time to wait before the controller reports an error, in ms.
Return values
- 0: Timeout successfully changed.
- -1: Failed to change timeout because the bus system is not accessible.
Example: set timeout to 15 s (15000 ms):
RET = IOCTL("PNIO-CTRL",32776,15000)
Query PROFINET device status via KRL
Query device status at runtime using IOCTL.
Syntax:
RET = IOCTL("PNIO-CTRL",70,user ID)
Parameters
- RET: Variable to store the return value of IOCTL. Must be declared as INT.
- 70: IOCTL command for querying device status.
- user ID: User ID of the device to query.
Return values for RET
- 4: Device is decoupled.
- 5: Device is coupled but has an error.
- 6: Device is coupled and operational.
- 7: Device is decoupled but still active inside the PROFINET Controller. For example, this can occur when the device was decoupled with IOCTL 60. In this case, the PROFINET Controller will search for the device using DCP.
Enable or disable bus fault via KRL
Bus fault handling is enabled by default. A bus fault may cause a stop and/or lock of activate commands. You can disable or re-enable bus fault handling at runtime using IOCTL. Disabling can be applied to one or more bus instances.
When bus fault is disabled:
- Bus fault does not stop or lock activate commands.
- No fault message appears in the smartHMI info window.
- The smartHMI info window displays a message indicating IO bus error suppression for the affected bus instances.
- If a bus instance already has a fault, bus fault cannot be re-enabled for that instance.
- Use the system variable $IOBUS_INFO to check whether a bus fault has occurred.
Syntax
To disable bus fault:
RET = IOCTL("KRC->PNIO-CTRL",1,1)
To enable bus fault:
RET = IOCTL("KRC->PNIO-CTRL",1,0)
Parameters
- RET: Variable to store IOCTL return value. Declare as INT.
- 1,1: IOCTL command to disable bus fault.
- 1,0: IOCTL command to enable bus fault.
Return values
- 0: IOCTL command executed successfully.
- -1: Specified bus driver not found.
- -3: IOCTL contains an invalid parameter.
- -4: Activation not allowed due to a bus fault.
Query energy-saving mode of the robot controller via KRL
Query the controller's energy-saving mode at runtime using IOCTL.
Syntax:
RET = IOCTL("PNIO-DEV",1002,0)
Parameters
- RET: Variable to store IOCTL return value. Declare as INT.
- PNIO-DEV: Bus driver name.
- 1002: IOCTL command to query the controller energy-saving mode.
Return values
- -1: Error during query.
- 2: Controller is in 'brakes engaged' state.
- 240: Controller is in Energy_Saving_Disabled state.
- 255: Controller is in Ready_To_Operate state.
- 256: PROFIenergy not initialized.
- 257: Controller is in an overload state.
Restart the bus system via KRL
After a bus fault, restart the bus system at runtime using IOCTL.
Syntax:
RET = IOCTL("PNIO-CTRL",12,0)
Parameters
- RET: Variable to store IOCTL return value. Declare as INT.
- 12: IOCTL command to restart the bus system.
Return values
- 0: Bus system restart successful.
- 3: Bus system restart failed.
Query number of faulty PROFINET devices via KRL
Query the number of PROFINET devices on the bus system that have faults.
Syntax:
RET = IOCTL("PNIO-CTRL",32774,0)
Return values
- 0: All devices on the bus system are functioning correctly.
- >0: Number of faulty devices.
Query number of configured PROFINET devices via KRL
Query the number of configured PROFINET devices on the bus system.
Syntax:
RET = IOCTL("PNIO-CTRL",32775,0)
Return values
- -1: Error executing IOCTL command.
- >0: Number of configured devices.
ALLPCB