Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: BluePinnacle on January 20, 2009, 11:36:14 AM

Title: Offsets for spherical tools
Post by: BluePinnacle on January 20, 2009, 11:36:14 AM
Hi. Simple question, difficult machining. Can mach3 be set up to allow for a spherical offset system? I need to machine a compound curve - a reflector parabola, in fact - and a spherical or ball-nosed cutter would be the thing to do it. Can a simple offset be used to do this or will I have to wear out  a calculator translating 3D values into real controlled point movements?

Also, pointing me to a section herein on building formulae into G-code would be extremely useful.

Thanks in advance :)
Title: Re: Offsets for spherical tools
Post by: ger21 on January 20, 2009, 01:37:40 PM
Use a CAM program and 3D model.

Within the last week, someone (VMAX) posted a macro for doing a sphere on the Yahoo group. If he reads this, maybe he'll post it here.
Title: Re: Offsets for spherical tools
Post by: Sam on January 20, 2009, 05:20:56 PM
out of curiosity, are you making a telescope?
Title: Re: Offsets for spherical tools
Post by: vmax549 on January 20, 2009, 06:54:48 PM
OH BOY a challenge, A sphere is fairly simple with parametric programming(yea right) if you like math.

THere several methods,

Let a CAM program do all the work (My favorite)

Program the math into a parametric variable and use the GCODE math to do the work. (Works very well IF you can do the initial math) and my SOns favorite approach(;-)

Use the Mach math channels for the axis's (very little known about how it acutally works).

Let me know if I can help, (;-) TP


PS: a small example of the code to do a  simple sphere. it makes use of sin/cos

