Machsupport Forum
Mach Discussion => VB and the development of wizards => Topic started by: birillo1959 on April 04, 2018, 02:16:16 PM
-
406/5000
good evening
I have this macro (not my found on the internet) "centerpiece full" and 'can modify it? I try to explain myself:
1 position me in the middle (approximate)
2 launch the macro, go x +
3 comes down and comes back to touch
4 gets up
and 'here' that I would like to change it, before it rises I would like it to come back a few mm, and if it could double-fingered.
thanks for any help
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")
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")
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(43) '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 - OutsideDiameter * .6
Code "G31 X" &XNew
While IsMoving() 'wait for the move to finish
Wend
XPos1 = GetVar(2000) 'get the probe touch location
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 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 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 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
Sub ProbeGrounded()
Code "(Probe plate is grounded, check connection and try again)"
Call ReturnG90G91State()
End Sub
Sub ReturnG90G91State()
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
End Sub
-
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")
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")
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(43) '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 - OutsideDiameter * .6
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
Sub ProbeGrounded()
Code "(Probe plate is grounded, check connection and try again)"
Call ReturnG90G91State()
End Sub
Sub ReturnG90G91State()
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
End Sub
-
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")
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")
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(43) '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"
anyhow this XNew is set nowhere before it is used.
-
the macro is OK !! thanks TPS for the help ;)
-
good morning
the macro works, but it gives me a problem, at the end of the probing in the dro it displays the dimension of the piece + meta 'probe, I explain if the diameter of the piece is 80 mm
the probe is 6mm in the dro display 83mm, is it possible to correct?
-
try to Change this:
CurrentToolDiameter = GetOemDRO(43) 'gets the current tool Diameter
to:
CurrentToolDiameter = GetOemDRO(22) 'gets the current tool diameter
-
tried to change always remains the problem, if in settings / probe diameter imposed 3mm (the tip is 6mm) the result is fine.
to make me understand I have to set the half of the real measure.
-
can you please change the following oices of code:
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"
to
Code "G90 G0 Y" &YCenter
While IsMoving ()
Wend
Call SetDro (1,0.000)
While IsMoving ()
Wend
Call SetUserDro (1152,YPos2 - YPos1 - CurrentToolDiameter)
msgbox "YPos2: " &YPos2 & " YPos1: " &YPos1 & "Tooldiamter: " &CurrentToolDiameter
Code "G4 P0.25"
and Report the displayed values?
Where do you set the probe Diameter ? screenshot ?
-
I modified the macro, and the piece got worse and it's 80mm
as you can see in the photo the result in the dro is 70.261
-
can you mofify the code:
msgbox "YPos2: " &YPos2 & " YPos1: " &YPos1 & "Tooldiamter: " &CurrentToolDiameter
to:
msgbox "XPos2: " &XPos2 & " XPos1: " &XPos1 & "Tooldiamter: " &CurrentToolDiameter
-
same problem
-
courious, because the messagebox Shows only the coordinates where the probe was hit and the Diameter of the probe.
from the data it Looks like 70mm not 80mm ???
when you watch axis dro's are they about +- 38mm when the probe is hit ?
-
the round is 80 mm I enclose photos
1 photo of the round
2 probing with last macro
3 probing with macro just modified, probe and '6mm (I set half as photo) Reply # 1 on: April 05, 2018, 12:40:44 AM
-
ok i have tested the following code here on my machine,
and it showed allway the correct diameter, did about 10 runs.
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")
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")
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(43) '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 - OutsideDiameter * .6
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)
MsgBox "diameter: " &GetUserDro(1152) &" mm"
Code "G4 P0.25"
Code "F" &CurrentFeed 'restore starting feed rate
Call ReturnG90G91State()
Exit Sub
End If
Sub ProbeGrounded()
Code "(Probe plate is grounded, check connection and try again)"
Call ReturnG90G91State()
End Sub
Sub ReturnG90G91State()
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
End Sub
-
tried the macro, same problem maybe I have some wrong setting. when I use it I divide (: 2) the probe !! thanks for the patience TPS !!!
-
if you push your probe by Hand, is it switching imediately, or maybe after 3mm push ?
-
you can also try to replace
this code:
Call SetUserDro (1152,YPos2 - YPos1 - CurrentToolDiameter)
by:
Call SetUserDro (1152,YPos2 - YPos1 - (CurrentToolDiameter/2))
-
the switching is immediate, also tested with another probe, the change does not work.
-
i have tested the code from reply #13 again.
it is working perfect here,
so i am out of ideas. sorry.
-
good morning
TPS, I documented (in my small) I solved by replacing OEM code fuction 221 with 1000 (I saw 1024.set) then in the macro I replaced:
CurrentToolDiameter = GetOemDRO (43) 'gets the current tool diameter
with
CurrentToolDiameter = (GetOEMDRO (1000) / 2) 'gets the current tool diameter
it works well, I wanted to ask you (of VB I do not understand almost anything !!) if it is done well or if it is dangerous.
-
if the oemdro(1000) is used nowhere else in your Screen it is ok.
-
I did a search and "oemdro (1000)" is not used anywhere !!
thanks TPS for the help !!