首页 > KUKA示教器维修 > KUKA库卡机器人编程如何log数据(日志)

KUKA库卡机器人编程如何log数据(日志)

日期:2020-01-03   人气:  来源:互联网
简介:下面讲下如何将一些数据log下来,可以基于机器人本身的CWRITE指令来实现此功能: (1).Log文件自动以时间命名; (2).每隔10秒log一次; (3).每条信息独立一行; 具体实现过程如下: 1.在SmartPad上创建一个xxx.src,如下: DEF Write_File( ) DECL INT handle……

下面讲下如何将一些数据log下来,可以基于机器人本身的CWRITE指令来实现此功能:
 
(1).Log文件自动以时间命名;
 
(2).每隔10秒log一次;
 
(3).每条信息独立一行;
 
具体实现过程如下:
 
1.在SmartPad上创建一个xxx.src,如下:

	
 
DEF Write_File( )
DECL INT handle
DECL STATE_T STAT
DECL MODUS_T MODE
DECL CHAR AxisPos[256]
DECL CHAR ProState[256]
DECL CHAR ErrorID[256]
DECL CHAR FILENAME[256]
DECL INT  Offset
DECL BOOL bok
DECL char LF 
MODE = #SYNC
HANDLE = 0
OFFSET=0
bOK=STRCLEAR(AXISPos[])
BOK=STRCLEAR(Prostate[])
BOK=STRCLEAR(ERRORID[])
LF = 10
 
SWRITE(AxisPos[],STAT,Offset,"%S:%F|%F|%F|%F|%F|%F","Current Axis Position",$AXIS_ACT.A1,$AXIS_ACT.A2,$AXIS_ACT.A3,$AXIS_ACT.A4,$AXIS_ACT.A5,$AXIS_ACT.A6)
Offset=0
SWITCH $PRO_STATE1
  CASE #P_ACTIVE
    ProState[]="Program State: RobotProgram is selected and running!"
    CASE #P_FREE
    ProState[]="Program State: RobotProgram is deselected!"
    CASE #P_END
    ProState[]="Program State: RobotProgram is selected and the end of program has been reached!"
    CASE #P_RESET
    ProState[]="Program State: RobotProgram is selected and has been stopped and reset!"
    CASE #P_STOP
    ProState[]="Program State: RobotProgram is selected and has been stopped!"
ENDSWITCH
SWRITE(ERRORID[],STAT,offset,"ErrorINFO: ERRORID-%D|LINENR-%D|PROG-%S|SUB-%S",$ERR.NUMBER,$ERR.LINE_NR,$ERR.MODULE[],$ERR.UP_NAME[])
offset=0
IF STRCLEAR(FILENAME[])THEN
SWRITE(FILENAME[],STAT,offset,"%D%D%D-%Dh%Dm%Ds.txt",($DATE.year),($DATE.MONTH),($DATE.DAY),($DATE.HOUR),($DATE.MIN),($DATE.SEC))
ENDIF
WAIT FOR TIMER_LIMIT(10)     
CWRITE($FCT_CALL,STAT,MODE, "krl_fopen",FILENAME[], "w", HANDLE)
CWRITE($FCT_CALL, STAT, MODE, "krl_fputs", HANDLE, AxisPos[])
CWRITE($FCT_CALL, STAT, MODE, "krl_fputc", HANDLE, LF)        
CWRITE($FCT_CALL, STAT, MODE, "krl_fputs", HANDLE, PROSTATE[])
CWRITE($FCT_CALL, STAT, MODE, "krl_fputc", HANDLE, LF)        
CWRITE($FCT_CALL, STAT, MODE, "krl_fputs", HANDLE, ErrorID[])
CWRITE($FCT_CALL, STAT, MODE, "krl_fclose", HANDLE)
END
2.在SPS里调用该程序:
3.确保SPS运行:
4.在机器人控制器路径下C:\KRC\Roboter\Userfiles看生成的log文件:
5.查看具体log文件:
免责声明:本网部分文章和信息来源于互联网,本网转载出于传递更多信息和学习之目的。如转载稿涉及版权等问题,请立即联系网站所有人,我们会予以更改或删除相关文章,保证您的权利。