Hello Guest it is April 16, 2024, 06:48:41 AM

Author Topic: New Mach3 v4 VB Interface  (Read 10623 times)

0 Members and 1 Guest are viewing this topic.

New Mach3 v4 VB Interface
« on: October 16, 2009, 09:45:49 PM »
Below is the proposed set of VB functions to be supported in the first release of the Mach3 v4 VB interface, excluding Modbus and Serial.  Modbus will remain unchanged for now, and Serial support will be completely new, but is, as yet, undefined.

All you VB users, please review, and if you see any missing functionality, or have questions about what some of the functions do, or how, please let me know.  The interfaces have been "regularized", to make them more consistent, and in the hopes of making the functions more clear just from the names.  Redundancy has been eliminated, and arguments and return values are now also consistent.  So, for example, in the old interface, FeedRate returned the FeedRate in units/min, but SetFeedRate set the new FeedRate in units/second, the new GetFeedRate and SetFeedRate both operate in units/minute.  The "Is" functions now all return Booleans, rather than Integers.   Overall, it should be FAR easier to learn to write and debug Mach3 macros. 

There are also countless "invisible" changes that will eliminate some of the more frustrating aspects of Mach3 programming.  For example, it should normally *never* be necessary to insert wait loops or Sleeps in the code, as it currently is.  Execution will be far more deterministic, with far fewer hidden pitfalls.

Port/Signal I/O:
Sub AssertOutput(Signal As Integer)
Sub DeassertOutput(Signal As Integer)
Function IsInputAsserted(Signal As Integer)As Boolean
Function IsSignalDefined(Signal As Integer) As Boolean
Function IsOutputAsserted(Signal As Integer) As Boolean

File I/O:
Sub OpenDigFile()
Sub CloseDigFile()
Function OpenTeachFile (Filename As String) As Integer
Function AppendTeachFile(Filename As String) As Integer
Sub CloseTeachFile() As Integer
Sub LoadTeachFile() As Integer
Function GetFileName() As String
Function GetMach3Folder() As String
Sub LoadProgram(FilePath As String) As Integer
Sub LoadAndRunProgram(FilePath As String) As Integer
Sub RunProgram() As Integer
Sub LoadWizard(WizardName As String) As Integer

Screenset/UserI/O:
Function AskUserForDouble() As Double
Function AskUserForText() As String
Function AskUser(Prompt, “Title” As String, DialogType As Integer) As Integer
Sub ErrorMessage(MessageText As String)
Sub TickerMessage(TickerNum As Integer, TickerText As String)
Function AskUserForCoords(Prompt As String) As Integer
Function GetXCoord() As Double
Function GetYCoord() As Double
Function GetZCoord() As Double
Function GetACoord() As Double
Function GetBCoord() As Double
Function GetCCoord() As Double
Sub DoOEMButton(OEMButtonCode As Integer)
Function GetOEMLED(LEDNum As Integer) As Integer
Sub SetOEMDRO(DRONum As Integer, DROVal as Double)
Function GetOEMDRO(DRONum As Integer) As Double
Sub SetUserLED(LEDNum As Integer, State As Integer)
Function GetUserLED(LEDNum As Integer) As Integer
Sub SetUserDRO(DRONum As Integer, DROVal As Double)
Function GetUserDRO(DRONum As Integer) As Double
Sub SetVar(VarNum As Integer, Val As Double)
Function GetVar(VarNum As Integer) As Double
Sub SetUserLabel(LabelNum As Integer, LabelText As String)
Function GetUserLabel(LabelNum As Integer) As String
Sub SetButtonText(Text As String)
Function GetButtonText() As String
Sub SetScreensetPage()
Function GetScreensetPage() As Integer
Sub ToggleScreenset()
Sub ReloadScreenset()
Sub SetTriggerMacro(Signal As Integer, MacroName As String)

G-Code:
Sub SetBufferedCodeState(Boolean)
Function GetBufferedCodeState() As Boolean
Sub Code(Gcode As String)

