Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: Ya-Nvr-No on May 15, 2014, 08:28:06 PM

Title: Creating a Probe File
Post by: Ya-Nvr-No on May 15, 2014, 08:28:06 PM
--Inspired by Nicks (Bodini) Tool table exporter
--Place under a button
--can be called from a probe input in the future development

local AXIS_X = mc.mcAxisGetMachinePos(inst,0);
local AXIS_Y = mc.mcAxisGetMachinePos(inst,1);
local AXIS_Z = mc.mcAxisGetMachinePos(inst,2);

filename = "ProbeData.txt";

file = io.open(filename,"a"); -- create new file or add to it
ProbeData = string.format("X%4.4f Y%4.4f Z%4.4f \n",AXIS_X, AXIS_Y, AXIS_Z);
file:write(ProbeData)

file:close()
Title: Re: Creating a Probe File
Post by: BR549 on May 17, 2014, 10:49:28 PM
HIA Craig, I am working on converting a HIGH SPEED  probing routine to Mach4.

It appears that MACH4 does NOT have an internal file write to save the points to file ??

SO we have to create that part ourselves ????  BUMMER seems we are backing up here(;-)

SO in Gcode how do we save the points collected each trip to a save points file ?

In mach3 we had a Macro M40 that opened the point file and that switched on the record function inside Mach3 that wrote the points to file each trip.

IS THERE something in mach4 like that ???

(;-) TP

Title: Re: Creating a Probe File
Post by: BR549 on May 17, 2014, 11:38:15 PM
I do not see where Mach4 writes to the #var for the point on a G31 call.

#5061
#5062
#5063

SO it must not work yet ???
Title: Re: Creating a Probe File
Post by: Ya-Nvr-No on May 18, 2014, 07:30:09 AM
This code just takes the Dro values and writes them to a file, because a screen button, panel button, keyboard or modbus input can trigger an action.
Using the signal script routine, if the probe input was tripped it would write the values to the file. Crude and dirty but was an attempt of showing how you can pass DRO data to a file.
Title: Re: Creating a Probe File
Post by: ger21 on May 18, 2014, 07:43:17 AM
Would you use something like mc.mcRegGetValue(number hReg) to get the probe trip points?
Title: Re: Creating a Probe File
Post by: Ya-Nvr-No on May 18, 2014, 08:07:38 AM
I use it like this:
first you have to create a reg variable name and know the path
then fill it with something

    local Xval = mc.mcAxisGetPos(inst,0);
    WriteReg("iRegs0/Xvalue", Xval);

then go get it with something like this

    local hXval = mc.mcRegGetHandle(inst, "iRegs0/Xvalue");
    local Xval = mc.mcRegGetValue(hXval);

so you would have to pass the trip points into a register then read the register
Title: Re: Creating a Probe File
Post by: BR549 on May 18, 2014, 05:46:51 PM
HIYA Brian, can you tell us what register contains the Indicator (value)  for the ProbeTrip ? I am working on a new HIGHSPEED 3d probing routine and I need to know on each G31 call if it tripped or ran to end point.

There are times IF it gets to the endpoint it is an error AND sometimes it will get to an endpoint and it is normal to the function BUT in all cases it cannot write the endpoint values as it would be False data and corrupt the point cloud.


IS there an endpoint register for the G31 call that shows what the endpoint values are ?

Thanks, (;-) TP
Title: Re: Creating a Probe File
Post by: Ya-Nvr-No on May 19, 2014, 10:59:38 AM
Just tested Probing... Worked better than expected.
I created a Button and then when pushed it called a probing.tap file that I ran with cycle start.
Did as it was coded and was fast
no more "isMoving", all seemed to get handled in the G31 move.
Liking/Lovin it  ;D


Title: Re: Creating a Probe File
Post by: Ya-Nvr-No on May 19, 2014, 11:47:57 AM
Also tested the Probe file creation file I posted above with the Signal Script in the Load Screen Script section. Added a block of code for input13, then in mach turned on the input 13 and associated to the probe input. When it was tripped it created the file and added the data. So straight forward and easy to make happen. Just takes awhile to wrap your head around the new capabilities of Mach4 :-\
Spent a lot of time throwing rocks as Terry says.
Title: Re: Creating a Probe File
Post by: BR549 on May 19, 2014, 01:50:12 PM
Ok maybe I missed something but WHY  did you have to do ANYTHING scripting wise to make probing WORK in Darwin ???

All that code must be built into Mach4 not rely on scripting to make it work.

I am close to having a new 3d routine for probing Might need you to test it.  Hard to verify some of the moves without a moving  machine where probing works. It will be a G65 macro type function where you program in the #vars to program the function.  ALL in GCODE no scripting.

(;-) TP

(;-) TP
Title: Re: Creating a Probe File
Post by: Ya-Nvr-No on May 19, 2014, 02:36:59 PM
you dont have to script a thing I just did it to create a text file of the probed points
I'm looking at it for a future point cloud scanning routine.

that's what the probing routine was all Gcode, then I ran it as a regular program. Do believe that the button script can call the gcode file, load it, run it and move the machine to where you want to be left at and then have it set the DRO's to whatever you programmed in the code for it to be. So on a hole it might be centered 1" above the face of the part (X0Y0Z1) all done with variables.
Title: Re: Creating a Probe File
Post by: BR549 on May 19, 2014, 03:48:13 PM
I use it like this:
first you have to create a reg variable name and know the path
then fill it with something

    local Xval = mc.mcAxisGetPos(inst,0);
    WriteReg("iRegs0/Xvalue", Xval);

then go get it with something like this

    local hXval = mc.mcRegGetHandle(inst, "iRegs0/Xvalue");
    local Xval = mc.mcRegGetValue(hXval);

