Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: Chris.Botha on May 10, 2009, 05:41:26 AM

Title: hole macro help please :)
Post by: Chris.Botha on May 10, 2009, 05:41:26 AM
Hi guys..

This may seem a simple task to the guru's here but after playing around with mach for a while i have to admit defeat (ie: i reached the threshold where i stop being obstinate and ask for help instead)

i have a repetitive task that need to happen for virtually every ring i cut. so i have the gcode saved on my desktop for it.. it simply drills a  hole (6mm hole with 3.17mm endmill)  in the middle of a hub in the centre of a ring to allow me to pick it up 90' to a finishing pass on my 4th axis.. i have been playing with MachScreen for tweaking my mach interface and i was thinking it would be cool to be able to add a button that would simply drill this hole for me. the example attatched is round but i hve a variety of hubs so i was hoping to add another screen to mach and have a few different hub buttons.. once i figure out how to add one the rest will be easy.. i hope :)

some clues to get me going in the right direction?

posting images and the gcode as an example.



Thanks in advance

Chris :)


[edit] aded rhino hub to help this post make more sense.. i hope




Title: Re: hole macro help please :)
Post by: Hood on May 10, 2009, 06:14:35 AM
Make the macro and store it in the macro fiolder of the profile you use with a name such as M111.m1s  (User macro should be over 100 if I recall correctly) then its  just a matter of having a VB button on your screen that calls the macro, all you would need in the button is code("m111").  Incidentally calling M111  from MDI or code would also do that macro.

How the macro is written depends on what you need to do but  if its simple then its just a case of
Code("G0X0Y0XZ2")
While IsMoving()
Sleep(10) 'the sleep should not be needed if using one of the recent revisions of Mach
Wend
Code ("G1Z-5F40")
etc etc


You will may need to add spindle calls etc, all depends on how you want to do things and how your machine is setup.
I am not good enough at VB to rattle things off in seconds and it often takes me a few hours to do simple things I want to do but in the end it all works out and the sense of achievment is a nice thing for a thicko like me :)

Hood
Title: Re: hole macro help please :)
Post by: Hood on May 10, 2009, 06:36:17 AM
Just tested things out and looks like the VB will wait until the code is completed before executing the next line so probably no need for the
While IsMoving()
Wend

but as said I am a thicko when it comes to VB so test with caution ;)

Hood
Title: Re: hole macro help please :)
Post by: M250cnc on May 10, 2009, 06:44:54 AM
Another great tip learned.

Hood don't sell yourself, short next to me your a genius.  ;D

Phil
Title: Re: hole macro help please :)
Post by: Chris.Botha on May 10, 2009, 07:08:08 AM
Code("G0X0Y0XZ2")

ok so in my case i have a whole swag of code happening .. so i can do this??

code ("
G17 G21 G40 G54 G64 G90
M03
G00 Z4.5850
X0.0000 Y0.0000
G01 Z0.0250 F300.0
Z0.0000 F600.0
X0.9116 Y1.0778 Z-3.0000
X0.8753 Y1.1079
X0.8743 Y1.1088 Z0.0000
etc
etc
etc
etc
Z0.0250
G00 Z4.5850
G00 Y0.0000
M05
M30
")


or

do i need to edit in the

code (" ")
section on each line of code?




Title: Re: hole macro help please :)
Post by: Hood on May 10, 2009, 08:07:44 AM
Phi next to some I may be  a genius but there are many more that are geniuses when compared  to me ;)

Chris
Test and see , easy enough to do, just open Mach copy your code and then go to the Operator menu and open the VB editor. Paste in your code and then add the Code(" to the start and ") to the end, Press the green arrow and you will either get a syntax error or the code will run correctly, I suspect it will need to be line by line though.

Hood

Title: Re: hole macro help please :)
Post by: Hood on May 10, 2009, 08:17:00 AM
Ok just tested myself and as suspected you will need tto put it on each line, you might also need to put a G0, G1 or whatever on each line that involves axis movementl.

Hood
Title: Re: hole macro help please :)
Post by: Chris.Botha on May 10, 2009, 03:42:17 PM
thanks man.. gave it a whirl and got syntax error..




some of the code is huge!  i will have to brush up a bit or manually load code for now.. occurs to me it should be easir to insert a section of gcode into a macro?

thanks for all the help man :)

Title: Re: hole macro help please :)
Post by: Hood on May 10, 2009, 05:08:21 PM
You may be able to call the code from a macro, sort of like calling a sub but afraid I dont know enough about that.
Hood
Title: Re: hole macro help please :)
Post by: Chris.Botha on May 11, 2009, 02:36:44 AM
thanks man thats kinda what i was hoping..

