Willmac16 / OctoPrint-GcodeLeveling

An OctoPrint plugin for leveling of Z values in Gcode using measured positions
https://plugins.octoprint.org/plugins/gcodeleveling/
GNU Affero General Public License v3.0
5 stars 0 forks source link

Easy ? to add workpiece registration to electronically correct misalignment (and optionally scaling) in the XY plane #19

Open dirkvdb2 opened 1 month ago

dirkvdb2 commented 1 month ago

There are no tools in many low-end CNC machines to accurately position a milling or laser plan relative the workpiece. This would be required eg. to work with a DIY PCB that has holes already drilled and need to be laser exposed, or to place a mill or laser plan in some existing feature of the workpiece.

A solution would be to allow calibrated transformation of (X, Y) cordinate into a new coordinate system based on two known workpiece-referenced tool positions (eg. fiducials). The current plugin corrects already the Z-coordinate, could perhaps easily be extended to allow calibration based on two known (X1,Y1) and (X2,Y2) points. A practical mechanism could be to move the tool to a known position, register that, than jog to the correct position and register that as well. . Repend for a second point far away from the first point. This is sufficient to calculate the four elements of a transformation matrix,

A further enhancement could be to allow multiple redundant calibrating positions and do a least squares approximation, with X-scaling, Y-scaling on/off (In some instances scaling (X, Y, both) could be useful, in other (like PCB exposure or milling) absolutely not).

Describe alternatives you've considered Mechanically repositioning the workpiece is very cumbersome and inaccurate, and does not allow for scaling.

Additional context Add any other context or screenshots about the feature request here.

Willmac16 commented 1 month ago

@dirkvdb2

If you'd like to take a stab at adding this feature, I'd be happy to answer questions/offer advice, but currently I'm away at college without a personal CNC machine and a bit busy with other projects.

I definitely agree that this should be doable. I even already wrote a different plugin that handles just translation/cloning https://plugins.octoprint.org/plugins/translatemodel/

The difficulty in doing this well really would come down to the interactive/UX design of jogging and sending those values to octoprint or a script and then properly parsing and modifying Gcode the same way your CNC will.

I would suggest you first check that your CNC machine supports offset, scaling and rotation commands--Gcodes like G52, G54, or G92 tend to be pretty common and are how professional CNC machines handle running the same operations across multiple parts or adjusting offsets to ensure tolerance.

If you have access to the source code of your CNC machine's firmware, then I would suggest that as a safer avenue to this functionality. While a Gcode parser is much easier to write and test, it is always guessing what the CNC machine will do with the commands; whereas, the firmware itself actually knows where it is and what it's doing.

dirkvdb2 commented 1 month ago

Thank youi, will, for your quick and positive answer.

Although I dont have the programming skills to accomplish anything myself, I looked though quite a bit of info on the internet and I was really surprised there is so little.

Of course, most 3D manufacturing machines (laser, CNC, 3D printers) dont typically need to align there jobs with w workpiece (laser ‘etching’ being an exception), so I understand it is not fundamental.

On the other hand, I am pretty sure there would be a lot of use for it when readily available.

What I have in mind as my application of most interest is to align laser/CNC exposure of milling, together with drilling of holes, in double sided PCBs.

The nice work that you already did, indeed, comes very, very close – closest of anything else I found available.

These may be interesting to have a look at as far as practical setup of hardware is concerned

How to Find Part Edges on Desktop CNC Fast with An Affordable Microscope - The White Owls

Zeroing a CNC | Beatty Robotics (beatty-robotics.com)

What I had in mind as underlying software model would be coordinate-system agnostic an as such would avoid any uncertainty about what coordinate system the CNC/laser.printer is using.

The only assumption it would make is that the coordinates that arte raed as the current position would be valid fo a ‘move to’.

The idea is to make the toolhead move a a position with a fiduciual record the (X,Y) coordinates and then jog to the correct position.

The digital microscope (actually a very cheap webcam!) would have an (X,Y) offset to the toolhead, but that would be calibrated away as well.

So basically, the workflow would be like this:

Then, with the workpiece in place:

I am sorry that I cant contribute in the actual programming, but I hope that the above is helpfull.

If you require more help apart from the actual programming, please let me know!

Dirk

From: Will MacCormack @.> Sent: Saturday, 13 July 2024 22:10 To: Willmac16/OctoPrint-GcodeLeveling @.> Cc: dirkvdb2 @.>; Mention @.> Subject: Re: [Willmac16/OctoPrint-GcodeLeveling] Easy ? to add workpiece registration to electronically correct misalignment (and optionally scaling) in the XY plane (Issue #19)

@.***(https://github.com/dirkvdb2)

If you'd like to take a stab at adding this feature, I'd be happy to answer questions/offer advice, but currently I'm away at college without a personal CNC machine and a bit busy with other projects.

I definitely agree that this should be doable. I even already wrote a different plugin that handles just translation/cloning https://plugins.octoprint.org/plugins/translatemodel/

The difficulty in doing this well really would come down to the interactive/UX design of jogging and sending those values to octoprint or a script and then properly parsing and modifying Gcode the same way your CNC will.

I would suggest you first check that your CNC machine supports offset, scaling and rotation commands--Gcodes like G52, G54, or G92 tend to be pretty common and are how professional CNC machines handle running the same operations across multiple parts or adjusting offsets to ensure tolerance.

If you have access to the source code of your CNC machine's firmware, then I would suggest that as a safer avenue to this functionality. While a Gcode parser is much easier to write and test, it is always guessing what the CNC machine will do with the commands; whereas, the firmware itself actually knows where it is and what it's doing.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>DD CNCD printers)