Hello Guest it is December 02, 2024, 12:53:20 PM

Author Topic: Getting Auto Tool Zero Operation to Work in Mach3  (Read 18130 times)

0 Members and 1 Guest are viewing this topic.

Offline JimG

*
  •  21 21
Getting Auto Tool Zero Operation to Work in Mach3
« on: September 05, 2023, 01:19:48 PM »
I've had a difficult day trying to get this operation to work in my Mach3 setup.   I have three scripts which I have tried and all work except for not adding the gauge offset when the probe touches.  The three scripts all date from around 2010 and all of them access the Gauge Block DRO with the code "GetUserDRO(1151)".  When I single step through the scripts,  the value from this operation is zero.

The screen I'm using is one supplied by support for Seig KX1/3 machines in the UK and I suspect that the work wasn't quite completes from a remark left in the script area of the Auto Touch button. :-)   I wondered if an OEM code wasn't attached to the DRO,  or whether a different one had been attached.   I've spent the afternoon trying to see if I could get some information using MachScreen to investigate the screen,  but absolutely nowhere.  It's not often that a bit of software beats me. :-)

I also picked up that OEM codes may have changed over the years and a more recent list of DRO OEM codes I accessed did not have a code 1151 in it.

Any suggestion on how I can find out what's going on.     

I also tried Screen4 to investigate the screen but that software just hung up,  even in compatability mode.

I'm running Version R3.043.062

Jim.
« Last Edit: September 05, 2023, 01:21:32 PM by JimG »

Offline Tweakie.CNC

*
  • *
  •  9,258 9,258
  • Super Kitty
Re: Getting Auto Tool Zero Operation to Work in Mach3
« Reply #1 on: September 06, 2023, 03:23:42 AM »
Hi Jim,

Everyone has their own preference for the Auto Tool Zero script. If its any help to you this is the one that I am using. You would have to make changes to some of the values to suit your set-up but the comments should help.

Tweakie.

Code: [Select]
CurrentAbsInc = GetOemLED (48) 'Copy current G90/G91 state
CurrentGMode = GetOemDRO (819) 'Copy current G0/G1 state
CurrentFeed = GetOemDRO (818) 'Copy current feedrate
Contact = 0 'Clear the contact flag
PlateThickness = 2.8 'Touch Plate thickness is set here
ProbeFeed = 100 'Probing feedrate is set here
SetVar (1, -20) 'Maximum probing distance is set here
SetVar (2, PlateThickness+5) 'Retract height is set here
Code "M5" 'Ensures spindle is not running
Code “G21” 'Ensure metric units are used
Zs = GetOemDRO (61) 'Copy current Z-Scale DRO
Call SetOemDRO (61,1) 'Set Z-Scale DRO to 1
Label1: 'Entry point for Retry
DoOemButton (1010) 'Zero Z-Axis DRO
Code "(Setting Tool Zero)" 'Message for status bar
While IsMoving () 'Wait until task has been completed
Wend
If GetOemLED (825) = 0 Then 'Check to see if touch plate is already grounded
Code "G90 G31 Z #1 F" & ProbeFeed 'Probing move
While IsMoving () 'Wait until task has been completed
Wend
If GetOemLED (825) = True Then 'Check to see if probe has touched plate
Contact = 1 'Set the contact flag
End If
DoOemButton (1003) 'Clear a possible feed-hold condition
ProbePos = GetVar (2002) 'Exact point probe touched
Code "G0 Z" & ProbePos 'Go back to exact point of touch if there was any overrun
While IsMoving () 'Wait until task has been completed
Wend
Call SetDRO (2,PlateThickness) 'Set Z-Axis DRO to Touch Plate thickness
Code "G0 Z #2" 'Retract off Touch Plate the set distance
While IsMoving () 'Wait until task has been completed
Wend
Code "(Z-Axis is now Zeroed.)" 'Message for status bar
Code "F" & CurrentFeed 'Restore feedrate to original setting
If Contact = 0 Then 'Probe reached max travel without touching
Code "(ERROR - Probe did not touch.)" 'Message for status bar
Response = MsgBox ("ERROR - Probe did not touch.",37,"Auto Tool Zero")
If (Response = 4) Then 'User chose Retry
GoTo Label1 'Retry Probing routine
End If
End If
Else
Code "(ERROR - Touch Plate is grounded.)" 'Message for status bar
Response = MsgBox ("ERROR - Touch Plate is grounded - Check connection.",16,"Auto Tool Zero")
End If
Call SetOemDRO (61,Zs) 'Restore Z-Scale DRO to original setting
If CurrentAbsInc = 0 Then 'If G91 was in effect before then return to it
Code "G91"
End If
If CurrentGMode = 0 Then 'If G0 was in effect before then return to it
Code "G0"
End If
 
PEACE

Offline JimG

*
  •  21 21
Re: Getting Auto Tool Zero Operation to Work in Mach3
« Reply #2 on: September 06, 2023, 03:45:43 AM »
Hi Jim,

Everyone has their own preference for the Auto Tool Zero script. If its any help to you this is the one that I am using. You would have to make changes to some of the values to suit your set-up but the comments should help.

Tweakie.


PlateThickness = 2.8 'Touch Plate thickness is set here


I note that your code does what I was contemplating,  i.e. hard coding the plate thickness into the code rather than reading the value from a DRO.   I will have a go at that today and run your code as well.  Many thanks.

Jim.

Offline JimG

*
  •  21 21
Re: Getting Auto Tool Zero Operation to Work in Mach3
« Reply #3 on: September 06, 2023, 06:26:23 AM »
Installed the script this morning and did a few adjustments to suit my setup and it works well. :)   I've been meaning to do this for years since I first got the KX1 in 2010 and I wonder why I never did anything about it until now.  :)  I can get rid of the cigarette papers.  :)

I'm no expert on VBScript but I find it interesting to compare the (now) four scripts I have to do the same function which all vary to quite an extent.

Jim.

Offline Tweakie.CNC

*
  • *
  •  9,258 9,258
  • Super Kitty
Re: Getting Auto Tool Zero Operation to Work in Mach3
« Reply #4 on: September 06, 2023, 06:40:32 AM »
Hi Jim,

I am pleased that you now have a working script. Onwards and upwards  ;)

Tweakie.
PEACE

Offline JimG

*
  •  21 21
Re: Getting Auto Tool Zero Operation to Work in Mach3
« Reply #5 on: September 06, 2023, 09:50:48 AM »
Just a quick follow-up - like a dog with a bone I wanted to find out the OEM code of the Gauge Height DRO on my screen.   I couldn't get on with MachScreen,  and Screen4 on my modern Win10 PCs crashed and stalled continually needing a lot of CTRL-ALT-DEL to restore order.   But the PC I use for Mach with my KX1 is a slightly elderly one running WinXP. 

So I loaded up Screen4 on it and it worked well.  I was able to right-click on the DRO in question on the screen and found that the OEM value was 1002.   I replaced the value for the 1151 value in the three VBScripts that were looking for the value in the DRO and they all worked. :)

However I will stick with the Tweakie script. :)

Jim.