You are on page 1of 127

KRNX API Manual

Robot Division
Kawasaki Heavy Industries, Ltd.
2021/07/05
Rev: DEV 2.3.0
Document No: 90210-1416DEC

About
This document is a manual for KRNX(Kawasaki Robot Network eXtension) API. This
document describes KRNX’s concept, usage, and data structure. KRNX is available for
OpenAS E controller and F controller.
This document does not describe robot operation and AS Language usage. If you want,
please refer “Operation Manual” and “AS Language Reference Manual”.
Please understand the robot motion control fully and use KRNX carefully.
This document describes the function of KRNX library version “DEV 2.3.0”. If you use the
older one, you cannot use some functions.

1
Revision History

Rev1.0 Initial version (2015/04/29)

Rev1.1 Update (2015/07/30)


Section Note
1.30 Add krnx_ExecMon()
3 Add Error Code
- KRNX_E_ASERROR
- KRNX_E_NOROBOT

Rev1.2 Update (2015/08/31)


Section Note
1. Add “Abstract” Section
5 Add “Related Files” Section
6 Add “Example” Section

Rev1.3 Update (2015/08/31)


Section Note
2.28 Krnx_ProgramInfo -> Krnx_GetProgramInfo

Rev1.4 Update (2015/12/23)


Section Note
1.2 Delete not-supported API : krnx_GetRobotName

Rev1.6 Update (2018/12/27)


Section Note
3 Add new RT-API (3.2 ~ 3.11)
4 Add new API (4.1)

Rev1.7 Update (2019/02/21)


Section Note
2 Add API : krnx_GetRobotName
3 Add new RT-API (3.12 ~ 3.13)
3 Modify RT-API description
A Add new AS command (A.4)
B Update API List

Rev1.8 Update (2019/03/08)


Section Note
1 Update description
3 Update API description

Rev: DEV 2.0.0 Update (2019/03/25)


Section Note
2 Add new AS-API (2.31)
5 Add new Data Structure (5.5)

Rev: DEV 2.0.3 Update (2020/02/27)


Section Note
6 Add a new section “About thread-safety and Reentrancy of API”

2
Rev: DEV 2.1.0 Update (2020/04/27)
Section Note
2, 3, 4 Devide AUX-API into “Common API”, “AUX-API”, “AS-API”
3 Add “krnx_SetAuxApiTimeoutPeriod” in AUX-API
4 Add “krnx_SetAsApiTimeoutPeriod” in AS-API

Rev: DEV 2.1.1 Update (2020/06/19)


Section Note
Appendix. B Update API List

Rev: DEV 2.1.3 Update (2020/09/29)


Section Note
2 Add a new chapter “Supported System”
7 Add a new chapter “Matrix-API”
10 Add a new chapter “RTC Function”
12 Add troubleshooting to error code

Rev: DEV 2.2.0 Update (2021/05/07)


Section Note
2 Add new supported arms
6, 9 Add APIs for RT cyclic data
10, B Update RTC Function and its usage

Rev: DEV 2.2.1 Update (2021/05/31)


Section Note
2 Add new supported arms

Rev: DEV 2.3.0 Update (2021/07/05)


Section Note
2 Add new supported arms

3
SYMBOLS

The items that require special attention in this manual are designated with the
following symbols.

Ensure proper and safe operation of the robot and prevent physical injury or
property damage by complying with the safety matters given within the boxes
with these symbols.

DANGER
Failure to comply with indicated matters can result in
imminent injury or death.

WARNING

Failure to comply with indicated matters may possibly


lead to injury or death.

CAUTION

Failure to comply with indicated matters may lead to


physical injury and/or mechanical damage.

Important

Key points for using functions this manual


explains.

4
WARNING
1. The accuracy and effectiveness of the diagrams, procedures, and detail
explanations given in this manual cannot be confirmed with absolute
certainty. Should any unexplained questions or problems arise, please
contact Kawasaki Robot Service.
2. Safety related contents described in this manual apply to each individual
work and not to all robot work. In order to perform every work in
safety, read and fully understand the safety manual, all pertinent laws,
regulations and related materials as well as all the safety explanation
described in each chapter, and prepare safety measures suitable for
actual work.

! CAUTION
 This manual is for explanation of KRNX functions, and does not
ensure application system using KRNX. We don’t take responsibility
for any damage by the application system. We don’t also take
responsibility for any trouble about any patents.
 This manual is subject to change without notice for modification and
improvement.
 No part of this manual may be reproduced in any form without
permission.
 This manual is published under strict quality control standards.
Should you notice any errors or other problems, please feel free to
contact us about them.

All rights reserved. Copyright  2021 by KAWASAKI HEAVY INDUSTRIES, LTD.

5
Contents
1 Abstract................................................................................................................... 9
1.1 Functions ........................................................................................................................ 9
1.2 AUX-API ......................................................................................................................... 9
1.3 AS-API .......................................................................................................................... 10
1.4 RT-API .......................................................................................................................... 11
1.5 Matrix-API .................................................................................................................... 12
1.6 Controller Number and Robot Number .................................................................... 13
2 Supported System .................................................................................................. 15
2.1 Supported library environment ...................................................................................... 15
2.2 Supported Controllers and Robot arms.......................................................................... 15
3 Common API ....................................................................................................... 19
3.1 Connect to Robot Controller ...................................................................................... 19
3.2 Disconnect from Robot Controller ............................................................................ 20
4 AUX-API ............................................................................................................... 21
4.1 Abort Robot Program ................................................................................................. 21
4.2 Hold Robot Program ................................................................................................... 22
4.3 Continue Robot Program ........................................................................................... 23
4.4 Execute Robot Program ............................................................................................ 24
4.5 Kill Robot Program...................................................................................................... 25
4.6 Set Monitor Speed ...................................................................................................... 26
4.7 Abort PC Program ...................................................................................................... 27
4.8 Finish PC program ...................................................................................................... 28
4.9 Continue PC Program ................................................................................................ 29
4.10 Execute PC Program.................................................................................................. 30
4.11 Kill PC Program ........................................................................................................... 31
4.12 Get Base Matrix............................................................................................................. 32
4.13 Set Base Matrix ............................................................................................................. 33
4.14 Get Tool Matrix ............................................................................................................. 34
4.15 Set Tool Matrix ............................................................................................................. 35
4.16 Get Input / Output signal ............................................................................................ 36
4.17 Set Output Signal ........................................................................................................ 37
4.18 Reset External Output Signals(Monitor Command) ......................................... 38
4.19 Delete Data(Monitor Command) ......................................................................... 39
4.20 List program and data ................................................................................................ 40
4.21 Error Reset................................................................................................................... 41
4.22 Execute Program Instruction ..................................................................................... 42
4.23 Prime Program ............................................................................................................ 43
4.24 Record Program .......................................................................................................... 44
4.25 Execute Monitor .......................................................................................................... 45
4.26 Set AUX-API Timeout Period .................................................................................... 46
5 AS-API .................................................................................................................. 48
5.1 Get Robot Name ............................................................................................................ 48
5.2 Get Axis Working Limit ............................................................................................... 49
5.3 Get IO Information ...................................................................................................... 50
5.4 Get Program Status Information ............................................................................... 51
5.5 Get Control Panel Information .................................................................................. 52
5.6 Get Error Code ............................................................................................................ 53
5.7 Convert Error Code .................................................................................................... 54
5.8 Get/Set RTC Information ........................................................................................... 55
5.9 Set AS-API Timeout Period ....................................................................................... 56
6 RT-API .................................................................................................................. 58
6.1 Set RT Cyclic Data Kind ............................................................................................... 58
6.2 Get RT Cyclic Data Kind .............................................................................................. 60
6.3 Get Current Motion Data ............................................................................................... 61
6.4 Get Current Motion Data (Extended) ............................................................................ 62
6.5 Get IO Information (Extended) .................................................................................. 63
6.6 Set RTC Complement Data....................................................................................... 64

6
6.7 Get RTC Complement Data ...................................................................................... 66
6.8 Clear Old RTC Complement Data ............................................................................ 67
6.9 Get RTC Complement Data Limit ............................................................................. 68
6.10 Set RTC Error Flag ..................................................................................................... 69
6.11 Get RTC Error Flag .................................................................................................... 70
6.12 Get RTC Switch .......................................................................................................... 71
6.13 Get RTC Complement Data Buffer Length ............................................................. 72
6.14 Get Current Error Lamp Asynchronously ................................................................... 73
6.15 Get Current Error Code Asynchronously ................................................................ 74
6.16 Prime RTC Complement Data .................................................................................. 75
6.17 Send RTC Complement Data ................................................................................... 77
6.18 Mask RTC Complement Data ................................................................................... 79
7 Matrix API ............................................................................................................. 81
7.1 Joint to XYZOAT/Matrix ............................................................................................. 81
7.2 XYZOAT/Matrix to Joint ............................................................................................. 82
7.3 Multiply XYZOAT/Matrix ............................................................................................ 84
7.4 Inverse XYZOAT/Matrix .............................................................................................. 85
7.5 Transform XYZOAT/Matrix ......................................................................................... 86
7.6 Calculate Frame Coordinates......................................................................................... 87
8 Internal API ........................................................................................................... 89
8.1 Get KRNX Version ....................................................................................................... 89
9 Dara Structure ........................................................................................................ 91
9.1 Transformation Values (XYZOAT) ........................................................................... 91
9.2 Transformation Matrix ................................................................................................ 91
9.3 TKrnxIoInfo .................................................................................................................. 92
9.4 TKrnxIoInfoEx .............................................................................................................. 93
9.5 TKrnxPanelInfo ........................................................................................................... 95
9.6 TKrnxProgramInfo ...................................................................................................... 96
9.7 TKrnxCurMotionData.................................................................................................. 98
9.8 TKrnxCurMotionDataEx ............................................................................................. 99
9.9 TKrnxRtcInfo .............................................................................................................. 100
10 RTC Function ............................................................................................... 101
10.1 About ........................................................................................................................... 101
10.2 Procedure ..................................................................................................................... 101
10.2.1. Preparation of Robot Program for RTC Function ............................................... 102
10.2.2. Preparation of Robot Program for RTC Function (If RTC_CTL is not supported)102
10.2.3. Configuration of RTC Information ..................................................................... 103
10.2.4. Execution of Robot Program and Handling States .............................................. 103
10.2.5. Sending RTC Complement Data ......................................................................... 105
10.2.6. Getting RTC Control Data .................................................................................. 105
10.2.7. Synchronization with AS control cycle ............................................................... 105
10.2.8. Sequence about RTC Function............................................................................ 107
10.2.9. Restrictions about RTC function ......................................................................... 109
11 Thread-safety and Reentrancy of API .......................................................... 112
12 Error Code .................................................................................................. 113
13 Related File ................................................................................................ 118
13.1 Header File ................................................................................................................ 118
13.2 Port Files .................................................................................................................... 118
14 Example ...................................................................................................... 120
Appendix. A:AS Language .................................................................................. 121
A.1 RTC_SW .................................................................................................................... 121
A.2 RTC_STATUS ........................................................................................................... 122
A.3 RTC_CTL ................................................................................................................... 122
A.4 KRNX_RTC ............................................................................................................... 122
A.5 KRNX_RTC_INFO .................................................................................................... 123
Appendix. B:API List............................................................................................. 125

7

Memo

8
1 Abstract

1 Abstract
1.1 Functions
User application on PC can communicate to Robot Controller with KRNX.
KRNX has the following functions.
- Robot Program Control (Abort, Hold, Continue, Execute, Stop, SetMonSpeed)
- PC Program Control (Abort, End, Continue, Execute, Stop)
- Program Execution Status Acquisition
- Robot Real time Position Acquisition ( Angle, Current, Encorder)
- Signal Control (Set, Get, Reset)
- Program Edit
- Axis Conversion
- AS Monitor Command

1.2 AUX-API
AUX-API links AS Language monitor command. User program can connect to AS and AS
User program with KRNX

Controller

User AS
Program User Program

AS-API
AUX-API AS To Servo Unit

User program can get robot information (ex. robot status) with AUX-API.
Because behavior of robot is written with AS user program, AS user program can use usual AS
Language while using AUX-API.
For the detail of AS Language, please refer to AS Language Manual.

! WARNING

Misusing AUX-API may possibly leads to robot’s


unexpected behavior.

9
1 Abstract

1.3 AS-API
AS-API links AS. AS-API can control Robot behavior. AS-API can get IO information, AS
User Program information, and etc. AS-API can get these information faster than AUX-API.
(About 10~100 msec).

Controller

User AS
Program User Program

AS-API AS To Servo Unit

! WARNING

Misusing AS-API may possibly leads to robot’s unexpected


behavior.

10
1 Abstract

1.4 RT-API
RT-API links AS. RTC (Real Time Correction) function can add RTC value to joint angles
per 2 msec. User program have to calculate RTC value par specified cycle. User program
can use RTC Function by using RT-API. RT-API can also get robot’s current joint angles par
2 msec.

Controller

User AS
Program User Program

RT-API AS

Pose Command + Pose


+ Modified Pose
RTC +

RTC Function only works in REPEAT mode. RTC Function is enabled if AS user program
use RTC command (refer to “Appendix. A:AS Language”).

! WARNING
Incorrect RTC value may possibly leads to robot’s unexpected
behavior.

! CAUTION
To use RTC function, Robot controller needs to support RTC
function.

User program doesn’t need to synchronize its RTC value and


joint angles value of AS user program.

11
1 Abstract

1.5 Matrix-API
Matrix-API calculate kinematics of robot arm. Using Matrix-API, user program can get
matrix about kinematics and inverse kinematics.

12
1 Abstract

1.6 Controller Number and Robot Number


The Controller Number is used to distinguish Robot Controllers connected to the user
program.
The first argument “cont_no” of APIs is the Controller Number. One PC can manage 8 robot
controllers at maximum.
The Robot Number is used for to distinguish robot arms connected to the robot controller.
The second argument “robot_no” of APIs is the robot number.
There is the following relationship between Controller Number, Robot Number, Robot
Controller, and Robot Arm.

