Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

String select table


Recommended Posts

I'm having a hard time understanding how the string select tables work. I've read the documentation, but I still don't understand how to get the variable selector to set to the value of the string I want.

I'm trying to get my post to select G43 when my map_mode = 1; and select G43.4 L1 P3 when my map_mode = 0; and select G49 at the end of an operation.

This is the string select table I want to use:

# Tool length compensation G code selection
sg43    : "G43"      #Tool Length Offset
sg43_4  : "G43.4 L1 P3"    #Tool Length Offset (TCP)
sg49    : "G49"      #Cancel tool length offset
stcp    : ""         #Target string

fstrsel sg43 toollength stcp 3 -1

Do I have to create a postblock & build logic, something like this?

ptcp

    if

    [

    map_mode = one, toollength = 0

    if map_mode = zero, toollength = 1

    ]

    else, toollength = 3

 

 

Link to comment
Share on other sites

Sure. You don't necessarily need a separate post block. You could just set 'toollength' on a Post Line, prior to using the 'stcp' target variable.

For example, you could put something like this on a Post Line:

  toollength = mi1$

Now that variable would take on the value of Misc Integer #1, whenever that line is executed. The trick is making sure you are setting the variable in a good spot.

For example, if you did want to set the the Tool Length variable to a Misc Value, there are two Post Blocks that are predefined for doing just that:

pmiscint$ and pmiscreal$

Really, you can write multiple lines of logic in different places, as long as you set the 'selector' variable prior to encountering 'stcp' on an output line.

Remember that the Post is looking at the Modality of 'toollength' to determine if 'stcp' should be output or not. That means that if your first 'toollength' value is '0', and you set it to '0', it won't output unless you force it. To get around this during the first pass, initialize the variable to a non-zero value:

toollength : -1

 

Link to comment
Share on other sites

Well, I'm starting to get it working, I created this postblock:

ptcp    #Tool length offset
      if stcp,
        [
        if map_mode = one, sg43
        if map_mode = zero, sg43_4
        if nextop$ = 1000, sg49
        if nextop$ = 1002, sg49
        ]
      else, sg49

But it is quite right yet. I get the correct output at the start of my tools:

( OP1 2ND DRILL SCREW HOLES IN PANEL )
N8
T36 M6
S4948 M3
G90 G56
G68.2 P1 Q312 X0. Y0. Z0. I-70. J0. K90.
G53.6
G0 G56 X-38.625 Y12.7793
G43 H36 Z3.6215

But I'm getting screwy output at the  my retract, either

M5
G43.4 L1 P3 G49
G69
M01
G0 G28 G91 Z0.
G0 G28 G91 C0. A0.

or

G0 Z3.6215
M5
G43 G49
M01
G0 G28 G91 Z0.
G0 G28 G91 C0. A0.

Still pluggin' along :)

Link to comment
Share on other sites

Yeah, the ptcp in my pretract was what was generating the screwy output. Absolutely because of something else I did wrong :construction:

I just replaced the ptcp in pretract with sg49. It's not as elegant as I'd like, but I still have a lot of other stuff I'm trying to learn with this post.

I'll come back & get it working after I get a couple other buggers fixed.

Thanks

Link to comment
Share on other sites

At a quick glance of the logic in ptcp I don't think you want 4 if's in a row like that.  I am not sure what you are trying to accomplish there looking at next op.  Thinking about it, I think all you may really need is.

 

ptcp    #Tool length offset
      if stcp,
        [
        if map_mode = one, sg43
        if map_mode = zero, sg43_4
        ]

 

 

Link to comment
Share on other sites
2 minutes ago, huskermcdoogle said:

At a quick glance of the logic in ptcp I don't think you want 4 if's in a row like that.  I am not sure what you are trying to accomplish there looking at next op.  Thinking about it, I think all you may really need is.

 


ptcp    #Tool length offset
      if stcp,
        [
        if map_mode = one, sg43
        if map_mode = zero, sg43_4
        ]

 

 

Yes, I had already determined that & removed them.

I gotta admit, this is some difficult stuff. I've never done any real coding, so I'm kinda fumbling my way around. But, I am really enjoying the challenge.

Thanks again Husker

Link to comment
Share on other sites

Ok, it looks like you've got some of the concepts down, but are missing some of the understanding of what "the mechanism" does.

