Hi Guys,
I am looking for a way to make Mach 3 do a very specific thing.
First of all I want to use a USB microscope to find my XY zero point, and a Z-probe just like in this blog post:
Zeroing a CNC
Unfortunately the blog poster didn't provide the Macro he is using.
Next I want to implement this guy's script:
In order to allign the machine axis to the workpiece. I need to be able to get the two refference points with the USB microscope, which will have a certain offset from the tool (Let's say +90mm in the X axis and +20mm in the Y axis).Here's how I do that.
I have my own screenset with a lot of useful buttons/macros. You will also need to add new buttons to your screenset.
Assume I have a clear zero mark on my physical part, and a line along desired X or Y.
Step 1. I get the part zero by using a ring probe, a camera or just visually aligning any tool with a pointed tip. X and Y are zeroed.
Step 2. I position a tool on the other end of the line (by the same means) but not alter X and Y.
Step 3. Current coordinates are copied to the dedicated DROs - I have a button for that. The code below assumes they are #1002 and 1003.
Step 4. A special button (I call it "Calc Angle") executes the following code.
Code:
dx = GetUserDRO( 1002 )
dy = GetUserDRO( 1003 )
Pi = atn( 1 ) * 4
If Abs( dx ) > Abs( dy ) Then ' horizontal, near X axis
angle = atn( dy / dx )
Else ' vertical, near Y axis
angle = atn( - dx / dy )
End If
angle = angle / Pi * 180
ret = MachMsg("A = " & roun(angle) & "° - set?", "Axis Rotation", 4)
If ret = 6 Then ' Yes
SetOEMDRO(118, angle) 'Code("G68X0Y0R" & angle)
End If
Message("A = " & roun(angle) & "°")
If you answer Yes, the computed angle will be in effect for machining. Otherwise, it just displays the result.
NOTE: if you have to interrupt the work and restart the system, the part offset are saved, but the axis rotation is reset. Hopefully the user DROs are preserved, and all you have to do is Step 4 above.
Can somebody help me modify this script so it takes into account the offset from the tool? and also create a VB macro for zeroing X and Y with the same offset?
I think this will be very useful for a lot of beginners like me.
Thanks.