Controller Robot Robot Robot


Number Number Controller Arm
0 0 The 1st The 1st
1 The 2nd
… …
7 The 8th
1 0 The 2nd The 1st
1 The 2nd
… …
7 The 8th
2 0 The 3rd The 1st
1 The 2nd

7 The 8th
… … … …
7 0 The 8th The 1st
1 The 2nd
… …
7 The 8th

If you use only one Robot Controller, the Controller Number equals 0, and the Robot Number
equals 0. If you specified an incorrect controller number, APIs related to Controller return error
number. If you specified an incorrect robot number, APIs related to Robot Arm return error
number.

13
1 Abstract


Memo

14
2 Supported System

2 Supported System
2.1 Supported library environment
KRNX supports these library environment

 E-Controller Internal
 F-Controller Internal
 Windows 32bit/64bit
 Windows 7/10
 Linux 32bit/64bit
 Ubuntu 16.04/18.04

2.2 Supported Controllers and Robot arms


KRNX supports OpenAS E Controllers and F Controllers.

Supported robot arms are different from API kind in KRNX. AUX-API/AS-API support all robot
arms. RT-API/Matrix-API support robot arms as below. The robot controller which KRNX
connects to is also needed to support the robot arms.

Series Supported robot arms RT-API Matrix-API


R series RS003N-A001 ✓ ✓
RS005N-A001
RS005L-A001
RS006L-A001
RS007N-A001
RS007N-B001
RS007L-A001
RS007L-B001
RS010N-A001
RS010L-A001
RS013N-A001
RS015X-A001
RS020N-A001
RS030N-A001
RS050N-A001
RS080N-A001
RS080W-A001

RA005L-A001
RA006L-A001
RA010N-A001
RA010L-A001
RA020N-A001

RD080N-A001
M series MX350L-A001 ✓ ✓
MX400N-A001
MX420L-A001
MX500N-A001

MC004N-A001/B001
MS005N-B001 ✓ -
K series KF121J/U-A001/B001/C001 ✓ ✓
KF121J-B001/C001

KF192-A001/B001

15
2 Supported System

KF193-A001
KF194-A001

KF262-A001/B001/S001/T0001
KF263-A001
KF264-A001

KH214-A001
KH264-A001

KT264-B001/C001

KJ125-A001/B001
KJ155-A001/B001/C001/D001
KJ194-A001/B001
KJ244-C001/D001
KJ264-A001/B001/S001/S002
KJ294-A001/B001

KG264-A001
KG284-B001

KD010-B001/B002

KLS400-03N
KLS600-06N
KF194-A001 - ✓
CP series CP180L-A001 ✓ ✓
B series BX100N-B001 ✓ ✓
BX100S-B011
BX130X-B001/C001
BX200L-A001/B001/C001
BX200X-C001
BX100L-B001/B011 - ✓
BX130X-B011
BX165N-B001
BX200L-B011
BX250L-B001
BX300L-B001

BT200L-A001
W series WD002N-A202L/A202U ✓ ✓
(duAro)
N series NC005N-A001 ✓ -
NC008-A001
JS series JS002-A001, JS005-E001 ✓ ✓
JS010-C001
U series UX120-E001 ✓ ✓

UB150-A003
UA100-D001 - ✓
F series FS006N-A001/B001 ✓ ✓
FS006L-A001/B001
FS010N-A001/B001
FS010E-A001/B001
FS010L-A001
FS010C-A001/B001
FS010X-A001
FS020N-A001

16
2 Supported System

FS020C-A001
FS020X-A001
FS030N-A001
FS030L-A001
FS045N-A001/B001
FS045C-A001
FS060L-C001
FS002N-A001/B001
FS003N-A001
FS003N-E001
FS003N-F001

FW003N-E001
FW003N-G001

FA006N-B001
FA006E-B001
FA006L-B001
FA010N-B001
FA010L-A001
FA020N-A001
FA030L-A001

FD050N-C001

FT020N-C001
FA006N-A001 - ✓
FA010N-A001
Z series ZT130S-B001/C001 ✓ ✓
ZT130U-C001
ZT165U-C001
ZT200S-B001/C001
ZT200U-C001

ZX130S-A001/B001/T001
ZX130L-B001
ZX130U-B001
ZX165L-B001/BS01
ZX165U-B001/BS01/T001
ZX165X-A001
ZX200S-A001/B001/S001/BS01
ZX200U- B001
ZX300S-A001/B001

ZD130S-A001/C001/D001/E001
ZD250S-A001/B001

ZS100U-A001/T001

ZH100U-A001

ZB150S-A001/B001/T001
ZX165S-T001 ✓ -
Others CMH01N-A001 ✓ ✓

KMO000-A001/C001
KMY000-A001

HGO000-A001/B001

17
2 Supported System

SR010-A001
SR010N-C004
SR030-C007
SR035-B001
SR070-D003

GFSW000-A001
OFSW000-A001
SR030H-B001 - ✓

HR050N-A001

18
3 Common API

3 Common API
3.1 Connect to Robot Controller
int krnx_Open(
int cont_no,
char *hostname
)

Parameters
cont_no
Controller number
hostname
IP address or hostname of the controller

Returns
cont_no : Connected controller number
Negative value : Error code (refer to “12 Error Code” )

Description
Connect to robot controller. After you call this API, you can use other APIs.

See also
krnx_Close

19
3 Common API

3.2 Disconnect from Robot Controller


int krnx_Close(
int cont_no
)

Parameters
cont_no
Controller number

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code” )

Description
Disconnect from robot controller. After you call this API, you cannot use other APIs.

See also
krnx_Open

20
4 AUX-API

4 AUX-API
4.1 Abort Robot Program
int krnx_Abort(
int cont_no
int robot_no
int *as_err_code
)

Parameters
cont_no
Controller number
robot_no
Robot number
as_err_code
Address of controller error code buffer
Refer to AS Language Manual “Error Message” for the robot controller error
code.

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code” )

Description
Abort robot program.
After the current step of robot program was finished, this API aborts the robot
program.
The robot program can be restarted by krnx_Continue.

See also
krnx_Excute, krnx_Hold, krnx_Continue

21
4 AUX-API

4.2 Hold Robot Program


int krnx_Hold(
int cont_no,
int robot_no,
int *as_err_code
)

Parameters
cont_no
Controller number
robot_no
Robot number
as_err_code
Address of controller error code buffer
Refer to AS Language Manual “Error Message” for the robot controller error
code.

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code”)

Description
Hold robot program.
This API holds robot program immediately even if the current step of robot program
was not finished.
Motor power is not turned off.
The robot program can be restarted by krnx_Continue.

See also
krnx_Continue, krnx_Abort

22
4 AUX-API

4.3 Continue Robot Program


int krnx_Continue(
int cont_no,
int robot_no,
int next,
int *as_err_code
)

Parameters
cont_no
Controller number
robot_no
Robot number
next
0 : Continue from the stopped step.
1 : Continue from the stopped next step
as_err_code
Address of controller error code buffer
Refer to AS Language Manual “Error Message” for the robot controller error
code.

Returns
KRNX_NOERROR : OK
Negative value : Error code(refer to “12 Error Code”)
Description
Continue the robot program stopped by krnx_Abort, krnx_Hold or AS error.

See also
krnx_Hold, krnx_Abort

23
4 AUX-API

4.4 Execute Robot Program


int krnx_Execute(
int cont_no,
int robot_no,
const char *program,
int exec_num,
int step_num,
int *as_err_code
)

Parameters
cont_no
Controller number
robot_no
Robot number
program
Program name
exec_num
Number of execution
Negative value : unlimited
0 : One
1 – 32768 : Number of execution

step_num
Start step number.
0 : Execute from the executable of the program.
as_err_code
Address of controller error code buffer
Refer to AS Language Manual “Error Message” for the robot controller error
code.

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code”)

Description
Execute the specified robot program. The program will be executed from the
specified number step and repeated for the specified number.

See also
krnx_Hold, krnx_Abort, krnx_Kill, krnx_Continue

24
4 AUX-API

4.5 Kill Robot Program


int krnx_Kill(
int cont_no,
int robot_no,
int *as_err_code
)

Parameters
cont_no
Controller number
robot_no
Robot number
as_err_code
Address of controller error code buffer
Refer to AS Language Manual “Error Message” for the robot controller error
code.

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code”)

Description
Initialize the stack for robot program.

See also
krnx_Execute, krnx_Abort

25
4 AUX-API

4.6 Set Monitor Speed


int krnx_SetMonSpeed(
int cont_no,
int robot_no,
float speed,
int *as_err_code
)

Parameters
cont_no
Controller number
robot_no
Robot number
speed
Monitor speed (%)
as_err_code
Address of controller error code buffer
Refer to AS Language Manual “Error Message” for the robot controller error
code.

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code”)

Description
Set monitor speed. The robot speed is specified by the multiple of this API value
and the program speed.

See also

26
4 AUX-API

4.7 Abort PC Program


int krnx_PcAbort(
int cont_no,
int pcprogram_no,
int *as_err_code
)

Parameters
cont_no
Controller number
pcprogram_no
PC program number (1 – 3)
as_err_code
Address of controller error code buffer
Refer to AS Language Manual “Error Message” for the robot controller error
code.

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code”)

Description
Abort PC program.
The PC program can be restared by krnx_PcContinue.

See also
krnx_PcContinue

27
4 AUX-API

4.8 Finish PC program


int krnx_PcEnd(
int cont_no,
int pcprogram_no,
int *as_err_code
)

Parameters
cont_no
Controller number
pcprogram_no
PC program number (1 - 3)
as_err_code
Address of controller error code buffer
Refer to AS Language Manual “Error Message” for the robot controller error
code.

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code”)

Description
If current PC program execute STOP instruction, the PC program will be stopped.
If the execution number is not 0, the stopped PC program will be started by
krnx_PcContinue.

See also
krnx_PcContinue

28
4 AUX-API

4.9 Continue PC Program


int krnx_PcContinue(
int cont_no,
int pcprogram_no,
int next,
int *as_err_code
)

Parameters
cont_no
Controller number
pcprogram_no
PC program number (1 – 3)
next
0 : Continue from the stopped step.
1 : Continue from the stopped next step
as_err_code
Address of controller error code buffer
Refer to AS Language Manual “Error Message” for the robot controller error
code.

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code”)
Description
Continue the PC program that was stopped by krnx_PcAbort, krnx_PcEnd .

See also
krnx_PcAbort, krnx_PcEnd

29
4 AUX-API

4.10 Execute PC Program


int krnx_PcExecute(
int cont_no,
int pcprogram_no,
const char *program,
int exec_num,
int step_num,
int *as_err_code
)

Parameters
cont_no
Controller number
pcprogram_no
PC program number (1 – 3)
program
PC program name
exec_num
Number of execution
Negative value : unlimited
0 : One
1 – 32768 : number of execution
step_num
Start step number.
0 : Execute from the executable of the program.
as_err_code
Address of controller error code buffer
Refer to AS Language Manual “Error Message” for the robot controller error
code.

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code”)

Description
Execute the PC program.

See also
krnx_PcAbort, krnx_PcEnd, krnx_PcKill

30
4 AUX-API

4.11 Kill PC Program


int krnx_PcKill(
int cont_no,
int pcprogram_no,
int *as_err_code
)

Parameters
cont_no
Controller number
pcprogram_no
PC program number (1 – 3)
as_err_code
Address of controller error code buffer
Refer to AS Language Manual “Error Message” for the robot controller error
code.

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code”)

Description
Initialize the stack for the PC program.

See also
krnx_PcExecute, krnx_PcAbort

31
4 AUX-API

4.12 Get Base Matrix


int krnx_GetBaseMatrix(
int cont_no,
int robot_no,
float *xyzoat,
int *as_err_code
)

Parameters
cont_no
Controller number
robot_no
Robot number
xyzoat
Address of current base transformation values
Refer to “9.1 Transformation Values (XYZOAT)” for the format.
as_err_code
Address of controller error code buffer
Refer to AS Language Manual “Error Message” for the robot controller error
code.

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code”)

Description
Get current base transformation values (X, Y, Z, O, A, and T).
Please allocate over 24 bytes (sizeof(float) * 6) area for xyzoat.

See also
krnx_SetBaseMatrix、krnx_GetToolMatrix、krnx_SetToolMatrix

32
4 AUX-API

4.13 Set Base Matrix


int krnx_SetBaseMatrix(
int cont_no,
int robot_no,
const float *xyzoat,
int *as_err_code
)

Parameters
cont_no
Controller number
robot_no
Robot number
xyzoat
Address of current base transformation values
Refer to “9.1 Transformation Values (XYZOAT)” for the format.
as_err_code
Address of controller error code buffer
Refer to AS Language Manual “Error Message” for the robot controller error
code.

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code”)

Description
Set current base transformation values (X, Y, Z, O, A, and T).
Please allocate over 24 bytes (sizeof(float) * 6) area for xyzoat.

See also
krnx_GetBaseMatrix、krnx_GetToolMatrix、krnx_SetToolMatrix

33
4 AUX-API

4.14 Get Tool Matrix


int krnx_GetToolMatrix(
int cont_no,
int robot_no,
float *xyzoat,
int *as_err_code
)

Parameters
cont_no
Controller number
robot_no
Robot number
xyzoat
Address of current tool transformation values
Refer to “9.1 Transformation Values (XYZOAT)” for the format.
as_err_code
Address of controller error code buffer
Refer to AS Language Manual “Error Message” for the robot controller error
code.

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code”)

Description
Get current tool transformation values (X, Y, Z, O, A, and T).
Please allocate over 24 bytes (sizeof(float) * 6) area for xyzoat.
Tool transformation values define the relative position and direction from tool
attached flange.

See also
krnx_SetToolMatrix、krnx_GetBaseMatrix、krnx_SetBaseMatrix

34
4 AUX-API

4.15 Set Tool Matrix


int krnx_SetToolMatrix(
int cont_no,
int robot_no,
const float *xyzoat,
int *as_err_code
)