A String Select Table is a special MP Function, designed to allow you to "link" a numeric variable to a List of Strings. It allows you to output a String, when the value of a different variable has changed. The reason is that you can use "Modality" to determine "when" to output a String, and most importantly, when not to output it.

I'm sure you're just like "I have no idea what he just said...".

Lemme explain. No, there is too much. Lemme sum up...

  1. The simplest rule to remember is: "You use a String Select Table by putting the Target String on an output line, as an Output Parameter. That is just the name of the variable, by itself, as an output parameter on the line.
  2. Example: pbld, n$, stcp, *tlngno$, e$
  3. As you can see, I just put 'stcp' as an output parameter on a post line. I also included 'tlngno$', which is the Tool Length Offset (H) parameter.
  4. The second rule to remember is "You don't "set" the Target Variable, you always set the Numeric Selector Variable!". This means that 'stcp', being a target variable, will always "receive" the string from the string list. MP does this for you. Like Magic! That is the entire point of the String Select Function. So you want to manipulate 'toollength', and when MP detects that the value has changed, in other words, that the "current value" is different from the "previous value", then MP will output the String indicated by the "current value" of 'toollength'.
  5. One thing you need to understand is that the 'fstrsel' function declaration tells MP, where the string list starts, and how many variables are in this "list". This list is a "one dimension array", which is just an ordered list of variables. The first variable in the list is known as the Index Variable. MP Arrays are always "Zero Based Arrays". This means the first variable in this list is the 0ᵀᴴ item in the list. So when 'toollength' is '0', it selects the 1st string in the string list. A value of '1' would select the 2nd item. And so on. You've got 3 possible choices. So you'd be setting 'toollength' to a value of '0, 1, or 2', and getting one of the three strings output.

Now I would recommend that you change your list a little bit. I would put the 'sg49' as the first (0) item in the list. This ties in with the idea of "0" being synonymous with "off". Then have 'sg43' as the 2nd (1) item, and 'sg43_4' as the 3rd string (value of 2). Then change your 'fstrsel' line to use 'sg49' as the index to your array.

This is just personal preference, and you can absolutely leave your string list "as-is" if you choose. Just remember that you don't really want to use the "strings" in the list themselves as output variables. It works, but it breaks the "link" between the Numeric Variable Modality and the String List.

 

  • Like 1
Link to comment
Share on other sites
8 hours ago, Colin Gilchrist said:
  • Example: pbld, n$, stcp, *tlngno$, e$
  • As you can see, I just put 'stcp' as an output parameter on a post line. I also included 'tlngno$', which is the Tool Length Offset (H) parameter.
  • The second rule to remember is "You don't "set" the Target Variable, you always set the Numeric Selector Variable!". This means that 'stcp', being a target variable, will always "receive" the string from the string list. MP does this for you. Like Magic! That is the entire point of the String Select Function. So you want to manipulate 'toollength', and when MP detects that the value has changed, in other words, that the "current value" is different from the "previous value", then MP will output the String indicated by the "current value" of 'toollength'.

That is how I had it set up and everything output correctly, except the cancelling in my pretract postblock. Which is why I tried using the ptcp postblock call in pretract, which didn't work, and then settled for using the sg49 string there instead I was aware that that syntax was not optimal.

 

8 hours ago, Colin Gilchrist said:

Now I would recommend that you change your list a little bit. I would put the 'sg49' as the first (0) item in the list. This ties in with the idea of "0" being synonymous with "off". Then have 'sg43' as the 2nd (1) item, and 'sg43_4' as the 3rd string (value of 2). Then change your 'fstrsel' line to use 'sg49' as the index to your array.

Well...that sounded like the missing link in my overall understanding of this. So, I changed my select table to this:

# Tool length compensation G code selection
sg49    : "G49"      #Cancel tool length offset
sg43    : "G43"      #Tool Length Offset
sg43_4  : "G43.4 L1 P3"    #Tool Length Offset (TCP)
stcp    : ""         #Target string

fstrsel sg49 toollength stcp 3 -1

I put the "stcp" target variable in my p_goto_strt_tl postblock (in both map_mode value areas) & my pretract postblok. But now I just get G49 output at every call in the codefile., no matter what my map_mode value is.

8 hours ago, Colin Gilchrist said:

MP does this for you. Like Magic!

Apparently, I'm not a very good magician :dizzy:

Back to the drawing board :whip:

Link to comment
Share on other sites

Here is some I have done over the years see if they give you some insight on how to use string tables.

