3 point level macro

Started by MIL-TFP-41, August 01, 2025, 11:05 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MIL-TFP-41

So I had some parts, some castings, that I wanted to probe to establish a best condition plane. I reached out to Renishaw, they do sell a add on package, Inspection Plus Advanced Cycles, that will establish a plane form 3 points.

Me being me, and knowing the math behind this isn't that tough, decided to brew up my own.

How it works -
Probe 3 points on a surface. Store the XYZ values of each point in #160 thru #168
For simplicity, I stored X & Y in point 1 as zero. The X and Y points 2 and point 3 are the incremental distance from point 1. The Z value at each point is what I am actually probing

so, for example, point 1 would be X0, Y0, Z(probe)
#160=0
#161=0
#162=(probe value)
point 2 would/could be X3. Y0. z(probe)
#163=3.
#164=0
#165=(probe value)
point 3, X2. Y2. z(probe)
#166=2.
#167=2.
#168=(probe value)

Once that data is collected, run it through the macro.
What is output -
#180 would be the angular error that the machine needs to rotate around "X" to make the plane flat
#181 would be the angular error that the machine needs to rotate around "Y" to make the plane flat
#183 would be the angular error that the machine needs to rotate around "Z" to make the plane flat

Now, in my experiments, the error in Z was not necessary for my purposes. I wrote the errors to the "a"(rotated around X) and "b"(rotated around Y) registers in the WSEC tables. I made G54.4 active, checked that part, and everything was now flat.

At first, the order of points collected was critical. I did add a section in "(--- Set Positive Vector Direction ---)" to overcome this, hopefully. I also found that when probing a plane in an orientation other than "home" one has to invert the angles depending on orientation. Not sure I can verbalize all of that efficiently on a forum.


 Anyway, enough explaining. Use at your own risk, yadda yadda.


O8526 (LEVEL PLANE ANGLE)
(INPUTS)
(S - WRITE TO WSEC OFFSET NUMBER)
(EX- S2. WILL WRITE VALUES TO G54.4 P2)
(FORMAT - G65 P8526 S2.)

(INPUT ERRORS)
IF[[#19LT1.]OR[#19GT7.]]GOTO1000

(POINT 1 DATA)
(#160 = X1)
(#161 = Y1)
(#162 = Z1)

(POINT 2 DATA)
(#163 = X2)
(#164 = Y2)
(#165 = Z2)

(POINT 3 DATA)
(#166 = X3)
(#167 = Y3)
(#168 = Z3)


(--- Compute Vectors V1 = P2 - P1 ---)
#170 = #163 - #160  (V1x = X2 - X1)
#171 = #164 - #161  (V1y = Y2 - Y1)
#172 = #165 - #162  (V1z = Z2 - Z1)

(--- Compute Vectors V2 = P3 - P1 ---)
#173 = #166 - #160  (V2x = X3 - X1)
#174 = #167 - #161  (V2y = Y3 - Y1)
#175 = #168 - #162  (V2z = Z3 - Z1)

(--- Compute Cross Product N = V1 x V2 ---)
#176 = [#171 * #175] - [#172 * #174]  (Nx)
#177 = [#172 * #173] - [#170 * #175]  (Ny)
#178 = [#170 * #174] - [#171 * #173]  (Nz)

(--- Set Positive Vector Direction ---)
WHILE [#178 LT 0] DO1
#176 = [#174 * #172] - [#175 * #171]
#177 = [#175 * #170] - [#173 * #172]
#178 = [#173 * #171] - [#174 * #170]
END1

(--- Normalize N ---)
#179 = SQRT[[#176*#176] + [#177*#177] + [#178*#178]]
#176 = #176 / #179
#177 = #177 / #179
#178 = #178 / #179

(--- Compute Angles in Degrees ---)
#180 = ATAN[#177 / #178]     (Rotate around X)
#181 = -ATAN[#176 / #178]    (Rotate around Y)
#182 = ATAN[#176 / #177]     (Rotate around Z — optional)

(--- Write Offset ---)
G90G10L23P#19 A#180 B#181
G11

M99

N1000
#3000=1(S INPUT ERROR)
M30
Like Like x 6 Love Love x 1 Thank  You Thank You x 2 View List

Zoffen

This would probably be a good time to ask for a raise.

When they ask why you think you deserve more money....

You just show them this macro and ask them if they understand it?  8)
Like Like x 2 Funny Funny x 4 View List
Believe none of what you hear and only half of what you see.

Safety! is no Accident!

jstell

That and show them the quote from Renishaw.
Like Like x 1 Funny Funny x 2 View List

CNCAppsJames

Quote from: jstell on August 01, 2025, 11:47 AMThat and show them the quote from Renishaw.
Yeah, how much are the advanced cycles?
"That bill for your 80's experience...yeah, it's coming due. Soon." Author Unknown

Inventor Pro 2026 - CAD
CAMplete TruePath 2026 - CAV and Post Processing
Fusion360 and Mastercam 2026 - CAM

CNCAppsJames

"That bill for your 80's experience...yeah, it's coming due. Soon." Author Unknown

Inventor Pro 2026 - CAD
CAMplete TruePath 2026 - CAV and Post Processing
Fusion360 and Mastercam 2026 - CAM

mkd

Cycle 431 native on Heidenhain. Easy peasy
Funny Funny x 2 View List

CNCAppsJames

Quote from: mkd on August 06, 2025, 01:31 PMCycle 431 native on Heidenhain. Easy peasy
G-Code > Conversational

:P 
Funny Funny x 2 View List
"That bill for your 80's experience...yeah, it's coming due. Soon." Author Unknown

Inventor Pro 2026 - CAD
CAMplete TruePath 2026 - CAV and Post Processing
Fusion360 and Mastercam 2026 - CAM

CNCAppsJames

Or... set #6055 = 431 and save as O9015.

BOOM!

G431Sn.

Easy peasy.

:rofl:
Like Like x 1 Love Love x 1 View List
"That bill for your 80's experience...yeah, it's coming due. Soon." Author Unknown

Inventor Pro 2026 - CAD
CAMplete TruePath 2026 - CAV and Post Processing
Fusion360 and Mastercam 2026 - CAM