Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: rrc1962 on January 18, 2018, 02:52:24 PM

Title: Coordinate Rotation
Post by: rrc1962 on January 18, 2018, 02:52:24 PM
If I rotate the coordinate system using G68, I'm noticing that all feed rate moves follow the rotated program correctly, but all rapids seem to ignore the rotation and go to the un-rotated position. Is there a Gcode I should be posting in the header to make M4 rapid to the correct rotated coordinates.

Thanks
Title: Re: Coordinate Rotation
Post by: bryannab on January 18, 2018, 03:51:13 PM
G68 is modal and should stay in effect until cancelled by G69. That being said, the rotation can sometimes become stacked. I noticed that a g code file I was using would rotate an addition 90 degrees if I stopped the code mid-run, rewound it, and then tried again. I can't say that's what you're seeing, but it may be a funny effect of G68. If you'd like to post your g code, I can take a look for you.
Title: Re: Coordinate Rotation
Post by: rrc1962 on January 18, 2018, 06:03:50 PM
Here is the code.  The G68 is happening before the program runs.  The operator sets the rotation, then runs the program.  G69 is not called until the operator presses a button to reset to zero rotation.

Code: [Select]
G20
G90
G91.1
M1100 (Rapid Z to safe Z)
M1111 (Apply G52 offset, which for us is always zero)
M1116 (Turns on an output)
G00 X2.44 Y2.35 (Rapids to un-rotated coordinate)
M14 A0 B100 C1 (Initiates start of cut sequence)
M1101 (Turn on THC)
G01 X2.59 (Feedrate moves are correctly oriented to the rotated coordinate system)
G01 Y9.85
G03 X2.29 Y9.85 I-0.15 J0
G01 Y2.35
G03 X2.59 Y2.35 I0.15 J0
M15 A0 B100 C1 (Stop cycle)
M01
G00 X4.88 Y2.35 (Rapids to un-rotated coordinate)
M14 A0 B100 C1
M1101
G01 X5.03
G01 Y9.85
G03 X4.73 Y9.85 I-0.15 J0
G01 Y2.35
G03 X5.03 Y2.35 I0.15 J0
M15 A0 B100 C1
M01
G00 X7.32 Y2.35
M14 A0 B100 C1
M1101
G01 X7.47
G01 Y9.85
G03 X7.17 Y9.85 I-0.15 J0
G01 Y2.35
G03 X7.47 Y2.35 I0.15 J0
M15 A0 B100 C1
M01
G00 X9.76 Y2.35
M14 A0 B100 C1
M1101
G01 X9.91
G01 Y9.85
G03 X9.61 Y9.85 I-0.15 J0
G01 Y2.35
G03 X9.91 Y2.35 I0.15 J0
M15 A0 B100 C1
M01
G00 X0 Y-0.5
M14 A0 B100 C1
M1101
G01 X0 Y0
G01 X0 Y12.2
G01 X12.2 Y12.2
G01 X12.2 Y0
G01 X-0.25 Y0
M15 A0 B100 C1
M01
M1109 (reset G52 offset, G52X0Y0)
M1105 (Rapid Z up)
G00 X0 Y0 (Return to zero)
M30
%
Title: Re: Coordinate Rotation
Post by: bryannab on January 19, 2018, 09:14:30 AM
Interesting!

Do you mind sending in a ticket with your profile and a copy of this code I can test with? I've included the link to our helpdesk below. You don't need to register, you can just click 'submit a ticket.' To send your profile, go to Help>Support>Package Current Profile and attach the file created to your ticket. Your build number and the G68 command that's being used would be very helpful as well.

Thank you,
Bryanna
Title: Re: Coordinate Rotation
Post by: rrc1962 on January 22, 2018, 10:56:55 PM
I’m out of town for a couple weeks.  I’ll do this when I get back.
Title: Re: Coordinate Rotation
Post by: Rob G on January 23, 2018, 09:15:58 AM
It appears to be your macros.  I removed them and your code ran rotated until I canceled it.  Take a look inside your the macros you are running here and see if there is anything that may be canceling the rotation.
Title: Re: Coordinate Rotation
Post by: Rob G on January 23, 2018, 09:17:20 AM
It appears to be your macros.  I removed them and your code ran rotated until I canceled it.  Take a look inside your the macros you are running here and see if there is anything that may be canceling the rotation.
Title: Re: Coordinate Rotation
Post by: rrc1962 on February 07, 2018, 12:18:25 PM
I found the offending line of code, but can't explain why it's cancelling the rotation.  In my M15 I have the following...

