How to make my sub work

More
29 Jun 2018 02:53 #113046 by 64dodge
I have been using linuxcnc for about a year on my little router at home
and like using it but havent tried subs yet.
I program fanuc machines with M98/M99 subs and fadal with L subs.
Cant get my head around using O thru the examples from the 2.7 documentation pdf
to repeat or loop a sub.
Here is an example of a fanuc sub I do to cut a radius / corner round on a part.

O100(MAIN 1/4 RADIUS CORNER ROUND)
T1M6(1/4 2F FLAT ENDMILL)
G0G90G54X.125Y.125S10000M3
G43H1Z.1
G1Z0F50.
G18
M98P101L23
G17
G0G90Z10.
G91G28Y0.
G90
M30

O101(INCREMENTAL RADIUS SUB)
G1G91Y-.025
G2X-.25Z-.25R.25
G1Y-.025
G3X.25Z.25R.25
M99

I would like to be able to do similar with linuxcnc.
The way I see it so far.
Fanuc Linuxcnc
M98 = O101 CALL
M99 = O101 ENDSUB
O101 = O101 SUB
L = ?

I know I will have to play with this but want a little better idea
of what im doing so I want screw up real bad.

Thanks

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

More
29 Jun 2018 03:34 #113050 by 64dodge
Replied by 64dodge on topic How to make my sub work
After some more studying the o repeat looks to be like
similar to maho philips 432 using G14 to repeat code inside
of program.

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

More
29 Jun 2018 03:57 #113051 by Todd Zuercher
You could do it with o101 repeat and o101 endrepeat with the code for your sub between. But if you want to keep your sub as a true sub or a separate file, you would have to use an o call in the repeat.

O-code programming can require a little different way of looking at problems than you might be used to with Fanuc. Especially if you are used to using goto statements and line numbers.

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

More
29 Jun 2018 12:24 #113086 by andypugh
Replied by andypugh on topic How to make my sub work
I don't know how Fanuc works, but I do know several programming languages, so LinuxCNC seems pretty straightforward to me.

I suspect that the fact that LinuxCNC does subroutines like (some) programming languages and Fanuc does it a different way is what is confusing.

In LinuxCNC you define a subroutine with matching O words at the beginning and end, and call it with the same number.
O123 SUB (This is the beginning)
   G1 F20 X100
O123 ENDSUB (this is the end)

Then you can call the subroutine from G-code any time you want
O123 CALL

Additional features to confuse matters include passing parameters, return values, putting the subroutines in different files to the main G-code file and using names rather than numbers for the subroutines.

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

More
30 Jun 2018 03:24 #113120 by 64dodge
Replied by 64dodge on topic How to make my sub work
Thanks guys

Todd
o101 repeat [23]
----
o101 endrepeat

With a [23] for L23 in a fanuc to loop an incremental sub.
Keeping it inside the main program is a plus, less to keep track
of where subs are at. I dont do much macro other than a very rare probe.

Andy
I started out on fadal, there subs are at the beginning of the program L100
Call it with L105 would repeat it 5 times.
Fanuc 3T-18i & Philips 432/532 is what I have been programming for many years now. Fanuc with seperate subs & m98 call thru me at first.
Then maho philips is totally different.
But it seems Linuxcnc is giving you many different ways to do it.

Thank you both

Tim

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

More
30 Jun 2018 11:09 #113129 by andypugh
Replied by andypugh on topic How to make my sub work
To add to the confusion :-)

To run a sub 5 times you would use
O100 SUB
  {Code Here}
O100 ENDSUB

O123 REPEAT[5]
 O100 CALL
O123 ENDREPEAT

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

More
01 Jul 2018 02:31 #113151 by 64dodge
Replied by 64dodge on topic How to make my sub work
Thanks Andy
This old dog is going to learn some new tricks.

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

Time to create page: 0.082 seconds
Powered by Kunena Forum