Machsupport Forum

Mach Discussion => VB and the development of wizards => Topic started by: Andre007 on January 31, 2013, 02:50:24 AM

Title: Mach3 machine material surface ZERO script
Post by: Andre007 on January 31, 2013, 02:50:24 AM
Hi All

The script below must have been seen by a lot of users using cnc machines and mach3. A lot of the lines are self explained, but this is the problem i had trying to make this script work for me.
The whole procedure woks fine, and the toolbit moves down , touches the touchplate that is 2mm thick and moves back up. Mach3 tells that machine Z is now ZERO-ed.

The problem i had was this. I had to tell mach3 that my plate was 2.7mm thick and not 2mm in order to get the toolbit to be exactly on the workpiece surface.
Before  the toolbit was always like 1 mm , sometimes 2mm and other times .5 mm above the workpiece surface.
Now i realized that all machines and hardware are different in setup than just inserting the script and expect it to work will not be as easy.

I want to know now, what setting is causing this . My machine is calibrated on the z-axis , so 15mm is 15mm when i use the motor calibration option. Below is the script.

Thanx in advance everyone.
Andre

PlateThickness = 2.0 'Z-plate thickness DRO ' This option i had to change to 2.7mm in order to get it to work properly.

If GetOemLed (825)=0 Then 'Check to see if the probe is already grounded or faulty
DoOEMButton (1010) 'zero the Z axis so the probe move will start from here
Code "G4 P5" ' this delay gives me time to get from computer to hold probe in place
Code "G31 Z-0.5 F5" 'probing move, can set the feed rate here as well as how far to move
While IsMoving() 'wait while it happens
Wend
ZProbePos = GetVar(2002) 'get the axact point the probe was hit
Code "G0 Z" &ZProbePos 'go back to that point, always a very small amount of overrun
While IsMoving ()
Wend
Call SetDro (2, PlateThickness) 'set the Z axis DRO to whatever is set as plate thickness
Code "G4 P0.25" 'Pause for Dro to update.
Code "G0 Z 20.0" 'put the Z retract height you want here
Code "(Z axis is now zeroed)" 'puts this message in the status bar
Else
Code "(Z-Plate is grounded, check connection and try again)" 'this goes in the status bar if aplicable
Exit Sub
End If
Title: Re: Mach3 machine material surface ZERO script
Post by: Andre007 on February 07, 2013, 02:58:44 AM
no ideas ANYBODY !
Title: Re: Mach3 machine material surface ZERO script
Post by: Tweakie.CNC on February 07, 2013, 05:43:19 AM
Which Mach screen .set are you using ?

Tweakie.
Title: Re: Mach3 machine material surface ZERO script
Post by: Andre007 on February 07, 2013, 06:12:54 AM
Hi

The standard one that comes with the installation. ... no mods.

TX
A
Title: Re: Mach3 machine material surface ZERO script
Post by: Tweakie.CNC on February 07, 2013, 06:39:43 AM
Hi Andre,

If it is of any help to you this is the button script that I use (second half of page) and how I have implemented it   http://www.cooperman.talktalk.net/files/17.htm

Tweakie.
Title: Re: Mach3 machine material surface ZERO script
Post by: Dragonfly on February 11, 2013, 01:51:49 PM
Hi there
Quote
Code "G31 Z-0.5 F5" 'probing move, can set the feed rate here as well as how far to move

Perhaps the original has been written for inch measurement units.
With millimeters it is a very short move at very slow speed.
"G31 Z-40 F200" would be more appropriate for millimeters. The tool has enough space to move down to touch the plate provided it is positioned before the start at less than 40 mm above the plate.
Title: Re: Mach3 machine material surface ZERO script
Post by: JohnHaine on March 01, 2013, 11:55:41 AM
Hi Tweakie, I have implemented your auto-tool-zero button script and it works very nicely with a little height-setting button I've made.  This has an insulated carbide sprung plate on a magnetic base that sits on the mill table.  Being sprung it can cope with tool over travel.  Thanks very much for this, a very nice utility. As you predicted I had a couple of issues with odd unicode characters in the copied code but soon fixed those.  I have a couple of questions.