Parameters
cont_no
Controller number
robot_no
Robot number
xyzoat
Address of current tool transformation values
Refer to “9.1 Transformation Values (XYZOAT)” for the format.
as_err_code
Address of controller error code buffer
Refer to AS Language Manual “Error Message” for the robot controller error
code.

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code”)

Description
Set current tool transformation values (X, Y, Z, O, A, and T).
Please allocate over 24 bytes (sizeof(float) * 6) area for xyzoat.
Tool transformation values define the relative position and direction from tool
attached flange.

See also
krnx_GetToolMatrix、krnx_GetBaseMatrix、krnx_SetBaseMatrix

35
4 AUX-API

4.16 Get Input / Output signal


int krnx_GetSignal(
int cont_no,
int signal_no,
int *status,
int *as_err_code
)

Parameters
cont_no
Controller number
signal_no
Output singal (1 - 960), input signal (1001 – 1960), internal signal(2001-2960)
status
Address of signal status buffer
1 : ON
0 : OFF
as_err_code
Address of controller error code buffer
Refer to AS Language Manual “Error Message” for the robot controller error
code.

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code”)

Description
Get the ON/OFF status of signal specified by signal_no.
Please allocate over 4 bytes area for status.

See also
krnx_SetSignal

36
4 AUX-API

4.17 Set Output Signal


int krnx_SetSignal(
int cont_no,
int signal_no,
int status,
int *as_err_code
)

Parameters
cont_no
Controller number
signal_no
Output singal (1 - 960), internal signal(2001-2960)
status
Signal Status
-1 : ON
0 : OFF.
as_err_code
Address of controller error code buffer
Refer to AS Language Manual “Error Message” for the robot controller error
code.

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code”)

Description
Set ON/OFF status of signal specified by signal_no.

See also
krnx_GetSignal, krnx_Reset

37
4 AUX-API

4.18 Reset External Output Signals(Monitor Command)


int krnx_Reset(
int cont_no,
int *as_err_code
)

Parameters
cont_no
Controller number
as_err_code
Address of controller error code buffer
Refer to AS Language Manual “Error Message” for the robot controller error
code.

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code”)

Description
Set OFF to all of external output signals.

See also
krnx_SetSignal

38
4 AUX-API

4.19 Delete Data(Monitor Command)


int krnx_Delete(
int cont_no,
const char *element_name,
int element_type,
int *as_err_code
)

Parameters
cont_no
Controller number
element_name
Delete target data name
If “*” is set, all of data included in element_type are deleted.

element_type
Delete target data type. (refer to the below table)
Multiple macros can be set by “OR” operation.

Macro Description
QUAL_PRG Program
QUAL_LOC Position Information
QUAL_REAL Real Variable
QUAL_STR String Variable
QUAL_INT Integer Variable

as_err_code
Address of controller error code buffer
Refer to AS Language Manual “Error Message” for the robot controller error
code.

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code”) Description
Delete the specified data from system memory.
When element_type is 0, the specified program and all of subroutine, variables
used by the program will be deleted. But the subroutine and variables used by the
other program will not be deleted.
When element_type is QUAL_PRG, the specified program will be deleted.
The subroutine, variables used by the program will not be deleted.

See also

39
4 AUX-API

4.20 List program and data


int krnx_List(
int cont_no,
const char *element_name,
int element_type,
char *buffer,
int buffer_sz,
int *as_err_code
)

Parameters
cont_no
Controller number
element_name
Specify output data. If NULL is specified, all of data will become target.
element_type
Specify the data type. The values are same as that of krnx_Delete.
buffer
Address of output buffer.
buffer_sz
Size of output buffer
as_err_code
Address of controller error code buffer
Refer to AS Language Manual “Error Message” for the robot controller error
code.

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code”)

Description
Write specified program or data to output buffer as text data.

See also
krnx_Delete

40
4 AUX-API

4.21 Error Reset


int krnx_Ereset(
int cont_no,
int robot_no,
int *as_err_code
)

Parameters
cont_no
Controller number
robot_no
Robot number
as_err_code
Address of controller error code buffer
Refer to AS Language Manual “Error Message” for the robot controller error
code.

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code”)

Description
Reset error for the robot. This API function is same as “Reset” switch of control
panel.

See also

41
4 AUX-API

4.22 Execute Program Instruction


int krnx_Do(
int cont_no,
int robot_no,
const char *cmd,
int *as_err_code
)

Parameters
cont_no
Controller number
robot_no
Robot number
cmd
Program instruction
as_err_code
Address of controller error code buffer
Refer to AS Language Manual “Error Message” for the robot controller error
code.

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code”)

Description
Execute the robot program instruction specified by “cmd”.

See also

42
4 AUX-API

4.23 Prime Program


int krnx_Prime(
int cont_no,
int robot_no,
const char *program,
int exec_num,
int step_num,
int create,
int *as_err_code
)

Parameters
cont_no
Controller number
robot_no
Robot number
program
Program name
exec_num
The number of program execution
step_num
Execution start step number
create
Non-zero : Create new program if the program is not exist on the memory.
as_err_code
Address of controller error code buffer
Refer to AS Language Manual “Error Message” for the robot controller error
code.

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code”)

Description
Prime the robot program for execution.
After calling krnx_Prime, please call krnx_Continue to execute the program.
If the program is not exist on memory and you call this function with non-zero create
parameter, the program will be created.
The new generated program does not have any instruction, but you can add a step
by krnx_RecOneStep.

See also
krnx_RecOneStep, krnx_Execute, krnx_Continue

43
4 AUX-API

4.24 Record Program


int krnx_RecOneStep(
int cont_no,
const char *program,
int step_num,
const char *step_data,
int insert,
int *as_err_code
)

Parameters
cont_no
Controller number
program
Program name
step_num
Execution start step number
step_data
Program instruction
insert
Non-zero : insert the step
0 : Overwrite the step
as_err_code
Address of controller error code buffer
Refer to AS Language Manual “Error Message” for the robot controller error
code.

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code”)

Description
Add a new step into the specified program.

See also
krnx_Prime

44
4 AUX-API

4.25 Execute Monitor


int krnx_ExecMon(
int cont_no,
const char *cmd,
char *buffer,
int buffer_sz,
int *as_err_code
)

Parameters
cont_no
Controller number
cmd
Monitor command
buffer
Address of output buffer
buffer_sz
Size of output buffer
as_err_code
Address of controller error code buffer
Refer to AS Language Manual “Error Message” for the robot controller error
code.

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code”)

Description
Execute monitor command and get the result from robot controller.

See also

45
4 AUX-API

4.26 Set AUX-API Timeout Period


int krnx_SetAuxApiTimeoutPeriod(
int cont_no,
int period,
)

Parameters
cont_no
Controller number
period
Timeout period

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code” )

Description
Set timeout period (msec) for AUX-API. Each AUX-API returns KRNX_E_TIMEOUT
if its data send/recv is not finished in this parameter.
Default period is 1000msec. This parameter can be set in each controller number.

See also

46
4 AUX-API


Memo

47
5 AS-API

5 AS-API
5.1 Get Robot Name
int krnx_GetRobotName(
int cont_no,
int robot_no,
char *name
)

Parameters
cont_no
Controller number
robot_no
Robot number
name
Address of robot name
You have to allocate over 26 bytes for the buffer.

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code”)

Description
Robot name is copied to the specified address.
ex) “FS002-A001”, “FS010-A001”, “FS045-A001”

See also

48
5 AS-API

5.2 Get Axis Working Limit


void krnx_GetLimitM(
int cont_no,
int robot_no,
float *limit_m
)

void krnx_GetLimitP(
int cont_no,
int robot_no,
float *limit_p
)

Parameters
cont_no
Controller number
robot_no
Robot number
limit_m
Address of the lower limit buffer
Unit : mm for Linear / radian for Rotational
You have to allocate over 72 bytes (sizeof(float) x 18) for the buffer.
limit_p
Address of the upper limit buffer
Unit : mm for Linear / radian for Rotational
You have to allocate over 72 bytes (sizeof(float) x 18) for the buffer.

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code”)

Description
Write the lower / upper limit into the buffer.
limit_m[i] corresponds to lower limit of axis i.
limit_p[i] corresponds to upper limit of axis i.

See also

49
5 AS-API

5.3 Get IO Information


int krnx_GetCurIoInfo(
int cont_no,
TKrnxIoInfo *ip
)

Parameters
cont_no
Controller number
ip
Address of robot IO information buffer
TKrnxIoInfo struct is defined as below.

#define KRNX_MAXSIGNAL 512


typedef struct
{
char io_do[KRNX_MAXSIGNAL/8];
char io_di[KRNX_MAXSIGNAL/8];
char internal[KRNX_MAXSIGNAL/8];
} TKrnxIoInfo;

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code”)

Description
Get the latest status of external input/output signal and internal signal.
Please refer “TKrnxIoInfo” for more detail.
You can also get IO Information by krnx_GetSignal and krnx_GetCurIoInfoEx

See also
TKrnxIoInfo, krnx_SetSignal, krnx_GetSignal, krnx_GetCurIoInfoEx

50
5 AS-API

5.4 Get Program Status Information


int krnx_GetProgramInfo(
int cont_no,
int robot_no,
TKrnxProgramInfo *ip
)

Parameters
cont_no
Controller number
robot_no
Robot number
ip
Address of robot program status information buffer.
TKrnxProgramInfo struct is defined as below.

#define KRNX_MAX_ROBOT 8
typedef struct
{
TKrnxMonInfo mon[KRNX_MAX_ROBOT];
TKrnxStepperInfo robot[KRNX_MAX_ROBOT];
TKrnxStepperInfo pc[3];
} TKrnxProgramInfo;

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code”)

Description
mon[] have current value of robot monitor speed, program speed, accuracy.
If controller connects to only one robot, only mon[0] is valid.
robot[] have working condition of robot program.
If controller connects to only one robot, only robot[0] is valid.
pc[] has a condition of PC program. You can execute 3 PC programs maximum at
the same time.
Please refer to 9.6 for TKrnxMonInfo, TKrnxStepperInfo.

See also
TKrnxProgramInfo, TKrnxMonInfo, TKrnxStepperInfo, krnx_SetMonSpeed

51
5 AS-API

5.5 Get Control Panel Information


int krnx_GetPanelInfo(
int cont_no,
int robot_no,
TKrnxPanelInfo *info
)

Parameters
cont_no
Controller number
robot_no
Robot number
info
Address of coltroll panel information buffer.
TKrnxPanelInfo is defined as below.
typedef struct
{
short error_lamp;
short motor_lamp;
short cyc_lamp;
short repeat_lamp;
short run_lamp;
short trigger_lamp;
short teach_lock_lamp;
short emergency;
} TKrnxPanelInfo;

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code”)

Description
Get control panel information.

See also

52
5 AS-API

5.6 Get Error Code


int krnx_GetErrorInfo(
int cont_no,
int robot_no,
int *error_code
)

Parameters
cont_no
Controller number
robot_no
Robot number
error_code
Address of controller error code buffer
Refer to AS Language Manual “Error Message” for the robot controller error
code.

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code”)

Description
Get error code occurred in robot controller. You can convert this code to AS error
level and code by using krnx_ConvertErrorCode.

See also
krnx_ConvertErrorCode

53
5 AS-API

5.7 Convert Error Code


int krnx_ConvertErrorCode(
int *error_code,
char *error_level
)

Parameters
error_code
Address of error code buffer (read / write)
error_level
Address of AS error code level buffer ( 2 Bytes)

Returns
Address of controller error code buffer
Refer to AS Language Manual “Error Message” for the robot controller error code.
Description
Convert error code (acquired by krnx_GetErrorInfo, monitor command API) into AS
error level and code. The converted error level and code are correspond to the AS
Language Manual “Error Message”.

See also
krnx_GetErrorInfo

54
5 AS-API

5.8 Get/Set RTC Information


int krnx_SetRtcInfo(
int cont_no,
TKrnxRtcInfo *rtc_info
)

int krnx_GetRtcInfo(
int cont_no,
TKrnxRtcInfo *rtc_info
)

Parameters
cont_no
Controller number
rtc_info
Address of KRNX RTC information buffer
Refer to chapter 5 TKrnxRtcInfo for more information.

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code”)

Description
Get/Set RTC information.
These API are same functions as AS Language “KRNX_RTC”

See also
TKrnxRtcInfo

55
5 AS-API

5.9 Set AS-API Timeout Period


int krnx_SetAsApiTimeoutPeriod(
int cont_no,
int period,
)

Parameters
cont_no
Controller number
period
Timeout period

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code”)

Description
Set timeout period (msec) for AS-API. Each AS-API returns KRNX_E_TIMEOUT if its
data send/recv is not finished in this parameter.
Default period is 100msec. This parameter can be set in each controller number.

See also

56
5 AS-API


Memo

57
6 RT-API

6 RT-API
6.1 Set RT Cyclic Data Kind
int krnx_SetRtCyclicDataKind(
int cont_no,
unsigned short kind,
)

Parameters
cont_no
Controller number
kind
Setting bit for RT Cyclic data kind
Bit map is as below (0: disabled, 1: enabled).

Kind Bit Getting APIs


Offset
Joint angle present value 0 krnx_GetCurMotionData
[rad or mm] krnx_GetCurMotionDataEx
Joint angle command value 1 krnx_GetCurMotionData
[rad or mm] krnx_GetCurMotionDataEx
Joint current present value 2 krnx_GetCurMotionData
[A] krnx_GetCurMotionDataEx
Joint encoder present value 3 krnx_GetCurMotionData
[bit] krnx_GetCurMotionDataEx
Error Lamp/Code 4 krnx_GetCurErrorLamp
krnx_GetCurErrorInfo
Joint current command value 5 krnx_GetCurMotionDataEx
[A]
Joint current saturation 6 krnx_GetCurMotionDataEx
ratio(present/command)
Joint encoder command value 7 krnx_GetCurMotionDataEx
[bit]
Joint velocity 8 krnx_GetCurMotionDataEx
value(present/command)
[rad/s or mm/s]
Transformation position 9 krnx_GetCurMotionDataEx
value(present/command)
[rad, mm, rad/s or mm/s]
External Output/Input signal 10 krnx_GetCurIoInfoEx
Internal signal 11 krnx_GetCurIoInfoEx

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code”)