In the notes part of the post:

# mr9 - Control Program Revision A to Z control in the post.
#       0 = N/C
#       1 = A
#       2 = B
#       26 = Z
#
# mr10 - Customer Selection output when posted.
#       0 = ADD CUSTOMER
#       1 = BOEING
#       2 = FUJI
#       3 = LEFIELL
#       4 = GE AEROSPACE
#       5 = MITSUBISHI
#       6 = SPIRIT
#       7 = GOODRICH LANDING
#       8 = ROCKWELL COLLINS
#       9 = SPIRIT
#       10 = D.O.D.
#       11 = LOCKHEED
#       12 = VOUGHT

Defined some things when needed:

mr9$         : 0    #Make mr9 to start with
mr2$         : 0    #Define mr2 so I can use it for the correct tool numbers with suffixes

fmt     22 rdbsuffix

Made the string selections:

# --------------------------------------------------------------------------
# Program Rev Complience with Boeing/Spirit MBD Requirements
sr00  : "N/C"
sr01  : "A"
sr02  : "B"
sr03  : "C"
sr04  : "D"
sr05  : "E"
sr06  : "F"
sr07  : "G"
sr08  : "H"
sr09  : "I"
sr10  : "J"
sr11  : "K"
sr12  : "L"
sr13  : "M"
sr14  : "N"
sr15  : "O"
sr16  : "P"
sr17  : "Q"
sr18  : "R"
sr19  : "S"
sr20  : "T"
sr21  : "U"
sr22  : "V"
sr23  : "W"
sr24  : "X"
sr25  : "Y"
sr26  : "Z"
srev : ""

fstrsel sr00 mr9$ srev 27 -1
# --------------------------------------------------------------------------
# Customer selector
scust0   : "ADD CUSTOMER"
scust1   : "BOEING"
scust2   : "FUJI"
scust3   : "LEFIELL"
scust4   : "GE AEROSPACE"
scust5   : "MITSUBISHI"
scust6   : "SPIRIT"
scust7   : "GOODRICH LANDING"
scust8   : "ROCKWELL COLLINS"
scust9   : "SPIRIT"
scust10  : "D.O.D."
scust11  : "LOCKHEED"
scust12  : "VOUGHT"
scust : ""

fstrsel scust0 mr10$ scust 13 -1
# --------------------------------------------------------------------------

Defined the call method:

prdbcustp
     *scust

psrev
     *srev

prdbsuffix
      rdbsuffix = mr2$
      *rdbsuffix

prdbsuffix_abc
      if mr2$ = 0, ".00"
      if mr2$ = 0.01,*stra
      if mr2$ = 0.02,*strb
      if mr2$ = 0.03,*strc
      if mr2$ = 0.04,*strd
      if mr2$ = 0.05,*stre
      if mr2$ = 0.06,*strf
      if mr2$ = 0.07,*strg
      if mr2$ = 0.08,*strh
      if mr2$ = 0.09,*strj
      if mr2$ = 0.11,*strk
      if mr2$ = 0.12,*strl
      if mr2$ = 0.13,*strm
      if mr2$ = 0.14,*strn
      if mr2$ = 0.15,*strp
      if mr2$ = 0.16,*strq
      if mr2$ = 0.17,*strr
      if mr2$ = 0.18,*strs
      if mr2$ = 0.19,*strt
      if mr2$ = 0.21,*stru
      if mr2$ = 0.22,*strv
      if mr2$ = 0.23,*strw
      if mr2$ = 0.24,*strx
      if mr2$ = 0.25,*stry
      if mr2$ = 0.26,*strz
      if mr2$ = 0.61,*sheavy, *stra
      if mr2$ = 0.62,*sheavy, *strb
      if mr2$ = 0.63,*sheavy, *strc
      if mr2$ = 0.64,*sheavy, *strd
      if mr2$ = 0.65,*sheavy, *stre
      if mr2$ = 0.66,*sheavy, *strf
      if mr2$ = 0.67,*sheavy, *strg
      if mr2$ = 0.68,*sheavy, *strh
      if mr2$ = 0.69,*sheavy, *strj
      if mr2$ = 0.71,*sheavy, *strk
      if mr2$ = 0.72,*sheavy, *strl
      if mr2$ = 0.73,*sheavy, *strm
      if mr2$ = 0.74,*sheavy, *strn
      if mr2$ = 0.75,*sheavy, *strp
      if mr2$ = 0.76,*sheavy, *strq
      if mr2$ = 0.77,*sheavy, *strr
      if mr2$ = 0.78,*sheavy, *strs
      if mr2$ = 0.79,*sheavy, *strt
      if mr2$ = 0.81,*sheavy, *stru
      if mr2$ = 0.82,*sheavy, *strv
      if mr2$ = 0.83,*sheavy, *strw
      if mr2$ = 0.84,*sheavy, *strx
      if mr2$ = 0.85,*sheavy, *stry
      if mr2$ = 0.86,*sheavy, *strz

