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:

Program number CONFLICT


Recommended Posts

Hello everyone,

   Suppose I defined my program number as 258 in the "FILES tab" =====> "TOOL SETTINGS tab" ======> "PROGRAM # yellow box" if the CHANGE PROGRAM # is ZERO.

 

PROGRAM # tab:

https://drive.google.com/file/d/0B4UZsmondnEzbHhvNjBRMmtjTGc/view?usp=sharing

 

Change Program#

https://drive.google.com/file/d/0B4UZsmondnEzbFVwanp4WnVERVE/view?usp=sharing

 

As I defined:

fmt ""  4  ProgramNumber
pparameter$ # Run parameter table

     if prmcode$ = 19113, ProgramNumber = rpar(sparameter$,1)

pwrttparam$ #Information from parameters

          if prmcode$ = 19113, ProgramNumber = rpar(sparameter$,1)

pheader$         #Call before start of file  

     if progno$ = 0, ProgramNumber, else, progno$

 

 

==============================================================

G-Codes shows me PROGRAM NUMBER as "0"

==============================================================

 

 

 

 

Would you guys please tell me what I've done wrong?  Thank you.

 

The reason I do this because I do not I need to go to "right click on TOOLPATH GROUP" ==============> "EDIT SELECT OPERATIONS" =======> "CHANGE PROGRAM#..." every time I program.

 

 

Please help,

   Thank you so much for your help.

Link to comment
Share on other sites

Technically, if it exists inside the Mastercam File, as a parameter, you should be able to extract it via the 'pparameter$' post block. ('pwrttparams$' for pre-read/tool list).

 

First, have you done a Parameter Dump? I think I showed you how to do that. There is a line in 'pparameter$' that is "commented out". By removing that pound sign, you can dump all the parameters.

 

But...

 

There is always a "but", right?

 

There is a command variable, "rd_mch_ent_no$", that must be set to "-1", in order to be able to capture "all" the machine parameters.

 

So I bet that is why the value is '0'.

 

So, why would that even be an option? Why not just write all the parameter values, all the time? The answer is "processing speed". It will slow down the posting process if you set the value to -1. How much? For most users, not enough to notice.

 

Now, I know that you've added a ton of extra stuff to your post Steven, so you will likely see some slowdown. How much? You'd have to time it, but I'm guessing a couple extra seconds. The more Operations, the more performance hit. But setting it to -1 is the only way to get ALL the parameter values.

Link to comment
Share on other sites

Now that I'm on a pc I can see your code.  I'm not sure if rpar will read before pheader$ without testing, If what Colin laid out doesn't work there are other ways to handle this.

 

1.Output header data in psof$ and send the tooltable to a sub and merge it back in so it is below the header data.

 

2. I'll assume you are importing a lot of toolpaths which causes some extra steps like editing the nc name and program #.  You can use a vb script or nethook to do your posting, the script/nethook would set/check the nc name, program #, etc... for all the toolpaths selected for posting and then post the code just by hitting one button.  

 

3. There are some useful options in the config file for naming the nc file, but nothing for the program #.

 

 

HTH

Link to comment
Share on other sites

Technically, if it exists inside the Mastercam File, as a parameter, you should be able to extract it via the 'pparameter$' post block. ('pwrttparams$' for pre-read/tool list).

 

First, have you done a Parameter Dump? I think I showed you how to do that. There is a line in 'pparameter$' that is "commented out". By removing that pound sign, you can dump all the parameters.

 

But...

 

There is always a "but", right?

 

There is a command variable, "rd_mch_ent_no$", that must be set to "-1", in order to be able to capture "all" the machine parameters.

 

So I bet that is why the value is '0'.

 

So, why would that even be an option? Why not just write all the parameter values, all the time? The answer is "processing speed". It will slow down the posting process if you set the value to -1. How much? For most users, not enough to notice.

 

Now, I know that you've added a ton of extra stuff to your post Steven, so you will likely see some slowdown. How much? You'd have to time it, but I'm guessing a couple extra seconds. The more Operations, the more performance hit. But setting it to -1 is the only way to get ALL the parameter values.

 

Hi Colin,

   I did changed from "0" to "-1" as you suggested and I still have program number as "0000".  I think I may need to define another parameter as 

 

if prmcode$ = 19113, ProgramNumber = rpar(sparameter$,1)

 

I have the same issue showing as "0"

 

Please help, thank you Colin.

 

 

 

# --------------------------------------------------------------------------
# Parameter read postblocks:
# --------------------------------------------------------------------------
pprep$          #Pre-process postblock - Allows post instructions after the post is parsed but before the NC and NCI file are opened.
 
      spathnc$ = smcpath$ #Overwrite file path for NC file
 
      param_read$ = 1
      #DO NOT ATTEMPT TO OUTPUT TO THE NC FILE IN THIS POSTBLOCK (OR ANY POSTBLOCKS YOU MAY CALL FROM HERE) BECAUSE THE NC OUTPUT FILE IS NOT YET OPENED!
      rd_mch_ent_no$ = -1  #Read only the machine base parameters (use to collect common parameters from CNC_MACHINE_TYPE)
      rd_md$       #Read machine definition parameters
 
      #debug
      #error_msg$ = 0
      #err_file$ = 4
      #bug2$ = 40
      fastmode$ = yes$
      #spathnc$ = smcpath$
Link to comment
Share on other sites

Below your line that says "rd_md$", add another line with the command "rd_tlpathgrp$". That will cause the call to 'pmachineinfo$' to occur for the Toolpath Group Parameters.

