Hello Guest it is December 09, 2021, 05:30:25 AM

### Author Topic: Calculating Tool length + setting hight.  (Read 961 times)

0 Members and 1 Guest are viewing this topic.

#### Simon Goderis

• 1
##### Calculating Tool length + setting hight.
« on: December 08, 2017, 05:35:39 AM »
Hi,

I am Simon, pretty new to this forum and working with my own 4-axis CNC-mill running on mach3 mill.
As i am trying to write a macro to calculate the tool length and setting the Z level for the current tool i am struggeling with some issuess.
The machine needs to touch a gage with a fix point on the spindle, the moves the mill point above the gage and touch again, the difference of these 2 hights +75mm should be the distance from the mill point to the turning axis of my spindle.

In this part i already succeded.

The sad truth is i failed in the most simple part
when the mill point hits the probe it needs to write all the settings and move +10, for this movement i used Code  "G90 Z +10 F5000"

Next thing that happend is the machine that goes down instead of up and destroys my gage.
How is this possible and how can i prevent it of doing this?

Under this post you can find my code.

Thanks for the help
Simon
Code: [Select]
`ZCurrent = GetOemDro(802)      'OEM DROs (802)=Z DROGageH = GetOEMDRO(1001)        'OEMDRO(1001)= hoogte ProbeZNew = ZCurrent - 100        'Probe 100mm naar benedenDim ZBlock  Dim ZFrees Dim Hhoogte Code "G53 X190 Y190 F5000"          'verplaatsen naar ProbeBlockPositieWhile IsMoving ()Sleep(10)WendCode "F500"            Code "G31 Z " &ZNew            'Beweging naar Gage While IsMoving ()Sleep(10)WendZBlock =  (GetOemDro(802))    'Hoogte wegschrijven als ZBlock Code  "G90 Z +70 F5000"        'beweeg naar veilige HoogteWhile IsMoving ()Sleep(10)Wend          Code  "G90 Y +86" 'Beweeg spindel boven GageWhile IsMoving ()Sleep(10)WendCode "F500"Code "G31 Z" &ZNew            'Beweging naar GageWhile IsMoving ()Sleep(10)WendZFrees =  (GetOemDro(802)) 'hoogte wegschrijven als ZFreesHhoogte = ((ZBlock*-1) - (ZFrees*-1) + 75)Call SetDro (2,GageH)        'DRO(2)=Z DROCode  "G90 Z +50 F5000" MsgBox("H = " & Hhoogte)`