Hello Guest it is March 28, 2024, 10:55:47 AM

Author Topic: Modifing Operator Editable Button Macros  (Read 27341 times)

0 Members and 1 Guest are viewing this topic.

Offline Tweakie.CNC

*
  • *
  •  9,196 9,196
  • Super Kitty
    • View Profile
Re: Modifing Operator Editable Button Macros
« Reply #30 on: April 20, 2018, 07:34:16 AM »
I have sent you a PM.

Tweakie.
PEACE

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: Modifing Operator Editable Button Macros
« Reply #31 on: April 21, 2018, 01:43:05 AM »
here your modified code, pls test carefully because i have not tested it.
it is just minimal code without any checks like , probe allready grounded when start, or no probe was hit.

Code:
'probe z surface macro
Sub Main()
   FeedCurrent = GetOemDRO(818)   'Get the current settings, OEM DROs (818)=Feedrate DRO
   ZCurrent = GetOemDro(802)      'OEM DROs (802)=Z DRO
   GageH = GetOEMDRO(1001)         'OEMDRO(1001)=Gage Block Height
   ZNew = -300                  'probe down 300 mm

   Code "G90F200"      'slow feed rate to 200 MM/MIN
   Sleep(200)         
   Code "G31 Z" &ZNew      'probe Z- 300 mm
   While IsMoving()
      Sleep(10)
   Wend
   ZTouch = GetVar(2002)
   'Go back to point where probe was hit
   code "G0 Z" &ZTouch
   While IsMoving()
      Sleep(10)
   Wend
   
   'set new z height
   Call SetDro (2,GageH)   'DRO(2)=Z DRO

   FinalMove = GageH + 10
   Code  "G0 Z" &FinalMove
   'return old feedrate
   Code "F" &FeedCurrent   'restore starting feed rate   

End Sub   
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.

Offline yemil

*
  •  21 21
    • View Profile
Re: Modifing Operator Editable Button Macros
« Reply #32 on: April 21, 2018, 08:19:21 AM »
no  it did not..
it  goes down slowly ..touches the plate  and then pushes down hard..

this one is working
                            'probe z surface macro
                             FeedCurrent = GetOemDRO(818)    'Get the current settings, OEM DROs (818)=Feedrate DRO
                            ZCurrent = GetOemDro(802)   'OEM DROs (802)=Z DRO
                            GageH = GetOEMDRO(1001)      'OEMDRO(1001)=Gage Block Height
                            ZNew = ZCurrent - 300      'probe down 20 mm

                            Code "G90F200"         'slow feed rate to 200 MM/MIN
                            SetOemDRO(818,200)
                            Rem Code "G4 P1"      'Pause 1 second to give time to position probe plate
                            Code "G31 Z" &ZNew
                            While IsMoving()
                            Sleep(10)
                           Wend
                           Call SetDro (2,GageH)      'DRO(2)=Z DRO
                           FinalMove = GageH + 10
                           Code  "G0 Z" &FinalMove
                           Code "F" &FeedCurrent        'restore starting feed rate   
                           SetOemDRO(818,FeedCurrent)

the problem is  that if i modify this for the other 2 axix  X and Y  they work fine if  put them  SEPARATED

if i join X and Y axis Zeroing macros together ,  the machine just senses the first X axis and set it to zero and then ignores the second  part ( just the Zeroing Y axis) it does the rapid movements


' probe x surface macro
FeedCurrent = GetOemDRO(818)    'Get the current settings, OEM DROs (818)=Feedrate DRO
XCurrent = GetOemDro(800)   'OEM DROs (800)=X DRO
GageX = -11.5                   'Gage Block x 10 plus 1.5
XNew = XCurrent + 300      'probe to the right
YCurrent = GetOemDro(801)   'OEM DROs (801)=Y DRO
GageY = -11.5         'Gage Block Y 10 plus 1.5


Code "G90F200"         'slow feed rate to 200 MM/MIN
SetOemDRO(818,200)
Code "G4 P1"              'Pause 1 second  to position probe plate
Code "G31 X" &XNew
While IsMoving()
Sleep(10)
Wend
Call SetDro (0,GageX)      'DRO(0)=x DRO