Description
Set kinds of RT cyclic data. This RT cyclic data is received from AS every 2ms.
By executing this API before krnx_Open, KRNX automatically receives the
specified data per 2ms from AS.
To get the value, use the corresponding APIs.
If AS doesn’t support the specified kinds of data, krnx_Open returns
KRNX_RT_CYCLIC for error.
Default data kinds of RT cyclic data are joint angle present value, joint angle
command value, joint current present value, and error lamp/code.

58
6 RT-API

See also
krnx_GetRtCyclicDataKind

59
6 RT-API

6.2 Get RT Cyclic Data Kind


int krnx_GetRtCyclicDataKind(
int cont_no,
unsigned short *krnx_kind,
unsigned short *as_kind
)

Parameters
cont_no
Controller number
krnx_kind
Address of setting bit for RT cyclic data kind by KRNX side.
Refer to “6.1 Set RT Cyclic Data Kind” for bit map.
as_kind
Address of supporting bit for RT cyclic data kind by AS side.
Refer to “6.1 Set RT Cyclic Data Kind” for bit map.

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code”)

Description
Get kinds of RT cyclic data. This RT cyclic data is received from AS every 2ms.
By KRNX side, krnx_kind gets the setting kind from krnx_SetRtCyclicDataKind.
By AS side, after krnx_Open, as_kind gets the supporting data kind of AS. And
before krnx_Open, as_kind gets the default data kind, joint angle present value, joint
angle command value, joint current present value, and error lamp/code.

See also
krnx_SetRtCyclicDataKind

60
6 RT-API

6.3 Get Current Motion Data


int krnx_GetCurMotionData(
int cont_no,
int robot_no,
TKrnxCurMotionData *md
)

Parameters
cont_no
Controller number
robot_no
Robot number
md
Address of motion data buffer
TKrnxCurMotionData struct is defined as below.

#define KRNX_MAXAXES 18
typedef struct
{
float ang[KRNX_MAXAXES];
float ang_ref[KRNX_MAXAXES];
float cur[KRNX_MAXAXES];
long enc[KRNX_MAXAXES];
} TKrnxCurMotionData;

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code”)

Description
Get the latest motion data from controller buffer. Buffered cycle is 2ms.
You can get the data which is selected by krnx_SetRtCyclicDataKind
Refer to “TKrnxCurMotionData” for more detail.
You have to allocate bytes of TKrnxCurMotionData for md.
If md is set NULL, this API returns KRNX_BADARGS.

See also
TKrnxCurMotionData

61
6 RT-API

6.4 Get Current Motion Data (Extended)


int krnx_GetCurMotionDataEx(
int cont_no,
int robot_no,
TKrnxCurMotionDataEx *md
)

Parameters
cont_no
Controller number
robot_no
Robot number
md
Address of motion data buffer
TKrnxCurMotionData struct is defined as below.

#define KRNX_MAXAXES 18
typedef struct
{
float ang[KRNX_MAXAXES];
float ang_ref[KRNX_MAXAXES];
float cur[KRNX_MAXAXES];
int enc[KRNX_MAXAXES];
float cur_ref[KRNX_MAXAXES];
float cur_sat[KRNX_MAXAXES];
float cur_sat_ref[KRNX_MAXAXES];
int enc_ref[KRNX_MAXAXES];
float ang_vel[KRNX_MAXAXES];
float ang_vel_ref[KRNX_MAXAXES];
float xyzoat[6];
float xyzoat_ref[6];
float xyzoat_vel;
float xyzoat_vel_ref;
} TKrnxCurMotionDataEx;

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code”)

Description
Get the latest motion data from controller buffer. Buffered cycle is 2ms.
You can get the data which is selected by krnx_SetRtCyclicDataKind
Refer to “TKrnxCurMotionDataEx” for more detail.
You have to allocate bytes of TKrnxCurMotionDataEx for md.
If md is set NULL, this API returns KRNX_BADARGS.

See also
TKrnxCurMotionDataEx, krnx_SetRtCyclicDataKind, krnx_GetRtCyclicDataKind

62
6 RT-API

6.5 Get IO Information (Extended)


int krnx_GetCurIoInfoEx(
int cont_no,
TKrnxIoInfoEx *ip
)

Parameters
cont_no
Controller number
ip
Address of robot IO information (Extended) buffer
TKrnxIoInfoEx struct is defined as below.

#define DI_MAX_SIGNAL 960


#define DO_MAX_SIGNAL 960
#define INTERNAL_MAX_SIGNAL 960
typedef struct
{
char io_do[DO_MAX_SIGNAL/8];
char io_di[DI_MAX_SIGNAL/8];
char internal[INTERNAL_MAX_SIGNAL/8];
} TKrnxIoInfoEx;

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code”)

Description
Get the latest status of external input/output signal and internal signal from
controller buffer. Buffered cycle is 2ms.
You can get the data which is selected by krnx_SetRtCyclicDataKind
Refer to “TKrnxIoInfoEx” for more detail.
You can also get IO information by krnx_GetSignal and krnx_GetCurIoInfo.

See also
TKrnxIoInfoEx, krnx_SetSignal, krnx_GetSignal, krnx_GetCurIoInfo

63
6 RT-API

6.6 Set RTC Complement Data

int krnx_SetRtcCompData(
int cont_no,
int robot_no,
const float *comp,
int *status,
unsigned short seq_no
)

Parameters
cont_no
Controller number
robot_no
Robot number
comp
Address of the RTC Complement data buffer
Unit : mm for Linear / radian for Rotational
status
Address of complement result status buffer.
The description of value is as below.

Value Description
0x0001 Operational area upper limit over
0x0002 Operational area lower limit over
0x0004 RTC Complement data limit over

seq_no
Sequence number
Please set incremented value one by one every time you call this function.

Returns
KRNX_NOERROR: OK
Negative value: Error code (refer to “12 Error Code”)

Description
Set RTC complement data into controller. If RTC switch is ON, the robot
moves to (AS each axis position command + complement data) position.
comp[i] is correspond to (i+1)-th axis.
You have to allocate over 72 bytes (18 x sizeof(float)) for the buffer.
If complement data is incorrect, the return value is negative value.

Detail of Complement data error is saved in status area.


Status[i] is correspond to (i+1)-th axis status.
You have to allocate over 72 bytes (18 x sizeof(float)) for the buffer.

If the sum of axis position command value in AS and RTC complement data is over
the upper limit (lower limit), operational area upper limit (lower limit) error status is
set.
If the difference between previous and current complement data is over the limit
value,
RTC Complement value limit error status is set.

Since AS command value is updated per 2 msec, RTC Complement data should be
sent per specified cycle time by KRNX_RTC and krnx_GetRtcBufferLength.

To use RTC function, RTC-implemented robot controller is required.


Please refer “10 RTC Function” for more detail.

64
6 RT-API

See also
krnx_PrimeRtcCompData, krnx_SendRtcCompData, krnx_GetRtcCompData,
krnx_GetRtcCompLimit, krnx_GetRtcBufferLengh, krnx_SetRtcInfo, krnx_GetRtcInfo,
_
A.1 RTC_SW, A.4 KRNX_RTC, A.5 KRNX_RTC_INFO (AS Language)

! WARNING
If incorrect complement value is set, the robot may move to
out of working area or too quickly.
Please be careful not to set incorrect complement value.
Don’t move into the safely fence when robot is moving
automatically.

! CAUTION
Please debug the program carefully before you move robot.
You can use Robot Controller simulation function.

65
6 RT-API

6.7 Get RTC Complement Data

int krnx_GetRtcCompData(
int cont_no,
int robot_no,
float *comp
)

Parameters
cont_no
Controller number
robot_no
Robot number
comp
Address of controller complement data buffer.
Unit: mm for Linear / radian for Rotational

Returns
KRNX_NOERROR: OK
Negative value: Error code (refer to “12 Error Code”)

Description
Get RTC Complement data that was set by krnx_SetRtcCompData.
comp[i] is correspond to (i+1)-th axis.
You have to allocate over 72 bytes (18 x sizeof(float)) for the comp buffer.

See also
krnx_SetRtcCompData

66
6 RT-API

6.8 Clear Old RTC Complement Data

int krnx_OldCompClear(
int cont_no,
int robot_no,
)

Parameters
cont_no
Controller number
robot_no
Robot number

Returns
KRNX_NOERROR: OK
Negative value: Error code (refer to “12 Error Code”)

Description
Clear previous RTC complement data.

See also
krnx_SetRtcCompData

67
6 RT-API

6.9 Get RTC Complement Data Limit

int krnx_GetRtcCompLimit(
int cont_no,
int robot_no,
float *comp_limit
)

Parameters
cont_no
Controller number
robot_no
Robot number
comp_limit
Address of RTC Complement data limit buffer.
Unit: mm for Linear / radian for Rotational

Returns
KRNX_NOERROR: OK
Negative value: Error code (refer to “12 Error Code”)

Description
Get RTC Complement data limit. When you set RTC Complement data by
krnx_SetRtcCompData, if the difference between previous data and current data is
larger than this limit, an error occurs.
comp_limit[i] is correspond to (i+1)-th axis.
You have to allocate over 72 bytes (18 x sizeof(float)) for the buffer.

See also
krnx_SetRtcCompData

68
6 RT-API

6.10 Set RTC Error Flag

int krnx_SetRtcErrorFlag(
int cont_no,
int robot_no,
int error_flag
unsigned short seq_no
)

Parameters
cont_no
Controller number
robot_no
Robot number
error_flag
RTC Error number.
If the value is negative, AS error message is issued and the robot stops.
seq_no
Sequence number
Please set incremented value one by one every time you call this function.

Returns
KRNX_NOERROR: OK
Negative value: Error code (refer to “12 Error Code”)

Description
AS outputs an error “(E1520) RTC)KRNX set RTC Error.” and the robot stops.
This error flag is reset by AS side error reset.

See also
krnx_GetRtcErrorFlag

69
6 RT-API

6.11 Get RTC Error Flag

int krnx_GetRtcErrorFlag(
int cont_no,
int robot_no,
int *error_flag,
)

Parameters
cont_no
Controller number
robot_no
Robot number
error_flag
Address of RTC Error number buffer

Returns
KRNX_NOERROR: OK
Negative value: Error code (refer to “12 Error Code”)

Description
Get RTC Error number that was set by krnx_SetRtcErrorFlag. The error number will
be reset to zero by AS side error reset.
You have to allocate over 4 bytes (sizeof(int)) for the buffer.

See also
krnx_SetRtcErrorFlag

70
6 RT-API

6.12 Get RTC Switch


int krnx_GetRtcSwitch(
int cont_no,
int robot_no,
int *rtc_sw
)

Parameters
cont_no
Controller number
robot_no
Robot number
rtc_sw
Address of RTC Switch buffer

Returns
KRNX_NOERROR: OK
Negative value: Error code (refer to “12 Error Code”)

Description
Get RTC Switch information.
Value 1 means RTC switch is ON. Value 0 means RTC switch is OFF.
You have to allocate over 4 bytes (sizeof(int)) area for the buffer.

See also
A.1 RTC_SW (AS Language)

71
6 RT-API

6.13 Get RTC Complement Data Buffer Length


int krnx_GetRtcBufferLength (
int cont_no,
int robot_no,
)

Parameters
cont_no
Controller number
robot_no
Robot number

Returns
KRNX_NOERROR: OK
Negative value: Error code (refer to “12 Error Code”)

Description
Get RTC complement data buffer length of the robot controller.
KRNX sends RTC complement data when krnx_SetRtcCompData() is executed.
After the robot controller receives it, it is stored in the internal buffer.
The robot controller uses the buffer by FIFO while controlling the robot arm.
By comparing this value and the specified buffering_cycle_num by KRNX_RTC, you
can adjust a cycle time lag between KRNX application and the connected robot
controller.

See also
krnx_SetRtcCompData, krnx_PrimeRtcCompData, krnx_SendRtcCompData, A.4
KRNX_RTC (AS Language)

72
6 RT-API

6.14 Get Current Error Lamp Asynchronously


int krnx_GetCurErrorLamp(
int cont_no,
int robot_no,
int *error_lamp
)

Parameters
cont_no
Controller number
robot_no
Robot number
error_lamp
Address of Error lamp

Returns
KRNX_NOERROR: OK
Negative value: Error code (refer to “12 Error Code”)

Description
Get Error lamp asynchronously from the robot controller.
Value -1 means Error lamp is ON. Value 0 means Error lamp is OFF (Normal).
This Error lamp information is updated in each 2 msec.
You can also get the Error lamp information by krnx_GetPanelInfo(), but this API
takes less time than krnx_GetPanelInfo() because of its asynchrony.
(krnx_GetCurErrorLamp: less than 0.5 msec, krnx_GetPanelInfo(): about 20 msec)

See also
krnx_GetPanelInfo

73
6 RT-API

6.15 Get Current Error Code Asynchronously


int krnx_GetCurErrorInfo(
int cont_no,
int robot_no,
int *error_code
)

Parameters
cont_no
Controller number
robot_no
Robot number
error_code
Address of Error code.
Refer to AS Language Manual “Error Message” for the robot controller error
code.

Returns
KRNX_NOERROR: OK
Negative value: Error code (refer to “12 Error Code”)

Description
Get Error code asynchronously from the robot controller.
This Error code information is updated in each 2 msec.
You can also get the Error code information by krnx_GetErrorInfo(), but this API
takes less time than krnx_GetErrorInfo() because of its asynchrony.
(krnx_GetCurErrorInfo: less than 0.5 msec, krnx_GetErrorInfo(): about 20 msec)

See also
krnx_GetErrorInfo

74
6 RT-API

6.16 Prime RTC Complement Data

