- Posts: 9
- Thank you received: 0
Editing gcode subroutine in gmoccappy locks up program
- george4657
- Topic Author
- Offline
- New Member
-
Less
More
10 years 1 week ago #81919
by george4657
Editing gcode subroutine in gmoccappy locks up program was created by george4657
I am trying to learn how to use o g-codes to generate subroutines.
Using linuxcnc 2.8.0 gmoccapy 2.1.0
I am an experienced C programmer trying to learn the syntax for g-code.
When testing while loops I make errors that causes an infinite loop and when I save file I think the program tests for errors and gets in the loop and never comes out.
I then have to crash out of linuxcnc and restart it. I then have to zero xy an z axis before I can try edit again.
My X and Y home are fast but my Z is slow as it has a fine thread drive and an offset for zero.
I there anyway to crash out of the editor without closing cnc program.
Thanks
George
Using linuxcnc 2.8.0 gmoccapy 2.1.0
I am an experienced C programmer trying to learn the syntax for g-code.
When testing while loops I make errors that causes an infinite loop and when I save file I think the program tests for errors and gets in the loop and never comes out.
I then have to crash out of linuxcnc and restart it. I then have to zero xy an z axis before I can try edit again.
My X and Y home are fast but my Z is slow as it has a fine thread drive and an offset for zero.
I there anyway to crash out of the editor without closing cnc program.
Thanks
George
Please Log in or Create an account to join the conversation.
- Todd Zuercher
- Offline
- Platinum Member
-
Less
More
- Posts: 4737
- Thank you received: 1480
10 years 1 week ago #81922
by Todd Zuercher
Replied by Todd Zuercher on topic Editing gcode subroutine in gmoccappy locks up program
Try it with a different ui like axis which uses a separate text editor and see what happens.
Please Log in or Create an account to join the conversation.
- george4657
- Topic Author
- Offline
- New Member
-
Less
More
- Posts: 9
- Thank you received: 0
10 years 1 week ago #81924
by george4657
Replied by george4657 on topic Editing gcode subroutine in gmoccappy locks up program
I set up a new format with axis.
First problem I loaded my test program and it loaded.
I clicked file->edit and bottom of screen filled up with program but I could not edit it. Do I have to setup editor in ini file.
Second problem I loaded a test file I know did not work in gmoccapy and it locked up the axis program also.
This in fact locked up the whole computer so I had to use power button to reboot computer.
I can't see how to add an attachment so i will paste file.
o100 while [#3 LT .1]
; 1 = center X
; 2 = center Y
; 3 = radius
#3 = [#3-1]
M5
g01 x[#1-#3] y[#2] f200
M3
g02 x[#1 +#3] y[#2] i[#3] j[0]
g02 x[#1-#3] y[#2] i[-#3] j[0]
#3 = [#3-1]
m5
o100 endwhile
g21
g90
g01 x0y0 f200
o100 call [0][10][10]
o100 call [0][20][9]
o100 call [10][10][8]
o100 call [10][20][7]
m2.
First problem I loaded my test program and it loaded.
I clicked file->edit and bottom of screen filled up with program but I could not edit it. Do I have to setup editor in ini file.
Second problem I loaded a test file I know did not work in gmoccapy and it locked up the axis program also.
This in fact locked up the whole computer so I had to use power button to reboot computer.
I can't see how to add an attachment so i will paste file.
o100 while [#3 LT .1]
; 1 = center X
; 2 = center Y
; 3 = radius
#3 = [#3-1]
M5
g01 x[#1-#3] y[#2] f200
M3
g02 x[#1 +#3] y[#2] i[#3] j[0]
g02 x[#1-#3] y[#2] i[-#3] j[0]
#3 = [#3-1]
m5
o100 endwhile
g21
g90
g01 x0y0 f200
o100 call [0][10][10]
o100 call [0][20][9]
o100 call [10][10][8]
o100 call [10][20][7]
m2.
Please Log in or Create an account to join the conversation.
- Todd Zuercher
- Offline
- Platinum Member
-
Less
More
- Posts: 4737
- Thank you received: 1480
10 years 1 week ago - 10 years 1 week ago #81925
by Todd Zuercher
Replied by Todd Zuercher on topic Editing gcode subroutine in gmoccappy locks up program
I think axis is still set up to use gedit as the default editor. You'll either have to install gedit or edit your ini to choose a different editor.
Now to look at your code. To start with, I don't think you can call your while loop code as a sub program, I think you may need to set up a sub program to contain your while loop, then call that.
Next I'm not sure what this is supposed to do
Are they comments? if so they should be in () as far as I know G-code doesn't use : for anything.
G-code is much simpler than C. The while/endwhile loop, just first performs the test and if true executes the g-code within and repeats.
So as I see it I think you are aiming more for something like this
Now to look at your code. To start with, I don't think you can call your while loop code as a sub program, I think you may need to set up a sub program to contain your while loop, then call that.
Next I'm not sure what this is supposed to do
Code:
; 1 = center X
; 2 = center Y
; 3 = radius
G-code is much simpler than C. The while/endwhile loop, just first performs the test and if true executes the g-code within and repeats.
So as I see it I think you are aiming more for something like this
Code:
o200 sub
o100 while [#3 GT .1]
(#1 = center X)
(#2 = center Y)
(#3 = radius)
g01 x[#1-#3] y[#2] f200
M3
g02 x[#1 +#3] y[#2] i[#3] j[0]
g02 x[#1-#3] y[#2] i[-#3] j[0]
#3 = [#3-1]
m5
o100 endwhile
M5
g01 x[#1-#3] y[#2] f200
o200 endsub
g21
g90
g01 x0y0 f200
o200 call [0][10][10]
o200 call [0][20][9]
o200 call [10][10][8]
o200 call [10][20][7]
m2.
Last edit: 10 years 1 week ago by Todd Zuercher.
Please Log in or Create an account to join the conversation.
- george4657
- Topic Author
- Offline
- New Member
-
Less
More
- Posts: 9
- Thank you received: 0
10 years 1 week ago #81927
by george4657
Replied by george4657 on topic Editing gcode subroutine in gmoccappy locks up program
From doc's ; ok
" Comments can be embedded in a line using parentheses () or for the remainder of a line using a semi-colon"
Doc's for while loop do not show it embedded in an other routine but this explains error "no file <o100> found" when calling while loop o100
Tested below code
-- crash from infinite loop ----
o200 sub
o100 while [#3 GT .1]
G01 x 40
o100 endwhile (would never be below .1 if all with value > .1)
o200 call[10]
---- same code loop fails test so no infinite loop so no crash ----
o200 sub
o100 while [#3 LT .1] (have to remember LT is Less than not Larger than)
G01 x 40
o100 endwhile (would never run as first loop < .1 so no error)
o200 call[10]
It is good that editor catches this error as you would not want an infinite loop to run on your cnc machine but I wish there was a way to exit editor or have editor time out.
Is there a simulator program I can use for code visualization rather than use actual linuxcnc?
" Comments can be embedded in a line using parentheses () or for the remainder of a line using a semi-colon"
Doc's for while loop do not show it embedded in an other routine but this explains error "no file <o100> found" when calling while loop o100
Tested below code
-- crash from infinite loop ----
o200 sub
o100 while [#3 GT .1]
G01 x 40
o100 endwhile (would never be below .1 if all with value > .1)
o200 call[10]
---- same code loop fails test so no infinite loop so no crash ----
o200 sub
o100 while [#3 LT .1] (have to remember LT is Less than not Larger than)
G01 x 40
o100 endwhile (would never run as first loop < .1 so no error)
o200 call[10]
It is good that editor catches this error as you would not want an infinite loop to run on your cnc machine but I wish there was a way to exit editor or have editor time out.
Is there a simulator program I can use for code visualization rather than use actual linuxcnc?
Please Log in or Create an account to join the conversation.
- Todd Zuercher
- Offline
- Platinum Member
-
Less
More
- Posts: 4737
- Thank you received: 1480
10 years 1 week ago - 10 years 1 week ago #81928
by Todd Zuercher
Replied by Todd Zuercher on topic Editing gcode subroutine in gmoccappy locks up program
Huh, learn something new every day. (regarding using colon for comments)
That is because the docs are showing using a while loop, not using a while loop as a subroutine.
Most of the G-code simulators/backplots I've played with usually barf on most subprograms, loops, or parametric programing. partly because most every control manufacturer/G-code dialect handles that stuff a little different.
I think this one camotics.org/ is derived at least partially from Linuxcnc code and does a better job than most with parametric programming.
That is because the docs are showing using a while loop, not using a while loop as a subroutine.
Most of the G-code simulators/backplots I've played with usually barf on most subprograms, loops, or parametric programing. partly because most every control manufacturer/G-code dialect handles that stuff a little different.
I think this one camotics.org/ is derived at least partially from Linuxcnc code and does a better job than most with parametric programming.
Last edit: 10 years 1 week ago by Todd Zuercher.
Please Log in or Create an account to join the conversation.
Time to create page: 0.101 seconds