Fully automatic xyz cnc probe macro
-
@tyrod
bump -
@tyrod Not sure it helps, but have you seen this thread?
https://forum.duet3d.com/topic/24706/automatic-tool-offset-xyz-for-syringe-printer/3?_=1652218329515
Sorry if I already shared before.
You may be able to use some of the published Gcodes to do part of what you want, but I agree that you will need variables, especially when you want to store and then reference the 'resume' position later on. I don't understand your exact use case (I don't have a CNC), but it definitely sounds possible.
If you can make simple macros already, then defining variables shouldn't be a bridge too far from that. Once you get that down you'll be good to go.
https://docs.duet3d.com/en/User_manual/Reference/Gcode_meta_commands
-
@hebigt
Thanks for your reply, checked your link but I don’t think it’s what would work. I’ll see if I can explain the function a bit better, x any y are 90 degrees to one another, now if I place a work piece down with dowels or whatever is used for alignment of stock to x and y axis, then all I need is to do one probe of x then y then z, subtract half probe width and I have all I need to proceed. But, i have a vacuum table so no dowel holes. So the best I can do is get it close, but x and y will always be skewed slightly. So, if after turning on the vacuum and securing the piece I do a a single xyz probe, the work piece will still be skewed with relation to the true xy positioning. But if I was able to do either an x or y second probe a certain distance(say 25 mm) away from the first probe, that would tell the machine to skew both x and y planes to suit the position of the workpiece. And if that could be done, no matter what type of work holding you use, you won’t need a known x or y plane(I always use x because y is my motive axis. Does that make sense? Or maybe I’m wrong about this? -
@tyrod Hey sorry about that. I completely misread your original post and assumed you were asking about XYZ tool offsets with a fixed workpiece! I was way off...
You said,
"But, i have a vacuum table so no dowel holes. So the best I can do is get it close, but x and y will always be skewed slightly."Are you saying that, because it is a vacuum table, the workpiece can be placed anywhere, and you do your best to align it to the X/Y axes?
I wonder if you could try to use M556, like you mentioned?
(This might be wrong) The way I read the description for M556, it's measuring the two orthogonal sides of a right triangle. If that's correct, you might be able to do something like:
For X-axis
-
Probe the absolute X position (of the workpiece) at one point
-
Probe the absolute X position at another point along the same face
(Ideally, these measurement points are far enough away from one another for there to be a discernible difference in the distance between the two, while still being on the workpiece) -
Subtract the above positions from one another and initialize the result as a variable, e.g. 'w'. The result may be negative or positive which tells you in what direction the piece is skewed.
-
Initialize a variable, e.g. 'd' which is the distance you had to move the Y-axis between the two points.
-
Feed both of those stored variables as parameters into an M556 command (or even another macro containing M556).
Use a similar method for the Y-axis. I imagine, If you are doing this by hand and eye-balling it, the skew will be small but not insignificant.
Making it automatic would require the machine to know where to probe the piece in the first place.
Again, I'm not sure if that's exactly how M556 works, but it may be worth a try. You should be able to easily test the skew compensation by applying it and then running the probe across a face of your workpiece to make sure it is following the face exactly. Or by measuring points along the face.
-
-
@hebigt
hi, yes, m556 looked good to me at first until i looked into its function a little closer. its used to correct misalignment of the frame. so with a misaligned frame the xy planes arent perpendicular to each other. i think what i want is G68 coordinate rotation. then i could rotate the xy plane to match the stock xy planes. note That i have visible xy lines to get my stock very close. what im trying to achieve is perfect realignment of stock if removed for any reason. G68 uses angle input to rotate xy plane keeping them perpendicular.
i can write a macro to probe all axis, even the 2 probe points on x axis. i would probe once, set that point to x0, then move a specific amount and do another g38.2 then read that point with M114 and this is where i get stuck. i would need a formula to take the length of the 2 points and their x differential and apply an angle . the BIG question is, how do i get gcode to do this automatically what formula would work. im not a programmer so meta commands and variables etc,etc are beyond my capabilities. -
Cool if G68 works!
I feel like I'm doing a lot of guessing here, but i'm fairly certain you can calculate the angle you need using meta commands.
RRF supports the atan function which you can use to calculate the small angle in a right triangle.
Here's a drawing and some notes (super messy, sorry!).
-
@hebigt
Wow! All Greek to me! Trigonometry etc was a long time ago I just turned 64 on the 13th. Anyway I searched through the info on meta commands and it’s nothing I can deal with. That being said, I went online and found what I think I need to calculate the angle in degrees(for g68)
Not sure but I think picture b would be the correct way. Side note, I believe probing y would have to come after doing this but not z height.
I’ve searched to see if there is a complete formula to do this that is usable as a meta command but I’m not sure of what to do with it even if I did. I need help!! -
Since you have a vacuum table, I would flip the problem:
- Insert a pointy thing in your chuck.
- Do a G0 move to location (0,0)
- Align part of the part at that location
- Do a G0 move to location (100,0)
- Rotate the part to align rotation in the X-Y plane
- Turn on the vacuum
I get that the part may be unusually-shaped, but you need known coordinates on the part to locate it using the coordinate-system transformation method anyway, so instead of doing that, just make G0 moves to those known locations and orient the part correctly.
-
@alankilian
Ahh, the k.i.s.s method
I already do that but the issue is that it’s difficult to keep the original 0,0 from shifting in some cases. I really believe a software solution would benefit all cnc users. As a lot of cnc users are probing it seems an automatic probing solution is a logical step forward. I’m really hoping someone can help. -
@tyrod
Just found m673 align plane on rotary axis. Alas, it doesn’t support xy axis! I wonder if there’s a workaround? -
@tyrod
I guess there’s not enough interest in this at this time since it’s mainly a cnc thing. I can still use a macro to probe twice on x axis then use tan on a calculator to get what I need. Maybe dc42 or another of the many smart contributors could comment on this idea? I think this may need its own gcode like the m673 align plane on rotary axis one. I’ll carry on and try to write a macro with a pause to input the g68 and degrees. Thanks to everyone who replied! -
@tyrod
You could put a request in the firmware wishlist section for an R parameter to be added to G10http://www.linuxcnc.org/docs/2.6/html/gcode/gcode.html#sec:G10-L2_
-
@owend
Thanks owend, I looked at the link and I noticed it says “ when a rotation is in affect jogging an axis will only move that axis in a positive of negative direction and not along the rotated axis” does that mean only jogging ignores the rotation but gcode follows the rotation? I assume so, I hope -
@tyrod
Owend, I would still need to find the rotational offset required to shift xy axis to line up with my stock shown in my drawing. That’s why I thought g68 was a good way to go. I was looking at meta commands and found reference to tan under function subheading, dc42 was referring to deamon.g and I followed that link and that’s when I found it. I have some idea how to: 1st probe x, set to g92 x0 as the base, move, say,50mm and do second probe and that would give me the distance of the perpendicular. So now I know length of base and length of perpendicular to be able to use the tan function to calculate the degree rotation of xy plane. I think(not sure) I can use m114 to report x and y coordinates to host. From here I have no idea if it’s possible to get the required calculations performed by meta command(or daemon.g) or however it’s done to then add the angle in degrees to g68 and run it which would theoretically rotate the xy axis to match the stock material. Easy to remove by using g69 as well -
@tyrod OwenD wrote an intro-document for g code meta commands. Check it out!
https://forum.duet3d.com/topic/16495/conditional-g-code-introduction-tutorial-pdf
-
@hebigt
Hey Hebigt, thanks for that! I read through it. While I now have a better understanding how I could make macros do a lot more work for me, unfortunately my knowledge on the language is nil. I think I have found a c++ program to calculate the angle in degrees that g68 needs. But have no idea how to use it. I just don’t have the knowledge I would need and a crash course in c++ or whatever needed is not in the cards. -
@tyrod I just found “Feature request-workpiece angle compensation CNC” by jay_s_uk and in it he wrote a script to do exactly what I wanted. I just searched for g68 and it’s on the second search page. I haven’t the time right now to try it. Thank you jay_s_uk! (And everyone else)!
-