Then called in in the header for the Rev and Customer:

pheader_upr
      #"%", e
      #!spaces$
      spaces$ = 0
      #*progno$, " (", sprogname$,")", e$
      #spaces$ = prv_spaces$
      #pbld, n$, *smetric, e
      "(PROGRAM NAME - ", sprogname$, ")", e$
      "(CUSTOMER     - ", prdbcustp, ")", e$ # Added RDB
      "(PART NUMBER  - ", smachgrp_name, ")", e$ # ADDED Roger Martin
      "(MODEL #      - ", smachgrp_name, ".CATPART)", e$ # Added RDB         
      "(PROGRAMMER   - RON B)", e$ # Added RDB
      "(DATE         - ", *smonth,"-",day$,"-",*year2,")", e$ #Date output as month,day,year - Ex. Feb. 12 2005
      "(TIME         - ",ptime,")", e$  #12 hour time output 3:52 PM
      "(PROGRAM REV  - ", psrev, ")", e$
      "(TOOL LIST)", e$ #Giving it a title 
      "(--------------------------------------------------------------------------)", e$
      spaces$ = 1

The tool suffix is a Mazatrol thing I used for years:

ptoolcomment    #Comment for tool
      tnote = t$
      toffnote = tloffno$
      tlngnote = tlngno$
      #tldianote = tldia$
      strtool$ = ucase(strtool$)
      stoper = ucase(stoper)
      stinsert2 = ucase(stinsert2)
      stholder2 = ucase(stholder2)
      #popnote = ucase(popnote)
      spaces$ = 0
      result = newfs(22, tnote1)
      #"(", *tnote1, *toffnote1, ")", e$
      #if posttype$ = two,
      #  "(", *stoper, " ", *strtool$, " ", *stinsert, *stinsert2, ")", e$
      #else,
      #  "(", *stoper, " ", *strtool$, ")", e$


           if posttype$ = 2,
             [
             "(", *tnote, " | ", plistcomm,  "| EIA SUFFIX - ", prdbsuffix," | ","MAZATROL SUFFIX - ", prdbsuffix_abc, ")", e$
             "(", *stholder, *stholder2, "|", *stinsert, *stinsert2, " | CORNER RADIUS - ", *tradius, ")", e$
             ]
           else,
             [
             if mill5$ = 1,
                 [
                 "(", *tnote, " | ", plistcomm, " | EIA SUFFIX - ", prdbsuffix, " | ","MAZATROL SUFFIX - ", prdbsuffix_abc, ")", e$
                 #"(", *popnote, " | ", *toffnote, " | ", *tlngnote, [if not(drillcyc$), " | ", *tldianote], ")", e$
                 scomm_str, "TOOL DIAMETER PROGRAMMED - ", *tdia, punit, " | TOOL RADIUS PROGRAMMED - ", *tradius, punit, scomm_end, e$
                 ]
             else,
                 [
                 "(", *tnote, " | ", plistcomm, " | EIA SUFFIX - ", prdbsuffix," | ","MAZATROL SUFFIX - ", prdbsuffix_abc, ")", e$
                 #"(", *popnote, " | ",  *toffnote, " | ", *tlngnote, [if not(drillcyc$), " | ", *tldianote], ")", e$
                 scomm_str, "TOOL DIAMETER PROGRAMMED - ", *tdia, punit, " | TOOL RADIUS PROGRAMMED - ", *tradius, punit, scomm_end, e$
                 ]
             ]

      spaces$ = sav_spc