int krnx_PrimeRtcCompData(
int cont_no,
int robot_no,
const float *comp,
int *status,
)

Parameters
cont_no
Controller number
robot_no
Robot number
comp
Address of the RTC Complement data buffer
Unit : mm for Linear / radian for Rotational
status
Address of complement result status buffer.
The description of value is as below.

Value Description
0x0001 Operational area upper limit over
0x0002 Operational area lower limit over
0x0004 RTC Complement data limit over

Returns
KRNX_NOERROR: OK
Negative value: Error code (refer to “12 Error Code”)

Description
Prime RTC complement data into controller board.
comp[i] is correspond to (i+1)-th axis.
You have to allocate over 72 bytes (18 x sizeof(float)) for the buffer.
The primed data is sent to controller by executing krnx_SendRtcCompData.
If complement data is incorrect, the return value is negative value.

Detail of Complement data error is saved in status area.


status[i] is correspond to (i+1)-th axis status.
You have to allocate over 72 bytes (18 x sizeof(float)) for the buffer.
If the sum of axis position command value in AS and RTC complement data is over
the upper limit (lower limit), operational area upper limit (lower limit) error status is
set.
If the difference between previous and current complement data is over the limit
value,
RTC Complement value limit error status is set.

krnx_PrimeRtcCompData is similarly to krnx_SetCompData. If you want to prime and


send RTC complement data at once, please use krnx_SetRtcCompData.

To use RTC function, RTC-implemented robot controller is required.


Please refer “10 RTC Function” for more detail.

75
6 RT-API

See also
krnx_SendRtcCompData, krnx_SetRtcCompData, krnx_GetRtcCompData,
krnx_GetRtcCompLimit, A.1 RTC_SW, A.4 KRNX_RTC (AS Language)

76
6 RT-API

6.17 Send RTC Complement Data

int krnx_SendRtcCompData(
int cont_no,
unsigned short seq_no
)

Parameters
cont_no
Controller number
seq_no
Sequence number
Please set incremented value one by one every time you call this function.

Returns
KRNX_NOERROR: OK
Negative value: Error code (refer to “12 Error Code”)

Description
Send RTC complement data to controller board. If RTC switch is ON, the robot
moves to (AS each axis position command + complement data) position.
Comp[i] is correspond to (i+1)-th axis.
If complement data is incorrect, the return value is negative value.

Since AS command value is updated per 2 msec, RTC Complement data should be
sent per specified cycle time by KRNX_RTC and krnx_GetRtcBufferLength.

You have to allocate over 72 bytes (18 x sizeof(float)) for the buffer.
To use RTC function, RTC-implemented robot controller is required.
Please refer “10 RTC Function” for more detail.

See also
krnx_PrimeRtcCompData, krnx_SetRtcCompData, krnx_GetRtcCompData,
krnx_GetRtcCompLimit, krnx_GetRtcBufferLength, krnx_SetRtcInfo,
krnx_GetRtcInfo, A.1 RTC_SW, A.4 KRNX_RTC, A.5
_
KRNX_RTC_INFO (AS Language)

77
6 RT-API

! WARNING
If incorrect complement value is set, the robot may move to
out of working area or too quickly.
Please be careful not to set incorrect complement value.
Don’t move into the safely fence when robot is moving
automatically.

! CAUTION
Please debug the program carefully before you move robot.
You can use Robot Controller simulation function.

78
6 RT-API

6.18 Mask RTC Complement Data


int krnx_SetRtcCompMask(
int cont_no,
int robot_no,
int mask
)

Parameters
cont_no
Controller number
robot_no
Robot number
mask
Mask bit of RTC complement data

Returns
KRNX_NOERROR: OK
Negative value: Error code (refer to “12 Error Code”)

Description
Enable/disable setting RTC complement data.
Enabling/disabling is determined by parameter “mask” for mask bit per joint.
Bit i of “mask” is correspond to (i+1)-th axis and “0/1" means “Disabling/Enabling”.
If setting RTC complement data is disabled, the RTC complement data of disabled
joints does not affect the connected robot controller by krnx_SetRtcCompData or
krnx_PrimeRtcCompData.
To use RTC function, RTC-implemented Robot controller is required.
Please refer “10 RTC Function” for more detail.

See also
krnx_SendRtcCompData, krnx_SetRtcCompData, krnx_GetRtcCompData、
krnx_GetRtcCompLimit、krnx_GetRtcInfo、krnx_SetRtcInfo、RTC_SW、KRNX_RTC、
KRNX_RTC_INFO (AS-Language)

79
6 RT-API

 Memo

80
7 Matrix API

7 Matrix API

7.1 Joint to XYZOAT/Matrix


int krnx_JointToXyzoat(
int cont_no,
int robot_no,
const float *joint,
float *xyzoat
)

int krnx_JointToMatrix(
int cont_no,
int robot_no,
const float *joint,
float *matrix
)

Parameters
cont_no
Controller number
robot_no
Robot number
joint
Address of joint value.
Unit: mm for Linear / radian for Rotational
comp[i] is correspond to (i+1)-th axis.
xyzoat
Address of transformation values which describe the position and orientation
of robot flange transformed by parameter “joint”.
Refer to “9.1 Transformation Values (XYZOAT)” for the format.
matrix
Address of transformation matrix which describe the position and orientation
of robot flange transformed by parameter “joint”.
Refer to “9.2 Transformation Matrix” for the format.

Returns
KRNX_NOERROR: OK
Negative value: Error code (refer to “12 Error Code”)

Description
Calculate transformation values (XYZOAT) or matrix which describe the position and
orientation of robot flange on robot null base coordinate.
If base/tool transformation values are set, additional calculation of the values are
needed.
krnx_JointToXyzoat calculate transformation values (XYZOAT) from joint values.
Please allocate over 24 bytes (sizeof(float) * 6) area for xyzoat.
krnx_JointToMatrix calculate a transformation matrix from joint values.
Please allocate over 48 bytes (sizeof(float) * 3 * 4) area for matrix.

See also
krnx_XyzoatToJoint、krnx_MatrixToJoint

81
7 Matrix API

7.2 XYZOAT/Matrix to Joint


int krnx_XyzoatToJoint(
int cont_no,
int robot_no,
const float *xyzoat,
float *joint,
const float *old_joint
)

int krnx_MatrixToJoint(
int cont_no,
int robot_no,
const float *matrix,
float *joint,
const float *old_joint
)

Parameters
cont_no
Controller number
robot_no
Robot number
xyzoat
Address of transformation values which describe the position and orientation
of robot flange.
Refer to “9.1 Transformation Values (XYZOAT)” for the format.
matrix
Address of transformation matrix which describe the position and orientation
of robot flange.
Refer to “9.2 Transformation Matrix” for the format.
joint
Address of joint value transformed by parameter “xyzoat/matrix”.
Unit: mm for Linear / radian for Rotational
comp[i] is correspond to (i+1)-th axis.
old_joint
Address of reference joint values to calculate transformed joint values.

Returns
KRNX_NOERROR: OK
Negative value: Error code (refer to “12 Error Code”)

Description
Calculate joint values which describe the position and orientation of robot flange on
robot null base coordinate.
If base/tool transformation values are set, calculation of the values are previously
needed.
Several joint solutions exist in inverse kinematics. Parameter “old_joint” are used to
find an adequate solution.
If you set NULL to “old_joint”, KRNX calculate a solution based on specified robot
arm configuration. Refer to AS Language Manual “Setting Robot Configurations”.
krnx_XyzoatToJoint calculate joint values from transformation values (XYZOAT).
Please allocate over 72 bytes (sizeof(float) * 18) area for joint.
krnx_MatrixToJoint calculate joint values from transformation matrix. Please allocate
over 72 bytes (sizeof(float) * 18) area for joint.

82
7 Matrix API

See also
krnx_JointToXyzoat、krnx_JointToMatrix

83
7 Matrix API

7.3 Multiply XYZOAT/Matrix


int krnx_MultiplyXyzoat(
const float *xyzoat_a,
const float *xyzoat_b,
float *xyzoat_c
)

int krnx_MultiplyMatrix(
const float *matrix_a,
const float *matrix_b,
float *matrix_c
)

Parameters
xyzoat_a
Address of transformation values which multiply from left.
xyzoat_b
Address of transformation values which multiply from right.
xyzoat_c
Address of transformation values which is result of multiplying parameter
“xyzoat_a” and “xyzoat_b”.

matrix_a
Address of transformation matrix which multiply from left.
matrix_b
Address of transformation matrix which multiply from right.
matrix_c
Address of transformation matrix which is result of multiplying parameter
“matrix_a” and “matrix_b”.

Refer to “9.1 Transformation Values (XYZOAT)” for the format.


Refer to “9.2 Transformation Matrix” for the format.

Returns
KRNX_NOERROR: OK
Negative value: Error code (refer to “12 Error Code”)

Description
krnx_MultiplyXyzoat multiplies transformation values.
Please allocate over 24 bytes (sizeof(float) * 6) area for xyzoat.
krnx_MultiplyMatrix multiplies transformations matrixes.
Please allocate over 48 bytes (sizeof(float) * 3 * 4) area for matrix.
Please be careful to multiplying order because the results may be different.

See also

84
7 Matrix API

7.4 Inverse XYZOAT/Matrix


int krnx_InverseXyzoat(
const float *xyzoat_a,
float *xyzoat_b
)

int krnx_InverseMatrix(
const float *matrix_a,
float *matrix_b
)

Parameters
xyzoat_a
Address of transformation values for inverse calculation
xyzoat_b
Address of transformation values which is result of inverse calculation of
parameter “xyzoat_a”

matrix_a
Address of transformation matrix for inverse calculation
matrix_b
Address of transformation matrix which is result of inverse calculation of
parameter “matrix_a”

Refer to “9.1 Transformation Values (XYZOAT)” for the format.


Refer to “9.2 Transformation Matrix” for the format.

Returns
KRNX_NOERROR: OK
Negative value: Error code (refer to “12 Error Code”)

Description
krnx_InverseXyzoat calculates inverse of transformation values.
Please allocate over 24 bytes (sizeof(float) * 6) area for xyzoat.
The result of multiplying original xyzoat and its inverse is XYZOAT=(0,0,0,0,0,0).
krnx_InverseMatrix calculates inverse of transformation matrix.
Please allocate over 48 bytes (sizeof(float) * 3 * 4) area for matrix.
The result of multiplying original xyzoat and its inverse is as below.

1 0 0 0
0 1 0 0
0 0 1 0

See also

85
7 Matrix API

7.5 Transform XYZOAT/Matrix


int krnx_MatrixToXyzoat(
const float *matrix,
float *to_xyzoat
)

int krnx_XyzoatToMatrix(
const float *xyzoat,
float *to_matrix
)

Parameters
matrix
Address of original transformation matrix
to_xyzoat
Address of transformed transformation values

xyzoat
Address of original transformation values
to_matrix
Address of transformed transformation matrix

Refer to “9.1 Transformation Values (XYZOAT)” for the format.


Refer to “9.2 Transformation Matrix” for the format.

Returns
KRNX_NOERROR: OK
Negative value: Error code (refer to “12 Error Code”)

Description
krnx_MatrixToXyzoat transforms transformation matrix to transformation values.
Please allocate over 24 bytes (sizeof(float) * 6) area for parameter “to_xyzoat”.
krnx_XyzoatToMatrix transforms transformation values to transformation matrix.
Please allocate over 48 bytes (sizeof(float) * 3 * 4) area for parameter “to_matrix”.

See also

86
7 Matrix API

7.6 Calculate Frame Coordinates


int krnx_FrameXyzoat(
const float *xyz_a,
const float *xyz_b,
const float *xyz_c,
const float *xyz_d,
const float *xyz_p
)

int krnx_FrameMatrix(
const float *mat_a,
const float *mat_b,
const float *mat_c,
const float *mat_d,
const float *mat_p
)

Parameters
xyz_a, xyz_b, xyz_c, xyz_d
Address of original transformation values
xyz_p
Address of transformation values which describe the frame (relative)
coordinates with respect to the base coordinates

mat_a , mat_b, mat_c, mat_d


Address of original transformation matrix
mat_p
Address of transformation matrix which describes the frame (relative)
coordinates with respect to the base coordinates

Refer to “9.1 Transformation Values (XYZOAT)” for the format.


Refer to “9.2 Transformation Matrix” for the format.

Returns
KRNX_NOERROR: OK
Negative value: Error code (refer to “12 Error Code”)

Description
krnx_XyzoatToMatrix calculates the transformation values which describe the frame
(relative) coordinates with respect to the base coordinates.
Please allocate over 24 bytes (sizeof(float) * 6) area for parameter “xyz_p”.
krnx_FrameMatrix calculates the transformation matrix which describes the frame
(relative) coordinates with respect to the base coordinates.
Please allocate over 48 bytes (sizeof(float) * 3 * 4) area for parameter “mat_p”.

See also

87
7 Matrix API


Memo

88
8 Internal API

8 Internal API
8.1 Get KRNX Version
int krnx_GetKrnxVersion(
char *ver_text,
int ver_len,
)

Parameters
ver_text
Specify string buffer for KRNX Version.
ver_len
Specify string buffer length of “ver_text”
If it is shorter than string for KRNX Version, this API gets the string up to
“ver_len”

Returns
KRNX_NOERROR : OK
Negative value : Error code (refer to “12 Error Code”)

Description
Get KRNX Version string. The version differs in its environment and application.
Ex. With executing krnx_GetKrnxVersion( ver_text, 128 ), ver_text got ”KRNX
Linux-x86_64 DEV 2.0.0 2019/03/29 00:00”

89
8 Internal API


Memo

90
9 Dara Structure

9 Dara Structure
9.1 Transformation Values (XYZOAT)
AS software describes the position and orientation of robot arm by 6 values “X,Y,Z,O,A,T”.
“X, Y, Z” describe the position, and “O, A, T” describe the orientation of robot arm. “O, A, T”
means Euler angles whose rotation order is “Z-axis”, “Y-axis”, and “Z-axis”.
The unit of “X, Y, Z” is mm, and the unit of “O, A, T” is radian. AS software treated as
single-precision floats.
This transformation values are passed to API (krnx_GetBaseMatrix, krnx_GetToolMatrix,
etc.) by address pointer. Pointed data structure is as below.

