Machsupport Forum

Support => Downloads => MACH TOOL BOX => Topic started by: BR549 on November 04, 2010, 11:43:48 AM

Title: TUBE COPING program
Post by: BR549 on November 04, 2010, 11:43:48 AM
Enclosed is an X/A axis Tube/Pipe coping program.  There are 2 code examples included, one is a standard program that you manually modify the variables before start and then begin.

The other has a programable front end macro that ASKs the question and you fill in the blanks. You will need to copy the macro code into a macro and move to YOUR macro directory before it will work.

There is NO Zaxis startup code such as Spindle speed or start or Zhom and plasma start etc. This just provides the motion code for you.


There are 4 variables  that HAVE to be input for correct operation.On the Programable Front End version it is NORMAL on file load to get a divide by ZERO error. That is because the Variable values have NOT been load yet by the macro. JUST say OK and hit rewind to continue. AS sonn as the macro runs and you have filled in the values the screen will reload and you will see the correct cut profile displayed.

#100 = CutTube Diameter
#101 = Uncut Tube Diameter
#103 = Cut Tube wall Thickness
#104 = Joint ANGLE



##### Program Code #####################################################

(CNC A axis Plasma TUBE Coping routine)
(Math derivative by Dan Hopper Copyright 2006)
#100= 1.250       (CutTube Diameter)
#101= 1.250       (Uncut Tube Diameter)
#103= .095         ( Tube Thickness )
#104= 45             (Joint ANGLE)
#200 = [#100 / 2]         (RO)
#201 = [#101 / 2]         (RU)
#202 = [#200 - #103]  (RI)
#203 = #104                (AF)
#204 = 0                       (ID)
#300= 2                        (A step in deg)
G0 G40 G54 G90 G49 G17 G50 G64 G91.1 G94
G0 A0.000 x0.000 Z1.000 F500
Z0.000
M98 P01 L180
G0  A0.000 X0.000 Z1.000
M30
o01
G1  A#300 X  [sqrt [#201 **2 - [ [#202 * sin [#204]] **2]] /  sin[#203] -  tan [90-#203] * #202 * cos[#204]]
#204=[#204+2]
#300=[#300+2]
m99
%


*****Programable Front End VERSION************************

'M1222  Macro to program Tube Coping Gcode Program
SetVar(100, Question (" P1  Cut Tube Diameter ?"))
SetVar(101, Question (" P2  Uncut Tube Diameter ?"))
SetVar(103, Question (" P1  Tube Thickness ?"))
SetVar(104, Question (" P2  Tube JOINT ANGLE ?"))
DoOemButton(160)
end


******************************************************

(CNC A axis Plasma TUBE Coping routine)
(Programable Front End)
(Divide By Zero ERROR is normal on startup)
(Caused By EMPTY variable values at this point)
(Hit REWIND and continue)
(Math derivative by Dan Hopper Copyright 2006)
G0 G40 G54 G90 G49 G17 G50 G64 G91.1 G94
M1222
#200 = [#100 / 2]         (RO)
#201 = [#101 / 2]         (RU)
#202 = [#200 - #103]  (RI)
#203 = #104                (AF)
#204 = 0                       (ID)
#300= 2                        (A step in deg)
(Verify Start Point and Press CYCLE START to Begin)  
G0 A0.000 x0.000 Z1.000 F500
Z0.000
M98 P01 L180
G0  A0.000 X0.000 Z1.000
M30
o01
G1  A#300 X  [sqrt [#201 **2 - [ [#202 * sin [#204]] **2]] /  sin[#203] -  tan [90-#203] * #202 * cos[#204]]
#204=[#204+2]
#300=[#300+2]
m99
%
Title: Re: TUBE COPING program
Post by: BR549 on November 04, 2010, 12:23:30 PM
YOu can use this routine with Plasma, router, mill, laser, etc,etc
Title: Re: TUBE COPING program
Post by: Deon Gerber on April 27, 2018, 08:15:20 AM
Hi

I've been trying to redo this macro in the form of a Wizard but I keep getting a script error in the flowing line

