1. Home
    1. Dashboard
    2. Search
  2. Forum
    1. Unresolved Threads
    2. Members
      1. Recent Activities
      2. Users Online
      3. Team Members
      4. Search Members
      5. Trophys
  3. Articles
  4. Blog
  5. Videos
  6. Jobs
  7. Shop
    1. Orders
  • Login or register
  • Search
This Thread
  • Everywhere
  • This Thread
  • This Forum
  • Articles
  • Pages
  • Forum
  • Blog Articles
  • Products
  • More Options
  1. Robotforum - Support and discussion community for industrial robots and cobots
  2. Forum
  3. Industrial Robot Support and Discussion Center
  4. Fanuc Robot Forum
Your browser does not support videos RoboDK Software for simulation and programming
Visit our Mainsponsor
IRBCAM
Robotics Channel
Robotics Training
Advertise in robotics
Sponsored Ads

FANUC PROJECT: Data recording with background Karel program

  • Axillus
  • August 12, 2019 at 5:56 PM
  • Thread is Unresolved
  • Axillus
    Trophies
    3
    Posts
    2
    • August 12, 2019 at 5:56 PM
    • #1

    Hello,

    I'm working on a Karel program inspired by the "Data Recorder" function available on collaborative robots made by KUKA (LBR iiwa):

    Look the Kuka Data Recorder documentation page 423

    In fact, it seems that there is anything comparable on FANUC robots, particularly on there collaborative robots where it will be very interesting to have a data (log) recording for risk assessment (for example).

    I'm working on CR-35iA (with R-30iB controller), a 6-axis collaborative robot made by FANUC.

    I looked at "Data Monitoring" option mainly destinated to arc welding robots, which can only record 5 items at the same time... and this is not very satisfasting (for example you can't record the joint positions of the 6 axis of CR-35iA because it's limited to 5 items).

    So, I'm discovering the Karel language and its possibilities, and according on what I've read on this forum and other documentations, it's seem possible to do what I want on a FANUC robot in Karel.
    Here is links I've look: Link 1, Link 2, Link 3, Link 4, Link 5, Link 6, Link 7, Link 8

    What I'm trying to do:

    • Identify data to record as same data that a collaborative Kuka can record (and more if possible):
      Variables I think I've identified are bolded:
      Kuka's Data recorder like:
      • Internal Joint Torque (6 axis) :
        $MOR_GRP[1].$CUR_TORQUE - ARRAY[9] OF SHORT
      • External Joint Torque (6 axis) :
        $MOR_GRP[1].$CUR_DIS_TRQ - ARRAY[9] OF SHORT
      • Cartesian Force (force sensor on CR-35iA) :
        ($DCSS_CLLB[1].$EXT_RFORCE) or ($DCSS_CLLB[1].$EXT_FORCE - ARRAY[6]) ?
      • Commanded Joint Position (6 axis) :
        ?
      • Current Joint Position (6 axis) :
        $MOR_GRP[1].$CURRENT_ANG - ARRAY[9] OF REAL
      • Commanded Cartesian Position (XYZWPR at TCP) :
        (maybe $PATHAJ_3POS[1]. $X, $Y and $Z) ?
      • Current Cartesian Position (XYZWPR at TCP) :
        ($MOR_GRP[1].$CUR_TCP with 2 = X, 3 = Y, 4 = Z, 5 = W, 6 = P, 7 = R) or ($MOR_GRP[1].$CURRENT_POS) ?

      More if possible, otherwise it's easy to calculate them:

      • Commanded Cartesian Velocity (at TCP) :
        ?
      • Current Cartesian Velocity (at TCP) :
        (maybe $SCR_GRP[1].$MCH_SPD) ?
      • Commanded Cartesian Acceleration (at TCP) :
        ?
      • Current Cartesian Acceleration (at TCP) :
        ?
      • Commanded Joint Velocity (6 axis) :
        ?
      • Current Joint Velocity (6 axis) :
        ?
      • Commanded Joint Acceleration (6 axis) :
        ?
      • Current Joint Acceleration (6 axis) :
        $MOR_GRP[1].$CUR_AXS_ACC - ARRAY[9] OF INTEGER
    • Make a Karel program we can launch from a TP program like that:
    Code
    !Start recording data each 100 ms, during 20000 ms in a usb file
    CALL DATARECORDER(100, 20000, 'UD1:logfile.dt')
    J P[1] 100% FINE
    J P[1] 100% FINE
    • Here is my Karel program skeleton:
    Code
    PROGRAM datarecorder
    
    %COMMENT = 'LOG DATA RECORD'
    %SYSTEM
    %NOLOCKGROUP
    %NOABORT=ERROR+COMMAND+TPENABLE
    %NOPAUSE=ERROR+COMMAND+TPENABLE
    %NOPAUSESHFT
    
    VAR
        logFile    : FILE
        filename   : STRING[16]
        
        duration   : INTEGER -- recording duration in milliseconds
        clock_var  : INTEGER -- clock count in milliseconds
        period     : INTEGER -- recording period in milliseconds (8 ms to 127 ms)
    
        timeInt    : INTEGER -- actual time
        timeStr    : STRING[18] -- formated
        
        IntTQa1    : REAL -- internal joint torque on axis 1
        IntTQa1Str : STRING[4] -- formated
     
        entry      : INTEGER
        status     : INTEGER
    
        -- tests
        test       : INTEGER
        clocky     : INTEGER
    
    -----------------------------------------------------------------------------------
    -- routine to set period
    ROUTINE SET_PERIOD(active : BOOLEAN)
    BEGIN
        IF active:
        --- set sample period
            SET_VAR(entry, '*SYSTEM*', '$SCR.$COND_TIME', period, status)
    END SET_PERIOD
    -----------------------------------------------------------------------------------
    
    -----------------------------------------------------------------------------------
    -- routine to get internal torque measured on axis 1
    ROUTINE GET_INT_TQ(active : BOOLEAN)
    BEGIN
        IF active:
            GET_VAR(entry, '*SYSTEM*', '$MOR_GRP[1].$CUR_TORQUE[1]', IntTQa1, status)
    END GET_INT_TQ
    -----------------------------------------------------------------------------------
    
    -----------------------------------------------------------------------------------
    -- main routine
    BEGIN -- execute the program
        clock_var = 0
        -- begin the clock time count
        CONNECT TIMER TO clock_var
        
        period = 150 -- ms
        -- set sampling period
        SET_PERIOD(TRUE)
        
        duration = 10000 -- ms
        
        filename = 'MC:'+'TEST'+'.dt'
        
        entry = 0
        status = 0
        
        -- tests
        test = 0
        clocky = 0
        
        -- get actual time and convert it into string
        GET_TIME(timeInt)
        CNV_TIME_STR(timeInt, timeStr)
        
        -- open the log file
        OPEN FILE logFile ('AP', filename)
        -- write actual time and make a carriage return
        WRITE logFile (timeStr, CR)
    
         -- start recording
        WHILE  (duration > clock_var) DO
    
            clocky = clock_var
    
            test = clocky+period
            
            WAIT FOR (clock_var>test) -- if removed, program bug
    
            GET_INT_TQ(TRUE) -- call internal torque routine
            CNV_REAL_STR(IntTQa1, 2, 2, IntTQa1Str)
    
            WRITE logFile(clock_var)
            --WRITE logFile(';')
            --WRITE logFile(IntTQa1Str, CR)
    
        ENDWHILE
    
        -- stop recording, close log file
        CLOSE FILE logFile
    
    -- end of program
    END datarecorder
    Display More

    As you can see, I want to make a log file (like the .csv generated by a Kuka) with the different data recorded at each period count.

    I have succeeded to write in a file but, my clock_var variable doesn't increase (stays to 0) if I remove the WAIT FOR statement (and the program infinite runs).

    Furthermore, I feel that the teach iPendant hangs until the Karel program is finished before continuing the TP program (I've only tested it on Roboguide).

    I want to run the KAREL program in background of the TP program but I don't know how to do this.

    Does anyone have ideas to help me?

    Thanks in advance :smiling_face:

    Edited 2 times, last by Axillus (August 13, 2019 at 10:32 AM).

  • massula August 12, 2019 at 5:59 PM

    Approved the thread.
  • Werner Hampel August 12, 2019 at 6:40 PM

    Approved the thread.
  • dha
    Reactions Received
    28
    Trophies
    6
    Posts
    397
    • August 13, 2019 at 7:52 AM
    • #2

    Try putting DELAY 50 instruction at the end of while loop.

    Instead of CALL DATARECORDER, use RUN command. You will have to set arguments before you use RUN, maybe in Register and String Register.

  • Isarobot
    Trophies
    3
    Posts
    6
    • August 15, 2019 at 7:09 AM
    • #3

    1 Make the interval to run this and delay it within the tp program that makes the call? you can also multitask this to run in Parallel with your other functioning programs.2 I'm not sure about being able to run this from a background task, but you may be able to because it contains no motion.

  • andreic
    Reactions Received
    24
    Trophies
    4
    Posts
    282
    • August 15, 2019 at 8:42 AM
    • #4

    Hello Axillus and welcome to the forum,

    There are some things to consider:

    1. I would replace WAIT FOR statement with a DELAY statement.
    2. If you want to run in parallel with other programs, as dha stated, you would start it with RUN.
    3. If you start it with RUN and you want to run it continously you will need another WHILE or REPEAT loop above WHILE (duration > clock_var) DO

    This loop will provide means on controlling the running/abort status of the program. Just use some virtual outputs (DO's mapped to rack 0, slot 0).
    If you want the program just to finish after logging the data at 20 sec interval you don't need this extra loop.
    In other case, run the program non-stop the program would look like :

    Code
      REPEAT 
      - start recording
        WHILE  (duration > clock_var) DO
        ......
        ENDWHILE
        clock_var=0
        DELAY(50)
      UNTIL DOUT[..]=OFF 

    And you make DOUT[...]=ON in the beginning of the program. If you want to cancel the program you just make DOUT[..]=OFF.

    And also take out SET_PERIOD routine.

    I've made some modifications to your code:

    Code
    PROGRAM datarecorder
    %COMMENT = 'LOG DATA RECORD'
    %SYSTEM
    %NOLOCKGROUP
    %NOABORT=ERROR+COMMAND+TPENABLE
    %NOPAUSE=ERROR+COMMAND+TPENABLE
    %NOPAUSESHFT
    
    VAR
        logFile    : FILE
        filename   : STRING[16]
        
        duration   : INTEGER -- recording duration in milliseconds
        clock_var  : INTEGER -- clock count in milliseconds
        period     : INTEGER -- recording period in milliseconds (8 ms to 127 ms)
        timeInt    : INTEGER -- actual time
        timeStr    : STRING[18] -- formated
        
        IntTQa1    : REAL -- internal joint torque on axis 1
        IntTQa1Str : STRING[4] -- formated
     
        entry      : INTEGER
        status     : INTEGER
        -- tests
        test       : INTEGER
        clocky     : INTEGER
    -----------------------------------------------------------------------------------
    -- routine to get internal torque measured on axis 1
    ROUTINE GET_INT_TQ(active : BOOLEAN)
    BEGIN
        IF active=TRUE THEN
            GET_VAR(entry, '*SYSTEM*', '$MOR_GRP[1].$CUR_TORQUE[1]', IntTQa1, status)
        ENDIF
    END GET_INT_TQ
    -----------------------------------------------------------------------------------
    -----------------------------------------------------------------------------------
    -- main routine
    BEGIN -- execute the program
        clock_var = 0
        -- begin the clock time count
        CONNECT TIMER TO clock_var
        
        period = 150 -- ms
    
        duration = 10000 -- ms
        
        filename = 'UT1:'+'TEST'+'.dt'
        
        entry = 0
        status = 0
        
        -- tests
        test = 0
        clocky = 0
        
        -- get actual time and convert it into string
        GET_TIME(timeInt)
        CNV_TIME_STR(timeInt, timeStr)
        
        -- open the log file
        OPEN FILE logFile ('AP', filename)
        -- write actual time and make a carriage return
        WRITE logFile (timeStr, CR)
         -- start recording
        WHILE  (duration > clock_var) DO
            clocky = clock_var
            test = clocky+period
            GET_INT_TQ(TRUE) -- call internal torque routine
            CNV_REAL_STR(IntTQa1, 2, 2, IntTQa1Str)
            WRITE logFile(clock_var)
            --WRITE logFile(';')
            --WRITE logFile(IntTQa1Str, CR)
              DELAY(period)
        ENDWHILE
        -- stop recording, close log file
        CLOSE FILE logFile
    -- end of program
    END datarecorder
    Display More
  • Axillus
    Trophies
    3
    Posts
    2
    • August 16, 2019 at 1:29 PM
    • #5

    Hello,

    Thanks you very much guys!

    RUN command works very well! (but is it possible to catch entries with RUN?)

    The DELAY period command instead of WAIT FOR also seems to work well!

    The goal of the program is that it must record a maximum of data for x seconds even if a security error is detected.

    Next challenge is to find which variable corresponds to which parameter (for example, I have associated CUR_TORQUE[n] to a REAL variable but the value is still 0 in the log file... same thing for CUR_DIS_TRQ[n]. The only variables I record well are CURRENT_ANG[n]).

  • lihui341124
    Trophies
    3
    Posts
    13
    • September 4, 2019 at 6:18 AM
    • #6

    Hello there!

    Can tell me how to apply in TP program

  • bugme
    Trophies
    3
    Posts
    2
    • September 6, 2019 at 10:11 PM
    • #7

    Hi, i'm after the same data recorder and i'm having some issues to figure it out about sys vars like


    $MOR_GRP[1].$CUR_TORQUE - ARRAY[9] OF SHORT$MOR_GRP[1].$CUR_DIS_TRQ - ARRAY[9] OF SHORT

    because i can't understand what they really represent or the way to scale it into REAL numbers who actually represent disturbance (A) and Torque (percent or Nm, idk).

    Anyone can pointme in the right direction? I've googled a lot and reviewed all sys var which are available. Readed all manualls about ZDT too and i don't know where are the variables like High Water Mark Torque, odometer, etc.

    Thanks in advance, i've been programming fanuc last three years and i think i can actually help people of the forum about some other stuff, so i will be around here.

    Greetings.

    Edited once, last by bugme (September 9, 2019 at 2:17 PM).

  • othonmt
    Trophies
    2
    Posts
    3
    • December 7, 2020 at 8:02 PM
    • #8

    Hi bugme ,

    Did you find what the $MOR_GRP variables represent or the way to scale it int real numbers who actually represent disturbance(A) and Torque .??

    When I compare the data in this variable to the axis screen it shows different values.

  • RookieWithRobots
    Reactions Received
    3
    Trophies
    4
    Posts
    76
    • December 8, 2020 at 7:04 AM
    • #9

    Hi there,

    Have you check that this variables is set to 1?

    $MISC_MSTR.$hpd_enb

    Minimum: 0

    Default: 0

    Maximum: 1

    karel/Data: RW

    Program: RW

    Control Start: RW

    Type: BOOLEAN

    Memory Location: CMOS

    Name: High Precision Disturbance Torque Enable

    Description: If TRUE: System will update $MISC.$HPD_TRQ[]. If FALSE: System does not update $MISC.$HPD_TRQ[].

    User Interface Location: SYSTEM Variables screen

  • othonmt
    Trophies
    2
    Posts
    3
    • December 8, 2020 at 8:00 PM
    • #10

    Hi, I did set $hpd_enb variable to TRUE, and I see $HPD_TRQ[] updated. But I don´t understand what does the value represent, since it is different than the values shown in the "axis" screen in the TP.

    Is this a % of disturbance related to the max allowed or related to the max specification of the servo?

  • RookieWithRobots
    Reactions Received
    3
    Trophies
    4
    Posts
    76
    • December 10, 2020 at 8:18 AM
    • #11
    Quote from othonmt

    Hi, I did set $hpd_enb variable to TRUE, and I see $HPD_TRQ[] updated. But I don´t understand what does the value represent, since it is different than the values shown in the "axis" screen in the TP.

    Is this a % of disturbance related to the max allowed or related to the max specification of the servo?

    Hi,

    Unfortunately I can't tell yo what is the relationship between disturbance values and those values. I just know that with monitoring those I'm able to make some part relocation based on those values. I tried to search from my manuals, but couldn't found much to share.

  • Famous_Fella
    Reactions Received
    25
    Trophies
    4
    Posts
    131
    • December 10, 2020 at 12:55 PM
    • #12

    I have spent many, many hours trying to convert the values from system variables concerning torque, max. torque, disturbance torque to match the Teach Pendant monitor values and I have concluded that the numbers in system variables concerning the HPD_TRQ[] array are double types and they in fact represent Amps (A) and match what you see on the Teach Pendant. So this you can use safely.

    Now concerning MOR_GRP system variables this is a whole lot different story. Values stored in $TORQUE, $MAX_TORQUE, $CUR_TORQUE are of type UINT and they are raw data coming straight from the Servo's DSP (Digital Signal Processor) cast internally by the Teach Pendant's Kernel to represent a measured value for MONITOR. I have not found a way so far to "pull" the value of the TP monitor screen because that value in my opinion is not stored in a system variable rather it is processed on-the-fly and updated.

    A method around I used to tackle this problem was to collect a big sample of data seperately for each axis from both the value of the variable and the value on the teach pendant and compare the mins and max between specific time intervals to find MINs and MAXs as a percent.

    Creating a Real-time robot torque monitor in PLC HMI

    This was a project of implementing a Live Robot Monitor directly on the PLC's HMI. Scroll to my last post and you can see a video.

  • ssaul
    Reactions Received
    8
    Posts
    54
    • March 28, 2025 at 8:05 AM
    • #13
    Quote from Famous_Fella

    I have spent many, many hours trying to convert the values from system variables concerning torque, max. torque, disturbance torque to match the Teach Pendant monitor values and I have concluded that the numbers in system variables concerning the HPD_TRQ[] array are double types and they in fact represent Amps (A) and match what you see on the Teach Pendant. So this you can use safely.

    Now concerning MOR_GRP system variables this is a whole lot different story. Values stored in $TORQUE, $MAX_TORQUE, $CUR_TORQUE are of type UINT and they are raw data coming straight from the Servo's DSP (Digital Signal Processor) cast internally by the Teach Pendant's Kernel to represent a measured value for MONITOR. I have not found a way so far to "pull" the value of the TP monitor screen because that value in my opinion is not stored in a system variable rather it is processed on-the-fly and updated.

    A method around I used to tackle this problem was to collect a big sample of data seperately for each axis from both the value of the variable and the value on the teach pendant and compare the mins and max between specific time intervals to find MINs and MAXs as a percent.

    Creating a Real-time robot torque monitor in PLC HMI

    This was a project of implementing a Live Robot Monitor directly on the PLC's HMI. Scroll to my last post and you can see a video.

    Could you share the program you used in this project please?

Advertising from our partners

IRBCAM
Robotics Channel
Robotics Training
Advertise in robotics
Advertise in Robotics
Advertise in Robotics

Job Postings

  • Anyware Robotics is hiring!

    yzhou377 February 23, 2025 at 4:54 AM
  • How to see your Job Posting (search or recruit) here in Robot-Forum.com

    Werner Hampel November 18, 2021 at 3:44 PM
Your browser does not support videos RoboDK Software for simulation and programming

Tag Cloud

  • abb
  • Backup
  • calibration
  • Communication
  • CRX
  • DCS
  • dx100
  • dx200
  • error
  • Ethernet
  • Ethernet IP
  • external axis
  • Fanuc
  • help
  • hmi
  • I/O
  • irc5
  • IRVIsion
  • karel
  • kawasaki
  • KRC2
  • KRC4
  • KRC 4
  • KRL
  • KUKA
  • motoman
  • Offset
  • PLC
  • PROFINET
  • Program
  • Programming
  • RAPID
  • robodk
  • roboguide
  • robot
  • robotstudio
  • RSI
  • safety
  • Siemens
  • simulation
  • SPEED
  • staubli
  • tcp
  • TCP/IP
  • teach pendant
  • vision
  • Welding
  • workvisual
  • yaskawa
  • YRC1000

Thread Tag Cloud

  • abb
  • Backup
  • calibration
  • Communication
  • CRX
  • DCS
  • dx100
  • dx200
  • error
  • Ethernet
  • Ethernet IP
  • external axis
  • Fanuc
  • help
  • hmi
  • I/O
  • irc5
  • IRVIsion
  • karel
  • kawasaki
  • KRC2
  • KRC4
  • KRC 4
  • KRL
  • KUKA
  • motoman
  • Offset
  • PLC
  • PROFINET
  • Program
  • Programming
  • RAPID
  • robodk
  • roboguide
  • robot
  • robotstudio
  • RSI
  • safety
  • Siemens
  • simulation
  • SPEED
  • staubli
  • tcp
  • TCP/IP
  • teach pendant
  • vision
  • Welding
  • workvisual
  • yaskawa
  • YRC1000

Tags

  • Fanuc
  • karel
  • data
  • recorder
  • log
  • background

Users Viewing This Thread

  • 1 Member and 2 Guests
  • asdf
  1. Privacy Policy
  2. Legal Notice
Powered by WoltLab Suite™
As a registered Member:
* You will see no Google advertising
* You can translate posts into your local language
* You can ask questions or help the community with your knowledge
* You can thank the authors for their help
* You can receive notifications of replies or new topics on request
* We do not sell your data - we promise

JOIN OUR GREAT ROBOTICS COMMUNITY.
Don’t have an account yet? Register yourself now and be a part of our community!
Register Yourself Lost Password
Robotforum - Support and discussion community for industrial robots and cobots in the WSC-Connect App on Google Play
Robotforum - Support and discussion community for industrial robots and cobots in the WSC-Connect App on the App Store
Download