Hello Guest it is May 20, 2019, 05:09:11 PM

Author Topic: VB Is Laughing At Me....  (Read 15926 times)

0 Members and 1 Guest are viewing this topic.

VB Is Laughing At Me....
« on: March 21, 2009, 09:26:37 PM »
I'm writing a bunch of Mach macros lately, to automate common tasks. But I'm finding myself scratching my head at times. The below code does not execute correctly. It calls the M900 macro, which works perfectly when called directly from button scripts. The M900 macro uses DRO 1105 to tell it which axis to probe (0=X, 1=Y, etc.), and DRO 1106 tells it which direction to probe (1=Plus, -1=Minus). When I run the code below, the M900 macro does run, but it gets the wrong parameters - I'm telling it to probe X in the Plus direction, and that is what is displayed by the code below, but the same printout code in the M900 macro shows the parameters it receives tell it to probe Y in the Minus direction. How can this be?


MacroParameter1DRO = 1105
MacroParameter2DRO = 1106

EdgeFindMacro = "M900"

XProbeDirection = GetDRO(MacroParameter1DRO)

' Probe first in X
SetDRO(MacroParameter1DRO, 0)
SetDRO(MacroParameter2DRO, XProbeDirection)

' Show the parameters we're passing
AxisName = Chr(Asc("X") + GetDRO(MacroParameter1DRO))
If GetDRO(MacroParameter2DRO) = 1 Then
    Direction = "+"
Else
    Direction = "-"
End If
Code "(Probing " & AxisName & Direction & ")"
Sleep 1000

' Set the "busy" LED
SetUserLED(200, 1)

Code EdgeFindMacro

' Wait until EdgeFindMacro completes, clearing UserLED 100
While GetUserLED(200) = 1
    Sleep 100
Wend

Regards,
Ray L.
Regards,
Ray L.

Offline poppabear

*
  • *
  •  2,231 2,231
  • Briceville, TN, USA
    • View Profile
    • S S Systems, LLC
Re: VB Is Laughing At Me....
« Reply #1 on: March 22, 2009, 09:10:57 AM »
Hey Ray,

   Your not calling the DROs correctly to load the inforamtion, also there are two types of DROs in Vb
