-
-
Notifications
You must be signed in to change notification settings - Fork 19.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: add ability to use radius format of G02/G03 commands (CNC) #4676
Comments
I've added support for negative radius. Turns out you don't need to mess with the X and Y values when doing negative radius. |
Didn't mean to close this request. |
Bob, do you know the C programming language? Can you put your concept into C for us? I don't understand what a negative radius even means. That seems kind of like an imaginary number. Why is this useful (from a mathematical perspective)? |
Sorry – I knew a little C about 15 years ago. Here’s a link that shows an example of a command with a negative radius. It’s towards the bottom of the page & is titled “R Method Example 2:”
I only included the negative radius so I can call my Excel macro complete. I’d be really surprised if any of the well known tools would generate a command with a negative radius. |
Do CNC machines use negative radius on their GCode commands? |
I doubt it but … I’m just a beginner at CNC |
Bob, we have a constant challenge to keep the feature set of Marlin up to date and debugged for the items that user really need. We can't be adding features that are not going to be used by a significant number of those users. The GitHub system handles this situation very well. What you do is you fork the code base, and add your features. Your customized version of Merlin that does the things you need it to do can exist in parallel to the main branch of Marlin. |
I agree that the negative radius is not worth the effort by itself. It’s just easy to include if positive radius is implemented. The positive radius commands are generated by the SketchUcam plugin for the SketchUp program. These are used a lot by the DIY CNC community. I expect that the user base for Marlin with the radius feature are those of us that want to use one machine to do both CNC and 3D printing. Bob PS – The second file I attached does both positive and negative radius. There’s only a few added statements from the first file to implement the negative radius. |
I've done my best to convert the conversion routine to C. One file has the C functions and the Excel syntax. That one I could test. It it the conversions correctly on a large gcode program. The C functions were mimiced by Excel functions that I created for the test. The other file has the C functions and the C syntax. I have no way of testing it so it needs to be looked at carefully before being used. Bob |
I've found the GRBL code to do the conversion. They use vector calculations. Seems like a lot more work than the method I found but I expect the real test is how fast they execute. Attached are two files that are portions of the gcode.c file in the main grbl branch. This is where the radius conversion code is.
Bob grbl_gcode.c_radius conversion most comments deleted.docx |
Marlin already implements Marlin also implements |
In the general case the G2 & G3 commands can use either I J K to specify the arc or a radius. Marlin implements only the I J K method. |
I've created a pull request for this feature request. |
Where? It seems to have been targeted someplace besides |
@thinkyhead Have you heard anybody talking about making G2 and G3 work with Delta's ? I wonder if it would be as easy as sending the intermediate steps down the same pathway as G1 does to get the work done? |
There’s two ways of specifying the arc. Marlin currently supports the I J method. This work would allow Marlin to also support the R (radius) method. |
@Roxy-3D G2 and G3 work just wonderfully with Delta. |
The "R" method seems like an interesting challenge. The code needs to determine the point that is equidistant from the start and end points, taking the clockwise or counter-clockwise path between them. Note that if the start and end points are the same, there's no way to determine (with just an "R" argument) what the center of the circle should be. It could be in any direction. For this reason, full circles are forbidden with the "R" method, and you must therefore specify an XY which is a different point from where you started. |
If the code isn't already written, here's how it will need to go… float e = clockwise ? -1 : 1, // clockwise -1, counterclockwise 1
dx = x2 - x1, dy = y2 - y1, // X and Y differences
d = HYPOT(dx, dy), // Linear distance between the points
h = sqrt(sq(r) - sq(d * 0.5)), // Distance to the arc pivot-point
mx = (x1 + x2) * 0.5, my = (y1 + y2) * 0.5, // Point between the two points
sx = -dy / d, sy = dx / d, // Slope of the perpendicular bisector
cx = mx + e * h * sx, cy = my + e * h * sy; // Pivot-point of the arc |
The code is written & tested. I think I’ve finally figured out how to set things up so I can do the pull. But I’ve said that twice before .. |
Oops, I went and wrote it. Let's compare. #4840 |
Just looking over the formula, I think maybe Corrected. Test code gives positive results:
|
The way I’ve been shooting myself in the foot today … it may take a couple of hours before I can get my code officially into an RCBugFix pull request. It’s already in a pull request in my section. Here’s the link to it. https://github.com/Bob-the-Kuhn/Marlin-RCBugFix--Radius-/pull/1 |
Thanks! But I think it's pretty well covered by #4840. I've got it checking the arguments for errors, calculating the arc offsets, and it simply uses the existing |
I think I finally got the pull request against RCBugFix created. Please see if #4841 is what you want to see. The good news is that the R method is moving forward. I looked at the |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
My CAM software sometimes generates the radius version of the G02/G03 command. It would be great if Marlin could handle the radius format.
I've written an Excel macro to do the conversion. I've attached it incase it's usefull to the coders.
The macro only handles positive values of the radius. Negative values of the radius requires messing with the X and Y parts of the command.
radius portion of Excel macro.txt
The text was updated successfully, but these errors were encountered: