Nested Loops in PC-DMIS

Published by CMMXYZ on August 13, 2020

PC-DMIS Tech Tip : This Tech Tip will teach you how to create a loop within a loop. Nested loops are often used in running multiple parts on a fixture.

In this video, I took a page from our level three training book on loops to show you how to create what's called a nested loop. This is otherwise known as a loop within a loop. My goal with this loop is to create a program on only one part and have it looped in such a way that it will measure all eight parts in the order that I want. What I have is two rows. I want to run the loop so that it measures row one. When it finishes row one, it'll go over to row two, and start the process all over again. Let's open PC-DMIS and I'll show you how it's done.

Here we are in PC-DMIS. I have my one program written. I'll just run it to show you what it is. That's my complete program start to finish, including two tip angles, my alignment features and my measured features. What I need to do now is to loop in two different ways, with two different offsets, I should say. Let's go ahead and start. Let's go to the beginning of the program. I'll start by placing my cursor before the first feature. We've selected our probe, we've selected our tip angle, and then we're just gonna go ahead and loop from this point. This is important in looping, you need to select your start point very carefully. From the menu, we'll go to Insert, Flow Control Command and Looping.

The first thing we need to do is decide how many times to loop. In our example, we're dealing with the first loop that will be inside the nest, loop one, so that will be three parts. This is the the left-hand column, start at one, finish at three. Next we have to say, or tell the software what the offset is. In my case, it's 100 millimeters. That's it. We'll click okay and you'll notice that I have the red lettering, which means there's some sort of a syntax error in my code. There's a problem there. That's expected and this always happens when you start a loop. The error in this case is that my loop has no end. I need a LOOP/START and a LOOP/END. In our case, the LOOP/END is just the end of the program. I'll put my cursor at the end, back to the menu, Insert, Flow Control Command, and we simply select End Loop. That's it. You'll notice also that our code has been indented a bit to indicate that this is all part of a loop. Let's go back to the beginning and also notice that the red lettering is gone.

I'm actually going to rename this feature. We'll call it loop one and just delete the rest there. This will help me explain it and how to stay organized. As it is now if I ran this as a loop, it would just measure the three parts with a 100-millimeter offset. That's my Y offset. The next thing is I need to do the second loop and it's kind of strange, that second loop in the code actually comes first. But that's just the way it works. Let's do our second loop. Insert, Flow Control Command and Looping. This time my end number is actually 2. This is just the second row. Moving over to the right, with an X axis offset of, in this case, 150 millimeters and we'll just say okay to that. And again, we have the red indicating that there's an error. We actually have to do a second loop end. We had to really keep track of all the LOOP/STARTS and the LOOP/END. We'll just do the second one and you'll see a second indent. Now I have a loop inside of a loop, which is actually in this case, loop 2. When PC-DMIS encounters the loops, it will go to the inside loop first, complete that with the 100-millimeter Y offset, and when it's finished, and it reaches the end of the loop for the third iteration, right here, it will go from this point up to the top and go to the outside loop which is loop 2. That's the X axis offset this case of 150 millimeters.

That's the loop inside the loop, otherwise known as a nested loop. Let's just take a look at that. There's my program, so I don't need to run it, I'll just show you the path lines and then you can see that that will work. Under the view option in the menu View, we can just say view path lines and we should see that populate just the way I want it to. There we go. You can see there's our Y offset for part two, it's going to jump to part three. So when part three is done it will go into the outside loop, loop 2 with a X axis offset of 150 millimeters. That'll be part four. There you go. That's working. That's it for the nested loop tutorial. Thanks for joining me, and we'll see you next time.

Related Articles

linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram