o codes

More
10 Apr 2016 20:21 #73075 by norbertfarquharsh
o codes was created by norbertfarquharsh
Hello,

Trying a first program with subroutines and looping and conditional statements.
Persistent error is "Unknown control command in o word."

I have tried whatever I could think of with no success. It is pointing to the subroutine call, I believe,
but am not certain after various commenting out and changing lines.

I would appreciate and help on the listing below.

%
G17 G20 G40 G49 G54 G80 G90 G94
#35=2.1250
#38=27.4000
/o100 DO
o101 WHILE [#35 LT 7.6250]
#36=[-SQRT[33.0625-[#35]*[#35]]]
G0 X[#35] Z[#36]
G0 Y[#38]
#35=[#35 + 0.5000]
o110 SUB
o111 IF[#38 GT 25]
o111 #38 = 0
o111 ELSEIF [#38 EQ 0]
o111 #38 = 27.4000
o111 ENDIF
o110 ENDSUB
o110 CALL
/o100 WHILE [#35 LT 7.6250]
o101 ENDWHILE
M2

%

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

More
10 Apr 2016 20:49 #73078 by BigJohnT
Replied by BigJohnT on topic o codes
Right off the bat you don't need % and M2, M2 is preferred.
You only put o100 before the if, elseif, and endif. It also looks like an endless loop with the o110 call. I don't think you can have a sub inside a while loop.
o100 sub
G53 G0 X0 Y0 Z0 (rapid move to machine home)
o100 endsub
; notice the call is outside the loop
o100 call (call the subroutine here)
M2

JT

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

More
11 Apr 2016 13:01 #73099 by norbertfarquharsh
Replied by norbertfarquharsh on topic o codes
To JT from another JT.

But my JT name is a Joe with a last name that is so common that I can never use any part of it as it is already used. So I use the user name that I came up with and it has always worked. But I cannot make my program work.

Thank you very much for your reply. I cleaned up as you suggested and also determined that it did not seem to require the
subroutine so I removed that whole call. However, it is still throwing that same error: Unknown control command in o word. The error statement points to the line with the ELSEIF command. Again I have tried different edits to try to figure it out but it is beyond me. Maybe I do not understand what is allowed within a loop as you mention.
I will paste a new copy of the code below.
And thanks again for your comments and help.
JT

G17 G20 G40 G49 G54 G80 G90 G94
#35=2.1250
#38=27.4000
o100 DO
#36=[-SQRT[33.0625-[#35]*[#35]]]
G0 X[#35] Z[#36]
G0 Y[#38]
#35=[#35 + 0.5000]
o111 IF [#38 GT 25]
o111 #38 = 0
o111 ELSEIF [#38 LT 5]
o111 #38 = 27.4000
o111 ELSE
o111 GO TO 999
o111 ENDIF
o100 WHILE [#35 LT 7.6250]
N999 M2

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

More
11 Apr 2016 13:16 #73101 by BigJohnT
Replied by BigJohnT on topic o codes
The o111 only goes with if, elseif, else, and endif.
o100 if x eq 2
some G code
more G code
even more G code
o100 endif

Take a look at the examples in the manual.

JT

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

More
11 Apr 2016 16:07 #73121 by norbertfarquharsh
Replied by norbertfarquharsh on topic o codes
JT

Thanks again for your reply and assistance. And, yes, I should look at the examples and understand all that it is saying and once I did what you told me, it worked. I look at the examples and do not pick up all that they are saying as it is not explicit enough for a goof like me.
It still does not work as now there are other problems but I am not going to ask about them at this point as they are no doubt other mistakes that I cannot see and I will try to work them out.
Thanks for your patience.

JT

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

More
12 Apr 2016 13:27 #73164 by norbertfarquharsh
Replied by norbertfarquharsh on topic o codes
JT

Thanks again for your help and patience.
I feel so stupid as I just cannot get this stuff. I built this machine to learn G code and have written some programs but each time I write one, I try to learn some new subject(s), but this has been the worst so far. I am going to paste on the latest revision and ask a few questions.

Using this program, the X and Y axes perform as the program directs them. The Z axis is supposed to move in calculated proportion to the movement of the X axis. The Z axis does not move and that is main problem. But there have been and still are other problems in reaching this point.
See comments below,

Thanks again.
JT


G0 X2.1250
#31 = 0.0500
#38 = 27.4000
o100 DO
#31 = [#31 + 0.05000]
G0 X[#31 + 2.1250]
#44 = [#5420**2] These lines containing #44 through #48 were written to perform the same function as the commented out
#45 = [33.0625 - #44] line below with the added function of trying to negate the value as the Z axis movement is required to
#46 = [SQRT [#46]] be negative. This proves to me that I am doing something incorrectly in the line below but I cannot see it.
#48 = -1] * [#46
G0 Z[#48]
/G0 Z[SQRT[33.0625-[#5420**2]]] This line is commented out as it throws errors saying it is feeding a negative value to the SQRT
G0 Y[#38]
o111 IF [#38 GT 25]
#38 = 0
o111 ELSEIF [#38 LT 5]
#38 = 27.4000
o111 ELSE
GO TO 999
o111 ENDIF
o100 WHILE [#5420 LT 7.6250]
N999 M2

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

More
12 Apr 2016 13:53 #73165 by BigJohnT
Replied by BigJohnT on topic o codes
#48 the brackets are backward. No need for N numbers.

Use the debug function to see what the value of a variable. Break down each item and check the variable value as you go along.
#50 = [SQRT[33.0625-[#5420**2]]]
(debug,#50)
M2

JT

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

More
13 Apr 2016 04:47 #73212 by Rick G
Replied by Rick G on topic o codes
Normally to comment out a line you would use a; or ( )
linuxcnc.org/docs/html/gcode/overview.html#gcode:comments

A / is optional block delete...

2.1. Block Delete
The optional block delete character the slash / when placed first on a line can be used by some user interfaces to skip lines of code when needed. In Axis the key combination Alt-m-/ toggles block delete on and off. When block delete is on any lines starting with the slash / are skipped.

linuxcnc.org/docs/html/gcode/overview.html

Rick G

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

More
13 Apr 2016 20:32 #73247 by norbertfarquharsh
Replied by norbertfarquharsh on topic o codes
Thank you both for your comments. Slowly making progress with help and reading the manual.

Joe

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

Time to create page: 0.082 seconds
Powered by Kunena Forum