XFinalMove = GageX -10
Code  "G0 X" &XFinalMove


YpreOne = YCurrent-30      ' Y positioning

Code "G0 Y" &YpreOne      
Code "G0 X20"

' probe y surface macro
YCurrent = GetOemDro(801)   'OEM DROs (801)=Y DRO
YNew = YCurrent + 300      'probe  on y axis
ZCurrent = GetOemDro(802)   'OEM DROs (802)=Z DRO
GageH = GetOEMDRO(1001)   

Code "G31 Y" &YNew      'Y Zero
While IsMoving()
Sleep(10)
Wend
Call SetDro (1,GageY)      'DRO(1)=y DRO

YFinalMove = GageY -10
Code  "G0 Y" &YFinalMove

'Z Position
ZpreOne = ZCurrent +15

Code "G0 Z"&ZpreOne
Code "G0 Y20"



Code "F" &FeedCurrent        'restore starting feed rate   
SetOemDRO(818,FeedCurrent)

thanks in advance

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: Modifing Operator Editable Button Macros
« Reply #33 on: April 21, 2018, 08:47:17 AM »
put the code in VB Scripter Window step through a see where it Fails.
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.

Offline yemil

*
  •  21 21
    • View Profile
Re: Modifing Operator Editable Button Macros
« Reply #34 on: April 21, 2018, 11:59:37 AM »
VB Scripter Window ???
the leaning curve has been so steep.........................

but i did it  and  made some adjustments...

here is the script...  and runs  very well


' probe x surface macro
FeedCurrent = GetOemDRO(818)    'Get the current settings, OEM DROs (818)=Feedrate DRO
XCurrent = GetOemDro(800)   'OEM DROs (800)=X DRO
GageX = -11.5                   'Gage Block x 10 plus 1.5
XNew = XCurrent + 300      'probe to the right
YCurrent = GetOemDro(801)   'OEM DROs (801)=Y DRO
GageY = -11.5         'Gage Block Y 10 plus 1.5
Code "G90F200"         'slow feed rate to 200 MM/MIN
SetOemDRO(818,200)
Code "G4 P1"              'Pause 1 second  to position probe plate
Code "G31 X" &XNew
While IsMoving()
Sleep(10)
Wend
Call SetDro (0,GageX)      'DRO(0)=x DRO
XFinalMove = GageX -10
Code  "G0 X" &XFinalMove
YpreOne = YCurrent-30      ' Y positioning
Code "G0 Y" &YpreOne      'X en posicion para medir Y
Code "G0 X20"
' probe y surface macro
YCurrent = GetOemDro(801)   'OEM DROs (801)=Y DRO
YNew = YCurrent + 300      'probe  on y axis
ZCurrent = GetOemDro(802)   'OEM DROs (802)=Z DRO
GageH = GetOEMDRO(1001)   
Code "G90F200"         'slow feed rate to 200 MM/MIN
SetOemDRO(818,200)
Code "G4 P1"
Code "G31 Y" &YNew      'Y Zero
While IsMoving()
Sleep(10)
Wend
Call SetDro (1,GageY)      'DRO(1)=y DRO
YFinalMove = GageY -10
Code  "G0 Y" &YFinalMove
'Z Position
ZpreOne = ZCurrent +15
Code "G0 Z"&ZpreOne
Code "G0 Y20"          'Y en posicion para medir Z
ZCurrent = GetOemDro(802)   'OEM DROs (802)=Z DRO
Znew = ZCurrent-300
Code "G90F200"         'slow feed rate to 200 MM/MIN
SetOemDRO(818,200)
Code "G4 P1"      'Pause 1 second to give time to position probe plate
Code "G31 Z" &ZNew
While IsMoving()
Sleep(10)
Wend
Call SetDro (2,GageH)      'DRO(2)=Z DRO
FinalMove = GageH + 10
Code  "G0 Z" &FinalMove
Code "F" &FeedCurrent        'restore starting feed rate   
SetOemDRO(818,FeedCurrent)

Offline yemil

*
  •  21 21
    • View Profile
