Multiple O103 repeat [n] in a single file

More
7 years 10 months ago #122124 by thadwald
I am using the O103 repeat[n] function to do some repetitive incremental moves. This works fine until I try to use a second O103 in the program. Then i get an error saying “error duplicate o-word o103.”

What am I doing wrong?

Please Log in to join the conversation.

More
7 years 10 months ago #122126 by Todd Zuercher
While you can call an o sub multiple times (same o number), but an o repeat command can only be used once in a g-code program. To do multiple repeat commands you will have to use a unique number for each repeat call that you use in a g-code program.

To do what I think you want to do I would suggest putting your repeat within an o sub, then call the o sub repeatedly throughout your g-code program.

Please Log in to join the conversation.

More
7 years 10 months ago #122205 by thadwald
Your suggestion to place the repeat into an o code would work for this particular program. But suppose I wanted to write a program with multiple repeats, each of which is different. How would I approach this? Will either of the other two looping commands (while/endwhile, do/while)let me create multiple loops in one program?

Please Log in to join the conversation.

More
7 years 10 months ago #122209 by Todd Zuercher
You can have multiple repeats in a program, but they each have to use a different o-number. Same with other o-commands.

Please Log in to join the conversation.

More
7 years 10 months ago #122210 by thadwald
Well!

Thank you for pointing that out. I'll try that.

If I may ask, what then is the purpose of the o-number?

Please Log in to join the conversation.

More
7 years 10 months ago #122213 by Todd Zuercher
For example here is an array repeat that will make rows and colums of some code using 2 repeat commands (one nested inside the other).
Code:
#1=3 (number of items on Y) #2=5 (number of items on X) #3=2.38 (column spacing for X) #4=23.5 (row spacing for Y) O100 sub (insert some g-code you want repeated here) O100 endsub O102 repeat [#1] (number of rows Y repeats) O103 repeat [#2] (number of columns X repeats) O100 call G0 X#3 Y0 (width of columns) G92 X0Y0 O103 end repeat G0 X[#3*-#2] G92X0 G0 X0 Y#4 (length of rows) G92 X0Y0 O102 endrepeat G92.1

Please Log in to join the conversation.

More
7 years 10 months ago #122214 by Todd Zuercher

thadwald wrote: Well!

Thank you for pointing that out. I'll try that.

If I may ask, what then is the purpose of the o-number?


I believe the main purpose of the o-number is to tie the repeat to the endrepeat so that you can use more than one repeat command.

Please Log in to join the conversation.

More
7 years 10 months ago #122416 by andypugh

thadwald wrote: If I may ask, what then is the purpose of the o-number?


G-code is a script, originally intended to be read line-by-line. Because of this the interpreter makes some assumptions, and is not particularly aware of syntax.
This means that pairing-up sub/endsub, if/then/else wasn't ever considered. So when the O-word branching add-ins were developed it was decided to take the easy way out and give the job of pairing up the tags to the programmer instead.

So, when the system finds an O111 ENDREPEAT all that interpreter has to do is search the text file for O111 REPEAT and set it's line-pointer back to there.

Please Log in to join the conversation.

Time to create page: 0.123 seconds
Powered by Kunena Forum