krc4 save baseframe in a file with date and hour

  • Unfortunately, KRL does not provide a means of writing data to external files.


    One possible workaround would be to write the data to a KRL .DAT file, and set up a script in the Windows side of the controller that would periodically copy the data from said file. A bit kludgey, but would probably work.

  • It is possible to write data to external files, for example a log file. Quick example below!


    The only problem i found so far is that i can't skip to the next row in the file.


    ;====================================================
    ; Write data to a CHAR array
    ;====================================================
    OFFSET=0
    SWRITE (sDate[], STAT, OFFSET, "%d%s%d%s%d%s", $DATE.DAY, ".", $DATE.MONTH, ".", $DATE.YEAR, " ")
    IF (STAT.RET1==#CMD_ABORT) THEN
    CheckError$FCT_CALL(STAT.MSG_NO,2)
    ENDIF
    OFFSET=0
    SWRITE (sTime[], STAT, OFFSET, "%d%s%d%s%d%s%d", $DATE.HOUR, ":", $DATE.MIN, ":", $DATE.SEC, ".", $DATE.CSEC)
    IF (STAT.RET1==#CMD_ABORT) THEN
    CheckError$FCT_CALL(STAT.MSG_NO,2)
    ENDIF


    ;====================================================
    ; Open as text file for write access. In this mode,
    ; the contents of the file are not deleted on opening
    ; instead, the written values are added at the end of
    ; the file. If the file does not exist, it is created
    ; under C:\KRC\ROBOTER\UserFiles
    ;====================================================
    CWRITE($FCT_CALL, STAT, MODE, "krl_fopen", "Date.log", "a", HANDLE)
    IF (STAT.RET1==#CMD_ABORT) THEN
    CheckError$FCT_CALL(STAT.MSG_NO,3)
    ELSE
    ;==================================================
    ; Write a character string to the file
    ;==================================================
    CWRITE($FCT_CALL, STAT, MODE, "krl_fputs", HANDLE, sDate[])
    CWRITE($FCT_CALL, STAT, MODE, "krl_fputs", HANDLE, sTime[])
    IF (STAT.RET1==#CMD_ABORT) THEN
    CheckError$FCT_CALL(STAT.MSG_NO,4)
    ENDIF
    ;==================================================
    ; Close the file
    ;==================================================
    CWRITE($FCT_CALL, STAT, MODE, "krl_fclose", HANDLE)
    IF (STAT.RET1==#CMD_ABORT) THEN
    CheckError$FCT_CALL(STAT.MSG_NO,5)
    ELSE
    HANDLE=0
    ENDIF
    ENDIF

    Edited once, last by Verga ().

  • :icon_eek: Is this documented anywhere? I've been wishing for a way to write to external files on KRCs for years, but never found one. Is this new for KSS 8.x, or has it been around longer?


    I cannot WAIT to try this out. :toothy9:

  • This is indeed an exciting new development! It's not often something this unexpected crops up.


    Looking through the KRC.o file in my favourite editor, it appears that there are also functions for other things including reading from files... krl_fscanf, krl_fgets, krl_fgetc.


    Back in the office tomorrow.... let's see what we can do

  • After a bit of hunting, it turns out that it is documented!


    The manual for CREAD/CWRITE has a whole section on it! I just wish my German was a little better...


    Damn it! Cross post! Ignore me

    Edited once, last by bert ().

  • Never mind my question,


    CWRITE($FCT_CALL, State, Mode, "krl_fwriteln", FileHandle, " ")


    Solves the problem with a new line!

  • OK, now I've got a question after reading the manual...


    On page 13 (Section 5) there is mention of a driver file tcpdrv.o, which I assume would allow us to use TCP/IP comms. I don't have this file on my controller and I wonder if anybody else does have it. If so, does it come, for instance, with KRL-XML or something similar?

  • You won't find the tcpdrv.o in KSS V8.2.23 or V8.3.6. It's also not a part of KUKA.EthernetKRL. To me it seems like the tcpdrv.o is only an example name of an external module and not an actual module delivered by KUKA.


  • best thread of the week. I was wondering where the new version of this manual was, as obviously a lot has changed...


    The file is on the official documentation DVD since at least 2012.
    The problem is that nearly nobody has or takes the time to read all the manuals and compare them to the old ones.

Advertising from our partners