Hello Guest it is January 15, 2021, 09:34:24 AM

Author Topic: macro external center piece  (Read 195 times)

0 Members and 1 Guest are viewing this topic.

macro external center piece
« on: December 20, 2020, 04:53:27 AM »
Buongirno
I use this macro for full center piece (modified to my needs by TPS) I would like to make some changes:
add double tap as it is not in my capacity.
I thank those who can help me.

  Rem VBScript To center probe outside diameter Metric Version
 
 
 
 
Speak (" psizionarsi CINQUE millimetri sopra il pezzo") 'Avviso Vocale
response = MsgBox ("   5 mm    SOPRA IL PEZZO")


  Begin Dialog ButtonSample 250,200,120,60,"   CENTRO PEZZO PIENO ? "
   OKButton 12,20,40,14
   CancelButton 68,20,40,14
End Dialog

Dim Dlg2 As ButtonSample
Button = Dialog (Dlg2)
If Button = 0 Then
   MsgBox "CENTRO PEZZO CANCELLATO !"
    Speak ("     CENTRO        PEZZO      CANCELLATO") 'Avviso Vocale
   Exit Sub
End If




Sleep (1000) ' pausa di 1 secondi
Speak (" CONFERMARE centro pezzo pieno") 'Avviso Vocale
Message "INIZIO CENTRO PEZZO PIENO"
Sleep (1000) ' pausa di 1 secondi
response = MsgBox ("CONFERMARE CENTRO PEZZO PIENO")

 Message "**** zero assi ****"
 
   DoOEMButton (1008) 'zero X
   DoOEMButton (1009) 'zero Y
   DoOEMButton (1010) 'zero Z
   Sleep (2000) ' pausa di 1 secondi   
Speak ("ZERO assi completato") 'Avviso Vocale


CurrentFeed = GetOemDRO(818) 'Get the current feedrate to return to later
CurrentAbsInc = GetOemLED(48) 'Get the current G90/G91 state
CurrentGmode = GetOemDRO(819) 'Get the current G0/G1 state
CurrentToolDiameter = GetOemDRO(1000) 'gets the current tool diameter

If GetOemLed (825) <> 0 Then 'Check to see if the probe is already grounded or faulty

    Call ProbeGrounded()
    Exit Sub

Else

    XCurrent = GetDro(0)
    YCurrent = GetDro(1)
    OutsideDiameter = GetUserDRO(1152)

    Code "G4 P1" 'Pause 1 second to give time to position probe plate
    While IsMoving ()
    Wend
    Call SetDro (0,0.000)
    While IsMoving ()
    Wend
    Call SetDro (1,0.000)
    Code "F50" 'slow feed rate to 100mm/sec
    Code "G90 G0 X" &XNew + OutsideDiameter * .6
    Code "G91 G0 Z-10"

Rem Probe Left

    XNew = Xcurrent - 75
    Code "G31 X" &XNew
    While IsMoving() 'wait for the move to finish
    Wend
    XPos1 = GetVar(2000) 'get the probe touch location
    Code "G91 G0 X2"
    Code "G91 G0 Z10"
    Code "G90 G0 X" &XCurrent 'rapid move back to start point
    Code "G91 G0 X" &XCurrent - OutsideDiameter * .6
    Code "G91 G0 Z-10"

Rem Probe Right

    XNew = XCurrent + 75 'probe 75mm to right
    Code "G31 X" &XNew
    While IsMoving()
    Wend
    XPos2 = GetVar(2000)
    Code "G91 G0 X-2"
    Code "G91 G0 Z10"
    XCenter = (XPos1 + XPos2) / 2 'center is midway between XPos1 and XPos2
    Code "G90 G0 X" &XCenter 'rapid move to the x center location
    While IsMoving ()
    Wend
    Call SetDro (0,0.000)
    Code "G4 P0.25"
    Code "G90 G0 Y" &YNew - OutsideDiameter * .6
    Code "G91 G0 Z-10"