Machine Control:
Sub SpindleOn(DIR)
Sub DoSpinCW()
Sub SpindleOff()
Sub SetRPM(RPM As Integer)
Function GetRPM() As Double
Function IsSpindleOn() As Boolean
Sub SetFeedRate(FeedRate As Double)
Function GetFeedRate() As Double
Sub Function CoupleSlave(MasterAxis As Integer, SlaveAxis As Integer)
Sub UncoupleSlave()
Function GetCurrentTool() As Integer
Sub SetIJIncremental(Boolean)
Function IsIJIncremental() As Boolean
Sub SetSafeZPos(SafeZ As Double)
Function GetSafeZPos() As Double
Sub GotoSafeZ()
Function IsSafeZEnabled() As Boolean
Sub SetAxisScale(Axis As Integer, Scale As Double)
Function GetAxisScale(Axis As Integer) As Double
Function GetSelectedTool() As Integer
Sub SetCurrentTool(ToolNum As Integer)
Function GetAxisToolChangeStartPos()
Function GetToolDesc(ToolNum As Integer) As String
Sub SetToolParam(ToolNum As Integer, ParamNum As Integer, ParamVal As Double)
Function GetToolParam(ToolNum As Integer, ParamNum As Integer)
Function ToolLengthOffset() As Double
Sub SetParam(ParamName As String, ParamVal As Double)
Function GetParam(ParamName As String) As Double
Function IsInEStop() As Boolean
Function IsProgramLoading() As Boolean
Function IsMoving() As Boolean
Function GetXMaxExtent() As Double
Function GetYMaxExtent() As Double
Function GetXMinExtent() As Double
Function GetYMinExtent() As Double
Sub WaitForTrigger(Signal As Integer)
Sub SwapAxis(FirstAxis As Integer, SecondAxis As Integer)
Sub UnSwapAxis()
Sub AxisJogOff(Axis As Integer)
Sub AxisJogOn(Axis As Integer, Dir as Integer)
Sub FeedMove(X, Y, Z, A, B, C As Double)
Sub RapidMove(X, Y, Z, A, B, C As Double)
Function SingleVerifyReport(Axis As Integer)
Sub SingleVerify(Axis As Integer)
Sub VerifyAxis(Silent As Boolean)
Sub RefCombination(Axes As Integer)
Sub THCOff()
Sub THCOn()
Sub ZeroTHC()
Sub ResetTHC()
Sub NotifyPlugins(Event As Integer)
Function QueueDepth() As Integer
Function CannedCycleRetractMode() As Integer
Sub SaveWizard() As Integer
Function SetAxisFormula(Axis As Integer, Formula As String) As Integer
Sub SetSpindlePulley(Pulley As Integer)

Lathe Only:
Function IsDiameterMode() As Boolean
Function GetToolTurretAng() As Double

VB/Misc:
Function PParameter() As Double
Function QParameter() As Double
Function RParameter() As Double
Sub PlayWave(Filename As String)
Sub Sleep(Time As Integer)
Sub Speak(TextToSpeak As String)
Function GetVBVersion() As String
Function GetMach3Version() As String
Regards,
Ray L.

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: New Mach3 v4 VB Interface
« Reply #1 on: October 16, 2009, 09:55:31 PM »
Quote
Function AskUserForCoords(Prompt As String) As Integer

Shouldn't this be "as double"?


Quote
Function AskUser(Prompt, “Title” As String, DialogType As Integer) As Integer

What's this do?
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: New Mach3 v4 VB Interface
« Reply #2 on: October 16, 2009, 09:57:49 PM »
Quote
Function AskUserForCoords(Prompt As String) As Integer

Shouldn't this be "as double"?


Ger,

No.  That function puts up a dialog where the user can fill in values for all axes.  The return value indicates whether the user closed the dialog with the OK or Cancel button.  The values entered are read using the GetXCoord()...GetCCoord() functions.  This is unchanged from the v3 interface, except the B and C axes will be added to the dialog.

Regards,
Ray L.
Regards,
Ray L.
Re: New Mach3 v4 VB Interface
« Reply #3 on: October 16, 2009, 10:25:51 PM »
Quote
Function AskUserForCoords(Prompt As String) As Integer

Shouldn't this be "as double"?


Quote
Function AskUser(Prompt, “Title” As String, DialogType As Integer) As Integer

What's this do?


AskUser displays a dialog with a variety of different buttons and fields in it.  This is the old MachMsg() function - see the v3 document I posted a few weeks ago for details.

Regards,
Ray L.
Regards,
Ray L.

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: New Mach3 v4 VB Interface
« Reply #4 on: October 17, 2009, 03:13:23 AM »
Hey Ray, Have I missed these in the past or are they new? Either way I love the idea of being able to have dynamic button labels in our screen sets.  :)

Sub SetButtonText(Text As String)
Function GetButtonText() As String

Would it be possible to add these functions to make our buttons smarter?

On press
On release
Mouse is over
Mouse is not over

A couple I don't see that would be nice.

DoSpinCCW
IsSpindleOnCW
IsSpindleOnCCW
SetIJABS
IsIJABS
GetZMaxExtent
GetZMinExtent
GetAMaxExtent
GetAMinExtent
GetBMaxExtent
GetBMinExtent
GetCMaxExtent
GetCMinExtent

