Simple/Manual Centre Finder

More
1 year 1 month ago - 1 year 1 month ago #334450 by andypugh
I have just realised that my thingy requires you to type in the values. That's not as ergonomic as one might hope. Give me a few minutes.
Files updated
 
Last edit: 1 year 1 month ago by andypugh.
The following user(s) said Thank You: Waldemar

Please Log in or Create an account to join the conversation.

More
1 year 1 month ago #334675 by Waldemar
Cheers Andy,

I'll get hold of 2.9.5 and try it out on the sim!

Please Log in or Create an account to join the conversation.

More
11 months 4 weeks ago #337844 by pgf
Replied by pgf on topic Simple/Manual Centre Finder
This is a good thread!

My probing support is in sort of a middle ground, niether fully manual, nor fully automatic. My automatic touchoff probes, and my manual touchoffs, all get logged to a file, courtesy LOGAPPEND/LOG/LOG_CLOSE. For a long time that log wasn't used -- it was just a byproduct of some sample code I'd started with over a decade ago.

But earlier this year I had a need to match the machines coordinate system to my workpiece. ((It was easier than trying to get it clamped down in perfect alignment.) So I wrote some (external) code to pull data from that probe logfile. The code took the last couple of touchoff points, and calculated the rotation angle of a line drawn through those points. And then printed the g-code command necessary to adjust the current coordinate system's rotation, i.e. "G10 L2 P0 R $angle". Later, I realized I could also use the log to find the center point between two probes, so I added that. If the two most recent probes were both done in the same direction, then they were likely probing an edge, and it prints the angle of the edge. If they were done in opposite directions, they were likely probing two edges (inside or out) of something whose center I'm interested in.

And then today, after finding this thread, I enhanced it a little more: It can now also look at the last three probes in the log file and give me the center point of the circle they describe.

All without any data entry, or modifications to my existing probing code. It runs from a button on my desktop (i.e. outside of and beside Axis), and puts up a window with its results. I simply copy the g-code commands it gives to the MDI window.

I'm happy to share what I have, but with caveats: a) it's written in shell, because that's what I like to do, and b), it calls out to a calculator program for the floating point. Almost any other language would have avoided 'b'.

Anyway, thanks for the inspiration, and for the center-finding equations.
The following user(s) said Thank You: Waldemar

Please Log in or Create an account to join the conversation.

More
2 months 4 days ago #349074 by Waldemar
I went back to this recently and looked into an alternative approach.  I simply don't have the knowledge (or courage!) to directly poke about with LinuxCNC, potentially breaking things as I go...  Anyway, this approach is browser based and uses a small Python bridging app, which (of course) ChatGPT wrote.  I'll attach the relevant files below.  To use them:

With LinuxCNC running, open a terminal in the directory containing the files and run python centre-finder.py, then open http://127.0.0.1:8080/centre-finder.html in Firefox.

The UI is pretty chonky, but I'll see about thinning it down in time.

Manually jog the tool to three points on the bore/cylinder, hit CAPTURE at each one, and it calculates the circle centre and sets the active WCS XY zero to that point. It doesn't move the machine — it's essentially a convenient operator interface sitting on top of LinuxCNC's Python interface. Currently working on 2.8.x/Python 2.7, with an eventual possibility of adding a horizontal electrical probe.

Once done and Firefox is closed, the Python server simply remains idle in the background waiting for another HTTP request; it does not generate motion or continuously interact with the LinuxCNC motion system, so it should have no meaningful effect on machine motion or step generation.

HOW IT WORKS:

The command the Python bridge sends to LinuxCNC is:

G10 L2 P0 X... Y...

Specifically, it constructs it as:

COMMAND.mdi("G10 L2 P0 X%.12f Y%.12f" % (new_wcs_x, new_wcs_y))

The important bit is P0:  P0 means the currently active coordinate system.  So if you're in G54, it writes G54. If you're in G55, it writes G55, etc.

COMPATIBILITY:

Developed and tested on LinuxCNC 2.8.x / Python 2.7. The browser interface is deliberately lightweight and the WCS write uses the standard LinuxCNC G10 L2 P0 command, so the underlying approach should be familiar across LinuxCNC versions. However, the Python bridge uses the LinuxCNC Python API and may need minor changes on significantly older/newer installations. Test in a SIM configuration before using it on a machine.

It is intended to set the active WCS XY offset; it does not move the machine.

Disclaimer: I've developed and tested this on a LinuxCNC 2.8.4 HAL SIM configuration and satisfied myself that the three-point calculation, active-WCS update and general workflow behave as intended. That said, this is very much a "use at your own risk" utility — please test it on your own configuration/SIM and verify the resulting coordinates before trusting it on a real machine. I accept no responsibility for damage to the machine, tooling or workpiece.
The following user(s) said Thank You: NWE

Please Log in or Create an account to join the conversation.

More
2 months 4 days ago - 2 months 4 days ago #349100 by JT
Replied by JT on topic Simple/Manual Centre Finder
A 3 point center finder is included with the Flex GUI...
 
JT
Last edit: 2 months 4 days ago by JT.
The following user(s) said Thank You: NWE

Please Log in or Create an account to join the conversation.

More
2 months 3 days ago #349113 by Waldemar
Yeah, I've seen that, but I'm very reluctant to start nuts and bolts messing with a system that works for me. Had a good look at Flex, but the installation etc. is still pretty opaque to me - add to that the fact that my LinuxCNC PC is sat offline everything becomes that bit more complicated..!

Please Log in or Create an account to join the conversation.

Time to create page: 0.374 seconds
Powered by Kunena Forum