Best practice for looping

  • Hello,

    I have a job that uses a loop around a CASE statement. When this runs on a DX100, it is very erratic and indeterministic without the .05 sec timer. Sometimes it seems to hang for random time periods.

    When I add the timer it runs reasonably well, but still seems like it should be faster. Is this happening because it is looping so fast that it can't service the CASE statement and the setting of variables?

    Is there a better way to address this besides the timer? I have seen plenty of looping examples on this forum that don't include a timer. I would assume they work fine.


    SET I003 0


    TIMER T=0.05

    SWITCH I003 CASE 1

    MOVL P001 V=800.0


    SET I003 2

    CASE 4

    CNVRT PX0025 PX0024 UF#(30) TL#(23)

    SET I003 5

    CASE 6

    SET I003 0






    Thanks for helping.

  • Place your Ad here!
  • massula

    Approved the thread.
  • I’ve got some ideas but without posting the actual code I don’t know what to suggest.

    This code doesn’t do much of anything. What is manipulating I000 the first time around.

    Set I003 0

    Fall through the label first time around.

    Execute the timer.

    Switch I003 which is 0 and no Case 0.

    Fall through to the Endswitch.

    Jump to the label.

    I know a thing or two, because I’ve seen a thing or two. Don't even ask about a third thing. I won't know it.

  • This is the actual code.

    There is a MotoCom application running on a PC that is writing the values and handshaking with it.

    It starts at 0 and loops until the MotoCom application sets I003=1.

    Can you typically execute a loop like this without needing a timer?

  • Yes, I (we) would execute a loop like this without timer.

    Whoever wrote PC application left an error in it, missing CASE 0 or DEFAULT in this case is the error. I003 counter should be reset to 1, if the programmer decided to not use CASE 0 or DEFAULT. Although it is up to the person who does robot commissioning to find and fix these type of bugs.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account
Sign up for a new account in our community. It's easy!
Register a new account
Sign in
Already have an account? Sign in here.
Sign in Now

Advertising from our partners