o140
   #8 = [[SIN[#5]*#6]*SIN[45]] ( X AND Y POSITION)
   #9 = [0-[[1-COS[#5]]*#6]] (Z HIGHT)
   G1X[#8]Y[#8]F3
   Z[#9]
   G18 G02 X[0-#8]Z[#9]I[0-#8]K[0-[#9+[#6]]]F5
   G19 G03 Y[0-#8]Z[#9]J[0-#8]K[0-[#9+[#6]]]
   G18 G03 X[#8]Z[#9]I[#8]K[0-[#9+[#6]]]
   G19 G02 Y[#8]Z[#9]J[#8]K[0-[#9+[#6]]]
   #5=[#5+#4]

The mach manual has the basics for the parametric coding and all the available math functions
Title: Re: Offsets for spherical tools
Post by: BluePinnacle on January 20, 2009, 08:53:30 PM
Brilliant, thanks - I'm making microwave reflectors for milimeter wave systems (potentially - it's an ongoing thing). I'll have another go at the manual, i looked ages ago but it was a bit opaque. Perhaps it will be clearer after more coffee. If there's a special coffee I must drink, do let me know ;)
Title: Re: Offsets for spherical tools
Post by: BluePinnacle on January 22, 2009, 12:16:34 PM
 ??? :o

Just read up on parametric programming. I can see that what I want to do is possible but it's going to need a lot of that very special coffee and a good lie-down afterwards. I will lock the children in the cupboard, unplug the dog and prepare for some very in-depth algebra.
Title: Re: Offsets for spherical tools
Post by: BluePinnacle on January 22, 2009, 03:47:28 PM
well, that wasn't too hard. Reading the manual, I came up with this.

It's only a demo file to check toolpaths on my laptop, so no units, spindle or anything fancy like that.

Quote
(vague parabola generator)

(SET THE VERTEX POINT OF THE PARABOLA AS 0,0,0)
G0 Y0
G0 Z0
G0 X-30
G0 Y100
#1=-30
M98 P33 L300
M30

O33
G0 Z[0.002*#1*#1]
g2 y-100 i0 j0
G0 Z180
G0 Y100
G0 X#1
#1 = [#1+1]
M99


So it should be a relatively simple matter to integrate some small X and Z offsets by calculating the tangential angle of a line against the profile of the parabola and altering the position of the tool before it does its G2 scan. I think ;)

What strikes me about this is the incredible economy and flexibility of handwritten G-code. The things I've seen spewed out by CAM programs is nobody's business, great reams of g01 here and g01 there, it's a nonsense.

Of course my code above might, in proper CNC terms, be a murderous bag of hacks, do say if so. I can learn. :D
Title: Re: Offsets for spherical tools
Post by: vmax549 on January 22, 2009, 08:14:33 PM
NOW you are getting the idea(;-) I have seen 12 lines of  parametric code replace 100,000 lines of normal code. IF you are good with the math there is little that cannot be done.


(;-) TP
Title: Re: Offsets for spherical tools
Post by: BluePinnacle on January 23, 2009, 02:25:56 PM
Cheers. Happier now. One thing I can't seem to find in the manual is how to apply an axis value off the DRO to a parameter; ie make the value of #3 equal to whatever X is reading at the time. Some clues here?  ???
Title: Re: Offsets for spherical tools
Post by: vmax549 on January 23, 2009, 04:53:12 PM
Here you have to be sneaky(;-) You would need to write a simple Macro in vb

Say    M9991     Inside the macro would be code like 

Code" #3=" & GetOEMDRO(*********x)          THat would load the value of the DRO into the Variable #3

OR use

Setparam(3),Getoemdro(xx)

OR if you wanted to be able to program the Macro for different Variables or DROs

M9991 P3 Q1202       Then the macro code would be like

SP= Param1()
GD=Param2()
Setparam() &SP, Getoemdro() &GD

That would specify what Varaiable t update and what DRO to use.

Then just call the macro anywhere in the Gcode where it is needed to update the #3 Variable

Hope that helps(;-) TP
Title: Re: Offsets for spherical tools
Post by: BluePinnacle on January 23, 2009, 08:03:57 PM
Hmm. Last time I used VB it was pretty gruelling. I'll try these and see what i can do. Cheers...

I thought of another way I could cut a parabola, sending the cutter round in an extremely long helix. I'll have a play with that too.
Title: Re: Offsets for spherical tools
Post by: BluePinnacle on January 24, 2009, 08:58:00 PM
I'm having no joy here. I can't get the macro to operate.

The macro is named M9991 and is stored in \macros.

the code I was using as a test should show red G0 moves +500 X, then +500Y, then +500 Z. The Z move defined by a parameter that the macro should create by calling it from the Y DRO.

Gcode here:

#10=0
#11=0
#12=0
G0 X500
G0 Y500
M9991
G0 Z#11
m30
%

Macro here:

CODE"#10="&GetOEMDRO(800)
CODE"#11="&GetOEMDRO(801)
CODE"#12="&GetOEMDRO(802)

I'll be honest, I have no idea what I'm doing. If i could see something work, I'd be a great deal happier. As it is it's like repairing a radio with a knife and fork. What i want to do is this:

 - get an axis DRO value
 - assign it to a conventional # parameter and use it in a regular parametric subroutine.

Sorry to bugger round in little circles over what should be a very simple affair but I've never written a macro before and I'm definitely missing a point somewhere... I've tried the suggested methods, with permutations and alterations galore, and I get errors, or it just doesn't work.

Is it not working on the simulations because the DRO doesn't actually move?

Is Mach looking for the macros somewhere else? A subfolder?

My head hurts and i'm going to bed.

 ???
Title: Re: Offsets for spherical tools
Post by: Hood on January 24, 2009, 09:17:38 PM
Dont have a clue about any of that stuff but your macro needs to be placed in your profiles macro folder, eg if your using the standard mill profile it would be C:\Mach3\Macros\Mach3Mill
 To see if Mach is looking at your macro put the following as the first line of your macro.

MsgBox("I am Running")



Hood
Title: Re: Offsets for spherical tools
Post by: ger21 on January 24, 2009, 09:42:53 PM
Try something like this:

x = getoemdro(800)
string1 = "#10=" & x
code string1
Title: Re: Offsets for spherical tools
Post by: vmax549 on January 24, 2009, 10:09:49 PM
CODE"#10="&GetOEMDRO(800)
CODE"#11="&GetOEMDRO(801)
CODE"#12="&GetOEMDRO(802)


Try

SetVar(10,GetOemDro(800))
SetVar(11,GetOemDro(801))
SetVar(12,GetOemDro(802))

(;-) TP

Title: Re: Offsets for spherical tools
Post by: vmax549 on January 24, 2009, 11:39:36 PM
Question? Did you set up a NEW set of DROs or are you trying to read dros that are already in use in MACH?

(;-) TP
Title: Re: Offsets for spherical tools
Post by: jimpinder on January 25, 2009, 03:15:48 AM
If you want to run a macro alongside GCode, then the macro must be written and then put in the correct folder so that Mach3 knows where to look for it. If you are using a Mill screen, then the folder is Mach3/macros/Mach3mill.

VB is a good program, in that you can check all your code before posting it, by stepping through the program. If the program won't step there is a fault, and it should be highlighted, or the cursor stops at the right place.When you first load the GCode, Mach 3 reads the program, complete with macros and displays it on the toolpath, so it gives you an idea whether you are right or not.

Be careful, because if the machine is attached and on, the machine will move in response to " Code" instructions. I write all my VB on a different computer, where I have Mach 3 installed, but not connected to any machine. In this way I can run the complete GCode, with Macros.

If you look at the video tutorial on scripting and copy say the part where you download the tool change position from the user DRO's for a test, this will get you going. Rather than writing complex codec, keep it simple, using easily recognisable variables. Then do the maths, and then write out the code to the machine. This is one of my macros for  rounding off a bar.

Rem Round End swinging arm

Code "G0 Z-17"

For depth = 0 To 10 Step 0.25

xpos = 26.34 - depth
Code "G0 X"&xpos
Code "G1 F25 Y15"
Code "G0 X"&(xpos+1)
Code "G0 Y-1"

Next depth 


For getting parameters from DRO, write them into variables first named something like oldxpos, oldypos, oldzpos usiing simple instructions like

oldxpos = GetOemDro(**)
OR
newxpos = GetUserDRO(***)

do whatever you want with it, then either post it back to Mach3 e.g. SetVar(10,newxpos) or write the code for the machine to run using Code"G1 X"&newxpos &"Y"&newypos  etc.

the machine runs as though you are writing the code on the MDI line, the only drawback being that you cant see it, the program just shows the macro number, not the macro itself.
I write some comments in the VB for the macro to post to the machine and it appears on the comments line, to let me know whereabouts the macro is, since some of them take an hour to run, where they are thinning down bar stock, then putting the profile on.

Stick at it.

If you email me and tell me what it is you want to do exactly, I will write some code for you, but I am a bit busy for the next three weeks, although I have some free evening time this first week.










Title: Re: Offsets for spherical tools
Post by: BluePinnacle on January 25, 2009, 06:55:48 AM
Thanks guys, very much appreciated. I'm going to have to learn about VB, it's just that the learning curve at this point is quite steep and a bit greasy.

I'll try some of the suggestions tonight - there seems to be a number of ways to do the same thing. The DRO I'm trying to read is the one on the "program run" screen, the regular X,Y and Z DROs that Mach will be using for the program as it runs, I think the OEM codes are 800, 801 and 802.

Jim - sound advice. I'm only doing proof-of-concept stuff for now, on a laptop with no mill attached. I'm keeping this muck well away from my real rig until I can say with confidence that I know what will happen ;)

Thanks again, I'll try to get this set up this evening and see how we go.
Title: Re: Offsets for spherical tools
Post by: vmax549 on January 25, 2009, 05:26:05 PM
IF you are trying to read the main screen axis dro you are using the wrong approach(;-)

They are Dro's 0-4 AND they  require

GetDRO(0)  for x
GetDro(1) for Y
GetDro(2) for Z

There are DROS, OEMDROs and USERDROs   (;-)

If you have your math worked out and know how it is to be applied  we probably can help you out with te macro side. AND YES there are several ways of doing things that end up with the same results.

Let US KNow if we can help out,(;-) TP
   
Title: Re: Offsets for spherical tools
Post by: jimpinder on January 26, 2009, 04:43:27 AM
I'll concur with that.

If you search for visual basic on the forum, there is a complete list of Mach3 specific functions in VB somewhere, if you haven't already got it.
Title: Re: Offsets for spherical tools
Post by: vmax549 on January 26, 2009, 10:14:31 AM
One other thing you need to consider . Youneed to do your math model where it is self supporting as to being able to run without outside references such as reading a dro for position correction.

It is NOT that mach cannot do it BUT to do it that way you will have to run the entire GCODE side from inside the macro as well AND MachVB with Gcode running inside do not always play well together at this time.(;-)

THe gcode side has ALL the math functions you should need.(;-)

Just a thought, (;-) TP

YOu should be able to develope a math model to do your shape in the 2 basic planes ZX and ZY so your parabola will be accurate

Title: Re: Offsets for spherical tools
Post by: BluePinnacle on January 28, 2009, 06:22:56 AM
Cheers. I had a re-think about this and I'm working on a different approach to cutting parabolas. The algebra is rather involved though, and I haven't had a lot of time to sit and think seriously about it. I'm taking over a factory and setting up some seriously hefty gear in there next week ... I'll get back to this when I can.

@   <--- mothball to keep it fresh