inns and outs of words an remapps
15 Sep 2020 04:50 #182184
by JR1050
inns and outs of words an remapps was created by JR1050
I have a lathe with a 4 sided tool probe( there is another thread on it). My idea is to use an Mcode with a couple variables to make a decision on which side of the probe will be used. The program is a Gcode program, intially written in faunuc macro (the result was lcnc spitting it out), so I attempted to write it as a user m code, which also didn't work( my guess is they have to have shell commands in them). My next try was remapped m code, which gave no errors and also did nothing.
There idea is to call this from mdi , M175 p-1 q0, which will probe the tip of an od turning tool in this case.
The section on O words and their rules is sparse on info, does every else state meant have to have an o-label ? Does every if statement have to end in endif ? Im used to using goto statements in standard macro or case in C, idea being that the code will fall through until it hits the correct function . Does every if and else need an o word label? Can I use multiple else's to let the code fall through until it sees a true condition? Does this require an o-call in it somewhere?
I set the paths in my ini and the remap, id post it, but its on a different flash drive... suggestions?
There idea is to call this from mdi , M175 p-1 q0, which will probe the tip of an od turning tool in this case.
The section on O words and their rules is sparse on info, does every else state meant have to have an o-label ? Does every if statement have to end in endif ? Im used to using goto statements in standard macro or case in C, idea being that the code will fall through until it hits the correct function . Does every if and else need an o word label? Can I use multiple else's to let the code fall through until it sees a true condition? Does this require an o-call in it somewhere?
I set the paths in my ini and the remap, id post it, but its on a different flash drive... suggestions?
o<m175> sub
(PROBE X OD TOOL USE P)
O101 if[#<p>=-1]
#102=-1.8031 (XOFFSET)
G49G94
G91
G38.2 X-.2 F5.
G0X.2
G38.2 X-.2 F5.
#101=[#5061+#102]
G0X.2
G90G49
G10 L1 P#5400 X#101
#<p>=0 #<q>=0
else
(PROBE X ID TOOL)
if[#<p>=1]
#103= 2.13 (XOFFSET)
G49G94
G91
G38.2 X.2 F5.
G0X-.2
G38.2 X.2F5.
#101=[#5061+#103]
G0Z.2
G90G49
G10 L1 P#5400 X#101
#<p>=0 #<q>=0
else
(PROBE Z FRONT OF TOOL USE Q)
if[#<q>=-1]
#104=-6.6714 (ZOFFSET)
G49G94
G91
G38.2 Z-.2F5.
G0Z.2
G38.2 Z-.2F5.
#101=[#5063+#104]
G0Z.2
G90G49
G10 L1 P#5400 Z#101
#<p>=0 #<q>=0
else
(PROBE Z LEFTHAND TOOL USE Q)
if[#<q>=1]
#105=-4.674 (ZOFFSET)
G49G94
G91
G38.2 Z.2F5.
G0Z-.2
G38.2 Z.2F5.
#101=[#5063+#105]
G0Z-.2
G90G49
G10 L1 P#5400 Z#101
#<p>=0 #<q>=0
O101 endif
#<p>=0 #<q>=0
M30
o<m175> endsub
Please Log in or Create an account to join the conversation.
15 Sep 2020 09:15 - 15 Sep 2020 11:06 #182196
by MaHa
Replied by MaHa on topic inns and outs of words an remapps
If you do o<m175> call [-1] [0] then in the subroutine it is #1, #2
Insert in the subroutine
O101 if[#<p>=-1] and similar: replace `=` by `EQ`
also change this and similar
to
place M30 or M2 after o<m175> endsub
If the logic don`t work, you could try
Insert in the subroutine
#<p> = #1
#<q> = #2
O101 if[#<p>=-1] and similar: replace `=` by `EQ`
also change this and similar
else
(PROBE X ID TOOL)
if[#<p>=1]
to
(PROBE X ID TOOL)
O101 elseif[#<p> EQ 1]
place M30 or M2 after o<m175> endsub
If the logic don`t work, you could try
O101 if[[#<p> EQ -1] and [ABS[#<q>] NE 1]]
Last edit: 15 Sep 2020 11:06 by MaHa.
The following user(s) said Thank You: Aciera
Please Log in or Create an account to join the conversation.
15 Sep 2020 22:20 #182290
by MaHa
Replied by MaHa on topic inns and outs of words an remapps
As my last reply was, how to use as subroutine, i had time to test on my laptop for remap to M275. (Mcodes M200 to M999 are free for remapping)
Using capital letters for PQ, its an error when missing one. As i have a simulation only, i could not check the probing, but at least something happening.
Did a check for no tool loaded, because of set #5400
save this file as m275.ngc in ncfiles or subroutines folder
under stanza [RS274NGC]
REMAP=M275 modalgroup=10 argspec=PQ ngc=m275
and execute M275 P-1 Q0
Using capital letters for PQ, its an error when missing one. As i have a simulation only, i could not check the probing, but at least something happening.
Did a check for no tool loaded, because of set #5400
save this file as m275.ngc in ncfiles or subroutines folder
under stanza [RS274NGC]
REMAP=M275 modalgroup=10 argspec=PQ ngc=m275
and execute M275 P-1 Q0
The following user(s) said Thank You: JR1050, tommylight
Please Log in or Create an account to join the conversation.
16 Sep 2020 05:33 #182368
by JR1050
Replied by JR1050 on topic inns and outs of words an remapps
Thank you, I have the same line defining the remap in my ini file. If you use capital letters in argspec, you have to include all of the variables you defined, if they are lower case, all are optional . The more I think about it, the less I see a need for two variables, I had inherited that from trying to use a user m code . It would be much easier to use P12, P3, P6 and P9 to define each probe head, as it would follow clock work. I suspect my main issue is using "=" instead of EQ. Ive been mixing C, Macro and lcnc's o word goofiness. Im still not sure why every if and else has to have an O word label, that would be tomorrows battle..
Please Log in or Create an account to join the conversation.
17 Sep 2020 01:52 - 17 Sep 2020 01:53 #182492
by JR1050
Replied by JR1050 on topic inns and outs of words an remapps
After fighting with this much longer then I needed to, It is working . Most of the issues were mismatched syntax , which stems from some less them complete documentation in the manual.
The remap section states not to use and .ngc extension on the remapped file-you need it, this should be fixed. Next, the .ngc file needs to be named in all lower case letter M175 wont work, M175.ngc wont work either. It needs to be m175.ngc. The file name also needs to be called in all lower case in the .ini file in the remap line by the ngc call. It is easy to confuse the need for the file to have the .ngc extension, when in fact it is the call out that doesn't use it. The actual file should be : m175.ngc, it should live in /linuxcnc/nc_files. I will also add it is easy to name your sub with upper case, when thay should be lower case , o<m175> sub ,
not o<M175> sub.The ini section for a remap should look like this.
[RS274NGC]
SUBROUTINE_PATH = /linuxcnc/nc_files
REMAP = M175 modalgroup=10 argspec=P ngc=m175
The remap section states not to use and .ngc extension on the remapped file-you need it, this should be fixed. Next, the .ngc file needs to be named in all lower case letter M175 wont work, M175.ngc wont work either. It needs to be m175.ngc. The file name also needs to be called in all lower case in the .ini file in the remap line by the ngc call. It is easy to confuse the need for the file to have the .ngc extension, when in fact it is the call out that doesn't use it. The actual file should be : m175.ngc, it should live in /linuxcnc/nc_files. I will also add it is easy to name your sub with upper case, when thay should be lower case , o<m175> sub ,
not o<M175> sub.The ini section for a remap should look like this.
[RS274NGC]
SUBROUTINE_PATH = /linuxcnc/nc_files
REMAP = M175 modalgroup=10 argspec=P ngc=m175
Last edit: 17 Sep 2020 01:53 by JR1050.
The following user(s) said Thank You: Mike_Eitel
Please Log in or Create an account to join the conversation.
Time to create page: 0.074 seconds