Yaskawa DX 200 FOR Loop Issue

  • I am currently using a DX200 controller in which my program is iterating through a set of instructions by the use of a FOR loop which is found within one of my subroutines. It currently looks like this:


    FOR I000 = 4 TO 60

    (STATEMENTS)

    NEXT I000


    The program essentially picks up the 4th part and places it, continuing this process all the way till the 60th part.

    However, once the next batch of parts come in I want it to restart from the beginning and pick up the 1st part - without having to manually change the number 4 to 1 in the subroutine.

    I noticed that the FOR function only accepts a numerical value in the range and thus I wasn't able to use a variable. Hence, I was wondering if there's a way for the numerical value of 4 to automatically be set to 1 after the end of the job?


    I'm fairly new to robotics so I'm not sure if this is a simple fix.

    Thank you!


    (P.S I have written a sample solution to better visualize what I am trying to achieve. I001 is simply an integer variable that I can set)


    FOR I000 = I001 TO 60

    (STATEMENTS)

    NEXT I000

    SET I001 1

  • Thank you very much for your reply, I just have a few questions to clarify:


    1) I'm not very familiar with the SWITCH CASE function so this question may sound quite simple. The I001 can be changed by going into variable and writing a specific value from 1-60 right? This would then look for the corresponding case value and run it?


    2) The line SET I001 4, I understand that now it'll pick up from part 4 to 60 but what if I want to change that. For example, if I wish to do it from part x to 60, where x is any number from 1-60? (It doesn't necessarily have to be 4)

    Would I have to write an individual case for each part?


    3) This is a follow up from the last point but let's say it completes the first case and runs through from part 1 to 60. Does that mean it'll now start from part 4 due to the SET I001 4 lineor does it go straight to ENDSWITCH? I only want it to run another part if the user enters that in the variable.


    Thanks!

  • 1) No. The only instruction( that I know) that you can link to another variable is the IF statement.


    IF Ixxx=Iyyy

    ....

    do something..

    ELSEIF Ixxx=Izzz

    ...

    do something

    ENDIF


    2) Yes. This is the reason I write on top: if you have a small number of batch


    3) So you have a dynamic change of the FOR's start counter : in that case Using IF..ELSEIF or SWITCH..CASE will partially solve your problem, because the FOR remain unlinkable to a variable.


    If you can share the program, maybe me or someone on the forum could have a look and gives you a solution. At this point I'm quite sure that you don't need a FOR.. LOOP but something else like an incremental variable with at least an IF statement with 60 statements.

  • Thank you very much! I seem to understand much more. I just want to ask a final question in regards to the CASE. How would the user choose which CASE to run? Would they simply write a numerical value in the integer variable?


    I would definitely love to share my program but I'm not exactly sure how; should I just type out what I have? Also, thank you for the IF ELSE idea I'll try that out and let you know if it works!

  • Thank you very much! I seem to understand much more. I just want to ask a final question in regards to the CASE. How would the user choose which CASE to run? Would they simply write a numerical value in the integer variable?

    Yes you can do it ( the way I use involves the Interface Panel, but this is another argument).


    Quote

    I would definitely love to share my program but I'm not exactly sure how; should I just type out what I have?

    Use attachments under your message box.

Advertising from our partners