Hello Guest it is March 29, 2024, 05:25:26 AM

Author Topic: I need help to make this subrutine run.  (Read 4268 times)

0 Members and 1 Guest are viewing this topic.

I need help to make this subrutine run.
« on: December 05, 2010, 09:57:12 PM »
I get this error:
Radius from end of acr differs from radius to start of arc line 18


%
(Shock Spacer)
g17 g20 g90
g0 x0 y0 z.250
m3 s1600
g1z-.625 f6
g1 y.190 (Shock shaft diameter)
g3 x0 y .190 i0 j-.190
g0 y0 z.250
g0 y1.0215 (Shock piston diameter)
g1 z0
M98 P006 L4
g90
g0 z.250
m30
%

O006 (sub)
g91
g2 x0 y1.0215 i0 j-1.0215 z-.170
M99
%

Offline alenz

*
  •  137 137
    • View Profile
Re: I need help to make this subrutine run.
« Reply #1 on: December 06, 2010, 12:10:37 AM »
Captain, If you delete the G91 from line 18 it will run but I doubt that will give the result that you want. I’m going to guess that you probably want the Z to feed continuously for all four passes in the sub. If so you might want to use a variable to increment the feed for each loop.

Something like this:

%
(Shock Spacer)
g17 g20 g90
g0 x0 y0 z.250
m3 s1600
g1z-.625 f6
g1 y.190 (Shock shaft diameter)
g3 x0 y .190 i0 j-.190
g0 y0 z.250
g0 y1.0215 (Shock piston diameter)
g1 z0
M98 P006 L4 #1 = 0
g90
g0 z.250
m30
%

O006 (sub)
(g91)
#1=[#1-0.170]
g2 x0 y1.0215 i0 j-1.0215 z#1
M99
%

Hope this helps,
Al

Offline alenz

*
  •  137 137
    • View Profile
Re: I need help to make this subrutine run.
« Reply #2 on: December 06, 2010, 02:04:39 AM »
As a follow up to the previous post, the G91 is actually in line 17, not 18. Also the use of a variable is only one of several ways to increment Z in the loop. Another would be to simply revise line 18 from
g2 x0 y1.0215 i0 j-1.0215 z-.170
To
 g2 x0 y0 i0 j-1.0215 z-.170
This will correct the cause of the error, i.e., the Y is being shifted due to being in incremental mode. The I and J are always incremental, so aren’t affected, thus by making Y = 0 only the Z is changed which I think is what  we want.  I just happened to have been using the variable method recently and it came to mind first.

Al
Re: I need help to make this subrutine run.
« Reply #3 on: December 06, 2010, 02:17:44 PM »
Thank you for your help. Using the variable, works well. In the other method, how does the Y shift due to being in incremental mode? I am trying to understand this better. It does run in absolute, but z does not increment.
Thank you

Offline alenz

*
  •  137 137
    • View Profile
Re: I need help to make this subrutine run.
« Reply #4 on: December 06, 2010, 10:45:14 PM »
It’s all in the way G2 and G3 are implemented. For example in G90 (Abs) mode your line
g2 x0 y1.0215 i0 j-1.0215 z-.170
tells Mach to draw a clockwise arc starting at the current position, (the last position before this line which in this case is X0, Y1.0215) and ending at the position specified in this G2 line, (which is also X0, Y1.0215). The I value is the X distance from the starting point to the arc center, (X0 + 0 = 0) and the J is the Y distance from the starting point to the arc center, (Y1.0215 – 1.0215 = 0) thus the arc center based on the STARTING point is X0, Y0.  Since the starting and end points are the same, obviously they will both have the same radius and everything is fine.

Now look at the same case but with G91 (Inc) active. Now the absolute values in line
g2 x0 y1.0215 i0 j-1.0215 z-.170
are redefined as the previous value shifted by the amount specified in this line i.e., the new X is the old X(0) + 0 = 0, the new Y is the old Y(1.0215) + 1.0215  = 2.0430 and the new Z is the old Z(0) -.170 = -.170.  Thus in absolute mode the line now means
g2 x0 y2.043 i0 j-1.0215 z-.170.
The start point is still X0, Y1.0215 (from the preceding lines) but now the end point has changed to X0, Y2.0430 thus the error message that the start and end radius doesn’t agree. The I and J modes are handled differently. They aren’t affected by G90 or G91. Their mode is set independently in Config / General Config and will normally be set to Inc. That’s why just changing the Y1.0215 to Y0 fixes the problem in that line.  It no longer changes the end point, still retains the same radius but allows the Z to increment as intended.

HTH,
Al
Re: I need help to make this subrutine run.
« Reply #5 on: December 07, 2010, 03:16:30 AM »
So that is why this subrutine worked. The X and Y were at zero. If they were not at zero it wouldn't run. Just talking about this helps it sink in. Thank you again.


M98 P1 L6
O1
G91
G2 X0.0 Y0.0 I0.5 J0.0 z-0.06 F20.0
M99

Offline alenz

*
  •  137 137
    • View Profile
Re: I need help to make this subrutine run.
« Reply #6 on: December 07, 2010, 10:20:54 PM »
Actually X and Y don’t necessarily ‘have’ to be zero for the line to ‘run’, it’s just that the arcs wont have a common center. The criteria for the G2 and G3 is that the start and end points must both lie on the same circle. For example you can modify your sample code snippet like this and it will run OK:

%
M98 P1 L6
M30 (required for sub)

O1
G91
G2 X1.0 Y0.0 I0.5 J0.0 z-0.06 F20.0 (change X from 0 to 1.0)
M99
%

It doesn’t matter to Mach where the start point is, (it’s actually whatever is currently entered in the X and Y DRO’s). It is telling Mach to draw an arc whose center is ½ inch to the right of the start and with the end one inch to the right of the start. Thus both points lie on the same one inch dia circle and so no prob. The next iteration thru the sub will use the current end point as the new start. An interesting exercise is to try entering various values in the X and Y DRO’s and note the effect.


As an aside I discovered (counter to what I said above >:() that changing the X from 0 to 1.50 in the above code doesn’t throw an error which it should in my opinion. Per the manual it is an error if the start and end radius lengths don’t agree within 0.0002 inch. I seem to remember Art changing this tolerance sometime back (because round off was causing an error if not enough decimal places were being used?).  But ½ inch seems pretty gross. It plots as a series of 1 ½ in wide 180 deg spirals (not true semicircles) end to end.
Can anyone shed light on this? 
Al