Adjusting TOOL_DATA

  • Right now I have a program that calculates the lenght of a tool over the z axis and it loads this into a database. However I want to adjust the TCP of the tool on the XYZ and orientation location with this toollenght. This is because the toolholder is mounted to the 6 axis with around 30 degrees offset. So every new tool loaded into the program will have a different TCP because of this offset. I can calculate the needed data however I dont know how to load these coördinates into TOOL_DATA[1]. This is what i thought would work but im getting compiling errors back. So how do i adjust the TOOL_DATA[1] with new coördinates that I calculated.


  • You can not use variables in aggregates like this:


    TOOL_DATA[1]={X ToolX, Y ToolY, Z ToolZ, A ToolA, B ToolB, C ToolC}


    You need to assign them individually


    TOOL_DATA[1].X = ToolX

    TOOL_DATA[1].Y = ToolY

    ...


    And btw but probably not my business: why not using the geometric operator ":" for your tool shifts?


    Fubini


  • Aaaah ofcourse! thankyouuu. I wasnt aware that those exist im still quite new to KLR programming. however when I use ":" it gives me the error message that "=" is expected... And when i use "=" it gives me the error that there is no structure data type...


  • Quote

    however when I use ":" it gives me the error message that "=" is expected... And when i use "=" it gives me the error that there is no structure data type...

    Probably as before just a syntax issue. Did you use it like e.g. this


    NewFrame = OldFrame : {X 0, Y 0, Z 0, A 0, B 0, C 60}


    It rotates X-Axis by 60 degrees. Of course if you have variables you still need to assign them individually. Then its something like this


    myVal = 60.0

    Shift.X = 0

    Shift.Y= 0

    Shift.Z= 0

    Shift.A = 0

    Shift.B= 0

    Shift.C= myVal

    NewFrame = OldGrame : Shift


    Fubini

  • I have applied it like the second methode. I have checked multiple times for spelling mistakes however i still get the error message "OldFrame invalid value" when i try to run the code and it reaches: "Tool_Data1=OldFrame:AdjustedTool.

    I have declared: Tool_Data1, AdjustedTool and OldFrame. In the USER INI section as shown below. I just cant seem to find out why its not uploading the data to: Tool_Data1, AdjustedTool and OldFrame....

  • Quote
    Code
    Tool_Data1 = {X 0, Y 0, Z 0, A 0, B 0, C 0}
    
    AdjustedTool = {X 0, Y 0, Z 0, A 0, B 0, C 0}
    
    OldFrame = {X 0, Y 0, Z 0, A 0, B 0, C 0}

    You are missing to specify the type of these variables. You should use FRAME type. Try what happens if you use


    Code
    FRAME Tool_Data1 = {X 0, Y 0, Z 0, A 0, B 0, C 0}
    ...


    Not sure what the default data type in KRL is. In older KRC version it was possible to declare a variable without specifying the type. But still its bad practice and was removed in newer version afaik.


    Also in KRL declarations have to be added before any code so you should move the declaration before the INI fold.



    Code
    DEF ...
    FRAME Tool_Data1 
    INI ...
    Tool_Data1 = {X 0, Y 0, Z 0, A 0, B 0, C 0}


    Fubini

  • Oh sorry. Mist on your usage in another subroutine. Where exactly are the variables declared? They need either to be global if used in multiple subroutines or you need to pass them as paramatersto your subroutine.


    Every variable has a scope where it is valid. This scope depends on where it is declared.

  • Thankyou for you advise, i have adjusted it so that I have my decelrations above my INI and I give their values in the INI. And now i have a error that is i presume connected to your last message :smiling_face:. The error that I get is: "Runtime data of the main program cannot be used". I assume that in my DAT. file I have to declare them as global?


    I have adjusted my DAT. file and added global valuables as such however I still get the same error notfication.


    I tried declaring them in Convig.dat but that didnt do anything


    Code
    DECL GLOBAL REAL ToolX=0.0
    DECL GLOBAL REAL ToolY=0.0
    DECL GLOBAL REAL ToolZ=0.0
    
    DECL GLOBAL REAL ToolA=30.14263
    DECL GLOBAL REAL ToolB=89.8666
    DECL GLOBAL REAL ToolC=0.0

    Edited 3 times, last by martenH: deleted a stupid comment of myself ().

  • Just to be sure could you share your current version of src and dat file. I suspect you have them declared multiple times now. Once in dat once in src and maybe also still in $config.dat.


    Btw you should try to read system integrators manual where all of this we talked about by now is explained.


    Fubini

  • Thankyou for checking, I dont think I have tho.... I deleted them from the CONFIG.dat again so that shouldent be a problem anymore. I have the expert manual infront of me but I just cant work it out what im doing wrong it all looks like its correct...


  • I have made the adjustments and moved them over to the Dat file now it says Datalist not public. i have declared them as;


    FRAME GLOBAL Tool_Data1

    FRAME GLOBAL AdjustedTool

    FRAME GLOBAL OldFrame


    After this I added public to the header of my Dat file and now it geves me multiple random errors in my sub routinne.... such as:


    dual decleration (got rid of this one)

    name expected (gor rid of this one)

    instruction not in instruction section (got rid of this one)


    It only gives me a "name expected" on my declecration in the DAT.file


    Code
    FRAME GLOBAL Tool_Data1
    
    FRAME GLOBAL AdjustedTool
    
    FRAME GLOBAL OldFrame

    changed it to DECL GLOBAL FRAM etc. that seems to do the trick

    Edited 4 times, last by martenH: figured some stuff out ().

  • I now only have a "datalist not PUBLIC" error. this is my current code I have declared in my DAT.file that it is public but it still doesnt recognize it.


  • thankyou for you reply I have added your suggestion to the bottom of my Dat.file however it still gives me the error "datalist not PUBLIC"


  • because that is not a valid KRL file.


    first line MUST contain


    DEFDAT MODULENAME

    or

    DEFDAT MODULENAME PUBLIC


    see the word "PUBLIC" in thre?




    and the last line MUST be:


    ENDDAT


    moreover, file cannot have more than one DEFDAT or ENDDAT

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

  • Sorry for the miss understanding, I tried to just write PUBLIC behind the DAT.file however it still doesnt recognize the datalist. So i thought to just add it to the end but that doenst do anything different. This is my current DAT.file. Or do I add your "myGlobal" separated from my main DAT.file?

    Edited 2 times, last by martenH ().

  • Noo it is a place where is store the xyz abc coordinates i added this to the DAT.file, and now it uploads new calculated files :

    Code
    DECL GLOBAL FRAME Tool_Data1 = { X 0, Y 0, Z 0, A 0, B 0, C 0}
    DECL GLOBAL FRAME AdjustedTool = { X 0, Y 0, Z 0, A 0, B 0, C 0}
    DECL GLOBAL FRAME OldFrame = { X 0, Y 0, Z 0, A 0, B 0, C 0}

    Apperently I was getting errors because of old Dat files that for som reason gave me duplication errors... very annoying. when i deleted all the files and had only one file on the KR2C it worked

Advertising from our partners