Add and Reset value added to a Point

  • I need to add a value in X of a point but I need it to reset to his original value if the Module restarts.

    Right now I have something like "XP1_Alto.X = XP1_Alto.X + (Part_Lengh/2)" but the XP1_Alto.X and at the end of the move I reverse "XP1_Alto.X = XP1_Alto.X - (Part_Lengh/2)"

    Is there other way to do something like this insteed of reserve the operation at the end?

  • MOM

    Approved the thread.
  • don't do that... any time you modify reference data, you are shooting yourself into a foot.

    let the reference data stay as is, create a temporary data and put the manipulated value into temporary data. then you do not have to worry if program was cancelled or robot was powered down at some critical moment.


    Code
    DECL E6POS tmp
    ;...
    
    
    tmp=xP1_Alto
    tmp.x = XP1_Alto.X + (Part_Lengh/2)
    ;...

    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

  • There's multiple ways to handle this. Which method to use depends on your specific needs.


    Panic's example makes a copy of XP1, and manipulates the copy. This way, XP1 does not get altered by the program in a way that could have negative side effects if the program were halted or restarted at the wrong moment.


    Another way would be to use offsets during execution. This is often used for Pick/Drop applications:

    Code
    ; Approach Drop
    PTP {X 0,Y 0,Z 100,A 0,B 0,C 0} : XDrop
    
    ; Drop
    LIN XDrop
    
    ; Depart Drop
    LIN {X 0,Y 0,Z 200,A 0,B 0,C 0} : XDrop

    In this simplistic example, only one point (XDrop) needs to be taught, and if/when it is altered, the Approach and Depart moves follow that change. This can be more convenient than teaching separate Approach, Drop, and Depart points.

  • yes, there are multiple approaches. each with own set of +/-


    for example, when using offset like that, one cannot test different offset values without cancelling and adapting program. if testing and adjustments are needed, it is better to declare offset also as a variable and initialize it before use, then one can make value offset adjustments in same session (using variable monitor etc.), then change initialization only once.


    Code
    DECL FRAME Approach,Depart
    Approach = {X 0, Y 0, Z 100, A 0, B 0, C 0}
    Depart = {X 0, Y 0, Z 200, A 0, B 0, C 0}
    
    PTP Approach:xDrop
    
    LIN xDrop ; this can also be an inline form
    OpenGripper()
    
    LIN Depart:xDrop

    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

  • Can someone confirm whats wrong with doing this? :


    tmp_Alto = XP1_Alto

    tmp_Alto.X = XP1_Alto.X + (Largura_Peca - 79)/2


    SLIN tmp_Alto Vel=2 m/s CPDAT12 Tool[1]:GARRA1 Base[1]:Bancada


    Robot is not moving anywhere close to XP1_Alto (It should be only a few milimiters X+)

  • And whats the value of Largura_Peca?

    Also: is the Inline forme actually using tmp_Alto? If points are created by means of inline forms they usually start with an X in front of the point name. For example


    SLIN P1 Vel=2 m/s CPDAT12 Tool[1]:GARRA1 Base[1]:Bancada


    used the point XP1 declared inside the dat-File. What does your code look like when you expand the inline form? Whats defined in your dat-File?


    Fubini

  • DEF Pegar_Peca( )

    INI
    DECL E6POS tmp_Alto
    DECL E6POS tmp_Baixo
    DECL E6POS tmp_Lateral
    DECL E6POS tmp_Lateral_Alto


    SPTP HOME Vel=100% DEFAULT


    lower_Pos() "It gives the lowerIndex"


    SWITCH lowerIndex


    CASE 1
    tmp_Alto = XP1_Alto (P1_Alto was created Inline)
    Xtmp_Alto.X = XP1_Alto.X + (Largura_Peca-79)/2

    "MOVE TO tmp_Alto already with the X offset"


    tmp_Baixo = XP1_Baixo (P1_Baixo was created Inline)
    Xtmp_Baixo.X = XP1_Baixo.X + (Largura_Peca-79)/2

    "MOVE TO tmp_Baixo already with the X offset"


    tmp_Lateral = XP1_Baixo (P1_Baixo was created Inline. Same as above)
    Xtmp_Lateral.X = XP1_Baixo.X + (Largura_Peca-70)/2

    "MOVE TO tmp_Baixo already with the X offset"


    HOW DO I MOVE TO THOSE POINTS? (DECL in src and not data. I need them to reset after reboot or wtv)

  • HOW DO I MOVE TO THOSE POINTS? (DECL in src and not data.

    Which points? The points with "tmp" in the name?


    That code looks valid, minus the typing errors. What happens when you run that code? What is the value of Largura_Peca when you execute that code? Using XP1_Alto.X + (Largura_Peca-79)/2, if Largura_Peca is 0, you're going to be off by 39.5mm from the taught location of XP1_Alto.


    Protip: post actual program code, not hand-typed copies. Using Code Frames also helps keep posts readable.

  • yup... but only if Largura_Peca is declared as integer

    if it is REAL, division will be same regardless if dividing by 2 or 2.0

    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

Advertising from our partners