Re: Modifing Operator Editable Button Macros
« Reply #35 on: April 21, 2018, 12:05:44 PM »
i would like to add some adjustments as

diameter of tool
and if is Z zeroing or XYZ Zeroing

Re: Modifing Operator Editable Button Macros
« Reply #36 on: April 21, 2018, 12:19:36 PM »
i would like to add some adjustments as

diameter of tool
and if is Z zeroing or XYZ Zeroing



Congratulations.

I you review the macros in the first two pages of this discussion thread you will see how to add the adjustments for getting tool diameter input and posting status messages on the screen.
airnocker

Everything depends on everything else

Offline yemil

*
  •  21 21
    • View Profile
Re: Modifing Operator Editable Button Macros
« Reply #37 on: April 21, 2018, 12:47:47 PM »
i did...

Dim ConfirmReady As String

means   tha ConfirmReady will be letters

and if i want to input  numbers?  like 6..
do i have to tell

Dim ConfirmReady As Integer    ?

Re: Modifing Operator Editable Button Macros
« Reply #38 on: April 21, 2018, 09:55:51 PM »
Yes, AskTextQuestion is a means to gather text or numeric input from the user.

I eventually made my AutoToolZero button macro versatile for every variation for what I do on my machine.
Sometimes I want to zero X and Y, then Z and sometimes I find it faster to manually zero X and Y where ultra precision is not required, then only zero Z.  So I built in questions that help remind and error check me, and I use programming numeric "Branch" labels to jump to the appropriate code section based on the response.  Mach3 VB only allows numeric jump points such as (1: or 2: or 3:, etc.) I also ask which touch plate thickness am I using since I have several with different thicknesses, so I'm gathering the adjustment to XY or Z's "zero" value.

Are the touch leads connected (y/n)  (one to the mill bit and one to ground)
If "y" then GoTo 1 Else GoTo 2

Examples from my code.  Bear in mind that you do not use the "If IsSuchSignal (22) Then" since this associates a parallel port interface to Mach3's Ports and Pins configuration.


2:
ToolDia = AskTextQuestion("What is the tool diameter?")
Message( "Auto Zeroing X...")
SetOEMDRO(XaxisDRO, 0.0000)
Sleep 1000
If IsSuchSignal (22) Then
   code "G31 X-2 F10"
   While IsMoving()
   Sleep 100
   Wend
   SetOEMDRO(XaxisDRO, ToolDia/2)
        Sleep 1000
   code "G1 X.5"
End If

Message( "Auto Zeroing Y..." )
SetOEMDRO(YaxisDRO, 0.0000)
Sleep 1000
If IsSuchSignal (22) Then
   code "G31 Y-1 F10"
   While IsMoving()
   Sleep 100
   Wend
   SetOEMDRO(YaxisDRO, ToolDia/2)
   Sleep 1000
   code "G1 Y.5"
End If

3:
DoZ = AskTextQuestion("Position the touch plate to zero Z.  y  to continue or n to skip.  (y/n)")
If DoZ = "y" Then GoTo 4 Else GoTo 6

4:
TouchPlate = AskTextQuestion("Enter Touch Plate thickness: e.g. 0 or .182")
Message( "Auto Zeroing Z..." )
SetOEMDRO(ZaxisDRO, 0.0000)
Sleep 1000
If IsSuchSignal (22) Then
   code "G31 Z-2 F5"
   While IsMoving()
   Sleep 100
   Wend
   SetOEMDRO(ZaxisDRO, TouchPlate)
   Sleep 1000
   code "G1 Z.25"
End If
GoTo 6

5:
Message ("Tool zeroing aborted.  Try again when ready.")
GoTo 7

6:
Message "Tool zeroing complete.  Check the results on the DROs."

7:
End Sub              



I hope this helps.
airnocker

Everything depends on everything else
Re: Modifing Operator Editable Button Macros
« Reply #39 on: April 21, 2018, 11:11:29 PM »
Yemil, do you have the Mach3 Macro manual?  Mach3_V3.x_Macro_Prog_Ref  You can download it from www.machsupport.com under the Product Manuals section here,  http://www.machsupport.com/help-learning/product-manuals/

airnocker

Everything depends on everything else