Jump to content

PCM Code to check position and stylus system?


---
 Share

Recommended Posts

I got the idea from the Equator comparators we have, before starting a measurement they check if they are homed, for machine safety reasons.

I want to do the same thing in Calypso, we use park position and that position is the same for all programs on a given CMM.

I use getPositionCMM() and that seems to give me the position relative to the master probe, which is great because that's how we setup our park positions. But is this result in text format? Because it looks like this "255.0d@-125.0d@-50.0d"

The park position isn't exact on live machines, off by as much as 1mm so I have it multiplying the position by 1000, then rounding, then dividing by 1000.

Where I'm getting stuck is defining the position to compare against. it looks like I have to convert it to text,

parkPos=text(255.0,-125.0,50.0)

which gives me "255.0d-125.0d-50.0d". If I try adding the @ it doesn't work, if I leave them as numbers, it adds them up, which would be fine, if I could convert the result from getPositionCMM() to a number and let it add up the result.

I've similarly failed at converting the result from getPositionCMM() to number, so I'm likely on the wrong track there.

Thanks to anybody who reads this!
Link to comment
Share on other sites

getPositionCMM() is returning a vector. Here is some stuff to play around with.

parkPos = vector(255,-125,-50)
getPositionCMM().rounded - parkPos
getParameterNamed(getPositionCMM().rounded - parkPos).x
getParameterNamed(getPositionCMM().rounded - parkPos).y
getParameterNamed(getPositionCMM().rounded - parkPos).z
Link to comment
Share on other sites

I need to play more and make sure it always works, then tab it correctly so the next person doesn't want to murder me, but I think it does, thank you!

Now I have to figure out how make the machine execute the park position in the recovery program, ideally without actually measuring anything.

if getActualInspectionDir() <> "C:\data\cmm\programs\inspections\Production Parts\Recovery" then
parkPos = vector(450,-150,-50)
x=val(getParameterNamed(getPositionCMM().rounded - parkPos).x)
y=val(getParameterNamed(getPositionCMM().rounded - parkPos).y)
z=val(getParameterNamed(getPositionCMM().rounded - parkPos).z)
maxdev=max(abs(x),abs(y),abs(z))

if maxdev >= 3 then 
executeCode("ICCDialog message: '<c:red>Machine is not homed, Program will STOP "+cr()+"Remove all parts from the machine and run the recovery program! </c>'asRichText")
cncBreak()
else
message("Home")
endif
endif
Link to comment
Share on other sites

 Share

×
×
  • Create New...