been a while since i coded too.. think Pascal/Fortran/C on a 4.77mhz pc/xt..  so long ago.. before i had a beer gut.. and guilt..

lol.. actually i learned to machine code on a commodore vic20..  man im old....

Title: Re: hole macro help please :)
Post by: MachineMaster on May 11, 2009, 06:10:32 PM
How about toggle switches on a PDP8 coding in Octal
Title: Re: hole macro help please :)
Post by: Graham Waterworth on May 12, 2009, 02:29:07 AM
Are the good old days,  CPM on an S100 with the luxury of a single 8" floppy, coding COBOL.

Hell I miss those days.............          NOT

Graham
Title: Re: hole macro help please :)
Post by: Chris.Botha on May 12, 2009, 02:33:20 AM
ok you guys win!!!

Title: Re: hole macro help please :)
Post by: Graham Waterworth on May 12, 2009, 02:35:24 AM
Why not just drop the code into subs and call them?

Graham
Title: Re: hole macro help please :)
Post by: Chris.Botha on May 12, 2009, 03:08:18 AM
i have no idea what you just said..

so i can save my code as is, rename file to something that can be called as a subroutne to a macro??  code idea please?


pretend like you talking to someone who has no idea :)



Title: Re: hole macro help please :)
Post by: Chris.Botha on May 12, 2009, 03:19:27 AM
err actually .. dont pretend.

Title: Re: hole macro help please :)
Post by: MachineMaster on May 12, 2009, 12:58:15 PM
I miss the Osborne computer running CPM with two 5 1/4" floppies and 128K of memory. That was a computer in its day.

Back to the Subroutine. The following is from page 10-34 in the Mach3Mill_1.84.pdf file. So you can put the subroutine in your current file
or in a seperate file and call the file.

10.8.7        Call subroutine - M98
This has two formats:
(a) To call a subroutine program within the current part program file code M98 P~ L~ or
M98 ~P ~Q The program must contain an O line with the number given by the P word of
the Call . This O line is a sort of "label" which indicates the start of the subroutine. The O
line may not have a line number (N word) on it. It, and the following code, will normally be
written with other subroutines and follow either an M2, M30 or M99 so it is not reached
directly by the flow of the program.
(b) To call a subroutine which is in a separate file code M98(filename)L~
for example M98 (test.tap)
For both formats:
The L word (or optionally the Q word) gives the number of times that the subroutine is to
be called before continuing with the line following the M98. If the L (Q) word is omitted
then its value defaults to 1.
By using parameters values or incremental moves a repeated subroutine can make several
roughing cuts around a complex path or cut several identical objects from one piece of
material.
Subroutine calls may be nested. That is to say a subroutine may contain a M98 call to
another subroutine. As no conditional branching is permitted it is not meaningful for
subroutines to call themselves recursively.
10.8.8 Return from subroutine
To return from a subroutine program M99 Execution will continue after the M98 which
called the subroutine.
If M99 is written in the main program, i.e. not in a subroutine, then the program will start
execution from the first line again. See also M47 to achieve the same effect.
Title: Re: hole macro help please :)
Post by: Chris.Botha on May 12, 2009, 03:40:31 PM
ok.. ill give it a try tonight..

so i can create a macro that contains this:

Code ("g0x0y0z40")
Code ("M98 (myroutine.tap)")


and it will run the the gcode in myroutine.tap?


i really need to read the manual....


Title: Re: hole macro help please :)
Post by: MachineMaster on May 12, 2009, 04:15:19 PM
You could, but why not just do it in your part file?
Title: Re: hole macro help please :)
Post by: Chris.Botha on May 12, 2009, 04:50:10 PM
i want to assign it to a button....

i want to add "one button" cutting to an extra screen in mach..(preferably with large buttons and pictures) this  "hole" is part of every single 3sided cut I do (amongst other repetitive tasks).. i am also going to be installing these mills for fellow jewellers who will be using milling wizards to generate paths and whom could care less about what makes it work and more about just getting the part out... so i need to simplify the process significantly to be able to sell more of these units....

my competition is printers...   load model.. hit print....

compared to milling... load model.. figure out what the mill cannot access..  write path, simulate, pull hair out, start again. add plugs, flip model etc etc etc so i need to find "one button" solutions as far as i can. 

1: load model in cam, insert hub, hit "flip cut" cam generation button   (i believe artcam allready has onebutton pathing for this)
2: load path in mach, hit cycle start
3: hit [cut hub]
4: flip wax onto 4th option, load path
5: hit cycle start
6: drink beer


thats how my customers would prefer it.. while I like getting into the nitty gritty most my customers wont.
Title: Re: hole macro help please :)
Post by: Chris.Botha on May 14, 2009, 03:53:48 AM
this code is supposed to drive the attached NC file.. any clues why mach sits there just looking at me instead?

