Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: corydoras on February 08, 2008, 06:34:47 PM

Title: Zero X & Y axis based on laser cross
Post by: corydoras on February 08, 2008, 06:34:47 PM
I have fairly large table on my machine, and use different positions to clamp my material according to size.
I saw a video on Youtube about aligning the laser at the corner of the object to work on and then make that the center of the spindle, this would make this X0 Y0, if you know what I mean, an offset so to speak.

The problem is that I dont know how to set it up, and I do not want i to be a homing position as I only run softlimits and sometimes work the pieces out of True X0 an Y0

Could anyone point me in the right direction?

I havemade a seperate button in my Screenset for this so I can choose this whenever I want, but need some scripters to help me out her:)

Cory
Title: Re: Zero X & Y axis based on laser cross
Post by: Hood on February 09, 2008, 09:34:23 AM
Edited for double post, I gotta clear my desk up so I am not reaching over everything to type and inadvertantly clicking on my mouse with my elbow  :D
Hood

Title: Re: Zero X & Y axis based on laser cross
Post by: Hood on February 09, 2008, 09:42:17 AM
Not sure I follow what you are meaning. Do you have physical limits? If not then how do you reference your machine? The machine needs to be referenced so that you can take advantage of SoftLimits. The reason for this is you need to tell Mach where the "true" zero position is (G53 Zero position) You can then move away and zero on a position you want your work to start at and that will  become your new working zero position (G54 )
Mach still knows trhe real zero position (G53) and with Softlimits correctly set will stop you from moving outwith this area. Your G54 zero position is not affected by your softlimits, what I mean by that is the softlimits do not change to the offset zero.
 Hope you follow as I am not the best at explaining things but I will try and give an example, I will just use X and Y axis to make things simpler for me.
 If you home your machine and it has a 1meter by 1 mete travel the G53 will be at the extreme end of each axis travel (your tool will be lower left corner). If you set up your softlimits  so that X minimum is 0 and X maximum is 1000mm then Mach will niot let you go outwith this, same for Y axis
 Now you then jog away from your G53 zero position to the corner of your material, say for example its  100mm on both x and Y and zero your DROs, this will now give you a work offset position of X0 Y0  and you can start your work from there. You can programme to move X and Y by minus 100 from this position but Mach will let you go no further, same applies for the positive direction, Mach will not let you go further than 900mm X and Y from your new zero position. This is because Mach still keeps a note of the "true" zero (G53)  and works out your softlimits from there.

Hope this is clear and helps a bit with your question, if not ask away again.
Hood
Title: Re: Zero X & Y axis based on laser cross
Post by: jimpinder on February 09, 2008, 10:02:00 AM
I am trying a laser alignmentsystem on my lathe. (I am waiting for the laser to arrive).

I want my lathe to aliign three things.

An X0 psition for my forward tool post which will be the lathe centre.
At the back of the cross slide are two tool posts holding 1) a centre drill 2) drilling post to take drills up to 10mm
I therefore need two more positions - fairly accurately since they must be on the centre line of the lathe, the idea being these replace the tailstock and are G Codable.

I have selected some laser detectors - 5 mm lenses, schmitt trigger digital output (0 or 5v) and a laser transmitter (ex Maplin (UK))

My idea is to mount the laser on the cross slide, shining parrallel to the lathe centre, and mount the detectors at right angles near the chuck. The idea is the cross slide traverses and a bit of code will allow me to ref the x axis for the front tool post. If I want either of the drills in the drilling position, a bit of code can select the appropriaite detector and  move across to it.

I will have to see how it goes.








Title: Re: Zero X & Y axis based on laser cross
Post by: corydoras on February 09, 2008, 12:25:05 PM
Hood:

I have homoing sensors on all axis, to reference against, and from there I have set my softlimits, and this works OK

What I am looking for is like you say set the tool on the corner of the material and Zero X & Y dros (not machine coor.), and work from here.

The thing is, that I have a laserpointer mounted on the side of my motormount on the z axis, aprox 49 mm on the X and 129 mm on the Y ofset from the tool.

So for conveniant use I want to jog the axis to get my laser pointer to the corner of the material and by a click of the "laser button" put on my sreen/layout execute the vb script taking the tool to t the position the laser was pointed and zero the dros for X & Y axis.

Hope this explains my problem better?

Cory
Title: Re: Zero X & Y axis based on laser cross
Post by: Hood on February 09, 2008, 01:59:13 PM
Ah ok so its the VB you are needing to do this? Well afraid I am crap at VB so probably wont be able to help much, will think about it and if I can work it out I will post. Hopefully someone else will jump in and help you a bit more than me ;)