ptooltable # Write tool table, scans entire file, null tools are negative
     if lturret$ = 0 & lwr_turret,
       [
       extprg$ = 1
       subout$ = 3
       ]
     else,
       [
       subprg$ = 2
       subout$ = 0
       ]
       tnote = abs(t$)
       toffnote = tloffno$
       tlngnote = tlngno$
       !spaces$
       spaces$=0

      #next_tool$ = int(next_tool$/100)
      #tnote = int(t$/100)
      #suffixnote = (t$/100) - tnote
      tnote = t$
      suffixnote = mr2$
      if t$ >= zero, tcnt = tcnt + one


      if t$ >= 0,
        [
           #"(TOOL LIST)", e$
           #"(--------------------------------------------------------------------------)", e$
           if posttype$ = 2,
             [
             "(", *tnote, ptspace, " | ", plistcomm, " | ", *suffixnote, " | ", "MAZATROL SUFFIX - ", prdbsuffix_abc, ")", e$
             "(", *stholder, *stholder2, "|", *stinsert, *stinsert2, " | CORNER RADIUS - ", *tradius, ")", e$
             "(--------------------------------------------------------------------------)", e$
             ]
           else,
             if mill5$ = 1,
                 [
                 "(", *tnote, " | ", plistcomm, " | EIA SUFFIX - ", prdbsuffix, " | ","MAZATROL SUFFIX - ", prdbsuffix_abc, ")", e$
                 #"(", *popnote, "| ", *toffnote, " | ", *tlngnote, [if not(drillcyc$), " | ", *tldianote], ")", e$
                 #"(", *stholder, *stholder2, "|", *stinsert, *stinsert2, ")", e$
                 scomm_str, "TOOL DIAMETER PROGRAMMED - ", *tdia, punit, " | TOOL RADIUS PROGRAMMED - ", *tradius, punit, scomm_end, e$
                 "(--------------------------------------------------------------------------)", e$
                 ]
             else,
                 [
                 "(", *tnote, " | ", plistcomm, " | EIA SUFFIX - ", prdbsuffix," | ","MAZATROL SUFFIX - ", prdbsuffix_abc, ")", e$
                 #"(", *popnote, "| ", *toffnote, " | ", *tlngnote, [if not(drillcyc$), " | ", *tldianote], ")", e$
                 #"(", *stholder, *stholder2, "|", *stinsert, *stinsert2, ")", e$
                 scomm_str, "TOOL DIAMETER PROGRAMMED - ", *tdia, punit,  " | TOOL RADIUS PROGRAMMED - ", *tradius, punit, scomm_end, e$
                 "(--------------------------------------------------------------------------)", e$
                 ]
        ]
           spaces$=prv_spaces$
           !t$

The Strings defined to be used in the post encase anyone find this thread and wants to see how I defined them for use with the Mazatrol Suffix output in a EIA process using Mazatrol Tool Offset as the control process:

# --------------------------------------------------------------------------
#String and string selector definitions for NC output
# --------------------------------------------------------------------------
#Address string definitions
stra        : "A"     #String for address A
strb        : "B"     #String for address B
strc        : "C"     #String for address C
strd        : "D"     #String for address D
stre        : "E"     #String for address E
strf        : "F"     #String for address F
strg        : "G"     #String for address G
strh        : "H"     #String for address H
stri        : "I"     #String for address I
strj        : "J"     #String for address J
strk        : "K"     #String for address K
strl        : "L"     #String for address L
strm        : "M"     #String for address M
strn        : "N"     #String for address N
stro        : "O"     #String for address O
strp        : "P"     #String for address P
strq        : "Q"     #String for address Q
strr        : "R"     #String for address R
strt        : "T"     #String for address T
stru        : "U"     #String for address U
strv        : "V"     #String for address V
strw        : "W"     #String for address W
srad        : "R"     #String for address R (radius)
srminus     : "R-"    #String for address R- (minus radius)
strs        : "S"     #String for address S
strx        : "X"     #String for address X
stry        : "Y"     #String for address Y
strz        : "Z"     #String for address Z
sc_minus    : "-"     #Manipulated string for signed rotary minus
sheavy      : "HEAVY " #String for Heavy Tools in Mazatrol

 

  • Like 1
Link to comment
Share on other sites
  • 2 weeks later...

Ok, I've been fighting this for a week, I've read & re-read the documentation and I still can't get this to work. I've got this string select table:

# Tool length compensation G code selection
sg49    : "G49"      #Cancel tool length offset
sg43    : "G43"      #Tool Length Offset
sg43_4  : "G43.4 L1 P3"    #Tool Length Offset (TCP)
stcp    : ""         #Target string

fstrsel sg49 toollength stcp 3 -1