Offset Data
0 Position・X-coordinate(mm)
4 Position・Y-coordinate(mm)
8 Position・Z-coordinate(mm)
12 Orientation・O(radian)
16 Orientation・A(radian)
20 Orientation・T(radian)

9.2 Transformation Matrix


Transformation matrix describes the position and orientation of robot arm by 3×4 matrix.
This matrix is same as matrix omitting 4th row of homogeneous transformation matrix.

nx ox ax px
ny oy ay py
nz oz az pz

Column vector n、o、a are unit vectors orthogonal to each other to describes the orientation
of robot arm. Column vector p describes the position of robot arm and its unit is mm.
This transformation matrix is passed to API (krnx_MatrixToJoint, krnx_MultiplyMatrix, etc.)
by address pointer. Pointed data structure is as below.

Offset Data Offset Data


0 nx 24 ax
4 ny 28 ay
8 nz 32 az
12 ox 36 px(mm)
16 oy 40 py(mm)
20 oz 44 pz(mm)

91
9 Dara Structure

9.3 TKrnxIoInfo
typedef struct
{
char io_do[KRNX_MAXSIGNAL/8];
char io_di[KRNX_MAXSIGNAL/8];
char internal[KRNX_MAXSIGNAL/8];
} TKrnxIoInfo;

TKrnxIoInfo includes robot IO information.

Members
io_do
External Output Signals
io_do[0] Bit0 corresponds to signal number 1.
io_do[1] Bit7 corresponds to signal number 16.

io_di
External Input Signals
io_di[0] Bit0 corresponds to signal number 1001
io_di[1] Bit7 corresponds to signal number 1016.

internal
Internal Signals
internal[0] Bit0 corresponds to signal number 2001.
internal[1] Bit7 corresponds to signal number 2016.

See also
krnx_GetCurIoInfo

92
9 Dara Structure

9.4 TKrnxIoInfoEx
typedef struct
{
char io_do[DO_MAX_SIGNAL/8];
char io_di[DI_MAX_SIGNAL/8];
char internal[INTERNAL_MAX_SIGNAL/8];
} TKrnxIoInfoEx;

TKrnxIoInfoEx includes robot IO information (Extended). This extended one includes more
size of signals (DO_MAX_SIGNAL, DI_MAX_SIGNAL, INTERNAL_MAX_SIGNAL)

Members
io_do
External Output Signals
io_do[0] Bit0 corresponds to signal number 1.
io_do[1] Bit7 corresponds to signal number 16.

io_di
External Input Signals
io_di[0] Bit0 corresponds to signal number 1001
io_di[1] Bit7 corresponds to signal number 1016.

internal
Internal Signals
internal[0] Bit0 corresponds to signal number 2001.
internal[1] Bit7 corresponds to signal number 2016.

See also
krnx_GetCurIoInfoEx

93
9 Dara Structure

94
9 Dara Structure

9.5 TKrnxPanelInfo
typedef struct
{
short error_lamp;
short motor_lamp;
short cyc_lamp;
short repeat_lamp;
short run_lamp;
short trigger_lamp;
short teach_lock_lamp;
short emergency;
} TKrnxPanelInfo;

TKrnxPanelInfo includes robot control panel information.

Members
error_lamp
Status of error lamp
0: Normal -1: Error
motor_lamp
Status of motor power lamp
0: Motor power off, -1: Motor power on
cyc_lamp
Status of cycle start lamp
0: Cycle start lamp off, -1: Cycle start lamp on
repeat_lamp
Status of repeat mode
0: Teach mode, 1: Repeat mode
run_lamp
Status of run
0: Hold, 1: Run
triggert_lamp
Status of trigger switch
0: Trigger switch off, -1: Trigger switch on
teach_lock_lamp
Status of teach lock
0: Teach lock off, 1: Teach lock on
emergency
Status of emergency button
0: Emergency stop off, 1: Emergency stop on

See also
krnx_GetPanelInfo

95
9 Dara Structure

9.6 TKrnxProgramInfo
typedef struct
{
TKrnxMonInfo mon[KRNX_MAX_ROBOT];
TKrnxStepperInfo robot[KRNX_MAX_ROBOT];
TKrnxStepperInfo pc[3];
} TKrnxProgramInfo;

TKrnxProgramInfo includes status of robot, robot program and PC program.


mon[0], robot[0] correspond to the first robot, and mon[1], robot[1] correspond to the second
robot.
pc[0],pc[1],pc[2] correspond to each PC program

Struct TKrnxMonInfo /TKrnxStepperInfo are defined as below.

typedef struct
{
short robot_status;
float monitor_speed;
float always_speed;
float accuracy;
} TKrnxMonInfo;

Members
robot_status
Robot status. (refer to the below table)
Multiple value can be set by “OR” operation.

Value Description
0x0001 Error
0x0002 Motor Power On
0x0004 Repeat Mode
0x0008 Working as Repeat Mode
0x0010 Check Mode

monitor_speed
Monitor speed (%)

always_speed
Program speed that was specified with ALWAYS (%)

typedef struct TKrnxStepperInfo


{
short status;
long exec_count, remain_count;
char program_name[20];
short priority;
short step_number;
char step_name[80];
} TKrnxStepperInfo;

96
9 Dara Structure

Members
status

Value Description
0x0001 WAIT
0x0002 EXECUTING
0x0004 STOP

exec_count
The number of program execution

remain_count
The number of remained program execution.
-1 means unlimited.
program_name
Executing program name.

priority
Priority of the program

step_number
Step number of executing program

step_name
Executing program instruction

See also
krnx_GetProgramInfo

97
9 Dara Structure

9.7 TKrnxCurMotionData
typedef struct
{
float ang[KRNX_MAXAXES]; /* Joint angle present value [rad or mm] */
float ang_ref[KRNX_MAXAXES]; /* Joint angle command value [rad or mm] */
float cur[KRNX_MAXAXES]; /* Joint current present value [A] */
int enc[KRNX_MAXAXES]; /* Joint encoder present value [bit] */
} TKrnxCurMotionData;

TKrnxCurMotionData includes motion data for robot arm.

See also
krnx_GetCurMotionData, krnx_SetRtCyclicDataKind, krnx_GetRtCyclicDataKind

98
9 Dara Structure

9.8 TKrnxCurMotionDataEx
typedef struct
{
float ang[KRNX_MAXAXES]; /* Joint angle present value [rad or mm] */
float ang_ref[KRNX_MAXAXES]; /* Joint angle command value [rad or mm] */
float cur[KRNX_MAXAXES]; /* Joint current present value [A] */
int enc[KRNX_MAXAXES]; /* Joint encoder present value [bit] */
float cur_ref[KRNX_MAXAXES]; /* Joint current command value [A] */
float cur_sat[KRNX_MAXAXES]; /* Joint current saturation present ratio */
float cur_sat_ref[KRNX_MAXAXES]; /* Joint current saturation command ratio */
int enc_ref[KRNX_MAXAXES]; /* Joint encoder command value [bit] */
float ang_vel[KRNX_MAXAXES]; /* Joint velocity present value [rad/s or mm/s] */
float ang_vel_ref[KRNX_MAXAXES]; /* Joint velocity command value [rad/s or
mm/s] */
float xyzoat[6]; /* Transformation position present value [rad or mm] */
float xyzoat_ref[6]; /* Transformation position command value [rad or mm] */
float xyzoat_vel; /* Transformation velocity present value [rad/s or mm/s] */
float xyzoat_vel_ref; /* Transformation velocity command value [rad/s or mm/s] */ }
TKrnxCurMotionDataEx;

TKrnxCurMotionDataEx includes motion data (Extended) for robot arm. This extended one
includes some additional data such as joint saturation ratio.

See also
krnx_GetCurMotionDataEx, krnx_SetRtCyclicDataKind, krnx_GetRtCyclicDataKind

99
9 Dara Structure

9.9 TKrnxRtcInfo
typedef struct
{
short cyc;
short buf;
short interpolation;
} TKrnxRtcInfo;

TKrnxRtcInfo includes KRNX RTC information.


This information is also handled by AS Language “KRNX_RTC”

Members
cyc
RTC cycle time [ms].
The range is 2 ~ 1000ms in 2ms.

buf
RTC buffering cycle number.
AS starts RTC control after receiving this size of RTC complement data.
By increasing this number, RTC control of KRNX application can be stable,
but delay of RTC command to the robot arm also increases.
The range is 1 ~ 1000.

interpolation
RTC interpolation method between “RTC cycle time” and “AS cycle time
(2ms)”.
For example, if RTC cycle time is 8 [ms], this interpolation method decides
values of RTC complement data [2ms, 4ms, 6ms].

The type of interpolation method is below.


0: No interpolation
1: Linear interpolation
2: Lagrange polynomial interpolation (n=2)
3: Lagrange polynomial interpolation (n=3)

See also
krnx_SetRtcInfo, krnx_GetRtcInfo

100
10 RTC Function

10 RTC Function
10.1 About
RTC (Real Time Correction) function can add RTC value to joint angles per 2 msec. User
program have to calculate RTC value par specified cycle. User program can use RTC Function
by using RT-API. RT-API can also get robot’s current joint angles par 2 msec.

Basically, PC user program fixes joint command values in AS robot program and control the
joints by RTC complement data. Overall system architecture including AS system and RT-API
is as below.

Robot Program Trajectory

Limit Info
Robot Arm
・Limit of joint displacement range
・Limit of joint velocity range

Joint command values Merged


Servo Control
(Fixed) Joint command values
AS

2 msec cycle

Robot Program State


2~1000 msec period Joint values

RTC Switch RTC Info


RTC Complement Data ・cycle time
Error State Buffer ・buffering cycle num
・interpolation method

2 msec cycle 2 msec cycle 2~1000 msec cycle 2 msec cycle

Get Robot Program State Buffer Control RTC Complement Control RTC Info Setting

krnx_GetRtcSwitch krnx_SetRtcCompData krnx_GetCurMotionData krnx_SetRtcInfo


KRNX API

krnx_GetCurErrorLamp krnx_GetRtcBufferLength krnx_SendRtcCompData krnx_GetRtcCompLimit krnx_GetRtcInfo

krnx_GetCurErrorInfo
krnx_OldCompClear krnx_PrimeRtcCompData krnx_GetRtcCompData

krnx_SetRtcCompMask
program
User

Motion Planning

Fig. 10.1 Overall system architecture: Bold line describes cyclic process and normal
line describes acyclic process .

10.2 Procedure
Procedure to utilize RTC function is as below. More detail is described in next sections.

1. Preparation of robot program for RTC function


2. Configuration of RTC information
3. Executing robot program and checking the state
4. Sending RTC complement data
5. Getting RTC control state
6. Cycle time synchronization with AS system
7. Limitation about RTC function

101
10 RTC Function

10.2.1. Preparation of Robot Program for RTC Function


RTC function needs to prepare a dedicated robot program. Please create a robot program
as below.

1) Single robot arm

.PROGRAM rb_rtc1()
RTC_SW 1: ON
1 RTC_CTL
GOTO 1
RTC_SW 1: OFF
.END

2) Dual robot arms (duAro series)


.PROGRAM rb_rtc1()
RTC_SW 1: ON
1 RTC_CTL
GOTO 1
RTC_SW 1: OFF
.END

.PROGRAM rb_rtc2()
RTC_SW 2: ON
1 RTC_CTL
GOTO 1
RTC_SW 2: OFF
.END

10.2.2. Preparation of Robot Program for RTC Function (If RTC_CTL is not
supported)
In 10.2.1, if using AS which is not supporting RTC_CTL, please refer to this section.
RTC function needs to prepare a dedicated robot program. Please create a robot program
as below. This robot program uses “#rtchome1”, “#rtchome2” for joint displacement values. So
please do not use them in other robot/PC programs.

1) Single robot arm

.PROGRAM rb_rtc1()
HERE #rtchome1
ACCURACY 0 ALWAYS
RTC_SW 1: ON
1 JMOVE #rtchome1
GOTO 1
RTC_SW 1: OFF
.END

2) Dual robot arms (duAro series)


.PROGRAM rb_rtc1()
HERE #rtchome1
FOR .i = 1 TO 8
.acc[.i] = 0
END
L3ACCURACY .acc[1] ALWAYS
RTC_SW 1: ON
1 JMOVE #rtchome1
GOTO 1
RTC_SW 1: OFF
.END
102
10 RTC Function

.PROGRAM rb_rtc2()
HERE #rtchome2
L3ACCURACY .acc[1] ALWAYS
FOR .i = 1 TO 8
.acc[.i] = 0
END
L3ACCURACY .acc[1] ALWAYS
RTC_SW 2: ON
1 JMOVE #rtchome2
GOTO 1
RTC_SW 2: OFF
.END

To configure AS for RTC function, it is also needed to change AS switch setting


“ZDBLREFFLT_MODSTABLE”. By default, this switch is set to “ON”, but please turns it to
“OFF” when using RTC function. AS Language “SWITCH” can change this switch setting.

10.2.3. Configuration of RTC Information


RTC function needs to configure RTC parameter (cycle time, buffering cycle number, and
interpolation method) for cyclic in advance. RTC cycle time is set for the sending cycle of user
program in msec. RTC buffering cycle number is set for the start number which AS start to use
received RTC complement values from user program in the buffer. RTC interpolation method
is set for AS to interpolate RTC complement data when the cycle time of user program is
different from AS (2msec).
To configure RTC parameter, please use KRNX API “krnx_SetRtcInfo” (refer to 5.8) or AS
Language “KRNX_RTC” (refer to A.4 KRNX_RTC). After the configuration, the parameter can
be checked by KRNX API “krnx_GetRtcInfo” (refer to 5.8) or AS Language “KRNX_RTC” (refer
to A.4 KRNX_RTC).