Msgbox("Please click [OK] to start cutting hub hole")

 Code("G0X0Y0Z50A0")
   While IsMoving()
   Sleep 100
   Wend

 Code("M98(femhole.nc)")
Title: Re: hole macro help please :)
Post by: MachineMaster on May 14, 2009, 12:10:46 PM
Just a WAG but try putting a space between M98 and (femhole.nc).
Title: Re: hole macro help please :)
Post by: Chris.Botha on May 14, 2009, 03:49:26 PM
nope.. loads gcode.. shows on status line.. jsut does not execute it...
Title: Re: hole macro help please :)
Post by: Hood on May 14, 2009, 04:00:29 PM
Try this, again heeding the warning that  I know SFA about VB ;)

MsgBox("Please click [OK] to start cutting hub hole")

 Code("G0X0Y0Z50A0")
   While IsMoving()
   Sleep 100
   Wend

 Code("M98(femhole.nc)")
 While IsLoading()
 Wend
 DoOemButton(1000)
Title: Re: hole macro help please :)
Post by: Chris.Botha on May 14, 2009, 04:54:46 PM
nope same result.. just sits there.. no code actually loads into the code window either...
Title: Re: hole macro help please :)
Post by: Hood on May 14, 2009, 04:56:15 PM
weird, seems to work here, can you attach your code so I can test out.
Hood
Title: Re: hole macro help please :)
Post by: Chris.Botha on May 14, 2009, 05:08:13 PM
look up to top of this page

attached file femhole.nc
Title: Re: hole macro help please :)
Post by: Chris.Botha on May 14, 2009, 05:16:26 PM
hmm strange i tried swapping out code for different code and just noticed this.. the code definitely loads.. i can scroll all the way down it to line 50000 etc but its not actually in the window.. after loading the file the yellow code window is 50 000 lines long but no text in it.. the code is at line 50 000 for example.. end of the code so i try hitting rewind and cycle start that jsut gives me "cannot load original file"


see attached capture after running macro.. this "invisible" code screen just sits there looking at me..


Title: Re: hole macro help please :)
Post by: Overloaded on May 14, 2009, 05:18:57 PM
....saw that too Chris. And if you hit EDIT CODE, it's there. Close that window and it loads properly.
I beat on this for a while earlier and gave up.  lol
RC
Title: Re: hole macro help please :)
Post by: Chris.Botha on May 14, 2009, 05:19:14 PM
oops mach ver = 3.042.040 FYI
Title: Re: hole macro help please :)
Post by: Chris.Botha on May 14, 2009, 05:20:53 PM
....saw that too Chris. And if you hit EDIT CODE, it's there. Close that window and it loads properly.
I beat on this for a while earlier and gave up.  lol
RC


ummm ok.. think this will be addressed?  kind of make my whole exercise pointless if i can load code from a macro?

Title: Re: hole macro help please :)
Post by: Hood on May 14, 2009, 05:21:50 PM
Works perfectly here but I had to change the M99 at the end of your code to a M30. I also added  the regen button in the VB so that the toolpath will display.
Hood
Title: Re: hole macro help please :)
Post by: Chris.Botha on May 14, 2009, 05:25:56 PM
ok.. i leave this alone till its sorted in a next revision perhaps.. im trying to simplify the process and as it stands its easier to explain to end users how to simply load the code manually than to get macro working right. .. less button presses actually lol

thanks for all the help guys :)
Title: Re: hole macro help please :)
Post by: Hood on May 14, 2009, 05:27:47 PM
Only one button press needed here, I have the regen done in the macro.
Hood
Title: Re: hole macro help please :)
Post by: Chris.Botha on May 14, 2009, 05:32:15 PM
ahh ok sorry never read properly


lemme test
Title: Re: hole macro help please :)
Post by: Hood on May 14, 2009, 05:35:29 PM
Ah well it may be due to the fact I have Rev4 here, have tried to go back but my xmls are screwed so not sure if the reason its not working now is because of that or because its and older revision.
Hood
Title: Re: hole macro help please :)
Post by: Chris.Botha on May 14, 2009, 05:36:26 PM
nope still invisible code...
Title: Re: hole macro help please :)
Post by: MachineMaster on May 14, 2009, 05:38:55 PM
What happens if you write a short G code program with the M98 call?
Title: Re: hole macro help please :)
Post by: Chris.Botha on May 14, 2009, 05:40:53 PM
actually manually clicking regenerate in my screen does not fix it either...
hitting edit button does th etrick but thats not a solution for what I need unfortunately.

how would i upgrade my mach to your revision? is it covered in my license?