Code "G1 A" & AStepDeg "X" & (Sqr(RO * 2 - ( (RI * Sin (ID)) *2)) /  Sin(JAngle1) -  Tan (90-JAngle1) * RI * Cos(ID))

It seems that it does not like the "x" part on the same line as the Y.
If I put it on a different line there are no errors but as expected the output is not the same.

A bump in the right direction would be appreciated  .

THX
Deon
Title: Re: TUBE COPING program
Post by: Deon Gerber on April 27, 2018, 10:25:23 AM
Hi

Made some progress.
The sub seems to be working except for the fact it incrementally ads to the X.
The A axis code does what it should do by incrementally adding 2 degrees at each loop.

On the X however it incrementally ads the result of the formula instead of just plotting the absolute value.

This is the code current output:

G40 G54 G90 G49 G17 G50 G64 G91.1 G94
G0 A0
G0 X0
F500
M98 P1000 L180
G0  A0
G0 X0
M30
O1000
G1 A2
X-6.2545201135712
M99
M30
%

Maybe I am just missing something.
I attached a pic of the tool path output.
Do you have a sample output code that I can look at.

Thanks in advance.
Deon
Title: Re: TUBE COPING program
Post by: Tweakie.CNC on April 27, 2018, 11:15:08 AM
Hi Deon,

Try sending BR549 a PM. He does not visit here quite so often nowadays but I am sure he would be pleased to help.

Tweakie.
Title: Re: TUBE COPING program
Post by: TPS on April 27, 2018, 11:48:06 AM
the code is running the subroutine 180 times (G98 L01 L180)


that is the reason why the orignal uses #variables to calculate values by runtime.
Title: Re: TUBE COPING program
Post by: Deon Gerber on April 28, 2018, 10:39:34 AM
Hi TPS

correct me if I am wrong...... What is the difference between a #variable and a normal declared variable with out the #.
The loop part I understand....The A axis loops 180 times but the X formula gets solved once and then added incrementally to the previous amount.

It must be the way I do the script?????? That's why it does not update the formula in real time.......

G40 G54 G90 G49 G17 G50 G64 G91.1 G94
G0 A0
G0 X0
F500
M98 P1000 L180
G0  A0
G0 X0
M30
O1000
G1 A2
X-6.2545201135712
M99
M30
%


text in red is sopposed to be updated with every run of the loop.

This is where I am stuck....

Thanks
Deon
Title: Re: TUBE COPING program
Post by: Deon Gerber on April 28, 2018, 10:45:40 AM
Hi

Maybe you will understand better if I give you a snippet of the code in the wizard.
Think the problem is how I implement the sub routine.????
DRO values get filled in by the user.


Sub Main()
DoOEMButton (169)


CTubeDia = GetOEMDRO(1050)
UCTubeDia1 = GetOEMDRO(1051)
TThickness = GetOEMDRO(1052)
JAngle1 = GetOEMDRO(1053)
OD = GetOEMDRO(1050)
ID = 0
RO = (CTubeDia / 2)
RU = (UCTubeDia1 / 2)
RI = (RO - TThickness)
AF = JAngle1
AStepDeg = 2
Feed = (GetOEMDRO(1054))

OpenTeachFile "PipeCope.nc"
Code"G40 G54 G90 G49 G17 G50 G64 G91.1 G94"
Code"G0 A" & 0.000
Code"G0 X" & 0.000 
Code"F" & Feed
Code"M98 P1000 L180"
Code "G0  A" & 0.000
Code "G0 X" & 0.000
Code"M30"

Code "O1000" 
Code "G1 A" & AStepDeg
Code "G1 X" & (Sqr(RO^2 - ( (RI * Sin (ID))^2)) /  Sin(JAngle1) -  Tan (90-JAngle1) * RI * Cos(ID))
ID = (ID + 2)
AStepDeg = (AStepDeg + 2)
Code "M99"
Code "M30"
Code "%"
CloseTeachFile

Call LoadTeachFile
End Sub

Main                 

Any help will be appreciated.

Thanks
Deon
Title: Re: TUBE COPING program
Post by: Deon Gerber on April 28, 2018, 03:19:13 PM
OK you Guys

Think I have figured it out now.
Head is hurting after this but thats how you learn.

THX
Deon