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

Create a TP program with KAREL

  • flatcurve
  • November 17, 2014 at 6:39 PM
  • Thread is Resolved
  • flatcurve
    Reactions Received
    18
    Trophies
    3
    Posts
    58
    • November 17, 2014 at 6:39 PM
    • #1

    I'm trying to write a KAREL program that will create a TP program and populate it with a bunch of motion commands. The problem I'm having is it seems like there's a way to make a TP program (CREATE_TPE), but no way to add new lines or instructions to it. So what's the point of that command? I can modify existing motion commands with the SET_POS_TPE, but not create new points. So I tried to just create an LS file and use position registers to make it easy, but I keep running into problems with the /ATTR section of the program causing ASBN-002 syntax errors when loading.

    Anybody done something like this? I know there's got to be a command set for it, because FANUC has KAREL programs that basically do this.

  • rf103
    Reactions Received
    17
    Trophies
    4
    Posts
    264
    • November 18, 2014 at 7:36 PM
    • #2

    Right, so for most of these routines I don't have any documentation, but this is what I've been able to find:

    Code
    CLOSE_TPE(open_id:INTEGER, status:INTEGER)
    COPY_TPE(from_prog:STRING, to_prog:STRING, overwrite_sw:BOOLEAN, status:INTEGER)
    CREATE_TPE(prog_name:STRING, prog_type:INTEGER, status:INTEGER)
    OPEN_TPE(proc_name:STRING, open_mode:INTEGER, reject_mode:INTEGER, open_id:INTEGER, status:INTEGER)
    SELECT_TPE(prog_name:STRING, status:INTEGER)
    
    
    
    
    GET_TPE_CMT(open_id:INTEGER, pos_no:INTEGER, comment:STRING, status:INTEGER)
    SET_TPE_CMT(open_id:INTEGER, pos_no:INTEGER, comment:STRING, status:INTEGER)
    
    
    
    
    DEL_HEAD_TPE(open_id:INTEGER, index_1:INTEGER, index_2:INTEGER, status:INTEGER)
    FND_HEAD_TPE(open_id:INTEGER, appl_name:STRING, index_1:INTEGER, index_2:INTEGER, status:INTEGER)
    GET_HEAD_TPE(open_id:INTEGER, index_1:INTEGER, index_2:INTEGER, buf_siz:INTEGER, appl_data:BYTE, status:INTEGER)
    RD2_HEAD_TPE(ept_index:INTEGER, appl_name:STRING, buf_siz:INTEGER, appl_data:BYTE, status:INTEGER)
    RD_HEAD_TPE(prog_name:STRING, appl_name:STRING, buf_siz:INTEGER, appl_data:BYTE, status:INTEGER)
    SET_HEAD_TPE(open_id:INTEGER, index_1:INTEGER, index_2:INTEGER, opt_sw:INTEGER, buf_siz:INTEGER, appl_data:BYTE, status:INTEGER)
    
    
    
    
    END_EDIT_TPE()
    END_EXEC_TPE()
    
    
    
    
    DEL_INST_TPE(open_id:INTEGER, lin_num:INTEGER, status:INTEGER)
    GET_INST_TPE(open_id:INTEGER, lin_num:INTEGER, lin_data:BYTE, status:INTEGER)
    GET_RAW_INST(open_id:INTEGER, lin_num:INTEGER, lin_data:BYTE, status:INTEGER)
    REP_INST_TPE(open_id:INTEGER, lin_num:INTEGER, opt_sw:INTEGER, lin_data:BYTE, lin_len:INTEGER, status:INTEGER)
    SET_INST_TPE(open_id:INTEGER, lin_num:INTEGER, opt_sw:INTEGER, lin_data:BYTE, lin_len:INTEGER, status:INTEGER)
    SET_TEXT_TPE(prog_name:STRING, lin_num:INTEGER, opt_sw:INTEGER, lin_data:STRING, status:INTEGER)
    
    
    
    
    GET_JPOS_TPE(open_id:INTEGER, position_no:INTEGER, status:INTEGER, group_no:INTEGER (OPT)):JOINTPOS
    GET_POS_TPE(open_id:INTEGER, position_no:INTEGER, status:INTEGER, group_no:INTEGER (OPT)):XYZWPR
    SET_EPOS_TPE(open_id:INTEGER, position_no:INTEGER, posn:XYZWPR, status:INTEGER, group_no:INTEGER (OPT))
    SET_JPOS_TPE(open_id:INTEGER, position_no:INTEGER, posn:JOINTPOS, status:INTEGER, group_no:INTEGER (OPT))
    SET_POS_TPE(open_id:INTEGER, position_no:INTEGER, posn:XYZWPR, status:INTEGER, group_no:INTEGER (OPT))
    SET_TRNS_TPE(open_id:INTEGER, position_no:INTEGER, posn:POSITION, status:INTEGER, group_no:INTEGER (OPT))
    Display More

    For your specific use case, I think especially SET_TEXT_TPE() would be interesting.

    I don't know of any way of adding new, empty lines to TP programs other than using REP_INST_TPE().

    These same functions give you some nice insight into the binary encoding of TP programs, without the cumbersome compression that the actual files use.

    Edited once, last by rf103 (July 26, 2015 at 10:40 AM).

  • Beek
    Reactions Received
    2
    Trophies
    4
    Posts
    36
    • September 29, 2015 at 4:13 PM
    • #3

    I know this is a bit old but I'm wondering if Flatcurve every got this to work. I'm looking to do something very similar.

  • YellowOneKenobi
    Reactions Received
    1
    Trophies
    4
    Posts
    19
    • November 9, 2017 at 2:18 AM
    • #4

    FYI making your own tp program line by line in Karel is absolutely possible, but its no picknick.

  • bidzej
    Reactions Received
    23
    Trophies
    4
    Posts
    592
    • November 9, 2017 at 9:27 AM
    • #5

    As far as I know, there are dedicated Built-ins in Karel for creating and editing TP-programs, but they are not documented and seem to be reserved for Fanuc only :frowning_face:

  • rf103
    Reactions Received
    17
    Trophies
    4
    Posts
    264
    • November 9, 2017 at 9:34 AM
    • #6
    Quote from bidzej


    As far as I know, there are dedicated Built-ins in Karel for creating and editing TP-programs, but they are not documented and seem to be reserved for Fanuc only :frowning_face:

    The built-ins are all there, three posts up.

  • JT
    Reactions Received
    5
    Trophies
    3
    Posts
    10
    • November 26, 2017 at 2:23 PM
    • #7

    See attached code which contains a non supported build-in. Not all movement types are supported but it might do the trick for your application.

    Fanuc is not keen on supporting movement in Karel. Their vision is that all generated points should be teached by a qualified operator in TP. Karel logic programs can then call these teached movement TP programs.
    But FANUC seems to forget that in some cases you have to use the readily available robot kinematic model on the controller to compute or convert points during operation, so it is easier to let the controller generate the TP programs without any link to a PC/software. On the opposite of the attached code typically a software is used to create the TP program structure and points offline which is then uploaded to the controller. In the latter if anything goes wrong the software is to blame and not the controller. I guess it is a question of liability.

    Have fun!

    Files

    WRITETP-copy.zip 3.36 kB – 393 Downloads WRITETP-copy.zip 3.36 kB – 194 Downloads

    Edited once, last by JT (November 26, 2017 at 3:04 PM).

  • rf103
    Reactions Received
    17
    Trophies
    4
    Posts
    264
    • November 27, 2017 at 4:24 PM
    • #8

    Didn't SET_TEXT_TPE work here? Or does the validation step in that function return errors that made the mnemonic approach necessary?

  • lexx905
    Reactions Received
    11
    Trophies
    3
    Posts
    82
    • November 27, 2017 at 8:18 PM
    • #9
    Quote from JT


    See attached code which contains a non supported build-in. Not all movement types are supported but it might do the trick for your application.

    Fanuc is not keen on supporting movement in Karel. Their vision is that all generated points should be teached by a qualified operator in TP. Karel logic programs can then call these teached movement TP programs.
    But FANUC seems to forget that in some cases you have to use the readily available robot kinematic model on the controller to compute or convert points during operation, so it is easier to let the controller generate the TP programs without any link to a PC/software. On the opposite of the attached code typically a software is used to create the TP program structure and points offline which is then uploaded to the controller. In the latter if anything goes wrong the software is to blame and not the controller. I guess it is a question of liability.

    Have fun!


    Wow !!!

    Tell us in which manuals you found these functions?
    I usually created a TP via an LS file.
    It also works, but for this you need the ASCII Upload option

    Files

    Create_LS_HTool.zip 1.13 kB – 295 Downloads
  • JT
    Reactions Received
    5
    Trophies
    3
    Posts
    10
    • November 27, 2017 at 9:37 PM
    • #10

    Correct that is an important note which I did not mention: ASCII upload is always the way to go if you have the option installed. It provides full functionality while the mnemonic approach has limitations.

  • lexx905
    Reactions Received
    11
    Trophies
    3
    Posts
    82
    • November 28, 2017 at 5:27 AM
    • #11
    Quote from JT


    Correct that is an important note which I did not mention: ASCII upload is always the way to go if you have the option installed. It provides full functionality while the mnemonic approach has limitations.

    so in which description did you read about these instructions?

  • rf103
    Reactions Received
    17
    Trophies
    4
    Posts
    264
    • November 29, 2017 at 11:27 AM
    • #12

    Most mnemonics are documented in klevtpe.kl in the support sub dir of WinOLPC.

  • Vlad_T_20
    Trophies
    2
    Posts
    2
    • November 18, 2020 at 8:35 AM
    • #13
    Quote from lexx905

    Wow !!!

    Tell us in which manuals you found these functions?
    I usually created a TP via an LS file.
    It also works, but for this you need the ASCII Upload option

    Hello!

    I have question about WRITE file1('PROG_SIZE = 772;',CR) from your file. How do you found out that this size is suitable for your prog?

  • Vlad_T_20
    Trophies
    2
    Posts
    2
    • November 18, 2020 at 9:39 AM
    • #14
    Quote from JT

    See attached code which contains a non supported build-in. Not all movement types are supported but it might do the trick for your application.

    Fanuc is not keen on supporting movement in Karel. Their vision is that all generated points should be teached by a qualified operator in TP. Karel logic programs can then call these teached movement TP programs.
    But FANUC seems to forget that in some cases you have to use the readily available robot kinematic model on the controller to compute or convert points during operation, so it is easier to let the controller generate the TP programs without any link to a PC/software. On the opposite of the attached code typically a software is used to create the TP program structure and points offline which is then uploaded to the controller. In the latter if anything goes wrong the software is to blame and not the controller. I guess it is a question of liability.

    Have fun!

    Hello!

    Do you have examples of adding another motion-modify options to instructions, not only TIME BEFORE?

  • Marc Straehle
    Trophies
    1
    Posts
    1
    • August 7, 2022 at 6:30 PM
    • #15

    Hello together,

    I actually write a karel program which creates a standard tp programs and with the information about the klevtpe.kl from rf103 I already get my program partly working.

    Now I have to insert lines, which write to a register.

    For that, I use the parameters

    lm_const = 1 -- constant

    lm_index = 2 -- index

    lm_reg = 3 -- Register

    The only problem is it will not set the correct register number.

    Does some here did this already?

    Thx a lot


  • guidam313
    Trophies
    2
    Posts
    2
    • October 5, 2022 at 8:00 PM
    • #16

    This is absolutely awesome! Thank you so much!

    I just want to point out that in the following instruction

    Quote from WRITETP-copy.kl

    SET_POS_TPE(open_id, pos_num, tmp_pos, op_status , G1)

    tmp_pos is of XYZWPR but if it were replace by a JOINTPOS type, the same line would be written in the TP program but with a Joint representation... Might be obvious to some but still worthy of mentioning. :smiling_face:

  • petro1909
    Trophies
    2
    Posts
    4
    • November 14, 2022 at 3:44 PM
    • #17

    Hello everyone, is there any way to add weld instructions to tp program from karel? Is there any command? I can't find it in klevtpe.kl

    Edited once, last by petro1909 (November 16, 2022 at 7:45 AM).

  • RKind
    Trophies
    3
    Posts
    31
    • March 30, 2023 at 3:36 PM
    • #18

    Hello all!!

    I am just posting here without creating a new thread.

    I am new to Karel but trying to understand all the functions.

    I have created the code to send and receive the values from the controller to the PLC via a ProfiNET.

    But unfortunately it is not working.

    I would like to get some help from the experts out here.

    Code: WriteHM
    ------------------------------------------------------------------------------------------------------------------------
    --SECTION 1: Program environment
    ------------------------------------------------------------------------------------------------------------------------
    ------------------------------------------------------------------------------------------------------------------------
    PROGRAM WRITEHM
    %COMMENT = 'WRITEHM'
    %NOLOCKGROUP
    %NOBUSYLAMP
    %NOPAUSE = ERROR+COMMAND+TPENABLE
    %PRIORITY = 1                                 -- Priority for task execution -> 0 is highest priority
    %TIMESLICE = 8                                 -- Time slicer for tasks having the same priority, 1 is highest.
    %DELAY = 8                                 -- Each 256ms a task is delayed by default 8ms
    %ALPHABETIZE
    %NOPAUSESHFT
    --%INVISIBLE
    --%
    --%CMOSVARS
    %NOABORT= ERROR + COMMAND
    ------------------------------------------------------------------------------------------------------------------------
    ------------------------------------------------------------------------------------------------------------------------
    --SECTION 2 constant and variables declaration
    ------------------------------------------------------------------------------------------------------------------------
    ------------------------------------------------------------------------------------------------------------------------
    CONST
    CLR_SCRN     = 128
    VAR
    -- M and H code SPS_IN FANUC_OUT
    iMCode : ARRAY [5] OF INTEGER
    bMCodeREQ :  ARRAY [5] OF BOOLEAN
    iHCode : ARRAY [3] OF INTEGER
    bHCodeREQ :  ARRAY [5] OF BOOLEAN
    rHCode : ARRAY [3] OF REAL
    -- M and H code SPS_OUT FANUC_IN
    bMCodeACQ :  ARRAY [5] OF BOOLEAN
    bHCodeACQ :  ARRAY [5] OF BOOLEAN
    ------------------------------------------------------------------------------------------------------------------------
    ------------------------------------------------------------------------------------------------------------------------
    --SECTION 3: ROUTINES
    ------------------------------------------------------------------------------------------------------------------------
    ------------------------------------------------------------------------------------------------------------------------
    ROUTINE tp_err(message:STRING;abort_flag:BOOLEAN)
    -- Writes on th TP error line a message & aborts the program if required
        BEGIN
            WRITE TPERROR (CHR (CLR_SCRN) , message, CR)
            IF abort_flag THEN ABORT; ENDIF
        END tp_err
        
    ROUTINE SetHCode (iHCode: INTEGER; rHCodeVal: REAL; bQuick: BOOLEAN)
        -- Suche "freien H-Code"
    VAR
    iSet : INTEGER
    I : INTEGER
    FANUC_OUT : ARRAY [5] OF INTEGER
    FANUC_IN : ARRAY [5] OF INTEGER
    
        BEGIN
            iSet=0 ;
            FOR I=1 TO 3 DO
                       IF NOT (FANUC_OUT.bHCodeREQ[I]) THEN
                    iSet=I;
                  ENDIF
            ENDFOR
            IF (iSet=0) THEN
                --WRITE TPPROMPT(’FEHLERMELDUNG AND BEWEGUNGSSTOP OR WARTEN BIS EIN H-Code FREI IST’,CR)
            else
                FANUC_OUT.iHCode[iSet]=iHCode;
                FANUC_OUT.rHCode[iSet]=rHCodeVal;
                FANUC_OUT.bHCodeREQ[iSet]=TRUE;
            ENDIF
            IF NOT (bQuit) THEN
                --BEWEGUNGSSTOP / PRGSTOP;
                WHILE NOT(FANUC_IN=bHCodeACQ[iSet])  DO
                    --WARTE EINEN ZYKLUS;
                ENDWHILE
                FANUC_OUT.bHCodeReq[iSet] = FALSE;
            ENDIF
            RETURN
        END SetHCode
    ROUTINE QuitHCodes() 
    --am Ende oder Anfang des ZYKLUS
        BEGIN 
            -- Quittiere alle H-Code
                FOR I:=1 TO 3
                    IF FANUC_IN.bHCodeACQ[I] THEN
                        FANUC_OUT.bHCodeREQ[I]:= FALSE;
                    ENDIF
                ENDFOR
                RETURN
        END QuitHCodes
    ROUTINE GetHCode() 
    -- am Anfang oder Ende des ZYKLUS
        BEGIN
            -- Suche "gesetzen H-Code"
                iSet:=0;
                FOR I:=1 TO 3
                    IF SPS_IN.bHCodeREQ[I] THEN
                        actHCode := SPS_IN.iHCode[I]
                        actHCodeVal := SPS_IN.rHCode[I]
                        ExecuteHCode(actHCode, actHCodeVal);
                        SPS_OUT.bHCodeACQ[I]:=TRUE;
                    ENDIF
                ENDFOR
                QuitHCodes();
                RETURN
        END GetHCode
    ROUTINE QuitHCodes()
        BEGIN
            -- Rücksetzen des Acquire-Bits
                FOR I:=1 TO 3 
                    IF  NOT(SPS_IN.bHCodeREQ[I]) THEN    
                        SPS_OUT.bHCodeACQ[I]:=FALSE;
                    ENDIF
                ENDFOR
                RETURN
        END QuitHCodes    
    END WRITEHM
    ------------------------------------------------------------------------------------------------------------------------
    ------------------------------------------------------------------------------------------------------------------------
    --SECTION 4: MAIN PROGRAM
    ------------------------------------------------------------------------------------------------------------------------
    ------------------------------------------------------------------------------------------------------------------------
    BEGIN
    WRITEHM
    END WRITEHM
    Display More
  • hermann
    Reactions Received
    405
    Trophies
    9
    Posts
    2,596
    • March 30, 2023 at 4:39 PM
    • #19
    Quote from RKind

    I am just posting here without creating a new thread.

    Why don't you open a new thread? You have a complete different question.

    Quote from RKind

    I am new to Karel but trying to understand all the functions.

    I have created the code to send and receive the values from the controller to the PLC via a ProfiNET.

    But unfortunately it is not working.

    What do you mean by 'it is not working'?

    Imho this code even won't be compiled. So it can't work.

    F.e. you define an array of integer: FANUC_OUT

    then you use FANUC_OUT as a structure FANUC_OUT.bHCodeREQ[i].

    This will not be compiled.

    Your main program

    Code
    --SECTION 4: MAIN PROGRAM
    ------------------------------------------------------------------------------------------------------------------------
    ------------------------------------------------------------------------------------------------------------------------
    BEGIN
    WRITEHM
    END WRITEHM

    doesn't do anything but calling itself, so what other things should this program do instead of nothing?

    Even worse, this is a endless recursive calling, you will get a stack overflow or something similar.

  • RKind
    Trophies
    3
    Posts
    31
    • March 31, 2023 at 9:38 AM
    • #20
    Quote from hermann

    Why don't you open a new thread? You have a complete different question.

    What do you mean by 'it is not working'?

    Imho this code even won't be compiled. So it can't work.

    F.e. you define an array of integer: FANUC_OUT

    then you use FANUC_OUT as a structure FANUC_OUT.bHCodeREQ[i].

    This will not be compiled.

    Your main program

    Code
    --SECTION 4: MAIN PROGRAM
    ------------------------------------------------------------------------------------------------------------------------
    ------------------------------------------------------------------------------------------------------------------------
    BEGIN
    WRITEHM
    END WRITEHM

    doesn't do anything but calling itself, so what other things should this program do instead of nothing?

    Even worse, this is a endless recursive calling, you will get a stack overflow or something similar.

    Display More

    Hello Hermann,

    Sorry I would have created a new thread.

    Exactly, I'm trying to compile the file but have so many errors that it doesn't work. :confused_face:

    That's where I would need your help to fix these errors.

    As mentioned before, I am new to KAREL. I am reading documents and learning through the threads created here.

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
  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