Multiple O103 repeat [n] in a single file

More
10 Dec 2018 00:47 #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 or Create an account to join the conversation.

More
10 Dec 2018 03:48 #122126 by Todd Zuercher
Replied by Todd Zuercher on topic Multiple O103 repeat [n] in a single file
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 or Create an account to join the conversation.

More
11 Dec 2018 12:52 - 11 Dec 2018 12:57 #122205 by thadwald
Replied by thadwald on topic Multiple O103 repeat [n] in a single file
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?
Last edit: 11 Dec 2018 12:57 by thadwald.

Please Log in or Create an account to join the conversation.

More
11 Dec 2018 14:42 #122209 by Todd Zuercher
Replied by Todd Zuercher on topic Multiple O103 repeat [n] in a single file
You can have multiple repeats in a program, but they each have to use a different o-number. Same with other o-commands.
The following user(s) said Thank You: thadwald

Please Log in or Create an account to join the conversation.

More
11 Dec 2018 14:52 #122210 by thadwald
Replied by thadwald on topic Multiple O103 repeat [n] in a single file
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 or Create an account to join the conversation.

More
11 Dec 2018 15:00 - 11 Dec 2018 15:07 #122213 by Todd Zuercher
Replied by Todd Zuercher on topic Multiple O103 repeat [n] in a single file
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).
#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
Last edit: 11 Dec 2018 15:07 by Todd Zuercher.
The following user(s) said Thank You: thadwald

Please Log in or Create an account to join the conversation.

More
11 Dec 2018 15:03 #122214 by Todd Zuercher
Replied by Todd Zuercher on topic Multiple O103 repeat [n] in a single file

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.
The following user(s) said Thank You: thadwald

Please Log in or Create an account to join the conversation.

More
14 Dec 2018 13:23 #122416 by andypugh
Replied by andypugh on topic Multiple O103 repeat [n] in a single file

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 or Create an account to join the conversation.

Time to create page: 0.106 seconds
Powered by Kunena Forum