Non-3d printer CNC discussion

I'm building a plugin for supporting the laser and CNC functions on a Snapmaker 3 in 1 printer's CNC / laser. (https://ron-linkertech.github.io/octoprint-snapmaker-control/)

I have run into many issues, so I'm starting a topic here to discuss them and get some ideas.

I have never used knockoutjs before, and I'd call my python skills "passable", but I have done a multitude of different languages over the years and it was not hard to get a functional plugin for the simple case of detecting and turning on and off the laser / cnc. Beyond that is where the issues started...

Here are some things I've learned about CNC. I'm a noob here, so I may have any of this wrong for the general case; I've only got what Snapmaker provided me with and a little googling. The gcode files that are created in the CNC / Laser space have a file extension of "nc" rather than "g", "gco", or "gcode". The files themselves do not have extruder parameters in the G(0,1) codes, but do have separate M3, M4, M5 commands to turn the tool on and off.

Initially I only wanted the controls to show up on the control tab when the specific printer is detected and the laser or CNC tool is on. It looks like the control.yaml approach would not support the conditional stuff I needed, so I just made them add themselves to the DOM based on my plugin finding the printer in the gcode stream. Knockout did not like me putting things in the control tab, so they are anchored below the tab container.

I wanted to find the boundary of the loaded file in order to support a "run boundary" tool, which is used to move the head in the x and y direction around your laser / cnc work to make sure it will fit where you want it.

The file manager does not support these files when uploading, so I intended to do a PR to allow this, but when I changed this locally and loaded a file, the existing analysis does not find the bounds of the file, as these files don't use an "extruder", and this is what is used to find the minxy maxxy. It also looks like the gcode tool will have issues, but I have not looked at this code yet to see how easy it would be to change to show "tool down" instead of "extrude" paths in the gcode.

I am starting to get that sinking feeling that this will be a lot harder than I thought, but I'd welcome some comments here about approaches I may be missing or other thoughts.

-Ron

1 Like

The term is "a labor of love" for that. :wink:

I'm not sure how the Snapmaker wants you to home the print job. (For those who haven't done CNC, the stock's positioning is relative in the X/Y/Z.) I'm guessing that you'd want some sort of pre-job wizard which will create/set offsets. I'm also not sure how you'll square the stock onto the bed but assume that you can just handle that manually.

files.py appears to be the point where OctoPrint is trying to find files. Line 545
filemanager Line 39
plugin/types.py Line 1861

It comes with a program called "Snapmakerjs" which appears to be a port of https://github.com/cncjs/cncjs

It looks like in this software it sends:

"on" - M3 (plus P and S on laser for power)
"off" - M5
"set origin" - G92 X0 Y0 Z0
"go to origin" - G0 X0 Y0 Z0 F3000
"run boundary" - G90, G92 X Y Z, G90, G0's to move around the bounds, G0 X0.00 Y0.00 Z0.00

Yea, I found where to change the extension to get the upload to work - really just init,py in filemanager does the trick.

I think I have an approach for the computation of boundary in gcodeInterpeter.py on these files:

If filename ends with "nc", then use "cnc mode"
if in cnc mode, where the extruder parameter in a movement is not there, go ahead and record the point in the min/max (calling self._minMax.record).

It seems to do the right thing on the few files I have to test with.

Is boundary just a rectangle then? If so, then it stands to reason that one could walk the gcode commands, filter by Gn and compare each X/Y value with an arbitrary default value.

If it's not a rectangle, then converting to polar coordinates is probably the way to go on that calculation. It would be a combination of pairs of (degree, distance) around the center.

1 Like

Was this finished?

I would absolutely LOVE to use this plugin.
It's EXACTLY what I'm looking for.

Sorry, I more or less abandoned the project in favor of using an old laptop running the snapmakerjs program for driving my cnc

Greetings,

I stumbled upon this thread and noticed the discussion regarding Snapmaker integration with OctoPrint. I wanted to share that I've initiated a related project as of yesterday.

The project, an OctoPrint plugin for Snapmaker, is currently in the early stages of development. As of now, it includes basic functionality such as auto bed leveling and laser calibration. I feel it's important to mention, though, that the laser calibration features are still in the process of being refined and don't yet have all necessary safeguards in place.

I plan to continue developing this plugin for the foreseeable future. If you have any suggestions for improvement, or if you're interested in contributing to the code, your input would be appreciated. You can find the project on GitHub at this link: OctoPrint-Snapmaker-Plugin.

Finally, if anyone is aware of an existing plugin with similar functionality, please let me know. Thanks for your time.

1 Like

Great news! Thanks for posting here.