Machsupport Forum
Mach Discussion => VB and the development of wizards => Topic started by: airnocker on July 11, 2010, 04:28:53 PM
-
I'm using a licensed version of Mach3, Version R3.042.038.
I've searched the forum and Mach Customize wiki until I'm blue in the face, so now I must ask. I am familiar with MS VBA and have a modest amount of successful experience with it.
I've read the following as well: Mach3 V3.x Programmer Reference Draft v0.11a.pdf, VB-Script-Commands.pdf, VB Constants Signal Numbers,VB Standard DROs and do not find my answers within.
When writing new VB for say, the Auto Tool Zero button, there seems to be Mach3 specific VB commands in the form of subroutines that can be entered without the formal Cypress VB "Sub Main()", "End Sub" beginning and end syntax.
As an example:
Message( "Auto Zeroing Z..." )
If IsSuchSignal (54) Then
code "G31 Z-3 F20"
While IsMoving()
Wend
Call SetDRO( 2, .059 )
code "G1 Z1"
End If
Can these VB statements be used inside of the normal Cypress VB subroutine structure as well, with defined variables etc. for an Operator Editable OEM button?
Are there any guidelines, published within the forum or wiki for doing so?
Does Cypress VB or Mach3 VB support the use of Labels as would be used with a "Goto BadEnd" statement, where "BadEnd:" is the syntax used on a script line for the goto entry point?
Many thanks in advance,
-
Ok, please, please...someone give me an answer to why this code generates a Syntax error when used for the Auto Tool Zero button macro.
Or at least tell me what I should do differently....
Sub XYZZeroMain
Dim ConfirmReady As String
Dim DoXY As String
ConfirmReady = AskTextQuestion("Confirm Touch plate circuit is grounded to bit (y/n).")
If ConfirmReady = "y" Then
Message "You entered " & ConfirmReady & "!"
Goto Start
Else Goto BadEnd
End If
Start:
DoXY = AskTextQuestion("Zero X and Y? (y/n)")
If DoXY = "y" then Goto XY
Else Goto Z:
End If
XY:
Message( "Auto Zeroing X..." )
If IsSuchSignal (22) Then
code "G31 X-2 F10"
While IsMoving()
Sleep 100
Wend
Call SetDRO( 0, .0625 )
code "G1 X.5"
End If
Message( "Auto Zeroing Y..." )
If IsSuchSignal (22) Then
code "G31 Y-1 F10"
While IsMoving()
Sleep 100
Wend
Call SetDRO( 1, .0625 )
code "G1 Y.5"
End If
Z:
Message( "Auto Zeroing Z..." )
If IsSuchSignal (22) Then
code "G31 Z-2 F10"
While IsMoving()
Sleep 100
Wend
Call SetDRO( 2, .059 )
code "G1 Z1"
End If
Goto GoodEnd
BadEnd:
Message ("Tool zeroing aborted." Try again")
Goto Done
GoodEnd:
Message "Tool zeroing complete."
Done:
End Sub
Thanks
-
I think I found the answer to my question above here: http://www.machsupport.com/MachCustomizeWiki/index.php?title=Communications_Routes under VB Script Programs.
Ok, so the latest version of Mach3 only supports a very small subset of Cypress VB so the use of GoTo statements and jump labels won't currently work.
So maybe in Mach4 as indicated in other posts herein we will see the more robust implementation of a VB interpreter, we hope, we hope, we hope!
-
SUre they work, use them all the time.
(;-)
-
BR,
That's very good to hear, so maybe you can suggest why after I load my M1s file shown in the above thread of mine, into the editor for the AutoTool Zero button and try to single step through the code I always get a syntax error that either highlights the "GoTo" line(s) or the label reference(s) but only one is every highlighted.
I'd really like to figure this out.
Thanks.
-
I have not studied it but it at least will run like this:
Sub Main()
Dim ConfirmReady As String
Dim DoXY As String
ConfirmReady = AskTextQuestion("Confirm Touch plate circuit is grounded to bit (y/n).")
If ConfirmReady = "y" Then GoTo 1 Else GoTo 4
1:
Message "You entered " & ConfirmReady & "!"
DoXY = AskTextQuestion("Zero X and Y? (y/n)")
If DoXY = "y" Then GoTo 2 Else GoTo 3
2:
Message( "Auto Zeroing X..." )
If IsSuchSignal (22) Then
code "G31 X-2 F10"
While IsMoving()
Sleep 100
Wend
Call SetDRO( 0, .0625 )
code "G1 X.5"
End If
Message( "Auto Zeroing Y..." )
If IsSuchSignal (22) Then
code "G31 Y-1 F10"
While IsMoving()
Sleep 100
Wend
Call SetDRO( 1, .0625 )
code "G1 Y.5"
End If
3:
Message( "Auto Zeroing Z..." )
If IsSuchSignal (22) Then
code "G31 Z-2 F10"
While IsMoving()
Sleep 100
Wend
Call SetDRO( 2, .059 )
code "G1 Z1"
End If
GoTo 5
4:
Message ("Tool zeroing aborted Try again")
GoTo 6
5:
Message "Tool zeroing complete."
6:
End Sub
end
-
Ooooooooooh, cool, so maybe it only likes numeric labels. I'll give it a try and report back.
Thanks BR
-
Many thanks BR.
The code runs perfectly with the numeric labels, hurray!
-
Glad you got it working, I love it when a plan comes together and chips fly. (;-)
-
For those who may have been following this post, here is the final version of my X,Y & Z Auto Tool Zero Macro. The macro asks for user input in the following sequence:
1. to confirm touch plate clips are connected otherwise exit
2. to zero X & Y? otherwise skip to zero Z
3. to confirm z touch plate is in position otherwise exit
The code is currently written to expect a tool or reference bit diameter of .125" and a 90 degree piece of 1/8" x 1 1/8" angle aluminum.
The inside faces of the aluminum angle have 1/16" copper clad circuit board super glued to them for better touch conductivity. See photo.
The angle aluminum is stood on end with the copper faced, inside angle held against the corner of the work piece that will become the 0,0 XY reference.
An interim "manual" XY zero is set so that the bit used to touch for the XY zeroing operation will be centered on each corresponding copper face. For my table the XY direction from "interim zero" toward the touch plate is in the negative direction.
An interim "manual" Z zero is set so that the bottom of the bit is about 1/2" to 1" above the work piece. For my table Z travel down is a negative direction.
The XY zeroing is consecutive without stopping.
The Z confirmation dialogue is to provide a "pause" to reposition the angle aluminum on a flat side on top of the work piece and possibly change to a different bit and set a new interim Z zero as described above, or exit
I've been very pleased with how this has worked for me.
Sub Main()
Dim ConfirmReady As String
Dim DoXY As String
Dim DoZ As String
ConfirmReady = AskTextQuestion("Confirm Touch plate leads are connected and ready. (y/n)")
If ConfirmReady = "y" Then GoTo 1 Else GoTo 5
1:
DoXY = AskTextQuestion("Zero X and Y also? (y/n)")
If DoXY = "y" Then GoTo 2 Else GoTo 3
2:
Message( "Auto Zeroing X..." )
If IsSuchSignal (22) Then
code "G31 X-2 F10"
While IsMoving()
Sleep 100
Wend
Call SetDRO( 0, .0625 )
code "G1 X.5"
End If
Message( "Auto Zeroing Y..." )
If IsSuchSignal (22) Then
code "G31 Y-1 F10"
While IsMoving()
Sleep 100
Wend
Call SetDRO( 1, .0625 )
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:
Message( "Auto Zeroing Z..." )
If IsSuchSignal (22) Then
code "G31 Z-2 F10"
While IsMoving()
Sleep 100
Wend
Call SetDRO( 2, .180 )
code "G1 Z1"
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
End
-
Here is the other picture that would not upload in my last post.
-
Looks good Airnocker
If you are thinking others may pick up this macro and use it then I would advise putting either;
DoOEMButton (1008)
or
SetOEMDRO (800,0)
at the beginning of each probe section (with appropriate number), followed by a "Sleep 100"
Save a bit of grief. :)
Greg
-
Thanks Greg.
Do you mean like this? Good catch, I forgot SetDRO is going out of style.
Version3
Sub Main()
Dim ConfirmReady As String
Dim DoXY As String
Dim DoZ As String
ConfirmReady = AskTextQuestion("Confirm Touch plate leads are connected and ready. (y/n)")
If ConfirmReady = "y" Then GoTo 1 Else GoTo 5
1:
DoXY = AskTextQuestion("Zero X and Y also? (y/n)")
If DoXY = "y" Then GoTo 2 Else GoTo 3
2:
Message( "Auto Zeroing X..." )
If IsSuchSignal (22) Then
code "G31 X-2 F10"
While IsMoving()
Sleep 100
Wend
Call SetOEMDRO( 800, .0625 )
Sleep 100
code "G1 X.5"
End If
Message( "Auto Zeroing Y..." )
If IsSuchSignal (22) Then
code "G31 Y-1 F10"
While IsMoving()
Sleep 100
Wend
Call SetOEMDRO( 801, .0625 )
Sleep 100
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:
Message( "Auto Zeroing Z..." )
If IsSuchSignal (22) Then
code "G31 Z-2 F10"
While IsMoving()
Sleep 100
Wend
Call SetOEMDRO( 802, .180 )
Sleep 100
code "G1 Z1"
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
End
-
No.
What I meant was, it is a good idea to zero the axis DRO before calling the probe move.
You will get users trying the script and saying "why does mine sometimes probe in the wrong direction?"
They may not manually zero the axis and say it is at -2 before the probe move.
The probe move might be "G31 Z-1". If they are in G90, then it will unexpectedly go in the wrong direction.
I have seen this exact scenario come up on the forum many times. :)
Greg
-
I see what you are saying now. As long as they have positioned the tool location reasonably close to the required starting point that takes them toward the intended XY touch plate location it would save them from having to manually zero X & Y first. I like that!
-
Thanks again Greg for the constructive suggestions.
New revisions to the XY & Z sections now zero the axis DRO's prior to moving toward the touch plate. The only prerequisite is the tool be positioned be less than +2" from the X touch plate face, less than +1" from the Y touch place face and less than +2" from the Z touch plate face.
The revised code now looks like this:
XYZ Auto Tool Zero Macro Version3.1 by airnocker
Sub Main()
Dim ConfirmReady As String
Dim DoXY As String
Dim DoZ As String
ConfirmReady = AskTextQuestion("Confirm Touch plate leads are connected and ready. (y/n)")
If ConfirmReady = "y" Then GoTo 1 Else GoTo 5
1:
DoXY = AskTextQuestion("Zero X and Y also? (y/n)")
If DoXY = "y" Then GoTo 2 Else GoTo 3
2:
Message( "Auto Zeroing X..." )
Call SetOEMDRO( 800, 0 )
Sleep 100
If IsSuchSignal (22) Then
code "G31 X-2 F10"
While IsMoving()
Sleep 100
Wend
Call SetOEMDRO( 800, .0625 )
Sleep 100
code "G1 X.5"
End If
Message( "Auto Zeroing Y..." )
Call SetOEMDRO( 801, 0 )
Sleep 100
If IsSuchSignal (22) Then
code "G31 Y-1 F10"
While IsMoving()
Sleep 100
Wend
Call SetOEMDRO( 801, .0625 )
Sleep 100
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:
Message( "Auto Zeroing Z..." )
Call SetOEMDRO( 802, 0 )
Sleep 100
If IsSuchSignal (22) Then
code "G31 Z-2 F10"
While IsMoving()
Sleep 100
Wend
Call SetOEMDRO( 802, .180 )
Sleep 100
code "G1 Z1"
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
End
-
hi i tried the script on my 3040 cnc..
the tip moved ..very slowly on each direction and back ...without touching the plate...
-
hi i tried the script on my 3040 cnc..
the tip moved ..very slowly on each direction and back ...without touching the plate...
Hi yemil,
Could you tell us more about your 3040 CNC machine and which version you are using of Mach? I've been using this macro with Mach3 successfully for many years. Let us know and we will try to help you.
-
Thanks .. that was fast...
i have a chinese 4030Z CNC conected with usb to my windows10 computer
the mach3 software that i am using ..i think is sort of modified mach3 software to be run under usb conected computer
as i have read ... most CNC with mach3 run on older computers with LPT1 port.... so
the software does not run many buttons as expected or seen in other youtube videos i thought i was alone ..
now .. i am trying to decipher this g code and macro stuff ...
and want to use the XYZ zero plate..
without any success at all....
can you help?...
what kind of info from my config , do you need?
thanks in advance
-
Thanks .. that was fast...
i have a chinese 4030Z CNC conected with usb to my windows10 computer
the mach3 software that i am using ..i think is sort of modified mach3 software to be run under usb conected computer
as i have read ... most CNC with mach3 run on older computers with LPT1 port.... so
the software does not run many buttons as expected or seen in other youtube videos i thought i was alone ..
now .. i am trying to decipher this g code and macro stuff ...
and want to use the XYZ zero plate..
without any success at all....
can you help?...
what kind of info from my config , do you need?
thanks in advance
I believe you just described the problem. :-( The USB break-out-board you are using (let me know which one it is, too) may not be able to emulate the LPT port functions or requires some "tweaking" in order to work with my zero touch-plate macro. I use a computer that has a legacy LPT parallel port and a CNC4PC C1R10.1 BOB (Break-Out-Board) https://cnc4pc.com/catalog/product/view/id/3/s/c1-parallel-port-interface-card/category/156/ .
We need to make sure you are using a USB break-out-board that emulates the parallel port's input and output pins.
-
the machine itself has a card BL-usbMach that works on usb....
but lets get into.... it
i use a 3 axis plate with an 10 mm gap extra on x and Y axis and 3 mm on the z axis
i have a macro that works on this version... for touch plate.. on Z axis
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 100 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)
it works for the touch plate.. and i want to modify it to make a 3 axis Zero
i modify it for the x axis as this...
FeedCurrent = GetOemDRO(818) 'Get the current settings, OEM DROs (818)=Feedrate DRO
XCurrent = GetOemDro(800) 'OEM DROs (800)=X DRO
Gagexy = -10 'OEMDRO(1001)=Gage Block xy
XNew = XCurrent + 300 'probe to the right
Code "G90F200" 'slow feed rate to 100 MM/MIN
SetOemDRO(818,200)
Rem Code "G4 P1" 'Pause 1 second to give time to position probe plate
Code "G31 X" &XNew
While IsMoving()
Sleep(10)
Wend
Call SetDro (0,Gagexy) 'DRO(0)=x DRO
FinalMove = Gagexy -10
Code "G0 X" &FinalMove
Code "F" &FeedCurrent 'restore starting feed rate
SetOemDRO(818,FeedCurrent)
and i works just fine for the x axis and puts the tip 20 mm to the left of plate
the y axis version is
' probe y surface macro
FeedCurrent = GetOemDRO(818) 'Get the current settings, OEM DROs (818)=Feedrate DRO
YCurrent = GetOemDro(801) 'OEM DROs (800)=Y DRO
GageY = -10 'OEMDRO(1001)=Gage Block xy
YNew = YCurrent + 300 'probe on y axis
Code "G90F200" 'slow feed rate to 100 MM/MIN
SetOemDRO(818,200)
Rem Code "G4 P1" 'Pause 1 second to give time to position probe plate
Code "G31 Y" &YNew
While IsMoving()
Sleep(10)
Wend
Call SetDro (1,GageY) 'DRO(1)=y DRO
YFinalMove = GageY -10
Code "G0 Y" &YFinalMove
Code "F" &FeedCurrent 'restore starting feed rate
SetOemDRO(818,FeedCurrent)
it also works fine
but as the time that i want to mix with movement on the axis ...nothing works
-
Thanks for showing your VB script.
Might I be correct in that your "Code "G90F200" is setting your feed rate to 200mm/min rather than what the comment denotes?
I'm assuming you know this but just in case, the use of a touch plate to effect zeroing XY or Z axes behaves as the ON/OFF switch for controlling the beginning and end of axis motion. It requires a wire be connected to the router bit and another connected to the axis contact plate. These two wires connect back to one input and one Ground terminal of the breakout board, forming a readable electro-mechanical switch.
The IF/THEN loop begins with the touch plate switch "OFF/Open" and for as long as the switch condition is open, (If IsSuchSignal(22) Then) move the axis in the defined direction at the defined feed rate, keep checking the state of the switch and when the switch reads "ON/Closed" stop all axis motion as the tool bit has come in contact with the conductive "zero" plate. Input 22 on the parallel port break-out board is internally held at 5v by a pull-up resistor, one of the two touch plate leads connects to here. The other lead is connected to the common Ground of the controller board. The VB touch plate loop is always checking whether pin 22 is pulled down to Ground potential. When the two leads meet, the "touch" is complete, the DRO is set to the touch plate thickness, etc.
In your code I do not see the "If IsSuchSignal()" statement, which may be why you are having these issues.
Here is a sample of my original Auto Tool Zero Method VB script.
If IsSuchSignal (22) Then 'this line is sensing whether a "touch" has occurred
code "G31 X-2 F10"
While IsMoving()
Sleep 100
Wend
Call SetOEMDRO( 800, .0625 )
Sleep 100
code "G1 X.5"
End If
-
ok...ok..
1.- I fixed the 200mm/min comment...
2.- I have not a parallel port on my machine so i dont know if the IF/THEN work as you said.
3.- I have the wires conected .... as all the Axis will work fine if they are on different macro .. i will post a video
4.- To avoid the pre contact of the plate i did put some adhesive tape under the plate... because on the CNC i have mounted a metal working space
5.- if i put the X zeroing macro first .. it works well on zeroing X axis ,and positionong the tip previous to the Y Axis Zeroing Macro
A------X axis zero macro
' 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 = -10 'OEMDRO(1001)=Gage Block xy
XNew = XCurrent + 300 'probe to the right
YCurrent = GetOemDro(801) 'OEM DROs (801)=Y DRO
GageY = -10 'OEMDRO(1001)=Gage Block y
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 X" &XNew
While IsMoving()
Sleep(10)
Wend
Call SetDro (0,GageX) 'DRO(0)=x DRO
XFinalMove = GageX -10
Code "G0 X" &XFinalMove
'Y to position
YpreOne = YCurrent-30
Code "G0 Y" &YpreOne
Code "G0 X20"
Code "F" &FeedCurrent 'restore starting feed rate
SetOemDRO(818,FeedCurrent)
------------------------------------------------------end of macro-------------------------------
6.- putting the next Y Zeroing macro on the ....Operator / Edit Button Script , erase the previous macro and puting the Y axis macro...
it works fine and prepares the tip for the Z Axis Zero on place.
' probe y surface macro
FeedCurrent = GetOemDRO(818) 'Get the current settings, OEM DROs (818)=Feedrate DRO
YCurrent = GetOemDro(801) 'OEM DROs (801)=Y DRO
GageY = -10 'OEMDRO(1001)=Gage Block y
YNew = YCurrent + 300 'probe on y axis
ZCurrent = GetOemDro(802) 'OEM DROs (802)=Z DRO
GageH = GetOEMDRO(1001) 'OEMDRO(1001)=Gage Block Height
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 Y" &YNew
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)
---------------------------End of Macro------------------------
7.- erase the previous script and place the Z Zeroing macro...
'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)
----------------------------------------------END----------------------------
this 3 works fine...
8.- But.. if i mix the 3 into one large script.....
the machine works erratic..
-
video 1 x zero and prepares for y zero
-
video 2 y zero and prepares for z zero
-
third video z zeroing
-
Nice update, thanks. The videos do show it working for each individual axis.
However, could you please point out for me where your code is sensing when the two wires for closing the circuit touch? I still do not see any evidence of this.
-
this 3 works fine...
8.- But.. if i mix the 3 into one large script.....
the machine works erratic..
IMHO your script's have some minor "leaks".
first read about GetVar(2000) to GetVar(2002), here are the values stored, where the the probe was hit,
because you will allways get an overrun of the axis caused by the decceleration during stop. so the usage
of this values is elementary (for me) for precise probing.
i personaly put allways after a movement instruction caused by script (G0 / G1) a
While IsMoving()
Sleep(10)
Wend
if you add this While IsMoving() to your code, you will see that the code will be a lot more
than you exepect.
you can also read about a Little bit here:
http://www.machsupport.com/forum/index.php/topic,36784.msg252331.html#msg252331
-
However, could you please point out for me where your code is sensing when the two wires for closing the circuit touch? I still do not see any evidence of this.
mmmmm...
as far as today... my learning curve for this has been ,
by learning in forums and watching youtube videos ,
the machine came with no manuals , and the modified version of mach3 have some different configuration
to be onest .............I have no clue
i added this commands by taking some notes and modifying some scripts found elsewhere..
they only sended this script ,
'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)
---------------------------------------------------------------------------
sensing the closing cicuit ? i have been trying to learn what every command does or what it is for....but i also cant find it..
-
here is my copy of the main screen..
-
I have sent you a PM.
Tweakie.
-
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
-
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
-
put the code in VB Scripter Window step through a see where it Fails.
-
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)
-
i would like to add some adjustments as
diameter of tool
and if is Z zeroing or XYZ Zeroing
-
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.
-
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 ?
-
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.
-
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/ (http://www.machsupport.com/help-learning/product-manuals/)
-
thanks..