Hello Guest it is March 29, 2024, 11:27:22 AM

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

0 Members and 1 Guest are viewing this topic.

Modifing Operator Editable Button Macros
« 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,


airnocker

Everything depends on everything else
Re: Modifing Operator Editable Button Macros
« Reply #1 on: July 13, 2010, 04:40:53 PM »
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
airnocker

Everything depends on everything else
Re: Modifing Operator Editable Button Macros
« Reply #2 on: July 13, 2010, 07:09:58 PM »
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!
airnocker

Everything depends on everything else

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Modifing Operator Editable Button Macros
« Reply #3 on: July 13, 2010, 08:20:20 PM »
SUre they work, use them all the time.

(;-)
Re: Modifing Operator Editable Button Macros
« Reply #4 on: July 13, 2010, 08:36:31 PM »
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.
airnocker

Everything depends on everything else

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Modifing Operator Editable Button Macros
« Reply #5 on: July 13, 2010, 08:57:21 PM »
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

Re: Modifing Operator Editable Button Macros
« Reply #6 on: July 13, 2010, 08:59:31 PM »
Ooooooooooh, cool, so maybe it only likes numeric labels.  I'll give it a try and report back.

Thanks BR

airnocker

Everything depends on everything else
Re: Modifing Operator Editable Button Macros
« Reply #7 on: July 13, 2010, 09:15:30 PM »
Many thanks BR.

The code runs perfectly with the numeric labels, hurray!

airnocker

Everything depends on everything else

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Modifing Operator Editable Button Macros
« Reply #8 on: July 13, 2010, 09:20:12 PM »
Glad you got it working, I love it when a plan comes together and chips fly. (;-)
Re: Modifing Operator Editable Button Macros
« Reply #9 on: July 27, 2010, 06:47:51 PM »
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


airnocker

Everything depends on everything else