Rem Probe up

    YNew = YCurrent + 75
    Code "G31 Y" &YNew
    While IsMoving()
    Wend
    YPos1 = GetVar(2001)
    Code "G91 G0 Y-2"
    Code "G91 G0 Z10"
    Code "G90 G0 Y" &YCurrent
    Code "G91 G0 Y" &YCurrent + OutsideDiameter * .6
    Code "G91 G0 Z-10"

Rem Probe down

    YNew = YCurrent - 75
    Code "G31 Y" &YNew
    While IsMoving()
    Wend
    YPos2 = GetVar(2001)
    Code "G91 G0 Y2"
    Code "G91 G0 Z10"
    YCenter = (YPos1 + YPos2) / 2

Rem move To the center

    Code "G90 G0 Y" &YCenter
    While IsMoving ()
    Wend
    Call SetDro (1,0.000)
    While IsMoving ()
    Wend
    Call SetUserDro (1152,YPos2 - YPos1 - CurrentToolDiameter)

    Code "G4 P0.25"

    Code "F" &CurrentFeed 'restore starting feed rate
   Call ReturnG90G91State()
   Exit Sub
End If

Offline TPS

*
  •  1,882 1,882
    • View Profile
Re: macro external center piece
« Reply #1 on: December 29, 2020, 01:45:43 AM »
what do you mean with double tap?
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: macro external center piece
« Reply #2 on: December 29, 2020, 02:05:38 AM »
Good morning
by double touch I mean that once the probe touches the piece it moves backwards by 2mm and then slowly touches the piece for the second time obtaining the most accurate measurement
I hope I explained myself (translated with google)
thanks TPS

Offline TPS

*
  •  1,882 1,882
    • View Profile
Re: macro external center piece
« Reply #3 on: December 29, 2020, 02:45:11 AM »
Code: [Select]
Rem VBScript To center probe outside diameter Metric Version
 
 
 
 
Speak (" psizionarsi CINQUE millimetri sopra il pezzo") 'Avviso Vocale
response = MsgBox ("   5 mm    SOPRA IL PEZZO")


  Begin Dialog ButtonSample 250,200,120,60,"   CENTRO PEZZO PIENO ? "
   OKButton 12,20,40,14
   CancelButton 68,20,40,14
End Dialog

Dim Dlg2 As ButtonSample
Button = Dialog (Dlg2)
If Button = 0 Then
   MsgBox "CENTRO PEZZO CANCELLATO !"
    Speak ("     CENTRO        PEZZO      CANCELLATO") 'Avviso Vocale
   Exit Sub
End If




Sleep (1000) ' pausa di 1 secondi
Speak (" CONFERMARE centro pezzo pieno") 'Avviso Vocale
Message "INIZIO CENTRO PEZZO PIENO"
Sleep (1000) ' pausa di 1 secondi
response = MsgBox ("CONFERMARE CENTRO PEZZO PIENO")

 Message "**** zero assi ****"
 
   DoOEMButton (1008) 'zero X
   DoOEMButton (1009) 'zero Y
   DoOEMButton (1010) 'zero Z
   Sleep (2000) ' pausa di 1 secondi   
Speak ("ZERO assi completato") 'Avviso Vocale


CurrentFeed = GetOemDRO(818) 'Get the current feedrate to return to later
CurrentAbsInc = GetOemLED(48) 'Get the current G90/G91 state
CurrentGmode = GetOemDRO(819) 'Get the current G0/G1 state
CurrentToolDiameter = GetOemDRO(1000) 'gets the current tool diameter

If GetOemLed (825) <> 0 Then 'Check to see if the probe is already grounded or faulty

    Call ProbeGrounded()
    Exit Sub

Else

    XCurrent = GetDro(0)
    YCurrent = GetDro(1)
    OutsideDiameter = GetUserDRO(1152)

    Code "G4 P1" 'Pause 1 second to give time to position probe plate
    While IsMoving ()
    Wend
    Call SetDro (0,0.000)
    While IsMoving ()
    Wend
    Call SetDro (1,0.000)
    Code "F50" 'slow feed rate to 100mm/sec
    Code "G90 G0 X" &XNew + OutsideDiameter * .6
    Code "G91 G0 Z-10"

