Hello Guest it is April 25, 2024, 08:40:19 AM

Author Topic: Problem reading G31 sytem varibles  (Read 1993 times)

0 Members and 1 Guest are viewing this topic.

Problem reading G31 sytem varibles
« on: July 29, 2021, 01:12:38 PM »
Hi
this is my first post
Please can anyone help me with getting values from system variables?
I am building a machine to grind stump grinder teeth and am trying to learn G code as I go.
Although nothing like a Mill I am using Machmil profile
So far I have managed to get over lots of problems as they came up
But I am stuck
I am using an optical switch as a probe to find depth of Z axis (to determine wear on cutter to be ground)
I am running Mach3 (Version R3.043.062) with a USB breakout board
The digitizer light comes on when the switch is triggered
When I try to read #2002 for the z position I get zero
I have included some sample code
When the machine runs the cutter moves till the light on the switch comes on then returns
And then moves the z axis to 2

g21
#50=3
a4.5 f200
g1 x193 y2 f600
g1 z1
g4 p1
g31 z20 f200
#50=[#2002+2]
g4 p1
z1.25
z#50
m30
(null line to load code)

I have looked at the forum chats and no one else seems to have trouble reading system variables
Am I being dumb or doing something stupid?
Please help

Offline Stuart

*
  •  311 311
    • View Profile
Re: Problem reading G31 sytem varibles
« Reply #1 on: July 29, 2021, 01:22:40 PM »
bet you have a Far Eastern USB board installed not setting the 2002 pound var is typical ie they do not work for probing in the 99.99% of them

IMHO get a smooth stepper USB if you must but Ethernet is better
Re: Problem reading G31 sytem varibles
« Reply #2 on: July 29, 2021, 01:30:01 PM »
Hi thanks for the reply
Yes it is a far eastern  board but I would have thought that if the digitizer light comes on then mach3 would be doing the variable setting internally

Offline Tweakie.CNC

*
  • *
  •  9,199 9,199
  • Super Kitty
    • View Profile
Re: Problem reading G31 sytem varibles
« Reply #3 on: July 29, 2021, 02:08:19 PM »
If the value is not stored in VAR(2002) then there is a good chance that it is stored in OEMDRO(802).

Tweakie.
PEACE
Re: Problem reading G31 sytem varibles
« Reply #4 on: July 29, 2021, 02:58:28 PM »
Thanks Tweakie
I have now tried looking at #802 and still got zero.
I seem to get zero from any system variable
any more suggestions?

Offline Tweakie.CNC

*
  • *
  •  9,199 9,199
  • Super Kitty
    • View Profile
Re: Problem reading G31 sytem varibles
« Reply #5 on: July 30, 2021, 12:49:32 AM »
OEMDRO(802) is not a system variable in the same sense as #802. It is usually read within a VB routine as GETOEMDRO(802).

Tweakie.
PEACE
Re: Problem reading G31 sytem varibles
« Reply #6 on: July 30, 2021, 10:33:27 AM »
I am not doing to bad with gcode but vb script is a bit beyond me at the moment.
I will try to get some help with it

Offline Graham Waterworth

*
  • *
  •  2,673 2,673
  • Yorkshire Dales, England
    • View Profile
Re: Problem reading G31 sytem varibles
« Reply #7 on: July 30, 2021, 12:43:44 PM »
#50=[#2002+2]

What is the +2 about?

Have you tried it this way :-

#50=[[#2002]+2]



Without engineers the world stops
Re: Problem reading G31 sytem varibles
« Reply #8 on: July 30, 2021, 01:03:01 PM »
I have now tried #50=[[2002]+2] still moving to 2 (so 0+2)
The plus 2 was because at one point I had it working and the value I got back was 2 higher than the z position I assumed some kind of probe compensation that I could not find.
the time it worked was after a new install but I have tried that again since and no joy.
Re: Problem reading G31 sytem varibles
« Reply #9 on: August 01, 2021, 08:51:11 AM »
if Tweakie is still seeing this
I now have enough vbscript to display variables in a message box.
But I do not understand the results.
the #2002 #5023 and oemdro(802) all read zero
if I assign a value to #5023 either before or after the g31 code then I get the value that I have assigned.
I don't know what else to try