Hello Guest it is December 10, 2019, 08:44:35 AM

Author Topic: Problems wit G31/M31 and subs  (Read 1863 times)

0 Members and 1 Guest are viewing this topic.

Problems wit G31/M31 and subs
« 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)?

Offline ger21

*
  • *
  •  6,291 6,291
    • View Profile
    • The CNC Woodworker
Gerry

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

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: Problems wit G31/M31 and subs
« Reply #2 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?

Offline ger21

*
  • *
  •  6,291 6,291
    • View Profile
    • The CNC Woodworker
Re: Problems wit G31/M31 and subs
« Reply #3 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
Gerry

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

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: Problems wit G31/M31 and subs
« Reply #4 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.

Offline TPS

*
  •  1,416 1,416
    • View Profile
Re: Problems wit G31/M31 and subs
« Reply #5 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     



anything is possible, just try it.
if you find some mistakes, in my bad bavarian english,they are yours.

Offline ger21

*
  • *
  •  6,291 6,291
    • View Profile
    • The CNC Woodworker
Re: Problems wit G31/M31 and subs
« Reply #6 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.
Gerry

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

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html

Offline TPS

*
  •  1,416 1,416
    • View Profile
Re: Problems wit G31/M31 and subs
« Reply #7 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)   
anything is possible, just try it.
if you find some mistakes, in my bad bavarian english,they are yours.

Offline ger21

*
  • *
  •  6,291 6,291
    • View Profile
    • The CNC Woodworker
Re: Problems wit G31/M31 and subs
« Reply #8 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.
Gerry

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

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: Problems wit G31/M31 and subs
« Reply #9 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?