First, I'd like to use the code as a macro in a program so that after a tool change I can just call the macro from the code - say "M100" - and it will set the tool height then let the program continue.  So I have copied the button code into a file and given it the name M100.m1s, but when I insert that code in a programme or type it into the MDI window, nothing happens!  There's probably something simple I've forgotten about or never knew - any ideas please?

The second thing is that I would like to generate modified code to set the X and Y zeros, using an isolated probe of known diameter I've made.  As you are the copyright owner, may I have your consent to this please as my code is likely to copy many of the same lines?

Thanks,

John.
Title: Re: Mach3 machine material surface ZERO script
Post by: Tweakie.CNC on March 01, 2013, 12:12:20 PM
Hi John,

I am pleased to hear that you got it all working OK.

Quote
First, I'd like to use the code as a macro in a program so that after a tool change I can just call the macro from the code - say "M100" - and it will set the tool height then let the program continue.  So I have copied the button code into a file and given it the name M100.m1s, but when I insert that code in a programme or type it into the MDI window, nothing happens!  There's probably something simple I've forgotten about or never knew - any ideas please?

I can't help with this one as it's not something I use and have a sound working knowledge of - but I am sure there are others who can help.

Quote
The second thing is that I would like to generate modified code to set the X and Y zeros, using an isolated probe of known diameter I've made.  As you are the copyright owner, may I have your consent to this please as my code is likely to copy many of the same lines?

My code is yours to do with as you please - it is my pleasure sir.

Tweakie.
Title: Re: Mach3 machine material surface ZERO script
Post by: JohnHaine on March 01, 2013, 12:51:18 PM
Many thanks!
Title: Re: Mach3 machine material surface ZERO script
Post by: JohnHaine on March 01, 2013, 01:25:12 PM
Fixed it!  Little bit of searching on this forum and I found that M codes up to and including 100 appear to be reserved for Mach...so I changed my file name to M999.m1s and it sprung into life!
Title: Re: Mach3 machine material surface ZERO script
Post by: Andre007 on April 11, 2013, 01:42:01 AM
Hi All

My problem is still not fixed. I have installed the 2010 screenset which uses mm. Problem is still that mach3 is cutting air above the workpiece. The only problem i can see is that the plate thickness is not subtracted correctly so the mill can get to the workpiece.

I can get something to cut if i remove the plate and manually zero the mill to the workpiece. This works, but i would like to use the routine . Its difficult to see with the eye when the mill is just touching the workpiece.

THX
A
Title: Re: Mach3 machine material surface ZERO script
Post by: JohnHaine on April 11, 2013, 04:14:16 AM
Andre,

How are you running this code?  Is it button code attached to the set tool zero button?  I have found it very hard to make this work properly.  As an alternative, you could try the following.  Copy your code into Notepad; save it as a Mach3 macro, i.e. with the file extension .m1s, in the Macros folder in the Mach3 directory, making sure to avoid the macro numbers up to 100 that are used internally.  You could for example save it as M900.m1s which is the filename I used.  Now the button script you need to call this is just Code"M900".  I used this approach and it works just fine.

I'm not sure you need the "Exit sub" line at the end of your code - this doesn't seem to be a requirement for Cypress Basic.

And just a thought, trying to zero a tool onto a workpiece by eye is very hard as you have found out.  Much better is to slow jog onto a feeler gauge until it is just nipped between the tool and the material.  But probing is even better!

I've now got scripts on all the tool setting buttons that call probing macros in this way for setting tool height and also X and Y references, and they work fine.

John.
Title: Re: Mach3 machine material surface ZERO script
Post by: Andre007 on April 11, 2013, 05:19:32 AM
Hi

