Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: rcaffin on October 07, 2016, 06:32:23 AM

Title: Read and write to Z DRO?
Post by: rcaffin on October 07, 2016, 06:32:23 AM
I'm playing around with touch probe automation. Everyone else does, so why not.

Anyhow, I want be able to zero the Z DRO directly, from within g-code, without using a macro. I know that some OEMDROs are mapped into vars, but I cannot find any reference to the on-screen DROS.
What I want to do is to write something like

#15802=0 and have the current Z DRO go to zero.

Am I out of luck?

PS: yes, I can do it with a macro. Yes, I can do it with several instructions using one of the work spaces. But I want to do it in one line.

Cheers
Roger
Title: Re: Read and write to Z DRO?
Post by: robertspark on October 08, 2016, 03:04:19 AM
G92 Z0 ?

That var is read only I suspect
Title: Re: Read and write to Z DRO?
Post by: Highspeed1964 on October 08, 2016, 04:02:14 AM
Just curious why you wouldn't want to do it with a macro?  Once a macro is written, it is called by a single line in the g-code (e.g. M101) which is what you're saying you want.  It doesn't have to be the tool change macro (T5 M6 or T1 M6) but writing to DROs is best accomplished with a macro as far as my experience has shown.

G92 is not a recommended way of zeroing an axis as this can offset other offsets. In other words, G92 is additive to other coordinate systems such as workpiece coordinates used with G54, G57, g54.23, etc. and could really get confusing if you're not completely sure how it works.

Stephen "Highspeed" Kruse
Title: Re: Read and write to Z DRO?
Post by: robertspark on October 08, 2016, 04:16:08 AM
When running a macro in mach3 there is a pause in motion when executing a macro as it compiles then executes

G92 z0 is the way to do it without a macro and therefore motion hesitation

G5x offsets... you only work in one of them at any time, and the way to get around this is copy the z axis dro var to another variable number, then when you want to remove the offset, subtract one from the other and reset to the new g92 offset...

Confusion is relative to task and perspective... vars are very handy if you code your own gcode... I don't really but my application doesn't use g5x offsets really

I can write the code down for you if you want? (No point if no interest)
Title: Re: Read and write to Z DRO?
Post by: rcaffin on October 08, 2016, 04:45:43 AM
There are several reasons for wanting to do it this way - avoiding the use of a macro (including stubborness).

But first, some background. I have been professionally involved in programming since about 1970. I have no problems writing either g-code by hand or writing macros. After all, BASIC??? But sometimes Mach3 puzzls me a bit  ;D

Now, a significant problem with Crystal Basic and its interaction with Mach3 is that you cannot normally call one macro from within another. There are exceptions of course: you CAN call M6 from within a user-written macro for instance. Whether this matters here I am not sure.

What is much harder to do is to write a macro which allows you to move the controlled point around via the cursor keys while the macro is executing. You can do this with M6 of course, but a feature of M6End is that it restores the starting position when it executes. To be sure, I could rewrite M6End, but I want to keep that feature in it. I could use little message boxes to enter new values for the axes, but that is a terrrible substitute for an arrow key.

In fact, right now, I can't see how to do this with arrow keys from within a macro. If someone knows of a way, please educate me!  This is what I really want to do.

Yes, one can do something close using G92, but that smashes the use of G52, which I want to retain. I will be using G52 too.

Another reason for wanting to be able to do this (write to the DRO directly) is simply that it is a problem I would like to solve, IF there is a solution. I begin to suspect not.

Can one read the actual DRO? So far I have not found out how to do that either. I can manipulate it by playing with Workspace offsets and tool offsets and G52 offsets, but read it? There is probably an answer deep in the Mach docs somewhere - which I have not found yet. How please!

Cheers
Roger
Title: Re: Read and write to Z DRO?
Post by: ger21 on October 08, 2016, 05:12:04 AM
Quote
Can one read the actual DRO

From a macro, yes, but not from g-code. But, the DRO value will be wherever the last g-code move went to.
Title: Re: Read and write to Z DRO?
Post by: rcaffin on October 08, 2016, 05:24:39 AM
Hi Gerry

Aye, there's the rub. I want to use the arrow keys. I think it's probably not possible to use them.

Cheers
Roger
Title: Re: Read and write to Z DRO?
Post by: stirling on October 08, 2016, 08:02:32 AM
you can call as many macros from macros as you want (except in very old versions of Mach). But just be aware they all run in their own concurrent threads and are therefore asynchronous. Any synchronization required is up to you to code.

USER DROs are accessible from gcode (in a somewhat flaky sort of way) but (AFAIK) OEM DROs are not.

Jogging is possible during any macro assuming the macro takes long enough to allow it.
Title: Re: Read and write to Z DRO?
Post by: rcaffin on October 08, 2016, 05:05:59 PM
Ah - asynchronous. OK, understood. I can handle that.
Jogging - OK, but without access to the OEM DROs from g-code ...

Strategy will have to adapt. Thanks
Cheers
Roger
Title: Re: Read and write to Z DRO?
Post by: stirling on October 10, 2016, 10:50:17 AM
Hi Roger

After a nudge - I re-read my notes and you can indeed access OEM DROs from gcode.

Use vars 99ABC where ABC is the OEM DRO number.
Title: Re: Read and write to Z DRO?
Post by: ger21 on October 10, 2016, 11:22:22 AM
I stand corrected by undocumented features.  ;)
Title: Re: Read and write to Z DRO?
Post by: rcaffin on October 10, 2016, 05:30:06 PM
Gotta love those undocumented features.

Yes indeed, #99802=0 does zero the Z axis DRO. Works for #9980n for n=0 - 5.
In addition, #99800=#99802 transfers the Z axis value into the X axis DRO. Full Read and Write.

And #5211 - #5216 are the G52/G92 offsets: touch them at your peril.

Thank you Stirling.

Cheers
Roger
Title: Re: Read and write to Z DRO?
Post by: RICH on October 10, 2016, 08:27:42 PM
stirling,

Do you have a listing of other  undocumented variables?

RICH
Title: Re: Read and write to Z DRO?
Post by: rcaffin on October 10, 2016, 11:11:32 PM
Yes please!
Roger
Title: Re: Read and write to Z DRO?
Post by: Davek0974 on October 11, 2016, 02:11:12 AM
stirling,

Do you have a listing of other  undocumented variables?

RICH

Anyone else see the irony in that question :)
Title: Re: Read and write to Z DRO?
Post by: rcaffin on October 11, 2016, 02:15:01 AM
Well, yes, but that's one of the joys of Mach3!
Cheers
Roger
Title: Re: Read and write to Z DRO?
Post by: RICH on October 12, 2016, 06:14:37 PM
Quote
Do you have a listing of other  undocumented variables?

Working on a list............lots of info available. ;D


RICH
Title: Re: Read and write to Z DRO?
Post by: stirling on October 17, 2016, 05:41:46 AM
stirling,

Do you have a listing of other  undocumented variables?

RICH

Not really - just what I've said about OEM DROs and 15001 - 15255 are linked (to a certain extent) with User Dros 1001 - 1255.

But as you've said above - lots of info available. There's lots of posts here that cover most of it that a few searches reveal.