CodeLine1 = 'G00 Z' .. SafeZ .. '\n'
mc.mcCntlGcodeExecute(inst, CodeLine1)

If I comment these lines of code, the program runs properly oriented.  IS there something in mc.mcCntlGcodeExecute that is cancelling rotation?
Title: Re: Coordinate Rotation
Post by: rrc1962 on February 07, 2018, 12:33:52 PM
G68 is modal and should stay in effect until cancelled by G69. That being said, the rotation can sometimes become stacked. I noticed that a g code file I was using would rotate an addition 90 degrees if I stopped the code mid-run, rewound it, and then tried again. I can't say that's what you're seeing, but it may be a funny effect of G68. If you'd like to post your g code, I can take a look for you.

I submitted a ticket with the profile attached. 
Title: Re: Coordinate Rotation
Post by: rrc1962 on February 07, 2018, 05:15:10 PM
So M14 has the same issue with this code...

CodeLine2 = 'G00 Z' .. PierceHeight .. '\n'
CodeLine2 = CodeLine2 .. 'F' .. ProgramFeedrate
mc.mcCntlGcodeExecuteWait(inst, CodeLine2)

Looks like mcCntlGcodeExecuteWait sends the Z up but it also sends X and Y to their respective un-rotated coordinates.  The problem appears to be with mcCntlGcodeExecuteWait and mcCntlGcodeExecute.
Title: Re: Coordinate Rotation
Post by: smurph on March 05, 2018, 09:50:41 PM
Anytime you use mcCntlGcodeExecuteWait or mcCntlGcodeExecute, you are firing up an new interpreter (which hasn't any rotation applied to it).  So you will need to check for rotation in those macros and apply it to the G code that those functions will execute. 

-- SV_ROTATION_X                   2135 stores X value from G68
-- SV_ROTATION_Y                   2136 stores Y value from G68
-- SV_ROTATION                       2137 stores Z value from G68


local inst = mc.mcGetInstance()
local grp15 = mcCntlGetModalGroup(inst, 15) -- G68 and G69 are in modal group 15.
CodeLine2 = ""

if (grp15 == 68) then
CodeLine2 = 'G68 X#2135 Y#2136 R#2137\n'
end

CodeLine2 = CodeLine2 .. 'G00 Z' .. PierceHeight .. '\n'
CodeLine2 = CodeLine2 .. 'F' .. ProgramFeedrate
mc.mcCntlGcodeExecuteWait(inst, CodeLine2)

Steve
Title: Re: Coordinate Rotation
Post by: harshal on August 08, 2018, 06:11:08 AM
FANUC G68 ROTATE COORDINATE MAIN PROGRAM & SUB PROGRAM EXAMPLE
August 08, 2018 - FANUC G68 ROTATE COORDINATE SYSTEM [M]

 

MAIN PROGRAM

N10  G54 X0 Y0 ;
N20  M06 T05 ;
N30  G43 H5 ;
N40  M03 S1500 ;
N50  M08 ;
N60  G98 F300 ;
M98  P034321 ; sub program call
N70  G00 Z100 ;
N80  M05 M09 M30 ;

SUB PROGRAM

O4321
N10  G91 G68 X10 Y10 R22.5 ;
N20  G90 X30 Y10 Z5 ;
N30  G01 Z-5 ;
N40  X47 ;
N50  G00 Z5 ;
N60  M17 ;

DESCRIPTION OF PROGRAM
Main program
N10- Work co-ordinate system command  ( Offset point) , where X0 and  Y0
N20- Tool change command , select tool no 5
N30- Tool height offset compensation  H5(we set tool height of z axis )
N40- Spindle on clockwise at speed 1500 rpm
N50- Coolant on
N60- Feed rate per minute F300
M98- Sub program call , P03- no same operation repeat ,4321- no. of sub program.
N70- Rapid command , where  Z100 [ tool up ]
N80- Spindle off , coolant off , main program end
Sub program
N10- Incremental co-ordinate command , rotate coordinate system command where  X10 , Y10 and angle of rotation               R22.5
N20- Absolute co-ordinate command , X axis distance count from 0 to starting position ,Y at same place 10           and tool is 5 mm up.
N30- linear interpolation command , cutting depth is 5
N40- Operation end position 47 along X

my link is
www.hdknowledge.com