Title: Re: hole macro help please :)
Post by: Chris.Botha on May 14, 2009, 05:41:20 PM
What happens if you write a short G code program with the M98 call?

that works fine.. i played with it lots last night..

the

Code ("G0X0Y0Z50A0")

part of code runs great ... its after the m99 that it all goes pear shaped..




Title: Re: hole macro help please :)
Post by: Chris.Botha on May 14, 2009, 05:43:18 PM
oops
damn
wait read wrong again
lemme test a shorter section of code

Title: Re: hole macro help please :)
Post by: Chris.Botha on May 14, 2009, 05:47:09 PM
nope no go.. still invisible code

30 lines of code
Title: Re: hole macro help please :)
Post by: Hood on May 14, 2009, 05:51:42 PM
Afraid the revision I have is the Alpha of the next rev of Mach, it will be at least a few weeks before its on the site.
Hood
Title: Re: hole macro help please :)
Post by: Chris.Botha on May 14, 2009, 05:56:31 PM
.... ok then.. one more project on the back burner..
Title: Re: hole macro help please :)
Post by: Hood on May 14, 2009, 06:01:32 PM
I am just restoring the backup folder I have so will see if it behaves the same for me with an older version of Mach as it does for you.
Hood
Title: Re: hole macro help please :)
Post by: vmax549 on May 14, 2009, 06:06:48 PM
Yall were close BUT there is problems with the VB and M98 on the later versions

Try from a button

Loadfile("c:/path of file/Filename")
Runfile()


Just remember to remove the M99 from the program file and add the M30 to the end of file. Or it may loop continuously in mach(;-)


Works here everytime, (:-) TP

Title: Re: hole macro help please :)
Post by: Chris.Botha on May 14, 2009, 06:14:29 PM
Cool


gonna give that  bash.. unpacking shop now :)
Title: Re: hole macro help please :)
Post by: Hood on May 14, 2009, 06:14:44 PM
So why did you not come here days ago and save us all this pain ;D

Hood
Title: Re: hole macro help please :)
Post by: Hood on May 14, 2009, 06:20:52 PM
Just for the record I replaced my screwed up folder with the backup and its doing exactly as it was for you guys so looks like its fine in the future Rev but not in these.
TP's way should work fine, will have to note that down :0
Hood
Title: Re: hole macro help please :)
Post by: Hood on May 14, 2009, 06:43:02 PM
Just tried it and it didnt work, so put a sleep(1000) in and it started fine.

Hood
Title: Re: hole macro help please :)
Post by: Chris.Botha on May 14, 2009, 06:47:09 PM
err lost me..

show me the code please?
Title: Re: hole macro help please :)
Post by: Hood on May 14, 2009, 06:51:30 PM
Loadfile("c:/Mach3/Subroutines/femhole.nc")
Sleep(1000)
RunFile()
Title: Re: hole macro help please :)
Post by: Chris.Botha on May 14, 2009, 06:54:53 PM
ahh ok thanks.. tested.. works.


i can start working on graphics tonight!!

thanks a million for all the help guys :)

 :) :) :) :) :) :)
Title: Re: hole macro help please :)
Post by: Hood on May 14, 2009, 06:56:36 PM
The shorter the code the faster it is likely to load so the shorter you could have the sleep but having a 1 or 2 second sleep would probably be ok for you and would almost guarantee it would start with any lenghth of code.
Hood
Title: Re: hole macro help please :)
Post by: vmax549 on May 14, 2009, 08:43:57 PM
I thought Brian had the sleep issue fixed so we did not need it anymore???????

Sleep() worked as a crutch BUT it really needs to be fixed so we don't need it. Really HARD to "GUESS" what value will work . I gues Rich's use of semaphores may be required after all(;-) just to be on the safe side.

(;-) TP
Title: Re: hole macro help please :)
Post by: Chris.Botha on May 15, 2009, 04:27:46 AM
woooooooohoooooooo

we have a winner!


i set up 8 place holders with buttons, code and images so co users can simply create any code they want and save into GCODE folder in format MACROFILE1.NC, MACROFILE2.NC, etc etc   and add userbitmaps named MACROIMAGE1.JPG, MACROIMAGE2.JPG, etc in the bitmaps folder. all tested and running well!

Title: Re: hole macro help please :)
Post by: Hood on May 16, 2009, 08:49:43 AM
Looks like it will work great :)
Hood
Title: Re: hole macro help please :)
Post by: vmax549 on May 16, 2009, 09:22:55 AM
Good Job Chris, It looks NICE.


(;-) TP
Title: Re: hole macro help please :)
Post by: Chris.Botha on May 16, 2009, 05:44:11 PM
thanks guys.. i am onto my next project but it requires me to first cut some fixtures for myself.. post as soon as its ready for code :)