Hood
Title: Re: Zero X & Y axis based on laser cross
Post by: Hood on February 09, 2008, 02:16:44 PM
Oh well that was easier than I thought, well that is if its what you are wanting.
 What you need to do is add a button to your Mach screen, then make  sure you set it as a VB button. Save your screen and then load Mach, go to the Operator menu and choose to Edit button script. Your new button should be flashing and all you do is click on it then paste the following into it and save.

Call setOEMDro (800,-49)
Call setOEMDro (801,-129)

Obviously you will have to put the numbers in that your laser is away from the actual spindle center but you get the idea.
If I am again misunderstanding just shout and I will kick myself :)
Hood
Title: Re: Zero X & Y axis based on laser cross
Post by: Hood on February 09, 2008, 02:32:14 PM
OK just been messing a bit more, if you put the following into your VB button you will with first click of the button set the DROs to your lasers offset, then if you press again the actual mill should move to your new X0 Y0 position.
Be carefull though as I may be doing something wrong or stupid so be ready with the E-Stop.
Hood


Call setOEMDro (800,-49)
Call setOEMDro (801,-129)

If GetOEMDro (800) =-49 And GetOEMDro (801)=-129 Then
Code "G0X0Y0"
End If
Title: Re: Zero X & Y axis based on laser cross
Post by: Overloaded on February 09, 2008, 02:50:14 PM
http://www.youtube.com/watch?v=Oc-9gTFj-y4
This video ?
Title: Re: Zero X & Y axis based on laser cross
Post by: corydoras on February 09, 2008, 03:10:17 PM
Thank you both Hood And Overloaded.

Now we are on the same track:), the first press on the button only changes the DRO to the correct inputted value, but it doesnt execute the move.

Overload.......You ar spot on...That was the video I had seen

Here is the script, with a couple of message boxes added, In Norwegian:)

CAn you spot the problem with the script, and why it is not moving the axis?

Cory
Title: Re: Zero X & Y axis based on laser cross
Post by: corydoras on February 09, 2008, 03:27:33 PM
Hi guys

Played aroud with the script and removed the math (if & and)

And it works.

Great forum, great software and great guys....what a combination.

Thanx again

I´m sure I´ll pop in a few more Q´s as time goes by:)

Cory
Title: Re: Zero X & Y axis based on laser cross
Post by: Hood on February 09, 2008, 03:29:06 PM
OK in the code I had the button pressed once would set the axis to the offsets then pressing again would move to X and Y zero. It seemed to work fine here but  I asked Brian what  he thought and he came up with a totally different code which is pasted below, its a bit more elegant than mine ;)

Hood

Code("G90")
XShift = -49
YShift = -129
SetDRO(0,XShift)
SetDRO(1,YShift)
Code"G4p.25"
While IsMoving()
Wend
Code"G0 X0.0 Y0.0"
Title: Re: Zero X & Y axis based on laser cross
Post by: Greolt on February 09, 2008, 04:25:46 PM
There are lots of ways to skin a cat.  Ask ten people for code and you'll get ten different codes.  ;D

This is what I use,

Xmove = GetUserDRO(1152) 'X distance DRO
Ymove = GetUserDRO(1153) 'Y distance DRO

Code "M9"
Code "G91 G0 X" &Xmove & "Y" &Ymove
While IsMoving ()
Wend
Code "G90"
DoOEMButton (1008)
DoOEMButton (1009)


I have two DROs on screen to set the offset required.  Overkill I know.  Once dialed in they should not need changing.

I also have a button to turn the laser on/off.  Cheated and used mist coolant commands to power laser.  That is what the "M9" is for.

Greg
Title: Re: Zero X & Y axis based on laser cross
Post by: Overloaded on February 09, 2008, 09:37:40 PM
You guys AMAZE me......BRILLIANT !
RC
Title: Re: Zero X & Y axis based on laser cross
Post by: bsims66173 on December 29, 2008, 07:35:17 PM
Hello.everyone. I have a homebuilt cnc router that I would like to put a laser cross on to zero the x and y axis. I have the buttons and the script that should work. What I need to know is how to power the laser and turn it on from mach. I am using a Bob Campbell bob. I have the touch plate for the z axis set up and it works great. I have a laser that is 5v. Can someone explain how to connect it to the bob. I have some relay outputs on the bob. Do I just find 5v and put it through one of the output relays? Man this is a great site with a world of knowledge and I am sure someone can help me. Thanks in advance.

Barry Sims