And I'm calling the target string in my psof section:

      if n_tpln_mch > m_one, #Toolplane mapping mode
        [
        #Enter your mapping scheme here...
        pg68_map
        n$, *speed, *spindle, pgear, e$
        n$, *sg90, *pwcs, e$
        pg68
        pcan1, n$, *sg00, pwcs, *xout, *yout, *stcp, *tt_tlngno$, *zout, scoolant, e$
#        pcan1, pbld, n$, *sgcode, *xabs_s, *yabs_s, strcantext, e$
        !workofs$
        ]
#      else, #5 axis and regular mode ( n_tpln_mch = -2)
#        [
#        if cut_ra_head & use_g45, #Swap xout and yout based on offset axis
#          [
#          tloffno2 = tlngno$ + g45_of_add
#          pcan1, pbld, n$, *sgcode, pwcs, *sgabsinc, *yout, *p_out, *s_out,
#            *speed, *spindle, pgear, strcantext, e$
#          pbld, n$, *stcp, *tloffno2, *xout, e$
#          ]
        else,
          [
          map_mode = zero
          pcan1, pbld, n$, *sgcode, pwcs, *sgabsinc, *xout, *yout, *p_out, *s_out,
          *speed, *spindle, pgear, strcantext, e$
          pbld, n$, *stcp, *tt_tlngno$,*xout, *yout, *zout, *p_out, *s_out e$
          !workofs$
          ]

And in my pretract section:

      pbld, n$, scoolant, e$
      pbld, n$, sccomp, spindle, e$
      n$, *stcp, e$
      n$, sg69, e$
      absinc$ = one
#      prefreturn #xout, p_out not output here
      absinc$ = sav_absinc
      protretinc                          #01/26/04
      #pbld, n, *sg28, protretinc, e      #01/26/04      

But my output is always G49, it outputs the correct tool length offset numbers, but never the 1 or 2 table select values:

( OP1 DRILL DOWEL HOLES FOR OP2 RELOCATION )
N6 ( T39 | 1/4 SCREW MACHINE LENGTH DRILL D39 H39 )
T39 M6
S3820 M3
G90 G56
G68.2 P1 Q312 X0. Y0. Z0. I-20. J0. K-90.
G53.6
G0 G56 X38.625 Y-17.6285 G49 H39 Z16.5293
G90 Z15.7793
G81 G99 Z14.4693 R15.7793 F15.28
X3.375
G80
Z16.5293
M5
G49
G69
M01
G0 G28 G91 Z0.
G0 G28 G91 C0. A0.

Anyone have an idea of why this isn't working? Do I need to create logic to set my length offset, instead of using the string select table?

 

Link to comment
Share on other sites
32 minutes ago, 5th Axis CGI said:

You have 4 items not 3 in your table.

No, there are 3 items and a target string. That is correct isn't it? The same as this standard one:

# Motion G code selection
sg00    : "G0"       #Rapid
sg01    : "G1"       #Linear feed
sg02    : "G2"       #Circular interpolation CW 
sg03    : "G3"       #Circular interpolation CCW 
sg04    : "G4"       #Dwell
sgcode  : ""         #Target string

fstrsel sg00 gcode$ sgcode 5 -1
Link to comment
Share on other sites

You do have your table correct Zeke, but not the number of items. You have 3 output strings, but have to include the target string. And you are correct about the Gcode table, except that table has 4 options, plus the target. That is why you see "5" at the near of the string. The number will always include the target variable in the list of strings, so it will always be 1 greater than your number of "options".

Study the Gcode list again. What mechanism actually causes the output of the Target String to change? It is the value of 'gcode$'!

As 'gcode$' changes while processing the NCI file, the post sees the change in the numeric variable, and outputs a string in response.

The part you are missing is that you are responsible for setting the Selector Variable every time. The Gcode table just appears to "work" all on its own, but that is because you can't see the processing that MP is doing for you in the background. MP is continually updating huge lists of variables, as the data is read from the NCI.

All you have to do is set the value of the Selector Variable. 

First, do this: get rid of the 'toollength' variable in your string select table.

Initialize a new numeric variable called 'tcpmode', and set the value to '-1'. Redo your 'fstrsel' line:

fstrsel sg49 tcpmode stcp 4 -1

Now, set the value of 'tcpmode' at the tool change:.

ptlchg$
      if mi1$ = 2 | mill5$, tcpmode = 2
      else, tcpmode = map_mode