A little off subject............... I think it would be a good idea to have a page number DRO.  I relise we have Sub SetScreensetPage() and Function GetScreensetPage() As Integer that we could use but a DRO would be nice IMO. Also a screen set label would be nice (1024.set).

Axis at refrence position LEDs for all axis (individually) would be nice too. These would be different from the refrenced LEDs we have now. They would be good for a quick visual check to see if the axis is at refrence position if you needed to know (during a tool change for example) without haveing to use DROs on a particular screen or running a brain in the background.  

I think that any DRO or tick box in any and all config. pages should have associated DROs and LEDs that you can at least read and as many as possible that you can read/write to from VB would be great.

Looking good so far.   :)
Brett



;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: New Mach3 v4 VB Interface
« Reply #5 on: October 17, 2009, 09:59:01 AM »
I see your "set Ticker message",
but didnt see the "get Ticker message"

Please make sure you keep the:  Set and Get Timers (the VB timers)

also:
you say that you no longer need the "While IsMoving()", what takes its place?

also:

What do you do for "Wait For Signal", if you want your VB to pause until a signal appears or disapears?

scott
« Last Edit: October 17, 2009, 10:15:06 AM by poppabear »
fun times
Re: New Mach3 v4 VB Interface
« Reply #6 on: October 17, 2009, 11:05:39 AM »
Brett,

See comments below...

Hey Ray, Have I missed these in the past or are they new? Either way I love the idea of being able to have dynamic button labels in our screen sets.  :)

*** SetButtonText has always been there, but probably never documented.  GetButtonText is new.

Sub SetButtonText(Text As String)
Function GetButtonText() As String

Would it be possible to add these functions to make our buttons smarter?

On press
On release
Mouse is over
Mouse is not over

*** I will ask, but my guess is the answer is "no".  OnPress, of course, you already have - the button script.

A couple I don't see that would be nice.

DoSpinCCW

*** DoSpinCW() should not have been in there.  DoSpinCW and DoSpinCCW are replaced by SpindleOn(DIR).

IsSpindleOnCW
IsSpindleOnCCW
SetIJABS
IsIJABS

*** All these are already accessible via OEM LEDs. I did not see the point in adding explicit functions for things that are available in OEM LEDs and DROs.

GetZMaxExtent
GetZMinExtent
GetAMaxExtent
GetAMinExtent
GetBMaxExtent
GetBMinExtent
GetCMaxExtent
GetCMinExtent

*** Meant to add these, but forgot...

A little off subject............... I think it would be a good idea to have a page number DRO.  I relise we have Sub SetScreensetPage() and Function GetScreensetPage() As Integer that we could use but a DRO would be nice IMO. Also a screen set label would be nice (1024.set).

Axis at refrence position LEDs for all axis (individually) would be nice too. These would be different from the refrenced LEDs we have now. They would be good for a quick visual check to see if the axis is at refrence position if you needed to know (during a tool change for example) without haveing to use DROs on a particular screen or running a brain in the background.   

*** I'll bounce these all off "the boss"...

I think that any DRO or tick box in any and all config. pages should have associated DROs and LEDs that you can at least read and as many as possible that you can read/write to from VB would be great.

*** I looked at all the config stuff, and couldn't see any real value in making it VB accessible.  Any examples of some that would be really useful, and for what?

Looking good so far.   :)
Brett




Hey Ray, Have I missed these in the past or are they new? Either way I love the idea of being able to have dynamic button labels in our screen sets.  :)

Sub SetButtonText(Text As String)
Function GetButtonText() As String

Would it be possible to add these functions to make our buttons smarter?

On press
On release
Mouse is over
Mouse is not over

A couple I don't see that would be nice.

DoSpinCCW
IsSpindleOnCW
IsSpindleOnCCW
SetIJABS
IsIJABS
GetZMaxExtent
GetZMinExtent
GetAMaxExtent
GetAMinExtent
GetBMaxExtent
GetBMinExtent
GetCMaxExtent
GetCMinExtent

A little off subject............... I think it would be a good idea to have a page number DRO.  I relise we have Sub SetScreensetPage() and Function GetScreensetPage() As Integer that we could use but a DRO would be nice IMO. Also a screen set label would be nice (1024.set).

Axis at refrence position LEDs for all axis (individually) would be nice too. These would be different from the refrenced LEDs we have now. They would be good for a quick visual check to see if the axis is at refrence position if you needed to know (during a tool change for example) without haveing to use DROs on a particular screen or running a brain in the background.   

