PyDNC - Python DNC script for CNC controls

Latest version, 2024 Apr 22, gzip'd tarball

2024 Jan 4 version, gzip'd tarball

2023 Aug 4 version, gzip'd tarball

Fadal CNC88HS Post Processor for FreeCAD Path workbench

Yasnac MX3 Post Processor for FreeCAD Path workbench

Introduction

PyDNC is a Python script to send and receive files from CNC controls over a serial line. It uses the PySerial library for the serial port interface, so it should work fine on Windows, Unix, OS X, etc. It has been tested with USB to RS232 converters with Haas, Yasnac, and Fadal controls with no problems at up to 38400 bps. Provision is made for various data bit options, stop bit options, parity, and baud rates.

Of particular use is that when sending data to the control, the script checks for an XOFF code every character to prevent RS232 overrun problems in the ancient controls. Note that most current Linux serial drivers for USB converters do NOT implement software (XON/XOFF) flow control in the driver!

Other Scripts

From the README file in the archive:

These programs are useful for making, sending, and receiving CAM files to and from a CNC control. Particularly ancient controls without macros, subroutines, or general math processing. There are also programs for modifying g-code files, extracting the travel limits from a g-code file, and removing dis-allowed code from a g-code file.

dnc_renumber.py

Process a g-code file, renumbering the lines as it goes. Drops existing line numbers, and renumbers ALL g-code lines, except O-word and "%" lines. Set the line number offset, and the roll-over point for those controls with maximum line numbers.

dnc_stats.py

Compute various statistics of a g-code file. Mostly, find the min and max X, Y, Z values for each tool, in order. Reports the max and min coordinates for each tool, so an operator can work out if tools stick out far enough _before_ running the code.

dnc_strip.py

Strip all comments, line numbers, etc. from a g-code file for those controls that can't handle such stuff in a DNC file. Specifically, note that Fadal controls won't accept O-words, line numbers, or comments in a program being drip-fed to the control.

dnc_xform.py

Offset or scale all the X, Y, and/or Z values in a g-code file. Can also swap spindle speed and feed rate commands. The spindle and feed replacements are matching the spindle and feed rate, not the tool number! Can be very helpful for modifying a g-code file from one machine to another (different max spindle, max feed, etc.). Can also be used to mirror or offset code.

plot_gcode.py

Convert g-code file to positions for plotting with gnuplot. Input is a g-code file, output is a long series of x,y,z,mode lines for each move in the g-code file. The mode is taken from the currently active motion mode (0, 1, 2, 3) for each move. The mode number has 1 added to the number for plotting in gnuplot, as line color 0 is special.

cam_macros.py

Python pre-processor to make a DNC-ready g-code-only file from a source file with g-code, macros, and setup comments. The macros allow a higher level of cam programming than straight hand-coding the coordinates. With a CAD program that can provide a consistent set of x, y, z coordinates for corners, the macros can be used as a CAM programming language for 2.5-D cutting.

Fadal CNC88HS Post

The Fadal post-processor, fadal_post.py, is for the FreeCAD Path workbench, and produces g code that conforms to the Format 2 Fadal specification, which is closer to Fanuc dialect. The post does not currently handle tapping jobs correctly, although that may be partly due to issues with the Fadal mill being used for testing.

Improvements welcome, as they will only be made here as problems have to be overcome.

Yasnac MX3 Post

The MX3 post-processor, fadal_post.py, is for the FreeCAD Path workbench, and produces g code that conforms to the MX3 minimal dialext. The development controller does not have most of the options, but does include arcs! The post does not currently handle tapping jobs correctly, although that may be partly due to issues with the Fadal mill being used for testing.

Improvements welcome, as they will only be made here as problems have to be overcome.


GUI for PyDNC

A user submitted a link to a Python GUI for the pydnc script: github link

I have not tested the GUI yet, but it looks like an excellent addition.


(C) 2023 Paul Gettings first initial dot last name at the goolge mail location