Hello Guest it is April 20, 2024, 02:17:10 AM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - dz32

Pages: 1 2 »
1
Mach SDK plugin questions and answers. / Re: VB6 Automation Sample
« on: February 12, 2016, 07:14:03 AM »
that perspective makes allot of sense. Everything should kept identical to the documentation and expectations of users who are use to using it and know it inside and out. I didnt take that into consideration.

I am totally new to these functions, so I am trying to digest whats there, find what I will need and make it as simple to use as I can for me. I know I wont be using it everyday, a project here, a project there. For me I will need all the major functionality to be hand fed to be with the intellisense lists and enumeration types otherwise I will have to dig out the docs every time for every task.

The beauty of open source is it doesnt have to be A or B. The way it should be is exactly the way it makes sense to the people who use it. Not offended at all ! Consider my contribution the answers and code bits for the referencing counting and component registration. Grab that and run with it :)


2
Mach SDK plugin questions and answers. / Re: VB6 Automation Sample
« on: February 12, 2016, 03:35:09 AM »
adding a zip of current snapshot for convenience/archival

3
Mach SDK plugin questions and answers. / Re: VB6 Automation Sample
« on: February 12, 2016, 03:10:27 AM »
Ok i did a bunch of testing on XP and win2k. I updated the InitMach() routine to automatically add the missing registry entry if its not found. Now works without problem with the current Mach3 build. I didnt try Vista+, should work fine but you will probably need to "Run as Administrator" for the first time so it has permission to add the registry keys.

The new initilization logic looks like this:
https://github.com/dzzie/home_automation/blob/master/mach3_vb6/CMach.cls#L165

Code: [Select]
Public Function InitMach() As Boolean
    On Error Resume Next
   
    InitErrorMsg = Empty
   
    If Not isMachRunning() Then
        InitErrorMsg = "Mach3 must be running"
        Exit Function
    End If
   
    If Not isMachCOMObjRegistered() Then
        If Not RegisterMachCOMType() Then
            InitErrorMsg = "Could not register Mach ProgId in Registry. Run again as administrator."
            Exit Function
        End If
    End If
   
    Set mach = GetObject(, "Mach4.Document")
   
    If mach Is Nothing Then
        InitErrorMsg = "Failed to GetObject(Mach4.Document) " & Err.Description
        Exit Function
    End If
   
    IncrementRefCount mach
    Set oScript = mach.GetScriptDispatch()
   
    If Err.Number = 0 Then
        InitMach = True
    Else
        InitErrorMsg = "InitMach Failed: " & Err.Description
        Exit Function
    End If
   
End Function

4
Mach SDK plugin questions and answers. / Re: Automating Mach from VB6
« on: February 11, 2016, 07:47:15 PM »
if you are running windows XP, put the following text into a file name test.reg and then double click on it to add it to the registry.

Code: [Select]
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Mach4.Document\CLSID]
@="{CA7992B2-2653-4342-8061-D7D385C07809}"

I have not yet had time to test on win2k or win7 yet but on XP this always solved it for me
also Mach must to be running when you call GetObject()

5
Mach SDK plugin questions and answers. / Re: IsMoving equivalent in Plugin?
« on: February 11, 2016, 07:08:27 PM »
IMach4.GetScriptDispatch() returns an
IMyScriptObject interface which contains
Function IsMoving()  As Integer

6
Mach SDK plugin questions and answers. / Re: VB6 Automation Sample
« on: February 11, 2016, 12:49:12 PM »
I know the extra wrappers look like allot of typing and extra complexity initially, but they really make using the code latter almost brain dead simple and way less typing and way less error prone. it takes memory out of the equation and just shows you what functions it supports, what the arguments are , and in some cases like the enumerations lets you select the argument value you want from a list it automatically displays. Thats the real strength.

7
Mach SDK plugin questions and answers. / Re: VB6 Automation Sample
« on: February 11, 2016, 12:40:44 PM »
yup looks good, class or module is fine. The reason I was adding wrapper functions around the oScript methods
was so that you had intellisense. I left oscript public so you could still access it directly to get ahold of everything.

type mach dot, and then it will pop up a list of the available functions. once
you select the function, it will then show you the function prototype. Otherwise you have to type blind
and it can not help on misspellings and you have to type the entire method name out manually

wrapping the functions, you can also include some extra functionality. In the git repo I have done this for a couple
such as the RunGCode

Code: [Select]
Sub RunGCode(singleLine As String, Optional andBlock As Boolean = True)
    On Error Resume Next
    oScript.code singleLine
    If andBlock Then
        While Me.IsMoving
            DoEvents
        Wend
    End If
End Sub

for the SendOEMcode you can also specify the argument to be of an enumeration type.
This will automatically display a list of available options you can choose from by name instead of having to
remember (and latter read) just numbers

Code: [Select]
Public Enum OEMCodes
    oem_FeedPerMin = 39
    oem_FeedPerRev = 40
    oem_JogCont = 204
...
end enum

Sub SendOEMCode(code As OEMCodes)
    On Error Resume Next
    oScript.DoOEMButton code
End Sub

another feature is to the read and write properties wrappers to simplify the interface

Code: [Select]
Property Get SpindleRPM() As Double
    On Error Resume Next
    SpindleRPM = oScript.GetRPM()
End Property

Property Let SpindleRPM(x As Double)
    On Error Resume Next
    oScript.SetSpinSpeed x
End Property

In order to read or set the rpm with this interface change, now all you have to do is:

Code: [Select]

msgbox mach.SpindleRPM
msch.SpindleRPM = 1200


I am not sure if modules allow you to use the property get/let construct.



8
Mach SDK plugin questions and answers. / Re: VB6 Automation Sample
« on: February 11, 2016, 10:19:56 AM »
Quote

Thanks for the link of what you're up to. I'm not quite sure I understand why you need Mach-automation though.
Once you have your PC program create the gcode - why not just load and run in Mach normally? What am I missing?


The first thing that caught my eye was using the integration to make the testing and calibration
stages easier. The first test will be something like:

set 0,0 on a parts corner, manually move the gantry around to the various hole centers. hit a button
to record the spot this builds a list in the pc program. go back to 0,0.power steppers, then click another button
to send first point in list to mach, click to send next point and cycle through the list.

This should also be useful latter for quickly transferring hole patterns from parts to mounting plates without
really having to measure.

Other ideas to build on top of it. Maybe I could also break out of the gcode a bit.
Add a layer of logic on top where I can take physically separate gcode files, stack them in a que to run.

still fleshing out ideas but it seems super useful.


9
Mach SDK plugin questions and answers. / Re: VB6 Automation Sample
« on: February 11, 2016, 06:52:47 AM »
Awesome thanks for the links. There is definitely allot of information to take in !

Assuming that the registry keys were not removed for a reason, we will be able to manually add them back in
so that it will work for latter versions. This is on my to-do list and should not be to hard.

For the project I am working on I really want the Mach integration.
It might be nice to be able to use the most current version.

For those curious here is the idea I am working torwards, (trainable CNC paths vrs conventional programming through manual, cam, or scanned/converted paths)

http://sandsprite.com/blogs/index.php?uid=13&pid=377

10
Mach SDK plugin questions and answers. / Re: VB6 Automation Sample
« on: February 11, 2016, 05:13:31 AM »
found the documentation on the IMYScriptObject functions and OEM codes:

http://www.machsupport.com/wp-content/uploads/2013/02/Mach3_V3.x_Macro_Prog_Ref.pdf

Pages: 1 2 »