You could also just use 'tcpmode = map_mode', if you are making sure 'map_mode' is set to 0, 1, or 2.

Then, at 'pretract' set 'tcpmode' to '0'.

The small snippet of code above just sets the Selector. You still need to have your target variable on an output line.

 

 

Link to comment
Share on other sites
4 hours ago, So not a Guru said:

No, there are 3 items and a target string. That is correct isn't it? The same as this standard one:


# Motion G code selection
sg00    : "G0"       #Rapid
sg01    : "G1"       #Linear feed
sg02    : "G2"       #Circular interpolation CW 
sg03    : "G3"       #Circular interpolation CCW 
sg04    : "G4"       #Dwell
sgcode  : ""         #Target string

fstrsel sg00 gcode$ sgcode 5 -1

No that has 5 items and you see the number 5. You have 4 items and have 3 so sorry, but its wrong. Colin gave and another great explanation and he has pointed you in the correct direction. I understand your zeal, but don't shoot the messenger. I was doing post modifications in Mastercam many years ago. I am not as good as Colin, but I can count. I still got all my fingers and toes to help. ;)

Edited by 5th Axis CGI
I was wrong here
Link to comment
Share on other sites
1 hour ago, Colin Gilchrist said:

You do have your table correct Zeke, but not the number of items. You have 3 output strings, but have to include the target string. And you are correct about the Gcode table, except that table has 4 options, plus the target. That is why you see "5" at the near of the string. The number will always include the target variable in the list of strings, so it will always be 1 greater than your number of "options".

Man, y'all are making me doubt that 1 +1 = 2.:unsure:

In the Gcode table, I see 5 strings; sg00 (G0), sg01 (G1), sg02 (G2), sg03 (G3) & sg04 G4). So it has a value of 5 for the number of strings and an overflow/underflow value of -1

My table has 3 strings; sg49 (G49), sg43 (G43) & sg43_4 (G43.4 L1 P3). So I have a value of 3 for the number of strings and an overflow/underflow value of -1 (which might need to be 0?)

I know I'm kinda thick headed, but I don't understand what I'm missing. Shouldn't the debugger give me an error if my string quantity is wrong?

Imma change it, but I don't understand why I'm doing so (definitely not a 1st! B))

I really do appreciate you guys patience.

Link to comment
Share on other sites
sg49    : "G49"      #Cancel tool length offset
sg43    : "G43"      #Tool Length Offset
sg43_4  : "G43.4 L1 P3"    #Tool Length Offset (TCP)
stcp    : ""         #Target string

sg49 is #1

sg43 is #2

sg43_4 is #3

stcp is #4

If you have included it above the fstsrel line then the number of items above this line must be counted as individual items. Not my rules and made the same mistake and ran into the same problems why I was pointing it out for you. The all not all that smart just been there done that.

Link to comment
Share on other sites
40 minutes ago, So not a Guru said:

Man, y'all are making me doubt that 1 +1 = 2.:unsure:

In the Gcode table, I see 5 strings; sg00 (G0), sg01 (G1), sg02 (G2), sg03 (G3) & sg04 G4). So it has a value of 5 for the number of strings and an overflow/underflow value of -1

My table has 3 strings; sg49 (G49), sg43 (G43) & sg43_4 (G43.4 L1 P3). So I have a value of 3 for the number of strings and an overflow/underflow value of -1 (which might need to be 0?)

I know I'm kinda thick headed, but I don't understand what I'm missing. Shouldn't the debugger give me an error if my string quantity is wrong?

Imma change it, but I don't understand why I'm doing so (definitely not a 1st! B))

I really do appreciate you guys patience.

Look at it again.

sg00    : "G0"       #Rapid
sg01    : "G1"       #Linear feed
sg02    : "G2"       #Circular interpolation CW 
sg03    : "G3"       #Circular interpolation CCW 
sg04    : "G4"       #Dwell
sgcode  : ""         #Target string

sgcode is also considered an items to be counted in the string.

This is all Wrong Ignore.

Edited by 5th Axis CGI
I was wrong
Link to comment
Share on other sites
10 minutes ago, 5th Axis CGI said:

Now I am confused as it 6 items not five. Okay I have bow out and pass this one off to Colin. I apologize and I if you look in my example they are the same number and in that case they are not. When you don't do it every day you make mistakes why I passed this off to the professionals.

Dude! In my book, YOU are the professionals!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

×
×
  • Create New...