Rem Probe Left

    XNew = Xcurrent - 75
    Code "G31 X" &XNew
    While IsMoving() 'wait for the move to finish
    Wend

    Code "G91 G0 X2 F10"
    While IsMoving() 'wait for the move to finish
    Wend
    Code "G31 X" &XNew
    While IsMoving() 'wait for the move to finish
    Wend

    XPos1 = GetVar(2000) 'get the probe touch location
    Code "G91 G0 X2 F50"
    Code "G91 G0 Z10"
    Code "G90 G0 X" &XCurrent 'rapid move back to start point
    Code "G91 G0 X" &XCurrent - OutsideDiameter * .6
    Code "G91 G0 Z-10"

Rem Probe Right

    XNew = XCurrent + 75 'probe 75mm to right
    Code "G31 X" &XNew
    While IsMoving()
    Wend

    Code "G91 G0 X-2 F10"
    While IsMoving() 'wait for the move to finish
    Wend
    Code "G31 X" &XNew
    While IsMoving() 'wait for the move to finish
    Wend

    XPos2 = GetVar(2000)
    Code "G91 G0 X-2 F50"
    Code "G91 G0 Z10"
    XCenter = (XPos1 + XPos2) / 2 'center is midway between XPos1 and XPos2
    Code "G90 G0 X" &XCenter 'rapid move to the x center location
    While IsMoving ()
    Wend
    Call SetDro (0,0.000)
    Code "G4 P0.25"
    Code "G90 G0 Y" &YNew - OutsideDiameter * .6
    Code "G91 G0 Z-10"

Rem Probe up

    YNew = YCurrent + 75
    Code "G31 Y" &YNew
    While IsMoving()
    Wend

    Code "G91 G0 Y-2 F10"
    While IsMoving() 'wait for the move to finish
    Wend
    Code "G31 Y" &YNew
    While IsMoving() 'wait for the move to finish
    Wend

    YPos1 = GetVar(2001)
    Code "G91 G0 Y-2 F50"
    Code "G91 G0 Z10"
    Code "G90 G0 Y" &YCurrent
    Code "G91 G0 Y" &YCurrent + OutsideDiameter * .6
    Code "G91 G0 Z-10"

Rem Probe down

    YNew = YCurrent - 75
    Code "G31 Y" &YNew
    While IsMoving()
    Wend

    Code "G91 G0 Y2 F10"
    While IsMoving() 'wait for the move to finish
    Wend
    Code "G31 Y" &YNew
    While IsMoving() 'wait for the move to finish
    Wend

    YPos2 = GetVar(2001)
    Code "G91 G0 Y2 F50"
    Code "G91 G0 Z10"
    YCenter = (YPos1 + YPos2) / 2

Rem move To the center

    Code "G90 G0 Y" &YCenter
    While IsMoving ()
    Wend
    Call SetDro (1,0.000)
    While IsMoving ()
    Wend
    Call SetUserDro (1152,YPos2 - YPos1 - CurrentToolDiameter)

    Code "G4 P0.25"

    Code "F" &CurrentFeed 'restore starting feed rate
   Call ReturnG90G91State()
   Exit Sub
End If
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: macro external center piece
« Reply #4 on: December 29, 2020, 03:44:29 AM »
the modification works great !!!
if I don't ask too much is it possible to separate axes?
I mean having 2 macros, one for x axis (always x for full)
one for y axis (always for full)
I sincerely thank you for the help given

Offline TPS

*
  •  1,882 1,882
    • View Profile
Re: macro external center piece
« Reply #5 on: December 29, 2020, 04:32:05 AM »
X-Axis
Code: [Select]
Rem VBScript To center probe X-Axis
 
 
 
 
Speak (" psizionarsi CINQUE millimetri sopra il pezzo") 'Avviso Vocale
response = MsgBox ("   5 mm    SOPRA IL PEZZO")


  Begin Dialog ButtonSample 250,200,120,60,"   CENTRO PEZZO PIENO ? "
   OKButton 12,20,40,14
   CancelButton 68,20,40,14
