Simple way to Read Force

  • Hello Guys,

    is there any progress regarding this topic ?

    I am trying to read current data from my force sensor but no luck.

    I ve tried following declarations: - in KAREL

    GET_VAR(entry, 'SYSTEM', '$FORCE_SENSE.$force_data[1]', value, status)

    GET_VAR(entry, 'SYSTEM', '$CCC_GRP[1].$FS_FORCE.[1]', value, status)


    in robot program I am able to use

    $CCC_GRP[1].$FS_FORCE.[1]

    but no luck in KAREL


    the plan is to make a force logger in KAREL, thats why I m trying to read those values there.


    where entry, value and status are declared as INTEGER, I also tried to change 'value' declaration to real, but no luck


    any idea how to move on with this ?


    Thanks in advance :smiling_face:

    Edited once, last by RudolfA ().

  • Hello,

    In order to read the correct force values, you need to take into account the ClearForce values.

    This code here works well for us; put it into a background logic task and the latest force values are then always available in registers.


    9: !================================ ;

    10: !SEND FORCE INFO TO REGISTERS ;

    11: !================================ ;

    12: R[1:X Axis Force (N)]=($CCC_GRP[1].$FS_FORCE[1]-$CCC_GRP[1].$CLR_FORCE[1]) ;

    13: R[2:Y Axis Force (N)]=($CCC_GRP[1].$FS_FORCE[2]-$CCC_GRP[1].$CLR_FORCE[2]) ;

    14: R[3:Z Axis Force (N)]=($CCC_GRP[1].$FS_FORCE[3]-$CCC_GRP[1].$CLR_FORCE[3]) ;

    15: R[4:W Force (N)]=($CCC_GRP[1].$FS_FORCE[4]-$CCC_GRP[1].$CLR_FORCE[4]) ;

    16: R[5:P Force (N)]=($CCC_GRP[1].$FS_FORCE[5]-$CCC_GRP[1].$CLR_FORCE[5]) ;

    17: R[6:R Force (N)]=($CCC_GRP[1].$FS_FORCE[6]-$CCC_GRP[1].$CLR_FORCE[6]) ;


  • Hey guys,

    I am also trying to do something similar at our company using a M-20IA force sensor. I have a few more questions regarding this.
    Are there any updates on this? Did the above solution work? Do you get the latest force values if it is run as a background logic? Are you able to control the logging interval? How do we write this into a csv file using a teach pendent program?

  • I can't really comment on the first part about the force sensing itself. But the other questions:

    Do you get the latest force values if it is run as a background logic?

    Yes. The background logic program typically executes every 8ms (in 'High' mode, possibly slower in 'Normal' mode if the controller can't keep up). When it executes it reads the values from the system variables which always get updated with the latest values behind the scenes. So assuming you're running the BG logic at an 8ms interval, you'd get data with a maximum delay of 8ms (excluding any delays that may result from the 'behind the scenes work' required to update the system variables).


    Are you able to control the logging interval?

    The BG logic program will run as your 'sampling loop' which does the computations and then only outputs them in registers for easy access. So you would need to create your own 'logging loop' which reads from the registers and outputs the values to a file. So of course then you would have complete control over the logging interval.


    How do we write this into a csv file using a teach pendent program?

    I don't believe TP programs are able to write to files. If you would use KAREL it's possible to write data to a file.

  • Thank you hoitzing.

    FANUC had helped us write a KAREL code to output the force log into a csv file. But the data logging interval seems inconsistent. I am new to KAREL codes and have undergone the basic TP programming course. FANUC seems to be providing minimal to zero support on KAREL and hence why I was considering to use TP programs to do the same job.

    I will try and run force logging as a bg program and see if it helps our data logs in any way. Do you know how I can compile .KL files to .PC files without Roboguide? I have been searching for a while but I have not found any convincing answers. If so, I could try modifying the KAREL code on my own.

  • Have you tried using one of the builtin force logs?


    One is executed from TP code, the other is accessed from the web interface (http://{ROBOT.IP.HERE}/frh/force/fsmonitor.htm.


    The one executed from TP code is referenced in the force control manual. It logs at every ITP; 4ms for new robots and 8ms for older robots.

  • Have you tried using one of the builtin force logs?


    One is executed from TP code, the other is accessed from the web interface (http://{ROBOT.IP.HERE}/frh/force/fsmonitor.htm.


    The one executed from TP code is referenced in the force control manual. It logs at every ITP; 4ms for new robots and 8ms for older robots.

    Hi pdl, thanks for the suggestion.

    I did try to record the data log from the interface.
    We would like a few string registers displayed on the csv file as we perform several different motion cycles on our product and these string registers would help us identify which motion was being executed for that particular force reading. We would also like to register with the cycle number to be read out on the csv files. When we tried the logs from the interface, they display only the basic information ie., time, force and moment values along the various axes. I don't think there is way to customize that log. Hence was looking for alternatives. Thanks for the suggestion though!

  • Hi guys,

    As an update, the reason why we weren't getting the right force value was because of an error in one of the background logic and a force sensor mounting issue. Having corrected them and using this logic above, we are now getting the correct force values.

    Thanks to everyone who helped.

Advertising from our partners