Adapting Clough42's Keyway Broach code - subroutine/o-word newbie

More
16 Apr 2021 16:52 #206113 by freemoore
Hi all,

I'm trying to use Clough42's cnc shaping ideas (as in this video:
) to cut keyways on my mill.

Attached is what I've got so far. I can't get the subroutine to happen. If I comment out this line:

48 o<plunge> call

then the file loads without error but ignores the repeat.

If I leave that line in, as I'm expecting to have to do to call the subroutine in the first place, running the file gives this error:

EOF in file:/home/freemoore/Desktop/GenericKeywayForLCNCSeparate.ngc seeking o-word: o<plunge> from line: 48

I must be missing something basic about the syntax of calling o-words. Is the sub supposed to be in a separate file, in a separate folder, or should it work with everything in one file?
Attachments:

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

More
16 Apr 2021 21:01 #206137 by JohnnyCNC
Did you edit the file on a windows machine? Your file has CRLFs line endings and it should just be LF.

Here is my file and it works. This was a fun project and works great.
(Cut a keyway in a bore with a vertical shaping tool)
(Spindle is zeroed on the center of the bore)
(Keyway is cut on the positive Y side)
(2018 Clough42 - clough42.com)
(For more information: https://youtu.be/cRve86xZbrw)

(parameters)
#1   = 0.236            (key width - b)
#2   = 0.110            (keyway depth - t2)
#3   = 0.748            (shaft diameter - d)
#4   = 0.123            (cutter width)
#5   = 0.406            (cutter length +y from spindle center)
#6   = 0.100            (top of stroke)
#7   = -1.700           (bottom of stroke)
#8   = 0.002            (depth of cut - per stroke)
#9   = 0.001            (x spring compensation)
#10  = 0.002            (y spring compensation)
#11  = 75               (plunge feedrate)

(calculated)
#100 = [#3 / 2]                             (shaft radius)
#101 = [#1/2]                               (half of key width)
#102 = [[#1-#4]/2]                          (x offset - half of key width minus cutter width)
#103 = FIX[[SQRT[[#100*#100]-[#101*#101]] - #5]] (starting Y position - Pythagorus FTW)
#104 = [#100 + #2 + #10 - #5]               (ending y position)
#105 = [#104 - #103]                        (total y feed)
#106 = [#105 / #8]                          (number of loops)


(main program)
G90 G94 G17 G91.1       (LinxCNC)
G20                     (LinxCNC inches)
G54                     (LinxCNC select coordinate system)

#200 = #103             (y position)
G0 X0 Y#200             (move to zero X and starting Y)
G0 Z#6                  (move Z to top of stroke)
M98 P0002 L#106         (run the plunge multiple times)
M30                     (end and rewind)
(subprogram for individual plunge)
O0002
G0 Y#200                (move to Y position)
G0 X[#102 + #9]         (move X to one side)
G1 Z#7 F#11             (plunge)
G0 Z#6                  (retract)
G0 X[0 - #102 - #9]     (move X to other side)
G1 Z#7 F#11             (plunge)
G0 Z#6                  (retract)
#200 = [#200 + #8]      (increment Y position)
M99
The following user(s) said Thank You: freemoore

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

More
16 Apr 2021 21:27 #206139 by freemoore
Thanks for your answer & example - I just got in from the workshop having managed to get the program working, but left the usb stick with it on, inside. Will come back later and post my working code, which is split into two files (probably unnecessary). I lost a square bracket from the equation for #103 when I was mucking around with the code, and put it back in the wrong place which led to it evaluating differently and resulting in no passes.

What is the function of FIX in that line as you have it? Mine works without.
Also the reason for mucking around with it, was that LCNC threw an error about the M98 so I spent a chunk of today on the o-word doc pages before I found the bracket error.

Edited files in sublime text and textedit on both mac and linux, no intentional line-ending settings from me.

It is a fun project! Now my mill is a mini-shaper too (thank you Clough42!)

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

More
16 Apr 2021 22:08 #206140 by andypugh
The G-code is so trivial that I didn't bother to post it, but it's easy on a lathe too:

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

More
16 Apr 2021 23:35 #206149 by JohnnyCNC

Thanks for your answer & example - I just got in from the workshop having managed to get the program working, but left the usb stick with it on, inside. Will come back later and post my working code, which is split into two files (probably unnecessary). I lost a square bracket from the equation for #103 when I was mucking around with the code, and put it back in the wrong place which led to it evaluating differently and resulting in no passes.

What is the function of FIX in that line as you have it? Mine works without.
Also the reason for mucking around with it, was that LCNC threw an error about the M98 so I spent a chunk of today on the o-word doc pages before I found the bracket error.

Edited files in sublime text and textedit on both mac and linux, no intentional line-ending settings from me.

It is a fun project! Now my mill is a mini-shaper too (thank you Clough42!)


The FIX function rounds down to an integer but I never looked into why it is need there. I just used Clough42's code and change the parameters to fit my machine/job. I may have changed/added some comments to aid my feeble brain but otherwise just used it,

Since you found the missing bracket to be the cause is appears that the EOL markers are not an issue.

John
The following user(s) said Thank You: freemoore

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

Time to create page: 0.073 seconds
Powered by Kunena Forum