On Saturday, February 18, 2012 04:08:25 PM Tomaz T. did opine:

> hi all,
> I am writing subrutine for automatic tool length measuring, as I have to
> change tool manually on my 5 axis ...
> 
> for now I came this far:
> 
> o<tool_probe>sub
> 
> #1002 = #5223                         (store G54 Z offset)
> 
> G49                                   (cancel existing offset if it is 
any)
> 
> G30                                   (to probe location)
> 
> G91                                   (incremental mode)
> 
> G38.2 Z-150 F300                      (probe fast)
> 
> G0 Z5
> 
> G38.2 Z-10 F80                                (probe slow)
> 
> #1003 = #5063                         (store probe resault)
> 
> #1000 = -[#1001 - [#1003]-[#5223]]    (calcutaing tool length ~ #1001 is
> previous probed distance without tool)
> 
> #5223 = [#1002-[#1000]]                       (correction in G54 Z 
offset)
> 
> G10 L1 P1 W[#1000]                    (Updating tool table)
> 
> G90                                   (absolute mode)
> 
> G30                                   (to safe distance)
> 
> T1 G43                                        (selecting tool)
> 
> G1 W0 F500                            (zeroing W axis for kinematics)
> 
> o<tool_probe>endsub
> 
> 
> So, with this I get correct tool length in my tool table, but problem I
> still have is that when subrutine ends, and for example next line in
> code is just going to Z0, machine goes higher for the distance of
> measured tool length (G54 Z variable number is correct Z offset
> according to new tool length), and if I enter in MDI manually  G0 Z0,
> then it goes to correct Z height, which is on same location as before
> calling subrutine and without any tool compensation.
> 
> For test purpose I was calling subrutine with:
> 
> G0 x0y0z0
> 
> o<tool_probe>CALL
> 
> G0 x0 y0 Z0
> 
> M30
> What am I missing or doing wrong?

Probably not using a different co-ord mapping could be fouling it up.
In my current project, a pcb for the opto stuff in a spindle position 
encoder, I now have 3 utilities I use.  First, I set a 3/32 brass tube just 
off the left front corner of the micarta pallet that carries the pcb.  This 
finds the exact center of that tubing using the G38 functions, and from 
that, sets up the g55 (top of board) and g56 (bottom of board) co-
ordinates.  My probe is another piece of brass tubing that is mounted in an 
1/8" collet, and carries that teeny little wire spring loop from a sewing 
machine needle threader.  I have a tanalum cap of around 2 microfarads that 
is shorted by any contact between that wire loop, turning at 500 revs, 
which saves the logic zero and 'debounces' the contact.  I manually 
position it of the end of the tube, and run this utility which seems to 
have a sub 0.001" repeat accuracy.

( tholefinder.ngc, a hole finding routine to aid in registering )
( the top and bottom machining operations based on the eagle CAD program. )
( The files are issued by pcb2gcode ulp when it converts an eagle )
( board to gcode commands)

( Copyright Feb 2012 by Gene Heskett, licensed the same as LinuxCNC )
#<yfudge>= -0.2047
#<xfudge>= 0.15
#<boffset> = 2.1008 ( for G56 settings )
M05 ( make sure spindle is off )
( remove all machine offsets )
G17 G20 G40 G49 G54 G80 G90 G94
S675 ( preset suitable spindle speed )
M03 G04 P1.5 ( start spindle slowly )
( find tubing)
G38.2 z-2 F2 ( establish initial #5061-#5069 values )
( copy #5063 to #101)
#<firstz>=#5063 ( initial contact Z )
G00 Z[#<firstz> + 0.018] ( raise it a wee bit to open probe )
( now find right edge of hole )
G38.2 X[#5061 + 0.055] F0.2 ( search slowly for right side of hole )
( Copy first x found to #<rightx> )
#<rightx>=#5061 ( record first x value )
G01 x[#<rightx> -0.005] ( open probe )
G04 P.2 ( wait for cap to charge )
G38.2 F0.2 X[#<rightx> -0.070] ( search slowly for left side of hole )
#<leftx>=#5061 ( record second x value )
#<centerx>=[[#<rightx> + #<leftx>] / 2.0000] ( gives center of hole in x 
dir )
G01 f2 x#<centerx> ( put probe in center of X )
G04 p0.2 ( wait for cap to charge )
G38.2 f0.1 y[#5062 +0.070] ( now find back of hole for backy )
#<backy>=#5062
G01 F2 y[#<backy> - 0.005] ( Open probe contact )
G04 P.2 ( wait for cap to charge )
G38.2 f0.1 y[[#<backy>] -0.060] ( now find front of hole )
#<fronty>=#5062
#<centery>=[[#<backy> + #<fronty>] / 2.0000]
G01 f2 y#<centery> ( put in center of hole )
(output value established, HOME XY here )
M05 (stop spindle)
G00 z[#<firstz> + 0.3] f1  (clear your tubing dummy!)
( for use in o<tedautoz.ngc and bedautoz.ngc)
( adjust fudge in above to hit corner of board at x.1y0 in in Gx mode )
#100 = [#<centerx> + #<xfudge>] ( last is board offset for top )
#101 = [#<centery> + #<yfudge>] ( new gage tube error? )
(debug, corrected X offset for top is #100)
(debug, corrected Y offset for top is #101)
(msg, now manually home X and Y )
( and program G55 co-ordinate tables )
G10 L2 P2 x[#100 - 0.1] y#101 ( offset G55 co-ordinates left 0.1 inches )
( and G56 for bottom of board values )
G10 L2 P3 x[#100 + 0.1 + #<boffset>] y#101
( sets G56 and assume board is dead straight with table )
( don't worry about home if its close )
M02

=================
Then here is the slow code, I didn't want to crash into the pcb and mark it 
up with the tools.  This is tedautoz.ngc, with the ted part meaning Top, 
Etch, Drill,  there is a corresponding bedautoz.ngc that diddles the G56 
mapping for cutting the bottom of the board.
=================
o<tedautoz> sub
( a top side only routine to auto compensate tool length offsets )
( Copyright Feb, 2012 by Gene Heskett )
( this code is licensed by the same license as LinuxCNC, )
( formerly N.I.S.T. and Electronic Machine Control )
( This program executes the moves to the tool changing position well above 
workpiece )
( subroutine to be called immediately after the M06 T# is found in the 
gcode )
( Try to put machine in known state. )
( Since this is a top side function, it will use G55 for X comp mapping,)
( the corresponding bottom side will use G56 for X comp)
( which it will setup in bedautoz.ngc from in memory vars set by 
bholefinder.ngc )
#1 = -2.0 ( well below expected contact. )
#2 = 0.0015 ( adjust for engraving depth, minus values to reduce, etc. ) 
G20 G90
S2600 (set spindle speed W/O since pcb-gcode does not)
M05 (stop spindle )
(msg, in tedautoz now canceling TLO and setting G54 work map )
G55 ( put in top etch/drill co-ord mapping and cancel any old tool length 
offsets )
G49
G01 F5 Z2.00 ( get it out of the way )
(debug, moving to original X0.1000 Y0.1000 to measure tool length)
G00 X0.30000 Y0.10000 ( in G55 set to safe spot on your board )
( from where originally HOME'd)
( Now probe fast for contact, stopping at #1 with error )
( if no contact found, broken drill, broken Z drive belt? )
(debug, now sort of fast probe to z=#1 is next )
(msg, lowering drill to probe contact, is right place?)
G38.2 F2 Z#1 ( sets #5063 to contact height )
(msg, moving away a tiny bit relative and do slow probe for final value)
G01 F2 z[#5063 +0.010 ]
G38.2 f.1 z#1 ( which will again stop on contact )
(debug, now setting TLO to z=[#2 + #5063])
G43.1 Z[#2 + #5063] ( to ensure it is set to machine zero +#2 for z offset 
)
G01 F5 X0.1 Y0 Z0.2000 ( clear board, slow so it can be stopped if wrong )
(debug, waiting to see if at LFront corner of board but x at 0.1 in axis 
and machine)
( job done, return to caller )
M03 ( restart spindle)
G04 P1.5 ( pause for spindle wind up time )
o<tedautoz> endsub
====================
Then for the bottom, bedautoz.ngc
===================


> ------------------------------------------------------------------------
> ------ Virtualization & Cloud Management Using Capacity Planning
> Cloud computing makes use of virtualization - but cloud computing
> also focuses on allowing computing to be delivered as a service.
> http://www.accelacomm.com/jaw/sfnl/114/51521223/
> _______________________________________________
> Emc-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/emc-users


Cheers, Gene
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
My web page: <http://coyoteden.dyndns-free.com:85/gene>
My BIOLOGICAL ALARM CLOCK just went off ... It has noiseless DOZE
FUNCTION and full kitchen!!

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to