I think that any DRO or tick box in any and all config. pages should have associated DROs and LEDs that you can at least read and as many as possible that you can read/write to from VB would be great.

Looking good so far.   :)
Brett




Regards,
Ray L.
Re: New Mach3 v4 VB Interface
« Reply #7 on: October 17, 2009, 11:09:28 AM »
Scott,

See below...

I see your "set Ticker message",
but didnt see the "get Ticker message"

*** Not sure what that would be useful for...  The status lines are by definition write-only.

Please make sure you keep the:  Set and Get Timers (the VB timers)

***Actually, the timers are going away, because they are part of the PP driver, so only availalbe if using PP.  And the PP, in the long run, is going away.

also:
you say that you no longer need the "While IsMoving()", what takes its place?

*** WhileIsMoving is still there, it's just now rarely needed.

also:

What do you do for "Wait For Signal", if you want your VB to pause until a signal appears or disapears?

*** It's being replaced by WaitForTrigger, which will be FAR more flexible.

scott
Regards,
Ray L.
Re: New Mach3 v4 VB Interface
« Reply #8 on: October 17, 2009, 12:20:28 PM »
Updated list with a few minor corrections:

Port/Signal I/O:
Sub AssertOutput(Signal As Integer)
Sub DeassertOutput(Signal As Integer)
Function IsInputAsserted(Signal As Integer)As Boolean
Function IsOutputAsserted(Signal As Integer) As Boolean
Function IsSignalDefined(Signal As Integer) As Boolean

File I/O:
Sub OpenDigFile()
Sub CloseDigFile()
Function OpenTeachFile (Filename As String) As Integer
Function AppendTeachFile(Filename As String) As Integer
Sub CloseTeachFile() As Integer
Sub LoadTeachFile() As Integer
Function GetFileName() As String
Function GetMach3Folder() As String
Sub LoadProgram(FilePath As String) As Integer
Sub LoadAndRunProgram(FilePath As String) As Integer
Sub RunProgram() As Integer
Sub LoadWizard(WizardName As String) As Integer

Screenset/UserI/O:
Function AskUserForDouble() As Double
Function AskUserForText() As String
Function AskUser(Prompt As String, Title As String, DialogType As Integer) As Integer
Function AskUserForCoords(Prompt As String) As Integer
Function GetXCoord() As Double
Function GetYCoord() As Double
Function GetZCoord() As Double
Function GetACoord() As Double
Function GetBCoord() As Double
Function GetCCoord() As Double
Sub ErrorMessage(MessageText As String)
Sub TickerMessage(TickerNum As Integer, TickerText As String)
Sub DoOEMButton(OEMButtonCode As Integer)
Function GetOEMLED(LEDNum As Integer) As Integer
Sub SetOEMDRO(DRONum As Integer, DROVal as Double)
Function GetOEMDRO(DRONum As Integer) As Double
Sub SetUserLED(LEDNum As Integer, State As Integer)
Function GetUserLED(LEDNum As Integer) As Integer
Sub SetUserDRO(DRONum As Integer, DROVal As Double)
Function GetUserDRO(DRONum As Integer) As Double
Sub SetVar(VarNum As Integer, Val As Double)
Function GetVar(VarNum As Integer) As Double
Sub SetUserLabel(LabelNum As Integer, LabelText As String)
Function GetUserLabel(LabelNum As Integer) As String
Sub SetButtonText(Text As String)
Function GetButtonText() As String
Sub SetScreensetPage()
Function GetScreensetPage() As Integer
Sub ToggleScreenset()
Sub ReloadScreenset()
Sub SetTriggerMacro(Signal As Integer, MacroName As String)

G-Code:
Sub SetBufferedCodeState(Boolean)
Function GetBufferedCodeState() As Boolean
Sub Code(Gcode As String)
Function GetXMinExtent() As Double
Function GetYMinExtent() As Double
Function GetZMinExtent() As Double
Function GetAMinExtent() As Double
Function GetBMinExtent() As Double
Function GetCMinExtent() As Double
Function GetXMaxExtent() As Double
Function GetYMaxExtent() As Double
Function GetZMaxExtent() As Double
Function GetAMaxExtent() As Double
Function GetBMaxExtent() As Double
Function GetCMaxExtent() As Double