End Dialog

Dim Dlg2 As ButtonSample
Button = Dialog (Dlg2)
If Button = 0 Then
   MsgBox "CENTRO PEZZO CANCELLATO !"
    Speak ("     CENTRO        PEZZO      CANCELLATO") 'Avviso Vocale
   Exit Sub
End If




Sleep (1000) ' pausa di 1 secondi
Speak (" CONFERMARE centro pezzo pieno") 'Avviso Vocale
Message "INIZIO CENTRO PEZZO PIENO"
Sleep (1000) ' pausa di 1 secondi
response = MsgBox ("CONFERMARE CENTRO PEZZO PIENO")

 Message "**** zero assi ****"
 
   DoOEMButton (1008) 'zero X
   DoOEMButton (1009) 'zero Y
   DoOEMButton (1010) 'zero Z
   Sleep (2000) ' pausa di 1 secondi   
Speak ("ZERO assi completato") 'Avviso Vocale


CurrentFeed = GetOemDRO(818) 'Get the current feedrate to return to later
CurrentAbsInc = GetOemLED(48) 'Get the current G90/G91 state
CurrentGmode = GetOemDRO(819) 'Get the current G0/G1 state
CurrentToolDiameter = GetOemDRO(1000) 'gets the current tool diameter

If GetOemLed (825) <> 0 Then 'Check to see if the probe is already grounded or faulty

    Call ProbeGrounded()
    Exit Sub

Else

    XCurrent = GetDro(0)
    YCurrent = GetDro(1)
    OutsideDiameter = GetUserDRO(1152)

    Code "G4 P1" 'Pause 1 second to give time to position probe plate
    While IsMoving ()
    Wend
    Call SetDro (0,0.000)
    While IsMoving ()
    Wend
    Call SetDro (1,0.000)
    Code "F50" 'slow feed rate to 100mm/sec
    Code "G90 G0 X" &XNew + OutsideDiameter * .6
    Code "G91 G0 Z-10"

Rem Probe Left

    XNew = Xcurrent - 75
    Code "G31 X" &XNew
    While IsMoving() 'wait for the move to finish
    Wend

    Code "G91 G0 X2 F10"
    While IsMoving() 'wait for the move to finish
    Wend
    Code "G31 X" &XNew
    While IsMoving() 'wait for the move to finish
    Wend

    XPos1 = GetVar(2000) 'get the probe touch location
    Code "G91 G0 X2 F50"
    Code "G91 G0 Z10"
    Code "G90 G0 X" &XCurrent 'rapid move back to start point
    Code "G91 G0 X" &XCurrent - OutsideDiameter * .6
    Code "G91 G0 Z-10"

Rem Probe Right

    XNew = XCurrent + 75 'probe 75mm to right
    Code "G31 X" &XNew
    While IsMoving()
    Wend

    Code "G91 G0 X-2 F10"
    While IsMoving() 'wait for the move to finish
    Wend
    Code "G31 X" &XNew
    While IsMoving() 'wait for the move to finish
    Wend

    XPos2 = GetVar(2000)
    Code "G91 G0 X-2 F50"
    Code "G91 G0 Z10"
    XCenter = (XPos1 + XPos2) / 2 'center is midway between XPos1 and XPos2
    Code "G90 G0 X" &XCenter 'rapid move to the x center location
    While IsMoving ()
    Wend
    Call SetDro (0,0.000)
    Code "G4 P0.25"

    Code "F" &CurrentFeed 'restore starting feed rate
   Call ReturnG90G91State()
   Exit Sub
End If

Y-Axis
Code: [Select]
Rem VBScript To center probe Y-Axis
 
 
 
 
Speak (" psizionarsi CINQUE millimetri sopra il pezzo") 'Avviso Vocale
response = MsgBox ("   5 mm    SOPRA IL PEZZO")


  Begin Dialog ButtonSample 250,200,120,60,"   CENTRO PEZZO PIENO ? "
   OKButton 12,20,40,14
   CancelButton 68,20,40,14
