Machsupport Forum

Third party software and hardware support forums. => CS-Lab => Topic started by: RikV on May 14, 2018, 09:50:42 AM

Title: Problems wit G31/M31 and subs
Post by: RikV on May 14, 2018, 09:50:42 AM
I have Mach3 v3.043.062 wit CSMIO-S and for the moment I am using the standard 1024.set.
After srtuggling with G31/M31 on some offset-macros I ended up with the following problem:
At the very end of the script I want to restore the changed parameters to their Original state (quite Obvious I think). But I cannot get this elementary and certainly most simple thing to work!
All documentation I find on DRO, LED and BUTTONs says the same: OEMLED(48) is true when G90 is active. And yet this does not work??

Code: [Select]
Dim CurrentFeed As Double
Dim CurrentAbsInc, CurrentGmode As Boolean

Sub Main()

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


code "G90"
code "F100"


ReturnG90G91State 'subroutine'


End Sub

Sub ReturnG90G91State()
If CurrentAbsInc = True Then 'if G91 was in effect before then return to it
Code "G90"
End If
If CurrentGMode = 0 Then 'if G0 was in effect before then return to it
Code "G0"
End If
   Code "F" &CurrentFeed 'restore starting feed rate
End Sub     

I don't know if it is my own fault, but I believe teh available "official" documentation on writing scripts is not at all clear. IS there more/better on the net?
Is there anywhere a COMPLETE detailed list of DRO, LED and BUTTONS? One that goes beyond OEM(1000)?
Title: Re: Problems wit G31/M31 and subs
Post by: ger21 on May 14, 2018, 11:50:38 AM
Check the Wiki.
http://www.machsupport.com/Mach3Wiki/index.php?title=Main_Page
Title: Re: Problems wit G31/M31 and subs
Post by: RikV on May 14, 2018, 05:41:30 PM
Hello Gerry,
I am aware of the Wiki, but it just doesn't give a clue to why thi bit of code is not working. In general, I think the documentation of the soft is very weak. Where, for example, can I find that DROs 2000...2002 are used by the system? How many others are there? This is not documented, how can we be expected to write consistent code this way?
Title: Re: Problems wit G31/M31 and subs
Post by: ger21 on May 14, 2018, 07:37:23 PM
2000 would be a custom User DRO, not a standard pre-defined one.
All pre-defined LED's and DRO's will be numbered 1000 or less, as described in the Wiki.

Try changing these lines like this:

Dim CurrentAbsInc, CurrentGmode

If CurrentAbsInc = 1 Then
     Code "G90"
End If

If CurrentGMode = 0 Then
     Code "G0"
End If
Title: Re: Problems wit G31/M31 and subs
Post by: RikV on May 15, 2018, 03:40:29 AM
Gerry,
DRO 2000... 2002 are the ones originally used by G31? Or am I wrong? SO, if they are, they can't be used for anything else and shouled at least be "reserved" DRO.
Therefore I was wondering how many and which other DRO, button and LED there are around I am not aware of.
And how can one make an inventory of used items on a screenset?
I will try yous suggestion, but this couple of lines appear many times in my script and thus belongs in a subroutine. And even when it works this way I would feel very unsatisfied not knowing WHY it doen not work the right way. See, I am someone who wants to KNOW why thins work or not.
Title: Re: Problems wit G31/M31 and subs
Post by: TPS on May 15, 2018, 05:54:16 AM
Code: [Select]
Dim CurrentFeed As Double
Dim CurrentAbsInc, CurrentGmode As Boolean

Sub Main()

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


code "G90"
code "F100"


ReturnG90G91State 'subroutine'


End Sub

Sub ReturnG90G91State()
If CurrentAbsInc = True Then 'if G91 was in effect before then return to it
Code "G90"
Else
Code "G91"
End If
If CurrentGMode = 0 Then 'if G0 was in effect before then return to it
Code "G0"
Else
Code "G1"
End If
Code "F" &CurrentFeed 'restore starting feed rate
End Sub     



Title: Re: Problems wit G31/M31 and subs
Post by: ger21 on May 15, 2018, 07:24:59 AM
G31 does not use any DRO's.
M31, which is a macro created by CS Labs, uses those DRO's.
Title: Re: Problems wit G31/M31 and subs
Post by: TPS on May 15, 2018, 08:36:08 AM
both of them are using the same uservars for the probing result:

   X_SENS = GetVar(2000)   
   Y_SENS = GetVar(2001)   
   Z_SENS = GetVar(2002)   
Title: Re: Problems wit G31/M31 and subs
Post by: ger21 on May 15, 2018, 08:46:35 AM
He said DRO, not Var.

Unfortunately, most of the Var's are undocumented. Except for a few that are listed in the manual.

The M31 does use some User DRO's, 1511, 1512, 1513.
Title: Re: Problems wit G31/M31 and subs
Post by: RikV on May 16, 2018, 04:20:15 AM
OK, Gerry and "TPS",
I did indeed not mention "Var". Don't feel attacked in person. But what I am trying to say is that there is too little documentation on Mach3 and it is spread all over the www. Couldn't some good soul start a Topic to collect all usefull links on the subject? Encourage people to add to the Wiki?
There should be a CD with sample soft included with "Cypress Enable". Anyone knows where I can find it?
Nevertheless I still have no answer to my initial question: why does that bit of code not work when placed in a subroutine? The variables are declared Global.
Is it possible to make a cross reference list on screen sets, macros and Brains of LED, Button, DRO and Vars?
Title: Re: Problems wit G31/M31 and subs
Post by: TPS on May 16, 2018, 05:20:33 AM
i allways declare my Global var's so for Example:

Global X_SENS as Double
Global Y_SENS as Double
Global Z_SENS as Double

Title: Re: Problems wit G31/M31 and subs
Post by: ger21 on May 16, 2018, 06:36:27 AM
I don't know why it doesn't work. As I mentioned before, it could be due to your motion controller. Macros can behave differently with different motion controllers.

Mach3 is at the end of it's life. Development stopped over 5 years ago. Documentation was always sparse, so your not going to see any new documentation now.
There is a Cypress manual, and a Mach3 programming manual available to download.

THe Wiki contains 99% of the Button, OEM and DRO numbers. There is a post somewhere here on the forum that may have a few more obscure ones in it, if you search. But the Wiki should have everything you need.

As for the Vars, as I said, they are not documented, except for a few in the manual. I've never seen a list anywhere, and I suspect that only the developers have a full list.
Title: Re: Problems wit G31/M31 and subs
Post by: RikV on May 16, 2018, 01:41:00 PM
Well then,
That's clear. Thanks for all the help you two. I hope I can come back to you when I run into trouble again.