Hello Guest it is March 28, 2024, 04:24:28 AM

Author Topic: Read and write to Z DRO?  (Read 6355 times)

0 Members and 1 Guest are viewing this topic.

Offline rcaffin

*
  •  1,052 1,052
    • View Profile
Read and write to Z DRO?
« 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
Re: Read and write to Z DRO?
« Reply #1 on: October 08, 2016, 03:04:19 AM »
G92 Z0 ?

That var is read only I suspect
« Last Edit: October 08, 2016, 03:10:59 AM by robertspark »
Rob

Albert Einstein ― “If you can't explain it to a six year old, you don't understand it yourself.”
Re: Read and write to Z DRO?
« Reply #2 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
« Last Edit: October 08, 2016, 04:05:28 AM by Highspeed1964 »
Re: Read and write to Z DRO?
« Reply #3 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)
Rob

Albert Einstein ― “If you can't explain it to a six year old, you don't understand it yourself.”

Offline rcaffin

*
  •  1,052 1,052
    • View Profile
Re: Read and write to Z DRO?
« Reply #4 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

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: Read and write to Z DRO?
« Reply #5 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.
Gerry

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

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

Offline rcaffin

*
  •  1,052 1,052
    • View Profile
Re: Read and write to Z DRO?
« Reply #6 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

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: Read and write to Z DRO?
« Reply #7 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.

Offline rcaffin

*
  •  1,052 1,052
    • View Profile
Re: Read and write to Z DRO?
« Reply #8 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

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: Read and write to Z DRO?
« Reply #9 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.