10.2.4. Execution of Robot Program and Handling States


RTC function needs to execute the prepared robot program before sending RTC
complement data from user program.
Before executing robot program, please execute KRNX API “krnx_OldCompClear()” (refer to
6.8) to clear old RTC complement data. After that, please execute the robot program which
created in 10.2.1 or 10.2.2 from the beginning step number 1). Also, please change the repeat
speed to 100%.
RTC function shows its control state by RTC switch ON/OFF. If the robot program is
executed, RTC switch is turned to ON, and the robot program continues the step “1 RTC_CTL”
or “1 JMOVE #rtchome1”/“1 JMOVE #rtchome2”. Then, AS is ready to control the robot arm in
RTC and user program can send RTC complement data. In that case, the display of teach
pendant is as below.

103
10 RTC Function

Fig. 10.2 The display of teach pendant when RTC switch is turned ON and the robot
program continues the step “1 JMOVE #rtchome1”

! DANGER

If you want to continue the robot program which was stopped due to
HOLD/ABORT/ERROR and etc., be sure to continue from step number 1
(HERE #rtchome1 or 2). Be sure not to continue from a step which the
robot program was stopped (ex. CONTINUE in AS Language). It you do,
the robot arm firstly moves to the position which previous robot program
set. This is dangerous.

104
10 RTC Function

10.2.5. Sending RTC Complement Data


If AS is ready to control the robot arm in RTC, user program can control the joint command
values of robot arm by sending RTC complement data to AS every specific cycle time (refer to
10.2.3).
KRNX provides 2 methods, krnx_SetRtcCompData (refer to 6.7) and
krnx_PrimeRtcCompData (refer to 6.16) / krnx_SendRtcCompData (refer to 6.17).
krnx_SetRtcCompData primes and sends RTC complement data to the specified robot arm of
controller at the same time. On the other hand, krnx_PrimeRtcCompData only primes RTC
complement data for the specified robot arm of controller, and krnx_SendRtcCompData only
sends RTC complement data of all robot arms to the specified controller. If you want to control
a single robot arm, you can use krnx_SetRtcCompData. If you want to control dual robot arms
such as duAro, you need to prime data by krnx_PrimeRtcCompData per robot arms and send
them to the robot controller by krnx_SendRtcCompData.

10.2.6. Getting RTC Control Data


In KRNX, you can get RTC control data by 2 msec cyclic communication with AS.
krnx_GetCurMotionData (refert to 6.3) can get joint displacement values of the robot arm.
krnx_GetRtcSwitch (refer to 6.12) can get RTC switch of the robot controller.
krnx_GetRtcBufferLength (refer to 6.13) can get RTC complement data buffer length of the
robot controller. Following 10.2.7 needs this length for synchronization with AS control cycle.
krnx_GetCurErrorLamp (refer to 6.14) can get error lamp of the robot controller.
krnx_GetCurErrorInfo (refer to 6.15) can get error code of the robot controller if an error occurs
in the robot controller.
KRNX can get these data by 2 msec cycle communication with AS, but KRNX doesn’t have
any buffer for storing them. Therefore these API can get the latest data from the robot
controller.

10.2.7. Synchronization with AS control cycle


In RTC function, User program needs to send RTC complement data in cycle time set by
10.2.3. User program sets the cycle time by 10.2.3 to synchronize to AS, but user program and
AS cannot be synchronized at the hardware clock level. So user program have to manually
synchronize to AS in software level.
To realize that, KRNX provides a synchronizing method that user program receives RTC
complement data buffer length of the robot controller and adjusts its cycle time by using this
length. Abstract of this method is as below.

105
10 RTC Function

Merge joint command values per 2msec


by interpolation method [I]

Merged
Joint command values
Joint command Servo Control Robot Arm
(Fixed)
values
2 msec cycle
[C] msec cycle

RTC Complement Data


Buffer
FIFO Buffer 1
AS

Buffer 2

Buffer ... RTC Info


・cycle time [C]
Buffer [B]
・buffering cycle num [B]
Buffer ... ・interpolation method [I]

Buffer n

2 msec cycle

[C] msec cycle

krnx_SetRtcCompData
KRNX API

krnx_GetRtcBufferLength krnx_SendRtcCompData

krnx_PrimeRtcCompData

Fig. 10.3 Buffering of RTC complement data

When AS received RTC complement data from user program, AS stores the received buffer
with that data. This received buffer are processed in FIFO manner. When the data length of
this received buffer exceeds the specified buffering cycle number (refer to 10.2.3), AS pops the
data in the specified cycle time and adds it to joint angles of the robot arm. This popping cycle
time is specified by 10.2.3, so this may be different from AS cycle time (2 msec). If so, AS
interpolates the RTC complement data by specified method (refer to 10.2.3) and adds the
interpolated value to joint angles of the robot arm par AS cycle time (2 msec).

After AS pops the RTC complement data, user program pushes and AS pops RTC
complement data in the specified cycle time. Because this cycle time of user program and AS
is almost same, the data length of AS received buffer keeps the nearly buffering cycle number
(refer to 10.2.3). User program can adjust its cycle time by using this data length as feedback
of cycle time difference between user program and AS.

Here are two examples of adjusting cycle time of user program. It assumes that the data
length of AS received buffer decreases from the specified buffering cycle number over time.
This means that the cycle time of user program is slightly slower than the cycle time of AS. In
this case, user program can adjust its cycle time by hastening and the data length of AS
received buffer can be back to the specified buffering cycle number. The opposite is the same.
It assumes that the data length of AS received buffer increases from the specified buffering
cycle number over time. This means that the cycle time of user program is slightly faster than
the cycle time of AS. In this case, user program can adjust its cycle time by latening and the
data length of AS received buffer can be back to the specified buffering cycle number.

KRNX provides AS Language “KRNX_RTC_INFO” as debugging the AS received buffer.


KRNX_RTC_INFO shows the current data length of AS received buffer, the times of when the
data length of AS received buffer becomes 0 par AS cycle time (2 msec), and the times of
when the sequence numbers of RTC complement data are not sequential in AS received
buffer par AS cycle time (2 msec). If the sequence numbers are not sequential, RTC

106
10 RTC Function

complement data user program sends may be lost in network between the user program and
the robot controller.

10.2.8. Sequence about RTC Function


An example of sequence about RTC function is as below.

107
10 RTC Function

sd RTC Function Sequense

User Prgoram KRNX Robot Controller

1: krnx_Open() 1.1: connect to the robot controller()

2: krnx_SetRtcInfo()
2.1: send RTC information data()

3: krnx_GetRtcCompLimit()

4: krnx_OldCompClear()

5: krnx_Execute()
5.1: execute the RTC robot program()

6: set RTC switch ON()

7: JMOVE()

loop : RTC Control

opt : Motion Control

8: krnx_PrimeRtcCompData()

9: krnx_SendRtcCompData()
9.1: send RTC complement data()

10: merge the data to joint command values()

11: move the robot arm()

opt : Feedback
12: send robot arm data()

13: krnx_GetCurMotionData()

14: krnx_GetRtcSwitch()

15: krnx_GetCurErrorLamp()

16: krnx_GetCurErrorInfo()

opt : Synchronization

17: krnx_GetRtcBufferLength()

18: Adjust the cycle time()

19: krnx_Hold()
19.1: hold the RTC robot program()

20: krnx_Close()
20.1: disconnect to the robot controller()

Fig. 10.4 Sequence of RTC function

108
10 RTC Function

10.2.9. Restrictions about RTC function


This section describes restrictions about RTC function.

10.29.1. Warranty of motion of robot arm by RTC function

In RTC function, AS doesn’t plan the motion of the robot arm and user program plan the
motion by sending RTC complement data. Thus the robot controller doesn’t warrant the motion
planning of the robot arm and its motion in RTC function.

10.29.2. Restriction about position, velocity, acceleration of joint angles in RTC function

In RTC function, krnx_SetRtcCompData (refer to 6.6) and krnx_PrimeRtcCompData (refer


to 6.16) limit position and velocity of the joint angles to the range which the robot arm can
move. This range of position and velocity is defined by each robot. The other hand,
krnx_SetRtcCompData and krnx_PrimeRtcCompData don’t limit acceleration of the joint
angles. Therefore user program can set any acceleration in motion planning, but the following
performance of the planned motion may be worse or the robot controller may make a deviation
error of robot joints. Also high accelerated planned motion may decrease the lifetime of the
robot arm.

10.29.3. Restriction about AS received buffer of RTC complement data

In RTC function, AS has received buffer of RTC complement data from user program (refer
to 10.2.7). Sure to adjust the data length of AS received buffer to the buffering cycle number. If
the data length of AS received buffer became 0, AS couldn’t pop a new RTC complement
value and the velocity of the robot arm would change to 0. If this change happened when the
velocity of the robot arm is high, the deceleration of the robot arm would be high and the robot
arm would momentarily stop its motion. The other hand, if the data length of AS received buffer
were over 1000 and user program continued to send the RTC complement data, AS couldn’t
store the received buffer with the data and it might be lost.

10.29.4. Restriction about combination with usual robot program

In RTC function, AS controls the robot arm by dedicated robot program. Therefore AS
cannot execute superposition of usual motion of robot program and RTC motion of this
dedicated robot program.

10.29.5. Restriction about network environment

In RTC function, user program have to control the robot arm in realtime. Be sure to make
stable network environment such as environment which user program and the robot controller
are connected via same LAN. Do not sure to make unstable network environment such as
environment which user program and the robot controller are connected via WAN.

109
10 RTC Function

10.29.6. Restriction about combination with other network functions

In RTC function, KRNX uses the network function of the robot controller. Please do not use
other network functions which use the Ethernet port of the robot controller (e.g. EtherNet/IP)

110
10 RTC Function


Memo

111
11 Thread-safety and Reentrancy of API

11 Thread-safety and Reentrancy of API


KRNX ‘s AUX-API, AS-API and RT-API guarantees thread-safety to use them in multi-thread
application.
On the other hand, these API does not guarantee reentrancy. For example, when using
AS-API in a main thread and signal handler, its function is not guaranteed.

112
12 Error Code

12 Error Code
Error Codes returned by APIs are defined in <krnx.h> .
The below table show the error code value and description.

Definition Description Trouble shooting

KRNX_NOERROR No error -

(0)

KRNX_E_BADARGS Bad arguments The specified arguments in API is invalid.

(-0x1000) Please check each argument is correct.

KRNX_E_INTERNAL Internal error Error occurs in KRNX internal shared memory.

(-0x1001) Please check that connected AS is supporting

KRNX version you use.

KRNX_E_NOTSUPPO The connected robot This API doesn’t support the robot arm of

RTED arm is not supported connected AS.

(-0x1002) Please use AS and its robot arm which KRNX

supports.

KRNX_E_TIMEOUT API execution is Timeout occurred because KRNX could not

(-0x1003) timeout receive the response from AS.

Please execute the API again after checking that

your network environment is normal.

KRNX_E_AUXNOTRE AUX-API is not ready AS is not ready to receive AUX-API.

ADY Please execute AUX-API again after waiting

(-0x1004) while.

KRNX_E_FOPENFAIL Failed to open the file KRNX failed to open the specified file.

(-0x1005) Please check the file name and its existence.

KRNX_E_FILENOTRE File is not ready This is not used now.

ADY

(-0x1006)

KRNX_E_MATRIX Matrix calculation error The specified matrix cannot be calculated by this

(-0x1007) API.

Please specify the calculable matrix.

KRNX_E_OUTOFRAN Out of range error in The result of inverse kinematics is out of range.

GE inverse kinematics Please specify transformation values or matrix


(-0x1008) which are in range of the robot arm motion.

113
12 Error Code

KRNX_E_CANNOTCA Cannot calculate KRNX cannot calculate inverse Jacobian matrix.

L inverse Jacobian Please specify calculable arguments.

(-0x1009) matrix

KRNX_E_COMPDATA RTC complement data The specified RTC complement data is invalid.

(-0x100a) error The detail of this error is stored in the API

argument “status”.

Please specify the valid RTC complement data

again after checking each status[i] (status[i] is

correspond to (i+1)-th axis).

KRNX_E_BADUSERID Bad user ID Please use valid user ID in KRNX.

(-0x100c)

KRNX_E_NULLRESP NULL response from KRNX received NULL data from AS.

(-0x100d) AS Please check that network environment is normal

and connected AS is supporting KRNX version

you use.

KRNX_E_LOSTPROM Lost prompt Timeout occurred in receiving a prompt from AS

PT (Receiving prompt in AUX-API.

(-0x100e) timeout) Please execute the API again checking that your

network environment is normal.

KRNX_E_BUFSND Sending buffer error KRNX sent the sending request by general

(-0x1010) communication, but KRNX received NULL data

from AS.
Please check that network environment is normal

and connected AS is supporting KRNX version

you use.

KRNX_E_BUFRCV Receiving buffer error KRNX sent the receiving request by general

(-0x1011) communication, but KRNX received NULL data

from AS.

Please check that network environment is normal

and connected AS is supporting KRNX version

you use.

KRNX_E_BUFTMO Buffer communication The API specified timeout occurred in general

(-0x1012) timeout communication.

If this timeout is not expected, please check it

again.

KRNX_E_ASERROR Error in AS side Some errors occurred in AS by executing

114
12 Error Code

(-0x1020) AUX-API.

Please reset errors in AS.

KRNX_E_NOROBOT Robot arm is not Robot arm is not specified in AS.

(-0x1021) selected in AS Please specify it in AS.

KRNX_E_SOCK Failed to make a KRNX failed to make an internal socket.

(-0x2000) socket Please check the permission of the KRNX

process which can handle sockets.

KRNX_E_NOHOST No hostname KRNX failed to resolve the hostname.

(-0x2001) Please specify available hostname or IP

address.

KRNX_E_IOCTLSOCK Failed to execute ioctl KRNX failed to execute ioctl about internal

(-0x2002) about socket blocking/non-blocking socket process.

Please check the permission of the KRNX

process which can handle blocking/non-blocking

socket process.

KRNX_E_SOCKWRIT Writing socket error KRNX failed to write the internal socket.

E Please check the permission of the KRNX

(-0x2003) process which can handle writing socket

process.

KRNX_E_SOCKREAD Reading socket error KRNX failed to read the internal socket.

(-0x2004) Please check the permission of the KRNX

process which can handle reading socket


process.

KRNX_E_NODATA Receiving no data by KRNX received no data by the internal socket.

(-0x2005) socket Please check that network environment with AS

is normal.

KRNX_E_INVALIDPO Invalid port number Specified port number in port_def.tbl and

RT port_ref.tbl is invalid.

(-0x2006) Please check that specified port number is

available.

KRNX_E_CONNECT Failed to connect to AS KRNX failed to connect to AS.

(-0x2007) Please execute krnx_Close(), krnx_Open()

again.

KRNX_E_CANTLOGIN Cannot login to AS in KRNX failed to login in AS in AUX-API.

(-0x2008) AUX-API Please check that AS is running. If AS is running,


please turn OFF & ON the control power of the

115
12 Error Code

robot controller.

KRNX_E_ALREADYO KRNX is already KRNX is already connected to AS.

PENED connected to AS If you want to connect again, please execute

(-0x2009) krnx_Open() after krnx_Close().

KRNX_E_UNEXPECT Received data format Received data format KRNX received from AS in

ED is unexpected in AUX-API is invalid.

(-0x2010) AUX-API Please check that connected AS is supporting

KRNX version you use.

KRNX_E_KINENOTRE Matrix-API doesn’t This Matrix-API doesn’t support the robot arm of

ADY support the connected connected AS.

(-0x2011) robot arm Please use AS and its robot arm which KRNX

supports.

KRNX_E_ASDELAYED Communication delay Request number between sending and receiving

(-0x2012) error in AS-API in AS-API is mismatched.

Please check that AS-API is not executed

simultaneously.

KRNX_E_BUFEMPTY Buffer is empty Data buffer for AS-API in AS is empty.

(-0x2013) Please delay the interval at executing AS-API for

AS to make data.

KRNX_E_BUFNO Buffer number is Buffer number specified by the API argument is

(-0x2014) invalid invalid.

Please specify buffer number under 7.

KRNX_E_BUFDATAN The number of sending The number of sending data specified by the API

UM data is invalid argument is invalid.

(-0x2015) Please change the number of sending data to

under 256 if data type is BYTE, and under 32 if

data type is others.

KRNX_E_RT_INTERN Internal error in RT-API This is not used now.

AL

(-0x2100)

KRNX_E_RT_CONNE Connection error in KRNX failed to connect the robot controller by

CT RT-API the specified controller number in RT-API.

(-0x2101) Please execute krnx_Open() after krnx_Close().

KRNX_E_RT_TIMEOU Receiving timeout in Timeout occurred because KRNX couldn’t

T RT-API receive the RT-API response from AS.


(-0x2102) Please execute the API again after checking that

116
12 Error Code

your network environment is normal.

KRNX_E_RT_NOTCO Not connected in Cyclic data communication with AS is

NNECT RT-API disconnected.

(-0x2103) Please execute krnx_Open() after krnx_Close().

KRNX_E_RT_SEND Sending data error in KRNX failed to send data to AS in RT-API

(-0x2104) RT-API Please execute krnx_Close() and krnx_Open()

after checking that your network environment is

normal.

KRNX_E_RT_CYCLIC RT Cyclic KRNX cannot communicate with AS by


(-0x2105) communication error selected RT cyclic data kind, or get selected
RT cyclic data from AS.
Please set RT cyclic data kind which AS
supports by krnx_SetRtCyclicDataKind()
and execute krnx_Open() after krnx_Close()
again.
KRNX_E_RT_SW_ON RTC switch ON error The processing is failed because RTC
(-0x2106) switch is ON.
Please turn off RTC switch, and execute the
API again.
KRNX_E_PCASALREA PC-AS is already PC-AS is already running.

DYRUNNING running Please stop all processes about PC-AS and

(-0x2200) KRNX, and execute them again.

KRNX_E_TOOMANYP Too many process The number of the startup process by

ROC exist runPcAs.ini exceeds upper limits.

(-0x2201) Please set the number to under 16.

KRNX_E_INVALIDFILE Invalid file name The specified file name is invalid.

NAME Please specify an existing file name existing.

(-0x2202)

KRNX_E_ILLCONTNO Invalid controller The specified controller number by runPcAs.ini is

(-0x2203) number invalid.

Please set the number to under 8 or 16.

KRNX_E_UNDEFF Undefined error This is not used now.

(-0xFFFF)

Moreover, there are another error codes that are returned by robot controller.
Refer to “AS Language Manual” for the error codes.

117
13 Related File

13 Related File

13.1 Header File


A header file “krnx.h” has the prototype definitions of KRNX APIs.
Please include this file when you use KRNX APIs.

13.2 Port Files


KRNX use several ports for network communication.
The ports are configured by 2 files (“port_def.tbl” and “port_ref.tbl”).
In “port_def.tbl”, the relationship between record number and port combinations are defined.
In “port_ref.tbl”, the relationship between controller number and port record number are defined.
For example, in the following figure, controller number 0 is related to port record 1.
So the port definition is as bellow.

port_def.tbl
port_ref.tbl aux=23:udp=[8101,8102]:telnet=23:kosmos=8000:pl
#0 :1 c=9000;0
#1 :2
#2 :3 aux=23:udp=[9101,9102]:eth=[9103,9104]:telnet=9
#3 :4 105:kosmos=9106:plc=9107:sync=9108;1
#4 :5 aux=9200:udp=[9201,9202]:eth=[9203,9204]:telnet
#5 :6 =9205:kosmos=9206:plc=9207:sync=9208;2
#6 :7
#7 :8
aux=9800:udp=[9801,9802]:eth=[9803,9804]:telnet
=9805:kosmos=9806:plc=9807:sync=9808:8

You need to change this setting based on the target (E-Controller or PC-AS)
AUX UDP ETH TELNET KOSMOS PLC
E-Controller 23 9101,9102 9103,9104 23 9106 9107
PC-AS 9100 9101,9102 9103,9104 23 9106 9107

118
13 Related File


Memo

119
14 Example

14 Example

This section describes KRNX usage example.


At first, you should call krnx_Open(). Then you can use any KRNX APIs until using krnx_Close()

PC

User Program KRNX Robot Controller

krnx_Open()

KRNX APIs is acceptable

krnx_GetCurMotionData()

Display motion information

krnx_GetCurIoInfo()

Display signal information

krnx_Close()

120
Appendix. A:AS Language

Appendix. A:AS Language

A.1 RTC_SW

Format
RTC_SW <robot_no>: <ON/OFF>

Description
Set RTC switch.
When RTC switch is ON, axis position command equals “AS position command +
complement data”.
It can be used as a program instruction.
As a monitor command, it can be used to only turn RTC switch OFF in teach mode.

Parameters
robot_no:
Robot number
If not specified, 1 is assumed.
ON/OFF:
“ON” or “OFF” of RTC switch
If not specified, “OFF” is assumed.

121
Appendix. A:AS Language

A.2 RTC_STATUS

Format
RTC_STATUS <robot_no>:

Description
Show RTC status.
It shows status of RTC switch and RTC error.

Parameters
robot_no:
Robot number
If not specified, 1 is assumed.

A.3 RTC_CTL

Format
RTC_CTL

Description
When RTC switch is ON, this instruction set the axis position command to “AS
position command + RTC complement data”.
It can be used as a program instruction.

Parameters
None

A.4 KRNX_RTC

Format
KRNX_RTC[qualifier] <cycle_time> <buffering_cycle_num> <interpolation_method>

Description
Change KRNX’s RTC setting.
This is same as API “krnx_SetRtcInfo”, “krnx_GetRtcInfo”

122
Appendix. A:AS Language

Parameters
qualifier:
If “/N” is specified, queries of parameters are omitted.
cycle_time:
Set RTC cycle time [ms].
The range is 2 ~ 1000ms in 2ms.
Default value is 4 [ms].
buffering_cycle_num:
Set RTC buffering cycle number.
AS starts RTC control after receiving this size of RTC complement data.
By increasing this number, RTC control of KRNX application can be stable, but
delay of RTC command to the robot arm also increases.
The range is 1 ~ 1000.
Default value is 1.
Interpolation_method:
Set RTC interpolation method between “RTC cycle time” and “AS cycle time
(2ms)”.
For example, if RTC cycle time is 8 [ms], this interpolation method decides
values of RTC complement data [2ms, 4ms, 6ms].

The type of interpolation method is below.


0: No interpolation
1: Linear interpolation
2: Lagrange polynomial interpolation (n=2)
3: Lagrange polynomial interpolation (n=3)
Default value is 1 (Linear interpolation).

A.5 KRNX_RTC_INFO

Format
KRNX_RTC_INFO

Description
Show information of KRNX’s RTC

Parameters

123
Appendix. A:AS Language

None.

Output format
BUFFER:
Show current buffering number of RTC complement data.
If a difference between this value and specified “buffering_cycle_num” of
KRNX_RTC, there would be a difference of cycle time between actual execution
of RTC API and specified “cycle_time” of KRNX_RTC. To solve this, please
adjust the cycle time of RTC API by using krnx_GetRtcBufferLength.

BUFFER_0:
Show the number of times of when buffering number of RTC complement data is
“0”. This counting starts when RTC switch turns ON and RTC buffering number
reaches specified “buffering_cycle_num” of KRNX_RTC.
If this number is not equal to “0”, cycle time of RTC API would be slower than
specified “cycle_time” of KRNX_RTC.
This number is reset to “0” when RTC switch turns OFF.

SEQ_ERR:
Show the number of times of when a difference of consecutive sequence
number is not equal to “1”. This counting starts when RTC switch turns ON.
If this number is not equal to “0”, the reason would be either wrong input of
sequence number of RTC API, or packet loss of sending RTC complement data.
This number is reset to “0” when RTC switch turns OFF.

124
Appendix. B:API List

Appendix. B:API List

Common API
Name Description Page
krnx_Close Disconnect from Robot Controller 20

krnx_Open Connect to Robot Controller 19

AUX-API
Name Description Page
krnx_Abort Abort Robot Program 21

krnx_AuxApiTimeoutPeriod Set AUX-API Timeout Period 46

krnx_Continue Continue Robot Program 23

krnx_Delete Delete Data(Monitor Command) 39

krnx_Do Execute Program Instruction 42

krnx_Ereset Error Reset 41

krnx_Execute Execute Robot Program 24

krnx_ExecMon Execute Monitor 45

krnx_GetSignal Get Input / Output signal 36

krnx_Hold Hold Robot Program 22

krnx_Kill Kill Robot Program 31

krnx_List List program and data 40

krnx_PcAbort Abort PC Program 27

krnx_PcContinue Continue PC Program 29

krnx_PcEnd Finish PC program 28

krnx_PcExecute Execute PC Program 30

krnx_PcKill Kill PC Program 31

krnx_Prime Prime Program 43

krnx_RecOneStep Record Program 44

krnx_Reset Reset External Output Signals(Monitor Command) 38

krnx_SetMonSpeed Set Monitor Speed 26

krnx_SetSignal Set Output Signal 37

125
Appendix. B:API List

AS-API
Name Description Page
krnx_AsApiTimeoutPeriod Set AS-API Timeout Period 56

krnx_ConvertErrorCode Convert Error Code 54

krnx_GetCurIoInfo Get IO Information 50

krnx_GetErrorInfo Get Error Code 53

krnx_GetLimitM Get Axis Working Limit 49

krnx_GetLimitP Get Axis Working Limit 49

krnx_GetPanelInfo Get Control Panel Information 52

krnx_GetRtcInfo Get/Set RTC Information 55

krnx_GetRobotName Get Robot Name 48

krnx_GetProgramInfo Get Program Status Information 51

krnx_SetRtcInfo Get/Set RTC Information 55

RT-API
Name Description Page
krnx_GetCurMotionData Get Current Motion Data 61

krnx_GetCurErrorInfo Get Current Error Code Asynchronously 74

krnx_GetCurErrorLamp Get Current Error Lamp Asynchronously 73

krnx_GetRtcBufferLength Get RTC Complement Data Buffer Length 72

krnx_GetRtcCompData Get RTC Complement Data 66

krnx_GetRtcCompLimit Get RTC Complement Data Limit 68

krnx_GetRtcErrorFlag Get RTC Error Flag 70

krnx_GetRtcSwitch Get RTC Switch 71

krnx_OldCompClear Clear Old RTC Complement Data 67

krnx_PrimeRtcCompData Prime RTC Complement Data 75

krnx_SendRtcCompData Send RTC Complement Data 77

krnx_SetRtcCompData Set RTC Complement Data 64

krnx_SetRtcCompMask Mask RTC Complement Data 79

krnx_SetRtcErrorFlag Set RTC Error Flag 69

126
Appendix. B:API List

Matrix-API
Name Description Page
krnx_FrameMatrix Calculate Frame Coordinates 87

krnx_FrameXyzoat Calculate Frame Coordinates 87

krnx_InverseMatrix Inverse XYZOAT/Matrix 85

krnx_InverseXyzoat Inverse XYZOAT/Matrix 85

krnx_JointToMatrix Joint to XYZOAT/Matrix 81

krnx_JointToXyzoat Joint to XYZOAT/Matrix 81

krnx_MatrixToJoint XYZOAT/Matrix to Joint 82

krnx_MatrixToXyzoat Transform XYZOAT/Matrix 86

krnx_MultiplyMatrix Multiply XYZOAT/Matrix 84

krnx_MultiplyXyzoat Multiply XYZOAT/Matrix 84

krnx_XyzoatToJoint XYZOAT/Matrix to Joint 82

krnx_XyzoatToMartix Transform XYZOAT/Matrix 86

Internal-API
Name Description Page
krnx_GetKrnxVersion Get KRNX Version 89

127

You might also like