End Dialog

Dim Dlg2 As ButtonSample
Button = Dialog (Dlg2)
If Button = 0 Then
   MsgBox "CENTRO PEZZO CANCELLATO !"
    Speak ("     CENTRO        PEZZO      CANCELLATO") 'Avviso Vocale
   Exit Sub
End If




Sleep (1000) ' pausa di 1 secondi
Speak (" CONFERMARE centro pezzo pieno") 'Avviso Vocale
Message "INIZIO CENTRO PEZZO PIENO"
Sleep (1000) ' pausa di 1 secondi
response = MsgBox ("CONFERMARE CENTRO PEZZO PIENO")

 Message "**** zero assi ****"
 
   DoOEMButton (1008) 'zero X
   DoOEMButton (1009) 'zero Y
   DoOEMButton (1010) 'zero Z
   Sleep (2000) ' pausa di 1 secondi   
Speak ("ZERO assi completato") 'Avviso Vocale


CurrentFeed = GetOemDRO(818) 'Get the current feedrate to return to later
CurrentAbsInc = GetOemLED(48) 'Get the current G90/G91 state
CurrentGmode = GetOemDRO(819) 'Get the current G0/G1 state
CurrentToolDiameter = GetOemDRO(1000) 'gets the current tool diameter

If GetOemLed (825) <> 0 Then 'Check to see if the probe is already grounded or faulty

    Call ProbeGrounded()
    Exit Sub

Else

    XCurrent = GetDro(0)
    YCurrent = GetDro(1)
    OutsideDiameter = GetUserDRO(1152)

    Code "G4 P1" 'Pause 1 second to give time to position probe plate
    While IsMoving ()
    Wend
    Call SetDro (0,0.000)
    While IsMoving ()
    Wend
    Call SetDro (1,0.000)
    Code "F50" 'slow feed rate to 100mm/sec
    Code "G90 G0 Y" &YNew - OutsideDiameter * .6
    Code "G91 G0 Z-10"

Rem Probe up

    YNew = YCurrent + 75
    Code "G31 Y" &YNew
    While IsMoving()
    Wend

    Code "G91 G0 Y-2 F10"
    While IsMoving() 'wait for the move to finish
    Wend
    Code "G31 Y" &YNew
    While IsMoving() 'wait for the move to finish
    Wend

    YPos1 = GetVar(2001)
    Code "G91 G0 Y-2 F50"
    Code "G91 G0 Z10"
    Code "G90 G0 Y" &YCurrent
    Code "G91 G0 Y" &YCurrent + OutsideDiameter * .6
    Code "G91 G0 Z-10"

Rem Probe down

    YNew = YCurrent - 75
    Code "G31 Y" &YNew
    While IsMoving()
    Wend

    Code "G91 G0 Y2 F10"
    While IsMoving() 'wait for the move to finish
    Wend
    Code "G31 Y" &YNew
    While IsMoving() 'wait for the move to finish
    Wend

    YPos2 = GetVar(2001)
    Code "G91 G0 Y2 F50"
    Code "G91 G0 Z10"
    YCenter = (YPos1 + YPos2) / 2

Rem move To the center

    Code "G90 G0 Y" &YCenter
    While IsMoving ()
    Wend
    Call SetDro (1,0.000)
    While IsMoving ()
    Wend
    Call SetUserDro (1152,YPos2 - YPos1 - CurrentToolDiameter)

    Code "G4 P0.25"

    Code "F" &CurrentFeed 'restore starting feed rate
   Call ReturnG90G91State()
   Exit Sub
End If
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: macro external center piece
« Reply #6 on: December 29, 2020, 05:35:47 AM »
the macros work well the only thing that in the measurement is 1mm less, I mean the piece is 80mm in the 79mm dro
I tried to insert +1 in the line:
  Call SetUserDro (1152, YPos2 - YPos1 - CurrentToolDiameter)
modified
  Call SetUserDro (1152, YPos2 - YPos1 - CurrentToolDiameter +1)
and that's okay but I don't know if it's a legitimate thing!!