UserDROs and OEMDros(some OEM dros just use the Set or GetDRO: (changes in bold)

MacroParameter1DRO = GetUserDRO(1105)
MacroParameter2DRO = GetUserDRO(1106)

EdgeFindMacro = "M900"

XProbeDirection = GetUserDRO(MacroParameter1DRO)

' Probe first in X
SetUserDRO(MacroParameter1DRO, 0)
SetUserDRO(MacroParameter2DRO, XProbeDirection)

' Show the parameters we're passing
AxisName = Chr(Asc("X") + GetUserDRO(MacroParameter1DRO))
If GetUserDRO(MacroParameter2DRO) = 1 Then
    Direction = "+"
Else
    Direction = "-"
End If
'Code "(Probing " & AxisName & Direction & ")"
Code ("Probing Axis:  ")  & AxisName & " Direction" & Direction
Sleep 1000

' Set the "busy" LED
'SetUserLED(200, 1) 'Uleds are from 1000-2255
SetUserLED(2000, 1)
'Code EdgeFindMacro
Code "(EdgeFindMacro)"

' Wait until EdgeFindMacro completes, clearing UserLED 100
While GetUserLED(2000) = 1
    Sleep 100
Wend
Commercial Mach3 & Mach 4, Design/Build/Retrofit CNC and Industrial machines.
http://www.ss-systems-llc.com/
Re: VB Is Laughing At Me....
« Reply #2 on: March 22, 2009, 10:59:03 AM »
Poppabear,

    I've tried that, and, if anything, it made things worse.  My understanding (perhaps wrong....) is that UserLEDs have OEM codes from 1000 up, buy if you use Get/SetUserLED to access them, you use the number - 1000.  On the DROs, GetDRO seems to work with ANY DRO number, whether OEM or User.  I do wish this stuff was actually documented, as the information available is cryptic, and often contradictory.

Regards,
Ray L.
Regards,
Ray L.

vmax549

*
Re: VB Is Laughing At Me....
« Reply #3 on: March 22, 2009, 12:06:33 PM »
HIYA RAY, Welcome to the been laughed at by MACH club. (;-)

Could you give a brief explanation of what you need the macro  to do.

Do you need DROs? Do you have them on a page for veiwing or could Vars be used.

I "think" I see your problem but need an explanation of what you think the code is suppose to do to verify it.

NOTE: There may be an easy way to do it.

Just a thought, (;-) TP
Re: VB Is Laughing At Me....
« Reply #4 on: March 22, 2009, 12:32:39 PM »
OK, I did some experimentation, to see how these things really work.  Here's what I've found:

For LEDs, unless I'm missing something, the only Set method we have is SetUserLED.  SetLED and SetOEMLED just throw syntax errors.  Similarly, GetLED seems to not throw a syntax error, but also doesn't seem to actually do anything.  GetOEMLED and GetUserLED appear to be identical, other than their names.  Either seems able to read any LED, and both appear to expect "User" LEDs to be numbered above 1000.

For DROs, I see no difference between SetOEMDRO/GetOEMDRO and SetUserDRO/GetUserDRO, and both appear to expect "User" LEDs to be numbered above 1000.  Any DRO written by one, can always be read by the other.  SetDRO/GetDRO has me a little confused, as it seems to access a different "space" from the other two.  i.e. - A DRO written by SetOEMDRO or SetUserDRO cannot be read by GetDRO, and vice-versa.

So, what, exactly, is the difference between all these, and why are there seemingly identical functions with different names?

Regards,
Ray L.
Regards,
Ray L.
Re: VB Is Laughing At Me....
« Reply #5 on: March 22, 2009, 12:42:06 PM »
HIYA RAY, Welcome to the been laughed at by MACH club. (;-)

Could you give a brief explanation of what you need the macro  to do.

Do you need DROs? Do you have them on a page for veiwing or could Vars be used.

I "think" I see your problem but need an explanation of what you think the code is suppose to do to verify it.

NOTE: There may be an easy way to do it.

Just a thought, (;-) TP

Terry,

   I *think* I have it working, and the problem does appear to be confusion over when/where/how to use the various LED and DRO functions.  Near as I can tell, there is no reason to ever use SetDRO/GetDRO.  I believe whatever they can do, can be done through SetOEMDRO/GetOEMDRO or, just as well, SetUserDRO/GetUserDRO.  Likewise, I was led astray by some of the information on the Wiki, which suggested using SetUserLED/GetUserLED use LED numbers from 0 to 255, which is not correct.

Regards,
Ray L.
Regards,
Ray L.

vmax549

*
Re: VB Is Laughing At Me....
« Reply #6 on: March 22, 2009, 04:15:58 PM »
(;-) Ray the syntqx has been modified over the years to fit some purposes only known by ART.  Maybe one day he will take time to write the wizards manual for MACH.

UNless you need to SEE the dros on a screen I do NOT use them to store values. I use SYSTEM Vars instead. We also have VARs 500-600 that are persistant if needed.

What I found using DROs is somewhere that DRO may end up being used by something else as well  AND IT WILL MAKE YOU PULL YOUR HAIR OUT trying to figure out where the phantom values keep coming from.

I have had it happen enough to know better know.

Let me know if you can't get it to work correctly .

Just a thought(;-)  TP
« Last Edit: March 22, 2009, 04:18:38 PM by vmax549 »
Re: VB Is Laughing At Me....
« Reply #7 on: March 23, 2009, 12:49:45 AM »
Terry,

   Thanks, it is all behaving now.  I've written a whole pile o'macros today, and all are now working fine.  I wrote nice, clean macros for doing edge, corner and center finding, and aligning a vise, or similar object, to the table, as well as one for re-mapping buttons on the ShuttlePro on-the-fly.

   I get the impression there was an intent there to re-think the macro interface, and make it more regular and consistent.  That would explain the User/OEM stuff.  But obviously only the interface was defined, with no supporting functionality, and the existing macros use a mish-mash of different methods of access.  There's a whole section in the "manual" listing deprecated functions, most of which are used in the macros that ship with Mach.

Regards,
Ray L.
Regards,
Ray L.
Re: VB Is Laughing At Me....
« Reply #8 on: March 23, 2009, 12:57:12 AM »
(;-) Ray the syntqx has been modified over the years to fit some purposes only known by ART.  Maybe one day he will take time to write the wizards manual for MACH.

UNless you need to SEE the dros on a screen I do NOT use them to store values. I use SYSTEM Vars instead. We also have VARs 500-600 that are persistant if needed.

What I found using DROs is somewhere that DRO may end up being used by something else as well  AND IT WILL MAKE YOU PULL YOUR HAIR OUT trying to figure out where the phantom values keep coming from.

I have had it happen enough to know better know.

Let me know if you can't get it to work correctly .

Just a thought(;-)  TP

Terry,

I'm confused about what you call "System Vars".  You mean using SetParam/GetParam?  The documentation makes it sound like those are limited to pre-defined variables.  Is that wrong?

Regards,
Ray L.
Regards,
Ray L.

vmax549

*
Re: VB Is Laughing At Me....
« Reply #9 on: March 23, 2009, 09:48:48 AM »
HIYA RAY, No I use the get/setVAR     Or some call them Gcode Vars or some call them System vars. Last I remember there are about 10,320 of them out there. Some are used for Gcode, some for SYSTEM functions and some are persistant( user use) some are for retaining fixture settings etc.

I'll try and find a listing of the Param & Vars available for us. That way we can at least write it down somewhere.

I use macros a lot myself to automate functions  such as Bolthole circles, probing, Cord rotation, S/n engrave (consectutive), Cutting circles, thread milling, etc.

There is also a side of GCODE call parametric programming that you would probably like as well.

It would be NICE to start a MACH TOOLBOX online to store usefull macros for us to swap ideas.  (IF you are interested) (;-)

Just a thought (;-) TP