Need Help! For crating VB Macro for zeroing tool, and rotating working coordinates


Results 1 to 2 of 2

Thread: For crating VB Macro for zeroing tool, and rotating working coordinates

  1. #1
    Registered
    Join Date
    Jan 2017
    Location
    Bulgaria
    Posts
    24
    Downloads
    0
    Uploads
    0

    Default For crating VB Macro for zeroing tool, and rotating working coordinates

    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:
    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.
    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.

    Similar Threads:


  2. #2
    Registered
    Join Date
    Jan 2017
    Location
    Russian Federation
    Posts
    1
    Downloads
    0
    Uploads
    0

    Default 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)



Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


About CNCzone.com

    We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

Follow us on


Our Brands

For crating VB Macro for zeroing tool, and rotating working coordinates

For crating VB Macro for zeroing tool, and rotating working coordinates