pset_mach       #Set post switches by reading machine def parameters
      rot_ax_cnt = 0
      rotaxerror = 0
      rot_axis = 0  #Turn off rotary axis unless it is detected in machine read - supresses rotary output in 3 axis machines
      #maxfeedpm = 999999       #Uncomment these variables to force use of machine def values as initial lowest max feedrate value 
      #maxfeedpm_m = 9999999    #Otherwise the default (post) initialization setting is used as initial value
      !maxfeedpm, !maxfeedpm_m
      
      rd_mch_ent_no$ = -1  #Retrieve machine parameters based on current axis combination
      rd_md$       #Read machine definition parameters - calls pmachineinfo$
      rd_cd$ 
      rd_tlpathgrp$ 
Link to comment
Share on other sites
Hi Colin,

  Thank you for your time to respond my question, after I added "rd_tlpathgrp$" as you directed and the program# still "0000".  Below these lines here are how I did it and I think I may be doing or missing something.  

 

=====================================

 

pprep$          #Pre-process postblock - Allows post instructions after the post is parsed but before the NC and NCI file are opened.

      spathnc$ = smcpath$ #Overwrite file path for NC file

      param_read$ = 1

      #DO NOT ATTEMPT TO OUTPUT TO THE NC FILE IN THIS POSTBLOCK (OR ANY POSTBLOCKS YOU MAY CALL FROM HERE) BECAUSE THE NC OUTPUT FILE IS NOT YET OPENED!

      rd_mch_ent_no$ = -1  #Read only the machine base parameters (use to collect common parameters from CNC_MACHINE_TYPE)

      rd_md$       #Read machine definition parameters

   rd_tlpathgrp$ ================================> ADDED THIS LINE

 

      #debug

      #error_msg$ = 0

      #err_file$ = 4

      #bug2$ = 40

      fastmode$ = yes$

      #spathnc$ = smcpath$

 

===============================

My original "PSET-MACH"

===============================

preset_mach

      rot_ax_cnt = 0

      rotaxerror = 0

      rot_on_x = 0  #Turn off rotary axis unless it is detected in machine read - supresses rotary output in 3 axis machines

 

      rd_cd$       #Read control definition parameters - calls pmachineinfo$

      #Output error message if Write NC operation information is not enabled in CD

      #if write_ops = 0, result = mprint(swriteopserror,2), exitpost$

 

      if sof = 1,

        [

        maxfeedpm = 999999       #Uncomment these variables to force use of machine def values as initial lowest max feedrate value

        maxfeedpm_m = 9999999    #Otherwise the default (post) initialization setting is used as initial value

        #minfeedpm = 999999

        #minfeedpm_m = 999999

        !maxfeedpm, !maxfeedpm_m  #, !minfeedpm, !minfeedpm_m

        rd_mch_ent_no$ = 0

        rd_md$       #Read machine definition parameters - calls pmachineinfo$

        ]

 

      rd_mch_ent_no$ = syncaxis$  #Retrieve machine parameters based on current axis combination - read from .nci G950 line

      rd_md$       #Read machine definition parameters - calls pmachineinfo$

      rd_tlpathgrp$  # Read toolpath group parameters - calls pmachineinfo$

 

      rd_prm_op_no$ = op_id$

      rd_params$       #Read operaitons parameters

 

      #We only need these set at toolchange (and start of file).  No need to set them each time a user may call rd_md

      if sav_rot_on_x = zero, rot_on_x = zero ""

      else, rot_on_x = rot_axis

      rot_cw_pos = rot_dir

      index = rot_index

      if rot_angle = zero, ctable = one #ctable zero will produce a divide by zero error, so force to one if zero in MD

      else, ctable = rot_angle

 

      if met_tool$ = 1,

        [

        maxfrinv = maxfrinv_m           #Set limit for feed inverse time

        minfrinv = minfrinv_m

        maxfeedpm = maxfeedpm_m         #Set limit for feed in mm/min

        minfeedpm = minfeedpm_m

        ]

 

      if use_md_rot_label, sav_srot_label = srot_label   #Backup the original rotary axis label

Link to comment
Share on other sites

Why are you placing your code in 'pprep$'? That's probably too early to be able to capture the data.

 

If you read the note in the 'pprep$' post block, that is the wrong place to add the code.

 

Try doing the test in a post that doesn't have all your modifications, and it works. I don't have the time to help you debug exactly where this is failing.

 

I took a standard "off the shelf" post, and used the 'pset_mach" post block.

 

I changed the 'rd_mch_ent_no$' variable to '-1', and added the 'rd_tlpathgrp$' code after the 'rd_md$'.

 

Then I uncommented the debug output line, which writes all the available parameters to the NC file, and this is what I got:

-->pmachineinfo prmcode$ 19113.    1234

So even though all the operations in my MCX-9 file show "Program #0", the parameter is being written.

 

It just isn't available inside 'pprep$'. Try making this modification inside a default post processor, and you'll see the parameter is being written.

  • Like 1
Link to comment
Share on other sites

Why are you placing your code in 'pprep$'? That's probably too early to be able to capture the data.

 

If you read the note in the 'pprep$' post block, that is the wrong place to add the code.

 

Try doing the test in a post that doesn't have all your modifications, and it works. I don't have the time to help you debug exactly where this is failing.

 

I took a standard "off the shelf" post, and used the 'pset_mach" post block.

 

I changed the 'rd_mch_ent_no$' variable to '-1', and added the 'rd_tlpathgrp$' code after the 'rd_md$'.

 

Then I uncommented the debug output line, which writes all the available parameters to the NC file, and this is what I got:

-->pmachineinfo prmcode$ 19113.    1234

So even though all the operations in my MCX-9 file show "Program #0", the parameter is being written.

 

It just isn't available inside 'pprep$'. Try making this modification inside a default post processor, and you'll see the parameter is being written.

 

Thank you, Colin.  You made it work.  Thank you.

  • Like 1
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...