Machine Control:
Sub SpindleOn(DIR)
Sub SpindleOff()
Sub SetRPM(RPM As Double)
Function GetRPM() As Double
Function IsSpindleOn() As Boolean
Sub SetFeedRate(FeedRate As Double)
Function GetFeedRate() As Double
Sub Function CoupleSlave(MasterAxis As Integer, SlaveAxis As Integer)
Sub UncoupleSlave()
Function GetCurrentTool() As Integer
Sub SetIJIncremental(Boolean)
Function IsIJIncremental() As Boolean
Sub SetSafeZPos(SafeZ As Double)
Function GetSafeZPos() As Double
Sub GotoSafeZ()
Function IsSafeZEnabled() As Boolean
Sub SetAxisScale(Axis As Integer, Scale As Double)
Function GetAxisScale(Axis As Integer) As Double
Function GetSelectedTool() As Integer
Sub SetCurrentTool(ToolNum As Integer)
Function GetAxisToolChangeStartPos()
Sub SetToolParam(ToolNum As Integer, ParamNum As Integer, ParamVal As Double) - Replaced by individual Set/Get functions
Function GetToolParam(ToolNum As Integer, ParamNum As Integer) - Replaced by individual Set/Get functions
Sub SetParam(ParamName As String, ParamVal As Double) - Replaced by individual Set/Get functions
Function GetParam(ParamName As String) As Double - Replaced by individual Set/Get functions
Function IsInEStop() As Boolean
Function IsProgramLoading() As Boolean
Function IsMoving() As Boolean
Sub WaitForTrigger(Signal As Integer)
Sub SwapAxis(FirstAxis As Integer, SecondAxis As Integer)
Sub UnSwapAxis()
Sub AxisJogOff(Axis As Integer)
Sub AxisJogOn(Axis As Integer, Dir as Integer)
Sub FeedMove(X, Y, Z, A, B, C As Double)
Sub RapidMove(X, Y, Z, A, B, C As Double)
Sub NotifyPlugins(Event As Integer)
Function CannedCycleRetractMode() As Integer
Sub SaveWizard() As Integer
Function SetAxisFormula(Axis As Integer, Formula As String) As Integer
Sub SetSpindlePulley(Pulley As Integer)

Lathe Only:
Function IsDiameterMode() As Boolean
Function GetToolTurretAng() As Double

Torch Only:
Sub THCOff()
Sub THCOn()
Sub ZeroTHC()
Sub ResetTHC()

VB/Misc:
Function PParameter() As Double
Function QParameter() As Double
Function RParameter() As Double
Sub PlayWave(Filename As String)
Sub Sleep(Time As Integer)
Sub Speak(TextToSpeak As String)
Function GetVBVersion() As String
Function GetMach3Version() As String
« Last Edit: October 17, 2009, 12:25:57 PM by HimyKabibble »
Regards,
Ray L.

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: New Mach3 v4 VB Interface
« Reply #9 on: October 17, 2009, 07:56:28 PM »
Thanks Ray,

Quote
*** SetButtonText has always been there, but probably never documented.  GetButtonText is new.
:)

Quote
*** I will ask, but my guess is the answer is "no".  OnPress, of course, you already have - the button script.

The main one to add for the buttons would be on release. Brian had said in the past he would add that function so hopefully it will be included. The others were just wishful thinking. As it is right now you can add a system function jog button that works as it should, but from VB you have to add a stop jog button which leaves a lot to be desired IMO. I never suggest a jog button be done from VB as it is now. Maybe this could be handled with a function (sysfunction&) and add VB to it? Some of the system functions versus VB do quirky things and maybe this would be a good option to handle that. I always prefer system functions to VB but if you want your buttons to do more than one thing you have to do them in VB. The jog stop on release is just one example but I think that function would add a lot of flexability (more than sysfunction&). Mouse is over would be great for interactive training screens but I knew when I mentioned it it was a stretch.  ;D


Quote
*** DoSpinCW() should not have been in there.  DoSpinCW and DoSpinCCW are replaced by SpindleOn(DIR).
Thanks for clearing that up.  :)

Quote
*** All these are already accessible via OEM LEDs. I did not see the point in adding explicit functions for things that are available in OEM LEDs and DROs
Fair enough. Why are these (Sub SetIJIncremental(Boolean), Function IsIJIncremental() As Boolean)worthy of having their on functions and these (SetIJABS, IsIJABS) aren't?

Quote
I think that any DRO or tick box in any and all config. pages should have associated DROs and LEDs that you can at least read and as many as possible that you can read/write to from VB would be great.

*** I looked at all the config stuff, and couldn't see any real value in making it VB accessible.  Any examples of some that would be really useful, and for what?
I can't remember now what I was wanting to monitor and act on from VB at the moment. But then again there are quite a few I have had no need for in the past but I suppose someone has. It would also help with consistency IMO. Would certainly be able to build one heck of a diagnostics page though.  ;D


Thanks,
Brett
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!