Welcome, Guest. Please login or register.
Did you miss your activation email?
August 18, 2018, 05:30:05 PM

Login with username, password and session length
Search:     Advanced search
* Home Help Search Calendar Links Login Register
+  Machsupport Forum
|-+  Support
| |-+  Downloads
| | |-+  MACH TOOL BOX
| | | |-+  TUBE COPING program
Pages: 1   Go Down
Print
Author Topic: TUBE COPING program  (Read 14740 times)
0 Members and 1 Guest are viewing this topic.
BR549
Mach4 Alpha

Offline Offline

Posts: 6,853


View Profile
« on: November 04, 2010, 10: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
%

* M1222.m1s (0.27 KB - downloaded 576 times.)

* Cope example.jpg (18.27 KB, 737x498 - viewed 1496 times.)
« Last Edit: November 04, 2010, 11:03:31 AM by BR549 » Logged
BR549
Mach4 Alpha

Offline Offline

Posts: 6,853


View Profile
« Reply #1 on: November 04, 2010, 11:23:30 AM »

YOu can use this routine with Plasma, router, mill, laser, etc,etc
Logged
Deon Gerber
Active Member

Offline Offline

Posts: 57



View Profile
« Reply #2 on: April 27, 2018, 07: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
Logged

If A is a success in life, then A equals X plus Y plus Z.
                               Work is X: Y is play and Z is keeping
                                                             your mouth shut.
Deon Gerber
Active Member

Offline Offline

Posts: 57



View Profile
« Reply #3 on: April 27, 2018, 09: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


* toolpath1.png (6.19 KB, 765x357 - viewed 109 times.)
Logged

If A is a success in life, then A equals X plus Y plus Z.
                               Work is X: Y is play and Z is keeping
                                                             your mouth shut.
Tweakie.CNC
CNC is only limited by our imagination.
Global Moderator
*
Offline Offline

Posts: 7,354


Super Kitty


View Profile WWW
« Reply #4 on: April 27, 2018, 10: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.
Logged

Success consists of going from failure to failure without loss of enthusiasm.  Winston Churchill.
TPS
Active Member

Offline Offline

Posts: 839



View Profile
« Reply #5 on: April 27, 2018, 10: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.
Logged

anything is possible, just try it.
if you find some mistakes, in my bad bavarian english,they are yours.
Deon Gerber
Active Member

Offline Offline

Posts: 57



View Profile
« Reply #6 on: April 28, 2018, 09: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?Huh?? 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
Logged

If A is a success in life, then A equals X plus Y plus Z.
                               Work is X: Y is play and Z is keeping
                                                             your mouth shut.
Deon Gerber
Active Member

Offline Offline

Posts: 57



View Profile
« Reply #7 on: April 28, 2018, 09: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.Huh?
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
Logged

If A is a success in life, then A equals X plus Y plus Z.
                               Work is X: Y is play and Z is keeping
                                                             your mouth shut.
Deon Gerber
Active Member

Offline Offline

Posts: 57



View Profile
« Reply #8 on: April 28, 2018, 02: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
Logged

If A is a success in life, then A equals X plus Y plus Z.
                               Work is X: Y is play and Z is keeping
                                                             your mouth shut.
Pages: 1   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.20 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!