530 guide

This commit is contained in:
lovebird 2025-03-13 09:05:07 +01:00
parent 77cef44808
commit 3c79e9e1b2

View File

@ -0,0 +1,127 @@
# **Mastercam Post Processor Development: A Comprehensive Guide with Heidenhain Examples**
Mastercam is a powerful and widely used CAD/CAM software package for generating CNC programs. However, the output from Mastercam needs to be translated into a language that your specific CNC machine can understand. This is where post processors come in. A Mastercam post processor is a critical piece of software that converts the generic toolpath data generated by Mastercam into the specific NC code that your CNC machine controller requires. This guide provides a comprehensive overview of Mastercam post processor development, with a focus on Heidenhain controllers and examples for drilling and probing operations.
## **Understanding Mastercam Post Processors**
Post processors are essential for ensuring that your CNC machine accurately and efficiently executes the desired toolpaths. They take into account the unique characteristics of your machine, such as:
* **Kinematics:** How the tool and workpiece move along the linear and rotary axes.
* **Control Syntax:** The specific G-code and M-code commands understood by your machine's controller.
* **Advanced Control Options:** Support for features like high-speed machining, tool compensation, and canned cycles.
Mastercam offers a vast library of pre-written post processors for many popular CNC machines1. However, you may need to customize an existing post processor or create a new one from scratch to meet the specific requirements of your machine or your unique machining processes.
To understand how Mastercam post processors work, it's important to know the different file types involved: 2
* **.pst (Post Processor File):** This is the main post processor file that contains the logic and instructions for converting Mastercam toolpath data into NC code. It defines the format, syntax, and specific commands used in the output.
* **.control (Control Definition):** This file defines the specific parameters and settings for the CNC machine controller. It includes information about the number of axes, available features, and supported G-code and M-code commands.
* **.machine (Machine Definition):** This file contains information about the physical characteristics of the CNC machine, such as the axis limits, spindle speed range, and tool changer configuration.
These three files work together to generate the final NC code. The post processor file uses the information from the control definition and machine definition to tailor the output to the specific machine and controller.
## **Developing Mastercam Post Processors**
Developing a Mastercam post processor can be a complex task that requires a deep understanding of both Mastercam and the target CNC machine controller. Here's a breakdown of the key steps involved:
1. **Gather Machine Information:** Collect detailed information about your CNC machine, including the controller model, axis configuration, available features, and supported G-code and M-code commands. You'll also need to understand the specific format and syntax required for the NC code3.
2. **Choose a Post Processor Development Environment:** Mastercam provides a built-in editor for modifying post processors. You can access it by going to File \> Edit \> Other in Mastercam 9 or File \> Edit-Open External in Mastercam X and selecting your post processor file. However, there are also third-party tools available, such as Code Expert, which offer a more user-friendly interface and advanced debugging capabilities4.
3. **Understand the Post Processor Structure:** A Mastercam post processor is typically a text file with a .pst extension. It contains a series of code blocks and variables that define how the toolpath data is translated into NC code. Familiarize yourself with the structure and syntax of the post processor language. A good starting point is the Mastercam post processor reference guide, which is available from your local Mastercam reseller2.
4. **Customize or Create the Post Processor:** Before making any changes to a post processor, it's crucial to create a backup copy of the original file5. This will allow you to revert to the original version if you encounter any problems or make irreversible errors. Start by modifying an existing post processor that is similar to your target machine. Alternatively, you can create a new post processor from scratch using the Mastercam post processor language2. When customizing a post processor, consider the specific needs and preferences of the machine operator6. Factors like preferred programming style (conversational vs. G-code) and the level of detail in the output should be taken into account.
5. **Test and Debug the Post Processor:** Thoroughly test the post processor with various toolpaths to ensure that it generates the correct NC code. Use the Mastercam post debugger or a third-party debugging tool to identify and fix any errors7.
## **Heidenhain Controllers: Features and Considerations**
Heidenhain controllers are known for their advanced features and powerful programming capabilities8. They are particularly well-suited for 5-axis machining due to features like PLANE commands for defining the working plane, TCPM (Tool Center Point Management) for tool center point control, and a wide range of powerful cycles for complex machining operations8.
Heidenhain controllers use a unique conversational programming language called Klartext, which allows for intuitive and efficient program creation10. Klartext uses plain language commands and interactive prompts to guide the programmer through the process, making it easier to learn and use compared to traditional G-code programming. When developing a Mastercam post processor for a Heidenhain controller, it's crucial to understand the specific syntax and format required for Klartext programs. This includes:
* **PLANE commands:** Defining the working plane for machining operations (e.g., PLANE STAY, PLANE TURN, PLANE MOVE)9.
* **CYCLE commands:** Utilizing Heidenhain's built-in cycles for drilling, tapping, and other operations (e.g., CYCLE 200, CYCLE 205, CYCLE 207\)11.
* **TCPM (Tool Center Point Management):** Supporting tool center point control for multi-axis machining9.
Heidenhain also offers freeware programming station software that allows you to simulate programs offline6. This can be a valuable tool for testing post processors and verifying NC code without access to the physical machine.
In addition to the programming language, Heidenhain controllers have several user interface features that contribute to their user-friendliness: 10
* **Syntax highlighting:** Different colors are used to distinguish commands, values, and comments, making the program easier to read and understand.
* **Color gradients and fonts:** A consistent and modern look and feel is used throughout the interface.
* **smartSelect function:** Provides a clear overview of available functions and displays detailed information from the TNCguide (the TNC's online help).
It's worth noting that customizing a post processor for Heidenhain conversational language can be more powerful and efficient than using the ISO equivalent6. This is because the conversational language allows for more concise and expressive programming, taking advantage of the advanced features and cycles built into Heidenhain controllers.
While empty lines are generally not allowed in Heidenhain programs, you can use comments with a semicolon (;) to create empty lines for improved readability12. This can help make the program more organized and easier to understand.
## **Examples for Drilling and Probing**
Here are some examples of how to customize a Mastercam post processor for Heidenhain controllers, specifically for drilling and probing operations:
### **Drilling**
* **Canned Drill Cycles:** Heidenhain controllers offer a variety of canned cycles for drilling operations, such as CYCLE 200 for drilling, CYCLE 205 for pecking, and CYCLE 207 for rigid tapping9. You can modify the post processor to output the appropriate CYCLE command based on the drilling parameters defined in Mastercam. For example, to output CYCLE 200 for a simple drilling operation, you might modify the post processor to include the following code:
`if drill_type = 0, #simple drilling`
`sbin, "CYCLE 200"`
`n$, *sgfeed, *sgspindle, "Z", *sgdepth, e$`
`endif`
* **Drilling with Chip Breaking:** For deep hole drilling, you can customize the post processor to include Heidenhain's chip breaking function (CYCLE 203\) to improve chip evacuation and prevent tool breakage9. This can be achieved by modifying the post processor to output the CYCLE 203 command with the appropriate parameters for chip breaking, such as the retraction distance and dwell time.
* **Coolant Control:** Ensure that the post processor outputs the correct coolant codes (e.g., M08 for coolant on, M09 for coolant off) according to the coolant settings in Mastercam9. This can be done by mapping the Mastercam coolant codes to the corresponding Heidenhain codes in the post processor.
### **Probing**
* **Touch Probe Support:** Heidenhain controllers are often used with touch probes for automated workpiece measurement and tool setting. You'll need to customize the post processor to output the necessary commands for probe activation, data acquisition, and error handling10. This might involve adding code to handle probe triggering, reading probe data, and storing the measured values in variables.
* **Probe Calibration:** Include support for probe calibration routines in the post processor to ensure accurate measurement results. This could involve outputting the necessary commands to perform a probe calibration cycle and store the calibration data in the controller.
* **Safe Retract Moves:** Implement safe retract moves after probing operations to prevent collisions between the probe and the workpiece or fixtures9. This can be done by adding code to retract the probe to a safe distance after each probing operation.
## **Testing and Debugging**
Thorough testing and debugging are crucial to ensure that your Mastercam post processor generates accurate and reliable NC code. Here are some key strategies:
* **Use the Mastercam Post Debugger:** Mastercam includes a built-in post debugger that allows you to step through the post processor code line by line, examine variables, and identify errors7. To enable the debugger, go to File \> Configuration \> Post Dialog Defaults and check the "Enable post debugger" option.
### **Debugging Techniques**
* **Step through the code:** Use the "Step Over," "Step Into," and "Step Statement" buttons to execute the post processor code one line or block at a time. This allows you to observe the flow of execution and identify any logic errors.
* **Set breakpoints:** Use breakpoints to pause execution at specific lines of code. This allows you to examine the values of variables and the state of the program at that point.
* **Watch variables:** Add variables to the "Watches" window to monitor their values as the post processor runs. This can help you track down errors caused by incorrect variable assignments or calculations.
* **Test with Various Toolpaths:** Test the post processor with a variety of toolpaths, including simple 2D operations, complex 3D contours, and multi-axis movements. This will help you identify any issues that may arise with different types of toolpaths.
* **Simulate the NC Code:** Use a CNC simulator to verify the generated NC code and visualize the toolpaths before running them on the actual machine. This can help you catch errors that might not be apparent from simply reviewing the code.
* **Manually Review the NC Code:** In addition to using the debugger and simulator, it's essential to manually review the generated NC code13. Check for correct syntax, proper formatting, and adherence to the machine's specifications. This can help you catch subtle errors that might be missed by automated tools.
* **Consult with Experts:** If you encounter difficulties, don't hesitate to seek help from experienced Mastercam post processor developers or your local Mastercam reseller2. They can provide valuable guidance and assistance in troubleshooting post processor issues.
## **Community Resources**
There are several online communities and forums where you can find information, ask questions, and get help with Mastercam post processor development. Some valuable resources include:
* **CNC Zone:** A popular forum with a dedicated section for Mastercam post processors2. This forum is a great place to find answers to common questions, share tips and tricks, and connect with other Mastercam users.
* **eMastercam:** An online community with forums, tutorials, and resources for Mastercam users14. eMastercam offers a wealth of information on post processor development, including tutorials, code examples, and discussions on specific topics.
* **Mastercam Forums:** A forum dedicated to Mastercam post processor development and support15. This forum is a good resource for finding solutions to specific post processor problems and getting help from experienced developers.
* **Mastercam Community:** The official Mastercam community website with forums, events, and resources16. The Mastercam Community website provides access to a wide range of resources, including the official Mastercam forum, training materials, and events.
## **Conclusion**
Developing Mastercam post processors for Heidenhain controllers requires a solid understanding of both Mastercam and the Heidenhain control language. By carefully following the steps outlined in this guide and utilizing the available resources, you can create post processors that generate accurate and efficient NC code for your specific Heidenhain-controlled CNC machines. Remember to thoroughly test and debug your post processors to ensure reliable and safe machining operations.
Mastercam post processors are essential for translating the generic toolpath data generated by Mastercam into the specific NC code that your Heidenhain controller can understand. Developing and customizing post processors can be challenging, but the benefits are significant. By taking the time to understand the intricacies of post processor development and utilizing the available resources, you can unlock the full potential of your Mastercam and Heidenhain-controlled CNC machines.
The online communities and forums mentioned in this guide are valuable resources for learning, troubleshooting, and connecting with other Mastercam users and post processor developers. Don't hesitate to reach out to these communities for assistance and support. Continuous learning and collaboration are key to mastering the art of Mastercam post processor development.
#### **Works cited**
1\. Post Processors \- Mastercam, accessed on March 13, 2025, [https://www.mastercam.com/solutions/post-processors/](https://www.mastercam.com/solutions/post-processors/)
2\. Learning to write MC Posts \- Mastercam \- CNCzone.com, accessed on March 13, 2025, [https://www.cnczone.com/forums/post-processors-for-mc/20310-posts.html](https://www.cnczone.com/forums/post-processors-for-mc/20310-posts.html)
3\. Post Processing for CAD/CAM Software: Your Complete Guide \- mastercam.com, accessed on March 13, 2025, [https://www.mastercam.com/news/blog/post-processing-for-cad-cam-software-your-complete-guide/](https://www.mastercam.com/news/blog/post-processing-for-cad-cam-software-your-complete-guide/)
4\. Post Editing : r/CNC \- Reddit, accessed on March 13, 2025, [https://www.reddit.com/r/CNC/comments/1cgtbnf/post\_editing/](https://www.reddit.com/r/CNC/comments/1cgtbnf/post_editing/)
5\. How To Edit Mastercam Post? \- CNCzone.com, accessed on March 13, 2025, [https://www.cnczone.com/forums/post-processors-for-mc/34091-edit-mastercam-post.html](https://www.cnczone.com/forums/post-processors-for-mc/34091-edit-mastercam-post.html)
6\. Heidenhain control / programs \- CNCzone.com, accessed on March 13, 2025, [https://www.cnczone.com/forums/controller-amp-computer-solutions/16671-cnc-forum-new-post.html](https://www.cnczone.com/forums/controller-amp-computer-solutions/16671-cnc-forum-new-post.html)
7\. www.reddit.com, accessed on March 13, 2025, [https://www.reddit.com/r/CNC/comments/1cgtbnf/post\_editing/\#:\~:text=Mastercam%20also%20has%20the%20post,little%20ladybug%20icon%20that's%20enabled.](https://www.reddit.com/r/CNC/comments/1cgtbnf/post_editing/#:~:text=Mastercam%20also%20has%20the%20post,little%20ladybug%20icon%20that's%20enabled.)
8\. TNC 640 | heidenhain, accessed on March 13, 2025, [https://www.heidenhain.us/wp-content/uploads/892916-28\_TNC640\_HSCI\_en.pdf](https://www.heidenhain.us/wp-content/uploads/892916-28_TNC640_HSCI_en.pdf)
9\. New post processor developed for Mastercam users \- HEIDENHAIN, accessed on March 13, 2025, [https://www.heidenhain.us/resources-and-news/tnc-5x-mill-post-processor/](https://www.heidenhain.us/resources-and-news/tnc-5x-mill-post-processor/)
10\. Creating programs | HEIDENHAIN \- Klartext Portal, accessed on March 13, 2025, [https://www.klartext-portal.com/tips/programming/creating-programs](https://www.klartext-portal.com/tips/programming/creating-programs)
11\. Mastercam Announces New HEIDENHAIN TNC 5X Mill Post Processor, accessed on March 13, 2025, [https://www.mastercam.com/news/press-releases/heidenhain/](https://www.mastercam.com/news/press-releases/heidenhain/)
12\. Basic Heidenhain course introduction \- YouTube, accessed on March 13, 2025, [https://www.youtube.com/watch?v=D4xPj90z8ZE](https://www.youtube.com/watch?v=D4xPj90z8ZE)
13\. mastercaX Post debugging \- Mastercam \- CNCzone.com, accessed on March 13, 2025, [https://www.cnczone.com/forums/mastercam/57871-mastercax-post-debugging.html](https://www.cnczone.com/forums/mastercam/57871-mastercax-post-debugging.html)
14\. How to edit post processors \- Industrial Forum \- eMastercam.com, accessed on March 13, 2025, [https://www.emastercam.com/forums/topic/35387-how-to-edit-post-processors/](https://www.emastercam.com/forums/topic/35387-how-to-edit-post-processors/)
15\. Mastercam Post Processor Development Forum \- MastercamForums.com, accessed on March 13, 2025, [https://mastercamforums.com/forum/index.php?board=7.0](https://mastercamforums.com/forum/index.php?board=7.0)
16\. Community \- mastercam.com, accessed on March 13, 2025, [https://www.mastercam.com/community/](https://www.mastercam.com/community/)