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

How to change the values of a system variable via Karel??

  • A_ghost
  • May 17, 2023 at 2:33 PM
  • Thread is Unresolved
  • A_ghost
    Reactions Received
    1
    Trophies
    2
    Posts
    36
    • May 17, 2023 at 2:33 PM
    • #1

    I'm trying to use the set_var command to change the value of the frame coordinates written to the system variable, but nothing works. How to write the code correctly??

  • PnsStarter
    Reactions Received
    92
    Trophies
    6
    Posts
    329
    • May 17, 2023 at 5:16 PM
    • #2

    Hi A_ghost,

    SET_VAR is the correct routine.

    - Figure out the correct sysvar name e.g. '$XY_VAR[2].$A_Value'

    - set prog_name to '*SYSTEM*'

    - use the status var (with POST_ERR) to debug your code and get more information about your error(s)

    - check the information the compiler/translater gives you

    Best regards

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

  • nhfMinion
    Reactions Received
    6
    Trophies
    1
    Posts
    20
    • May 17, 2023 at 5:57 PM
    • #3

    The system variable "$EADER_FRM " you are are using doesn't seem to be a standard system variable, could you show the path you are taking to get to your screen?

    Below is an example of how you can use the SET_VAR instruction in a Karel Routine (note: the parameter name might not be correct):

    PROGRAM VAR_SET

    --Translation Directive to work with system variables

    %ENVIRONMENT sysdef

    --Variable Definitions

    VAR

    status: INTEGER

    tempInteger:INTEGER

    parameter: STRING[40]

    value: REAL

    --Program Logic

    BEGIN

    parameter = '$EADER_FRM[1].$X'

    value = 563.000

    SET_VAR(tempInteger, '*SYSTEM*',parameter, value,status)

    END VAR_SET

  • A_ghost
    Reactions Received
    1
    Trophies
    2
    Posts
    36
    • May 22, 2023 at 7:00 AM
    • #4
    Quote from nhfMinion

    The system variable "$EADER_FRM " you are are using doesn't seem to be a standard system variable, could you show the path you are taking to get to your screen?

    Below is an example of how you can use the SET_VAR instruction in a Karel Routine (note: the parameter name might not be correct):

    PROGRAM VAR_SET

    --Translation Directive to work with system variables

    %ENVIRONMENT sysdef

    --Variable Definitions

    VAR

    status: INTEGER

    tempInteger:INTEGER

    parameter: STRING[40]

    value: REAL

    --Program Logic

    BEGIN

    parameter = '$EADER_FRM[1].$X'

    value = 563.000

    SET_VAR(tempInteger, '*SYSTEM*',parameter, value,status)

    END VAR_SET

    Display More


    I wrote the code, but when executing, the value of X does not change (((

  • A_ghost
    Reactions Received
    1
    Trophies
    2
    Posts
    36
    • May 22, 2023 at 7:44 AM
    • #5

    Is the system variable locked??

  • PnsStarter
    Reactions Received
    92
    Trophies
    6
    Posts
    329
    • May 23, 2023 at 12:06 PM
    • #6

    Hi

    as I wrote in my first answer:

    Quote

    - use the status var (with POST_ERR) to debug your code and get more

    information about your error(s)

    e.g.

    SET_VAR(.....,status)

    IF status <> 0 THEN POST_ERR(status, '', 0, 2) ENDIF

    And, are you sure you have to set these vars via karel?

    I think it might be dangerous to edit the COORD-Frames directly, unless you really know what you're doing...

    best regards

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

  • A_ghost
    Reactions Received
    1
    Trophies
    2
    Posts
    36
    • May 29, 2023 at 7:18 AM
    • #7
    Quote from PnsStarter

    Hi

    as I wrote in my first answer:


    e.g.

    SET_VAR(.....,status)

    IF status <> 0 THEN POST_ERR(status, '', 0, 2) ENDIF

    And, are you sure you have to set these vars via karel?

    I think it might be dangerous to edit the COORD-Frames directly, unless you really know what you're doing...

    best regard

    Display More

    When executing the program, it writes an unknown variable name. Why??

  • niram83
    Reactions Received
    1
    Trophies
    2
    Posts
    15
    • August 10, 2023 at 7:26 AM
    • #8

    Hello A_ghost,

    I have similar problem with another sys var

    Thread

    Karel set_var problem

    Hello everyone,

    I have some trouble to set variable that don't have $ before it. Is it possible?y3eehahxe

    (Code, 28 lines)

    niram83
    August 9, 2023 at 10:34 AM

    B.R.

  • ssaul
    Reactions Received
    8
    Posts
    54
    • March 12, 2025 at 5:40 PM
    • #9

    Hi guys, I want to change the name of a variable ($pro_cfg.$prog_name) but in Karel it doesn't let me and I can't do it from the TP either. I wanted to make it equal to an SR (string Register). Any idea on how to change the name?

  • A_ghost
    Reactions Received
    1
    Trophies
    2
    Posts
    36
    • March 13, 2025 at 11:05 AM
    • #10
    Code
    I have dealt with my problem

  • PnsStarter
    Reactions Received
    92
    Trophies
    6
    Posts
    329
    • March 13, 2025 at 12:11 PM
    • #11

    Hi A_ghost,

    I saw that you only do a check of status var at the end?

    Why did'nt you do this

    Quote from PnsStarter

    IF status <> 0 THEN POST_ERR(status, '', 0, 2) ENDIF

    directly after a builtin where you get a status ?


    @ssaul what is "$pro_cfg.$prog_name" used for?

    what error code do you get?

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

  • ssaul
    Reactions Received
    8
    Posts
    54
    • March 13, 2025 at 2:45 PM
    • #12
    Quote from PnsStarter

    @ssaul what is "$pro_cfg.$prog_name" used for?

    what error code do you get?

    The variable $pro_cfg.$prog_name saves the name of the program that will be analyzed in Motion Profiler. I want to automate it to change the name of the program without having to go to the teach pendant.

    Images

    • ERROR.png
      • 38.49 kB
      • 753 × 287
      • 11

    Edited once, last by ssaul (March 13, 2025 at 2:53 PM).

  • PnsStarter
    Reactions Received
    92
    Trophies
    6
    Posts
    329
    • March 13, 2025 at 4:24 PM
    • #13

    Hi ssaul,

    have you tried with SET_VAR builtin? Please try.

    Info: Not all sysvars are directly supported within RG (maybe you have to set an(other) %environment), if not familiar with that, use SET_VAR.

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

  • ssaul
    Reactions Received
    8
    Posts
    54
    • March 13, 2025 at 4:34 PM
    • #14
    Quote from PnsStarter

    Hi ssaul,

    have you tried with SET_VAR builtin? Please try.

    Info: Not all sysvars are directly supported within RG (maybe you have to set an(other) %environment), if not familiar with that, use SET_VAR.

    hi PnsStarer

    Currently this is my program, but I think the variable is not available for karel


    PROGRAM set_prog_name
    VAR
    prog_name : STRING[32] -- Variable para almacenar el nombre del programa
    status : INTEGER -- Variable para almacenar el estado de la operación
    BEGIN
    -- Inicializar la variable de estado
    status = 0

    -- Leer el valor de SR[1] y almacenarlo en prog_name
    GET_STR_REG(1, prog_name, status)

    -- Verificar si la operación de lectura fue exitosa
    IF status = 0 THEN
    -- Asignar el valor de prog_name a $PRO_CFG.$PROG_NAME
    $PRO_CFG.$PROG_NAME = prog_name
    -- Mostrar un mensaje de confirmación
    WRITE('El nombre del programa ha sido establecido a: ', prog_name, CR)
    ELSE
    -- Mostrar un mensaje de error
    WRITE('Error al leer el registro de cadena SR[1]', CR)
    ENDIF
    END set_prog_name

    Images

    • karel1.png
      • 137.55 kB
      • 661 × 477
      • 8
  • PnsStarter
    Reactions Received
    92
    Trophies
    6
    Posts
    329
    • March 13, 2025 at 4:53 PM
    • #15
    Code
    -- Asignar el valor de prog_name a $PRO_CFG.$PROG_NAME
    SET_VAR(ENTRY, '*SYSTEM*', '$PRO_CFG.$PROG_NAME', prog_name, STATUS)
    IF STATUS <> 0 THEN;POST_ERR(STATUS, '', 0, 2);ENDIF	

    you have also to add "ENTRY : integer" to var section...

    please get familiar with the (common) builtins..

    I haven't tested and I won't give you FULL program.... learning while coding :winking_face:

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

    Edited once, last by PnsStarter: Typo : *SYSTEM' --> *SYSTEM*' (March 14, 2025 at 1:33 PM).

  • ssaul
    Reactions Received
    8
    Posts
    54
    • March 14, 2025 at 1:21 PM
    • #16
    Quote from PnsStarter
    Code
    -- Asignar el valor de prog_name a $PRO_CFG.$PROG_NAME
    SET_VAR(ENTRY, '*SYSTEM', '$PRO_CFG.$PROG_NAME', prog_name, STATUS)
    IF STATUS <> 0 THEN;POST_ERR(STATUS, '', 0, 2);ENDIF	

    you have also to add "ENTRY : integer" to var section...

    please get familiar with the (common) builtins..

    I haven't tested and I won't give you FULL program.... learning while coding :winking_face:

    I don't want you to write the code, I just need to know if you can use the variable in Karel because I think it's protected.

  • PnsStarter
    Reactions Received
    92
    Trophies
    6
    Posts
    329
    • March 14, 2025 at 1:36 PM
    • #17

    Hi ssaul

    now I'm confused!

    Quote from ssaul

    I just need to know if you can use the variable in Karel because I think it's protected.

    What do you mean? It's writeable.


    But I do not know if it's is 'allowed' to change this 'manually' since this var is part of a struct so maybe you'll get unwanted behavior..

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

  • ssaul
    Reactions Received
    8
    Posts
    54
    • March 14, 2025 at 2:07 PM
    • #18
    Quote from PnsStarter

    Hi ssaul

    now I'm confused!

    What do you mean? It's writeable.


    But I do not know if it's is 'allowed' to change this 'manually' since this var is part of a struct so maybe you'll get unwanted behavior..

    Hello, good morning. It won't let me write it, hahaha. I write it, and the variable doesn't change color to indicate that it's being viewed. Sorry for my English. I use a translator.

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

Similar Threads

  • Dynamic control of FANUC Robot in Run-Time

    • Gokul N A
    • July 3, 2019 at 10:39 AM
    • Fanuc Robot Forum

Users Viewing This Thread

  • 2 Guests
  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