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

error when using multiple trigger when distance DO X=X+1

  • ML_VS
  • November 26, 2018 at 8:33 AM
  • Thread is Resolved
  • ML_VS
    Trophies
    3
    Posts
    15
    • November 26, 2018 at 8:33 AM
    • #1

    Hello there,

    KRC4 , kuka OPC V8.3.21 HF1 , KR240 , workvisual 4.0.26

    In one of my program, I'm using "trigger when distance" to keep track of which point has been reached by the robot.

    $advance = 2

    Code
    TRIGGER WHEN DISTANCE = 1 DELAY = 0 DO programStepNbr=programStepNbr+1
          ;FOLD PTP P1 CONT Vel=50 % PDAT1 Tool[12]:CNThandling Base[1]:WORLD;%{PE}%R 8.3.38,%MKUKATPBASIS,%CMOVE,%VPTP,%P 1:PTP, 2:P1, 3:C_DIS, 5:50, 7:PDAT1
             $BWDSTART=FALSE
             PDAT_ACT=PPDAT1
             FDAT_ACT=FP1
             BAS(#PTP_PARAMS,50)
             PTP XP1 C_DIS
          ;ENDFOLD
    
    
    
          ;STEP 6 MOVE TO FRONT CNT 2
          TRIGGER WHEN DISTANCE = 1 DELAY = 0 DO programStepNbr=programStepNbr+1
          ;FOLD PTP P2 CONT Vel=50 % PDAT0 Tool[12]:CNThandling Base[1]:WORLD;%{PE}%R 8.3.38,%MKUKATPBASIS,%CMOVE,%VPTP,%P 1:PTP, 2:P2, 3:C_DIS, 5:50, 7:PDAT0
             $BWDSTART=FALSE
             PDAT_ACT=PPDAT0
             FDAT_ACT=FP2
             BAS(#PTP_PARAMS,50)
             PTP XP2 C_DIS
          ;ENDFOLD
    
    
    
          ;STEP 7 MOVE TO FRONT CNT 3
          TRIGGER WHEN DISTANCE = 1 DELAY = 0 DO programStepNbr=programStepNbr+1
          ;FOLD PTP P3 CONT Vel=50 % PDAT0 Tool[12]:CNThandling Base[1]:WORLD;%{PE}%R 8.3.38,%MKUKATPBASIS,%CMOVE,%VPTP,%P 1:PTP, 2:P3, 3:C_DIS, 5:50, 7:PDAT0
             $BWDSTART=FALSE
             PDAT_ACT=PPDAT0
             FDAT_ACT=FP3
             BAS(#PTP_PARAMS,50)
             PTP XP3 C_DIS
          ;ENDFOLD
    Display More

    But, when doing like this, the variable programStepNbr is only incremeted once when the robot reaches P3.

    The only way I could make it work was to change TRIGGER WHEN DISTANCE = 1 DELAY = 0 DO programStepNbr=programStepNbr+1 by TRIGGER WHEN DISTANCE = 1 DELAY = 0 DO programStepNbr=7 , 8 , 9 and so on.

    I suspect it'is due to the advance run (again). Is there an explanation why ?

    Also, sometimes it can happen that 2 following points have the same coordinates (because while programming we put more points than necessary to create the trajectory). How will the "trigger when distance" behave?

    Thank you in advance

  • panic mode
    Reactions Received
    1,267
    Trophies
    11
    Posts
    13,033
    • November 26, 2018 at 1:57 PM
    • #2

    it does exactly what is supposed to do... synchronize action with next motion where DISTANCE decides if it is begin or end of that motion.

    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

  • Online
    SkyeFire
    Reactions Received
    1,040
    Trophies
    12
    Posts
    9,380
    • November 26, 2018 at 2:10 PM
    • #3

    For two points programmed at the same location in space, if each point has an identical TRIGGER command associated with it, the TRIGGERs will probably fire at the same time, but be sequenced by their order -- Probably, the first TRIGGER that the main run pointer encounters will fire first, with the second queued immediately behind it.

    TRIGGER statements are used to 'bypass' the Advance Run Pointer, so I doubt that's your issue. Normally, I would have said that you shouldn't be using a mathematical expression in the DO section of the TRIGGER, but it seems like it's working at least once... odd.

    My best suggestion at the moment is to create a small subroutine that performs the incrementing math, and call that subroutine from each TRIGGER (you will need to explicitly add the PRIO=-1 argument as well). I suspect this will resolve your issue.

  • ML_VS
    Trophies
    3
    Posts
    15
    • November 26, 2018 at 2:42 PM
    • #4

    panic mode , the trigger when distance is working fine, the issue that I have is that, in my example, after playing the 3 ptp points, my variable pragramstepNbr is incremented only once, while it should have been incremented 3 time.

    SkyeFire, thank you, I just tried using a subroutine and now it is working as it should be. Looks like it is indeed due to the mathematical expression in the trigger when distance.

    Anyway, thank you guys!

  • panic mode
    Reactions Received
    1,267
    Trophies
    11
    Posts
    13,033
    • November 26, 2018 at 3:13 PM
    • #5

    maybe... it depends on when and where your variable programStepNbr is used or if you are monitoring it correctly (refresh?)

    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

  • ML_VS
    Trophies
    3
    Posts
    15
    • November 26, 2018 at 4:00 PM
    • #6

    panic mode, the variable is local (defined in the .dat), but for the sake of debugging I removed it from the .dat and made it global (in config.dat). It is only used in this program, not in the sps.
    I didn't do anything else other than using a subprogram with the increment inside to solve the issue.

    and regarding the monitoring, I'm using the built-in variable display on the KCP (I'm working in auto-ext mode).

    Also, while debugging,I saw that if I put a wait sec between points , then there is no problem with the variable increment.

  • panic mode
    Reactions Received
    1,267
    Trophies
    11
    Posts
    13,033
    • November 27, 2018 at 5:12 AM
    • #7

    [size=1em]your $ADVANCE must be 3 or greater.[/size]
    [size=1em]this means all triggers are initialized while first motion is taking place. at THIS moment value is zero for your variable (and each trigger takes a note of it).[/size]

    [size=1em]so each trigger does work but... each of them takes variable value from the moment of initialization, then adds 1 to it. so in this specific example, they all get same result.[/size]

    [size=1em]the best solution is to not do calculations, just do an assignment:[/size]

    [size=1em]trigger .... DO programStepNr = 1[/size]
    [size=1em]trigger .... DO programStepNr = 2[/size]
    [size=1em]trigger .... DO programStepNr = 3[/size]
    [size=1em]etc.[/size]


    [size=1em]EDIT:[/size]


    [size=1em]I am fascinated how often people try to monitor or micromanage each and every motion of the robot, for example have PLC check and bless each and every robot instruction. i find this just crazy, if that is the goal, why not use mxAutomation? even if this had value that i don't see, amount of work and [/size][size=2px]maintainability[/size][size=1em] of programs are not favorable[/size][size=1em]. it would be much simpler to monitor changes of $POS_FOR to increment some "motion counter" variable automatically, without sprinkling entire program(s) with TRIGGER commands or IO instrctions. and that would work with ANY robot program... just saying. or how about $PRO_IP1, or more specifically $PRO_IP1.SNR and $PRO_IP1.SNR_C[/size]

    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

    Edited once, last by panic mode (November 27, 2018 at 5:33 AM).

  • ML_VS
    Trophies
    3
    Posts
    15
    • November 27, 2018 at 8:34 AM
    • #8

    panic mode ok it makes sense now.

    Regarding your comment, if it was a simple motion program I agree with you, but in this case it is a program with motions , collision detection and tool operation inside(which is not a simple gripper). The whole program can be interrupted, so we need to keep track of which step of the program - being a simple motion or a tool operation - was in progress to react accordingly.

    I'm sure there is most certainly an easier way to manage this. I will take a look at those system variables you suggested to see if it can be helpful in our current program structures.

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