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.
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).
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.
Re: For crating VB Macro for zeroing tool, and rotating working coordinates
Code "G69"'Сброс прошлых поворотов координат
Code "G91"
Code "G1x3 f500" 'едим по Х на точку замера
Code "G31 Y-100 F500" ' двигаться по -Y на 100 мм. до касания щупом
While IsMoving()
Wend ' дождаться конца движения
a = GetDRO(1)' записываем показания Y в a
Code "G04 p0.2" ' пауза 0.2 с
Code "G01 Y2 f1000" ' отъехать от стенки
Code "G0 Y10"
Code "G90"
Code "G1 x-3 f500" 'едим по Х в минус на точку замера
Code "G91"
Code "G31 Y-100 F500" ' двигаться по -Y на 100 мм. до касания щупом
While IsMoving()
Wend ' дождаться конца движения
b = GetDRO(1)' записываем показания Y в В
Code "G04 p0.2" ' пауза 0.2 с
Code "G01 Y2 f1000" ' отъехать от стенки
Code "G0 Y10"
Code "G90"
Code "G0 x0"
c=(a-b)/6 ' разница катетов, 6- это расстояние между точками замера по Х (6мм)
e=a-b ' Cмещение по Y
Del = Int(c*1000 + 0.5)/1000 'уравнять до трех знаков после запятой
d = Atn (Del)* 180 / 3.1415926535897932384626433832795 ' вычисляем угол через арктангенс
Ug = Int(d*1000 + 0.5)/1000 'уравнять до трех знаков после запятой угол
Code "G68 X0 Y0 R" & Ug' поворачиваем плоскость X Y ну угол Ug
responde = MsgBox ("Cмещение = " & e & ", A(tg) = " & Del & ", Угол = " & Ug)