so you would have to pass the trip points into a register then read the register



I am still lost Was THE ABOVE QUOTE  part of what you did to make it all work ??  


Something needs to OPEN the SavedPoints file (M40 #4000 =0) , ( AND it ALWAYS opens in a specific Directory, C:\\Mach4Hobby\\Points Files )

YOU need to see IF the probe tripped (#*********x = 0/1) to continue or error(#3000 = x , Probe reached Endpoint)

Something needs to write the Trip points to file (Mxx?) on demand
   OR automatically write to file on trip.  (For Example #4000 = 0 /Auto OFF   #4000 = 1 /Auto ON)

Something needs to CLOSE the SavedPoints file (M41)
Title: Re: Creating a Probe File
Post by: BR549 on May 19, 2014, 04:07:11 PM
I forgot to add that Mach4 must update the #5061-5064 vars on trip.
Title: Re: Creating a Probe File
Post by: Ya-Nvr-No on May 19, 2014, 04:24:23 PM
 ???
have no idea what your referring too
here is a snippet of the probing code
you sure your not sniffin flux?  :-X
that code you posted has to do with reading and writing to registers.
that's what I used for the wizzard I created
I think I kind of mixed you up when I answered Gerrys question when it really had nothing to do with the probing routine. Sorry

g61
#98 = 50 (rough probe speed)
#97 = 5 (fine probe speed)
g91
g01 z0.0
g31 y-1 f#98
g01 y.1
g31 y-.2 f#97 (Get the -Y Pos)
#102 = #5062
g0 y.1
g31 y2 f#98
g01 y-.1
g31 y.2 f#97 (Get the +Y Pos)
#103 = #5062
#104 = [#102 + [#103-#102]/2]
g90 g0 Y#104

Title: Re: Creating a Probe File
Post by: BR549 on May 19, 2014, 04:36:08 PM
NO sniffing but I have been throwing rocks at LUA. The dust must be effecting my PEE BRAIN.   :o


OK but in the example you are not opening, writing to and closing the Points files. From your example I can assume that the Writing to the Trip point registers WORK in mach4 ?

#5061-#5066

When I try to OPEN a points file I get a Call " call name" <nil> error and that normally means there is NO such call AND I do not see that call in the list.

Nor do I see a #var for the trip condition, But I do see a signal call for the trip condition but you cannot use that in Gcode.

Probably best for me to WAIT for a working Mach4 instead OF THE demo(sim) VERSION.

(;-) TP
Title: Re: Creating a Probe File
Post by: Ya-Nvr-No on May 19, 2014, 04:46:25 PM
haven't f'd with trying to open a points file as of yet. So can't help ya there.

I don't open a thing just run the code and tell it what to do with the point variables.

I have never gotten the Sim to work when it comes to probing. And I have tried every way that I though might work.
Title: Re: Creating a Probe File
Post by: BR549 on May 19, 2014, 05:00:34 PM
I am dragging out an old Mach3 PC and getting it ready for Darwin.  Hopefully THEN I can set up a manual switch to control the probe function.

I Don't think that probe emulation works in the SIM. Doesn't here.

(;-) TP

Title: Re: Creating a Probe File
Post by: Ya-Nvr-No on May 22, 2014, 03:42:22 PM
TP/guys/gals you all like to look at data and B---ch, here is a probing routine I wrote for checking a 3" id
It does move to the center using Darwin and a Renishaw/wire modified probe
no ball diameter or other variables are used other than what you find in the tap file.

there are 8 captured variable files used, the columns in the spreadsheet show just what was being saved and used after each (num in the tap file)
BTW: used Nicks program to create the variable files, Thanks Nick, very functional

here is the tap file and spreadsheet of variables

It probed the circle and moved to the center as well as i could tell.
We are missing tons of Fanuc variables to be truly effective but it did work.
And though it can probe I had to run this in single block as there are some issues running in auto.
I added the g4p2 to give me a block/line of code to write the variables to the file.

I put my original 4 axis router (8020 w/Nema 34 steppers) back together to help me create the Probing routines for Darwin/PP driver. :P
Still works fine and took no time to setup with Darwin. Anybody need a router?  ;D
Title: Re: Creating a Probe File
Post by: BR549 on May 22, 2014, 04:15:48 PM
Looks Good Craig,  You do not need probe tip comp with a center of routine the radius compensated ITSELF from both sides of the hole. YOU would need it IF you were looking for hole diameter as well.  In mach3 we had probe tip comp that worked very well. maybe we will get lucky in Mach4(;-)

 We do need the error codes setup #3000 and LOT more #vars  . ALSO we need the trip point value brought out to a #var. THERE IS a signal call for that(;-).

 Without the error traps it would be easy to mis program the probing length of an axis and cause the center of hole to be offcenter.

Question IF you let the probe run to the END POINT does it write the endpoint values.

You could use the   Last_output_X (#5002) to check against BUT it  outputs Machine Corrds at this point. BUT it does work with the G31 moves just ion Machine coords not work coords.

(;-) TP
Title: Re: Creating a Probe File
Post by: BR549 on May 22, 2014, 04:20:51 PM
OK now convert it to a G65 parametric macro so it can be called on demand and programed on the fly.  Can you send the centerpoint or diameter values to the Last Error Line ? good for Operator reference(;-).

Mach4 does have potential (;-)

(;-)TP
Title: Re: Creating a Probe File
Post by: Ya-Nvr-No on May 22, 2014, 06:11:06 PM
I might not need it all the time, but you can bet I'll have it  ;)
and yes the trip point is the end point if not hit.


Created a variables tab so can watch the updates in real time.