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

recording realtime cartesian position in a file on roboguide

  • clark99
  • May 15, 2024 at 10:40 AM
  • Thread is Resolved
  • clark99
    Posts
    10
    • May 15, 2024 at 10:40 AM
    • #1

    Hi experts

    Here is my situation and i need your guidance,

    i have been able to enable real time position monitor ( SCR_GRP[1].$M_POS_ENB to true), monitoring XYZ coordinates of the TCP
    and i have sent those values to 3 registers.

    While the simulation is running i can see those values changing in my registers.

    Now i would like to record those values in a file using a time sample.

    any help is welcome
    thank you in advance

  • kwakisaki May 15, 2024 at 12:37 PM

    Moved the thread from forum General Discussion of Industrial Robots Only to forum Fanuc Robot Forum.
  • PnsStarter
    Reactions Received
    90
    Trophies
    6
    Posts
    325
    • May 15, 2024 at 1:07 PM
    • #2

    I think without karel you have no chance.

    Backdate/TP-Tools: A small collection of tools that simplify the commissioning and programming of Fanuc robots. (github.com)

  • Nation
    Typical Robot Error
    Reactions Received
    521
    Trophies
    9
    Posts
    1,900
    • May 15, 2024 at 1:08 PM
    • #3

    What's the final application of the data you will gather, and what is the time sample rate you intend to use? That will help me determine what is the best way to do what you want.

    We will likely need Karel to do this, or an additional option.

    Check out the Fanuc position converter I wrote here! Now open source!

    Check out my example Fanuc Ethernet/IP Explicit Messaging program here!

  • Online
    hoitzing
    Reactions Received
    24
    Trophies
    1
    Posts
    128
    • May 15, 2024 at 1:20 PM
    • #4

    Since you're gonna be writing to a file, you're bound to use KAREL. If you're using KAREL anyways, you might as well use the system variables for the current position ($SCR_GRP[1].$MCH_POS_X/Y/Z) directly, instead of pushing these into a register and then reading the register value in KAREL.

    You can create a KAREL program in which you:

    1) open the file

    2A) periodically sample the time; a timestamp used to measure elapsed time in microseconds is available via the GET_USEC_TIM and GET_USEC_SUB functions. This result wraps after 2 minutes, but if you're only interested in relative time you can work around this. If you require the system's absolute time in timestamps, use the GET_TIME function, but I doubt this will have high enough precision. What I prefer to do is log an absolute timestamp of the system's time once when starting, and from there start logging the high-precision timestamps that can wrap.

    2B) in the same loop, sample the robot's position (using either the system variable directly, or by reading register values), and write the values to the file. In my experience the FANUC's 8ms cycle time can be reached if you're simply logging a position to a file.

    I read in your other posts you're interested in the positions during execution of a program. Then at the start of your main TP program you need to start the KAREL logging program in the background (RUN your_KAREL_prog). Note that your main TP program will not exit until the background KAREL program has finished. So be sure to add some condition to abort the logging loop (use a flag for example, which is easily set from the TP program).

    Edited once, last by hoitzing: add timestamps (May 15, 2024 at 1:26 PM).

  • clark99
    Posts
    10
    • May 15, 2024 at 1:25 PM
    • #5

    thank you for your answers.

    i am ready to dive in Karel if it is the only way.
    i will need a sample time of 3s. the final application of those data is to run a mesgrid on matlab

    i have been reading some post on the forum about running a karel program on the background of the tp program.

    this code for example (read on the forum)
    ________________________________________________________________
    !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

    _________________________________________

    PROGRAM datarecorder
    %COMMENT = 'LOG DATA RECORD'
    %SYSTEM
    %NOLOCKGROUP
    %NOABORT=ERROR+COMMAND+TPENABLE
    %NOPAUSE=ERROR+COMMAND+TPENABLE %NOPAUSESHFT

    i found a way to write karel code on roboguide using the file in the cell tree

    i am wondering if it is the right way to write a karel program to run in the background of my tp program

  • clark99
    Posts
    10
    • May 15, 2024 at 1:29 PM
    • #6

    hoitzing thank you very much

    will a karel code like this work for my application

    (read on the forum)

    _______________________________________________
    PROGRAM UD1_WRITE
    %NOLOCKGROUP

    VAR
    FTP_FILE :FILE
    --------------------------------------
    ROUTINE init_cond
    BEGIN
    IF OPOUT[1] = ON
    THEN
    ENDIF
    END init_cond
    --------------------------------------
    ROUTINE write_file
    BEGIN
    WRITE FTP_FILE ($SCR_GRP[1].$MCH_POS_X,',')
    WRITE FTP_FILE ($SCR_GRP[1].$MCH_POS_Y,',')
    WRITE FTP_FILE ($SCR_GRP[1].$MCH_POS_Z,',')
    WRITE FTP_FILE ($TIMER[1].$TIMER_VAL,CR)
    DELAY 100
    END write_file
    --------------------------------------
    BEGIN
    OPEN FILE FTP_FILE ('AP', 'UD1:\TEST13.CSV')
    WRITE FTP_FILE('X-POS, Y-POS, Z-POS, TIME',CR)
    WHILE TRUE DO
    init_cond
    write_file
    ENDWHILE
    WRITE FTP_FILE ('test complete',CR)
    CLOSE FILE FTP_FILE
    END UD1_WRITE

  • clark99
    Posts
    10
    • May 15, 2024 at 1:32 PM
    • #7

    Nation thank you in advance

  • Online
    hoitzing
    Reactions Received
    24
    Trophies
    1
    Posts
    128
    • May 15, 2024 at 1:54 PM
    • #8

    It looks your KAREL program should work, yes. But there are some style improvements I'd personally make:

    Code
    ROUTINE init_cond
    BEGIN
    IF OPOUT[1] = ON
    THEN
    ENDIF
    END init_cond

    This routine doesn't do anything; might as well delete it unless you were planning to add some functionality in here.

    Code
    ROUTINE write_file
    BEGIN
    WRITE FTP_FILE ($SCR_GRP[1].$MCH_POS_X,',')
    WRITE FTP_FILE ($SCR_GRP[1].$MCH_POS_Y,',')
    WRITE FTP_FILE ($SCR_GRP[1].$MCH_POS_Z,',')
    WRITE FTP_FILE ($TIMER[1].$TIMER_VAL,CR)
    DELAY 100
    END write_file

    I'd move the DELAY statement outside of the routine, and into the loop in the program's main body. If you need a very precise sampling time of 100ms it might be easier to regulate it this way. If you don't care about a very exact sampling time this should be fine (but subtract a few ms that goes into the logging).

    Note my earlier post where I mention some other options for timestamps. No need to change this though if it works for you.

    Code
    WHILE TRUE DO
    init_cond
    write_file
    ENDWHILE

    This is an endless loop. One option would be to use a FLAG to enable/disable the logger. The first line would then become WHILE FLG[1] DO so it will automatically finish the program once you set F[1]=OFF in your TP program.

    As for the TP program: the CALL statement will block the 'parent' program until the other program is finished, whereas the RUN statement will start running the 'child' program in the background while the 'parent' program continues. So change the call to:

    Code
    F[1]=ON
    RUN DATARECORDER(100, 20000, 'UD1:logfile.dt')
    
    ! do whatever you like while the logging is active here
    ! ...
    
    F[1]=OFF
  • clark99
    Posts
    10
    • May 15, 2024 at 2:15 PM
    • #9

    hoitzing you've saved me i am grateful. thank you for your time

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
  • roboguide
  • Save
  • File
  • Cartesian
  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