I`m using the 2010 screenset. All macros supplied and in mm units. A have seen a lot of positive feedback on it, and it works fine and the moves are correct, but when it comes to the cutting part of the 1st depth increment, its above the workpiece.  I suppose in time as it get to the increments , it will eventually strike the workpiece, but not when it starts out.

This problem i never could get fixed. I had to cheat by eyeing the top ZERO on the workpiece. All the cuts i do, is done by eye Zeroing, but it would be nice for it just to work.
I bought the 2010 screenset to get away from editing the scripts , but it seemed that something else ...a setting in Mach3 maybe , is keeping me from getting it right.

My settings im Cambam is negative from ZERO , so -0.05 or -.5 , so it has to go down if + is up

UNLESS the problem lies when i ZERO the machine. My Zero setting is at the home position at the top end of the z-axis. I have been thinking bout this as well.
When i Zero the machine, Zero lies at the top (bout 100mm from the machine worktable). Does the auto zero option Zero the machine then back to the workpiece top , or does it just adjust the difference to work out workpiece Zero ?.

Thanx
A
Title: Re: Mach3 machine material surface ZERO script
Post by: JohnHaine on April 11, 2013, 05:38:35 AM
Andre, frankly I have learned to ignore the axes home setting!  As far as I am concerned, zero is what I set it to be.  My convention is that zero Z is the table surface; zero X and Y are (usually) the nearest left corner of the workpiece.  This way I know that any negative value of Z in the code will crash the tool into the table!  I use G-simple usually to generate G code, and this allows you to se the top surface of the "block" (i.e. material) at a known level above the machine table.  I set the tool tip to a known height by using a setting gauge, which is a spring-loaded plate that sits 38.84 mm above the table surface.  I position the tool just above this, hit the auto tool zero button, the tool moves slowly down, touches it, retracts slightly, retouches, then lifts up to Z=50 mm.

As I understand it, Mach 3 has a set of machine coordinates  which are related to the home position, in a way that you can configure.  On my mill (Denford Novamill) home is at minimum X but maximum Y and Z.  I have configured Mach3 with the corresponding maximum feed values for soft limit purposes, but actually I never ever refer to the machine coordinates, but zero the machine so that the X Y and Z DROs are, as I said above, relative to the workpiece and table surface respectively.
Title: Re: Mach3 machine material surface ZERO script
Post by: Andre007 on April 11, 2013, 06:41:31 AM
I also have the fixed plate on the table, and the routine works fine when i run it. Till i find the culprit responsible for the aircuts, i `m gonna have to Zero the z-axis by manually.

Thanx
andre
Title: Re: Mach3 machine material surface ZERO script
Post by: ger21 on April 12, 2013, 08:33:55 PM
Try this.
Make sure that no g-code is loaded.
Place your plate on a sample workpiece, jog over it, and run the auto zero.

After it's finished, remove the plate.

Then, hit "Enter" to activate the MDI and type in G0 Z0, and hit enter again.
The tool should move down and touch the workpiece. If it does, then your zero is set correctly, and the problem probably lies with your g-code?

Note that with the 2010 screenset, there's an option to set zero to a location other than the surface of the workpiece. I call this the Material Offset. Make sure the Material Offset checkbox on the Toolchange tabis NOT checked.

Do the test above and let me know what happens.

If you still have trouble, send me your .xml file and some basic g-code that you're having trouble with. There are a LOT of 2010 screenset users, and none of them have ever had a problem with the auto zero macros.
Title: Re: Mach3 machine material surface ZERO script
Post by: Andre007 on April 15, 2013, 01:32:11 AM
Hi

I will run this test tonight and see what it does..

Thanx,
andre
Title: Re: Mach3 machine material surface ZERO script
Post by: Andre007 on April 16, 2013, 01:22:31 AM
ok, so i have done the auto tool zero operation. all works fine and the operation completes flawlessly.

No Gcode is loaded yet.

When i type G0 Z0 the tooltip moves down to the workpiece , but keeps a 2mm distance from the stock. Its like the plate on top of the stock is still there.

What i have noticed is that when the auto tool zero completes and the tooltip pull away after the last slow auto tool Zero , the tip pulls away to clear the stock. This looks normal , and i can remember is a setting that is inside the macro that handles the tool zero operation.

All seem to be normal, but the tooltip is still (2mm)away from stock zero when i enter G0 Z0 into the DRO and hit enter.

Thanx
A
Title: Re: Mach3 machine material surface ZERO script
Post by: ger21 on April 16, 2013, 08:29:37 AM
On the toolchange tab, do you have any value in the Material Offset DRO, and is the box checked? Do you have the correct plate thickness entered in the DRO?

Can you send me your .xml file?
Title: Re: Mach3 machine material surface ZERO script
Post by: Andre007 on April 17, 2013, 03:56:34 AM
Hi All

Its sorted. I have re-checked the touchplate thickness. My touch plate setting thickness was set at 2.0mm , but the real thickness turned out to be 2.28mm. This made all the difference. :)


Thanx to everyone for suggestions and comments.

another happy chappy
andre