Hello Guest it is March 28, 2024, 08:36:20 PM

Author Topic: Intermittent macro weirdness  (Read 2797 times)

0 Members and 1 Guest are viewing this topic.

Intermittent macro weirdness
« on: April 04, 2012, 11:17:28 AM »
I have a macro for single-profile thread milling that experiences an intermittent bug.  I've seen it randomly switch from incremental to absolute positioning.  My workaround is to pre-generate the thread milling Gcode, then it works 100%.  Attached is the Gcode that calls my VB macro (M5001.m1s) for thread milling.  And also attached is the Gcode produced by this macro.

I think the problem is that I don't wait for the machine to complete a Gcode instruction after calling the Code() function.  It's really not necessary and would only slow down the overall operation.  I used to have it wait after each Gcode instruction, but then the machine would momentarily pause at times.  It bothered me, so I removed all the waiting, now I've got this bug. 

Just before my VB macro exits and returns control to Mach3, it waits for the machine to stop moving.  This is the only wait in the macro.  I believe at some point during the operation it is switching to G90 (absolute positioning) where my Gcode is depending on G91 (incremental positioning) to be active.  It seems like it might be running a G90 instruction out of order, since that's always the last instruction executed.

Until I figure out what exactly is going on, I will continue to pre-generate my thread milling Gcode.

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Intermittent macro weirdness
« Reply #1 on: April 04, 2012, 05:23:42 PM »
WElcome to the world of MACH3 macros and Gcode. Yes you have to use wait states to control the flow of the macro if NOT you will see the code skip and jump over other code and get completely out of sync at times.

As you have found it is BEST to use the macro to generate the proper "Gcode" for MAch3 to use and that part works very well.

Other wise you will have herky jerky machine control trying use a CB and Gcode hybrid type of code as CB and Gcode do not always play well together in MACH3.



Just a thought, (;-) TP

Re: Intermittent macro weirdness
« Reply #2 on: April 05, 2012, 07:43:59 AM »
I wish Mach would fully document when the waiting must be done, when calling the Code() function from a CB macro.  Clearly, if your CB macro depends on DRO values, you should wait for the machine to stop moving before reading those values.  Otherwise, it would seem it's perfectly safe to queue up all possible Gcode instructions... but this is a wrong assumption.

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Intermittent macro weirdness
« Reply #3 on: April 05, 2012, 10:13:41 AM »
I have found the wait states depends on YOUR computor and OS.  Just my opinion BUT it rings true over all the testing I have done.

A safe assumption is to put a wait state after every GROUP of Gcode and after every read or write from CB.

But in the end you still adjust it to fit your machine.

Just a thought, (;-)