1. Chú ý: Các bạn nên tham khảo Nội quy trước khi viết bài (click vào liên kết bên dưới).
    * Nội quy và Thông báo diễn đàn CNCProVN.com
    * Nếu bạn thấy hứng thú với bài viết. Hãy dùng chức năng Share to facebook để chia sẻ bài viết lên facebook.

          
Kết quả 1 đến 20 của 81

Chủ đề: dự án thay máu cnc brother tc227 sang mach 3

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #37
    Thợ bậc 6
    Ngày tham gia
    Aug 2015
    Đang ở
    Sài Gòn
    Bài viết
    477
    Cám ơn
    153
    Được cám ơn 74 lần
           ở 61 bài viết
    file m6start.m1s của e




    Sub main()

    'OldTool=GetCurrentTool() 'current tool position


    If IsActive(OEMTRIG1) And Not IsActive(OEMTRIG2) And IsActive(OEMTRIG3) And Not IsActive(OEMTRIG4) Then

    OldTool = 1

    ElseIf Not IsActive(OEMTRIG1) And IsActive(OEMTRIG2) And IsActive(OEMTRIG3) And Not IsActive(OEMTRIG4) Then

    OldTool = 2

    ElseIf IsActive(OEMTRIG1) And IsActive(OEMTRIG2) And IsActive(OEMTRIG3) And Not IsActive(OEMTRIG4) Then

    OldTool = 3

    ElseIf Not IsActive(OEMTRIG1) And Not IsActive(OEMTRIG2) And Not IsActive(OEMTRIG3) And IsActive(OEMTRIG4) Then

    OldTool = 4

    ElseIf IsActive(OEMTRIG1) And Not IsActive(OEMTRIG2) And Not IsActive(OEMTRIG3) And IsActive(OEMTRIG4) Then

    OldTool = 5

    ElseIf Not IsActive(OEMTRIG1) And IsActive(OEMTRIG2) And Not IsActive(OEMTRIG3) And IsActive(OEMTRIG4) Then

    OldTool = 6

    ElseIf IsActive(OEMTRIG1) And Not IsActive(OEMTRIG2) And Not IsActive(OEMTRIG3) And Not IsActive(OEMTRIG4) Then

    OldTool = 7

    ElseIf Not IsActive(OEMTRIG1) And IsActive(OEMTRIG2) And Not IsActive(OEMTRIG3) And Not IsActive(OEMTRIG4) Then

    OldTool = 8

    ElseIf IsActive(OEMTRIG1) And IsActive(OEMTRIG2) And Not IsActive(OEMTRIG3) And Not IsActive(OEMTRIG4) Then

    OldTool = 9

    ElseIf Not IsActive(OEMTRIG1) And Not IsActive(OEMTRIG2) And IsActive(OEMTRIG3) And Not IsActive(OEMTRIG4) Then

    OldTool = 10

    Else
    MsgBox("Turret is missing alignment")
    DoOemButton(1021) 'reset

    End If 'end get current tool





    NextTool = GetSelectedTool() 'tool to be indexed
    TestM6 = False 'test run sub replace NextTool value by question
    A=35 'CCW ACTIVE atc reverse time
    B=35 'CW DEACTIVE

    '=============get current parameter==============


    ' Save the current feedrate.
    CurrentFeed = GetOemDRO(818)

    ' Save current coordinate mode (absolute/inc)
    oldCoordinateMode = GetOemLED(48)


    ' Save the current position

    CurrentPosX = GetDro(0)
    CurrentPosY = GetDro(1)
    CurrentPosZ = GetDro(2)

    ' use the user LED to store the state of coolant,
    If getoemled(13) Then
    'OEM LED 13 = "Flood LED" thus coolant is on
    ' set user led on
    setuserled(1000,1)
    Code "M9"
    Else
    'coolent is off
    ' set user led off
    setuserled(1000, 0)
    End If



    '============= end get current parameter==============




    While (GetOemLed(807) Or GetOemLed(808) Or GetOemLed(809))
    Message(" Please Home Machine before Tool Change")

    'Cycle Stop
    ' Button 5 - select Diagnostic screen
    DoOemButton(5)

    Exit Sub
    DoOemButton(105)

    Wend


    If TestM6 Then 'if test get tool to index
    NextTool = Question("Tool to index ")
    End If

    While NextTool>10 Or NextTool<1 'valid tool check
    'Message("Next Tool out of range")
    NextTool = Question("Next tool out of range, enter the right tool number ")
    'Exit Sub
    Wend

    Code"G91G28Z0."
    Message("Waiting for z home")

    While IsMoving ()
    Wend
    ' Code"G91G28X0.Y0."
    'Message("Waiting for x and y home")

    ' While IsMoving ()
    ' Wend





    '=============toolchange===============

    If OldTool <> NextTool Then 'if same tool skip index



    'Code"G91G28Z0" 'move z to tool machine zero
    Code"M9"
    ''While IsMoving ()
    ''Wend
    ActivateSignal(OUTPUT1) 'SON RELAY


    Sleep(150)

    '=====M19=====
    Code"M5"
    Code"S100M3"
    Sleep(1200)
    While (IsActive(OEMTRIG15)) 'index
    Wend
    activatesignal(output3) 'analog cut
    ActivateSignal(OUTPUT8)
    sleep(70)

    'DeActivateSignal(Output12) 'spindle cooling
    DeActivateSignal(OUTPUT1) 'son
    'DoSpinStop() this line causing toolchange error, code m5 is ok
    Code"M5"
    Message("Is anything is moving?")

    While IsMoving ()
    Wend
    Sleep(300)

    '=====end m19=====



    '====is spindle still rotating====
    If GetOEMDRO(39)>0 Then
    MsgBox("spindle still rotating ")
    DoOemButton(1021) 'reset
    End If
    '====end is spindle rotation chẹck====

    Code"G90 G53 G0 Z194." 'move z up to release current tool

    While IsMoving ()
    Wend


    '=== Index Tool === 'rotate DIRECTION

    If OldTool = 1 And (Nexttool = 2 Or Nexttool = 3 Or Nexttool = 4 Or Nexttool = 5 Or Nexttool = 6) Then
    ActivateSignal(Output5)
    setuserled(1001,1)


    ElseIf OldTool = 2 And (Nexttool = 3 Or Nexttool = 4 Or Nexttool = 5 Or Nexttool = 6 Or Nexttool = 7) Then
    ActivateSignal(Output5)
    setuserled(1001,1)


    ElseIf OldTool = 3 And (Nexttool = 4 Or Nexttool = 5 Or Nexttool = 6 Or Nexttool = 7 Or Nexttool = 8) Then
    ActivateSignal(Output5)
    setuserled(1001,1)


    ElseIf OldTool = 4 And (Nexttool = 5 Or Nexttool = 6 Or Nexttool = 7 Or Nexttool = 8 Or Nexttool = 9) Then
    ActivateSignal(Output5)
    setuserled(1001,1)

    ElseIf OldTool = 5 And (Nexttool = 6 Or Nexttool = 7 Or Nexttool = 8 Or Nexttool = 9 Or Nexttool = 10) Then
    ActivateSignal(Output5)
    setuserled(1001,1)

    ElseIf OldTool = 6 And (Nexttool = 7 Or Nexttool = 8 Or Nexttool = 9 Or Nexttool = 10 Or Nexttool = 1) Then
    ActivateSignal(Output5)
    setuserled(1001,1)

    ElseIf OldTool = 7 And (Nexttool = 8 Or Nexttool = 9 Or Nexttool = 10 Or Nexttool = 1 Or Nexttool = 2) Then
    ActivateSignal(Output5)
    setuserled(1001,1)

    ElseIf OldTool = 8 And (Nexttool = 9 Or Nexttool = 10 Or Nexttool = 1 Or Nexttool = 2 Or Nexttool = 3) Then
    ActivateSignal(Output5)
    setuserled(1001,1)

    ElseIf OldTool = 9 And (Nexttool = 10 Or Nexttool = 1 Or Nexttool = 2 Or Nexttool = 3 Or Nexttool = 4) Then
    ActivateSignal(Output5)
    setuserled(1001,1)

    ElseIf OldTool = 10 And (Nexttool = 1 Or Nexttool = 2 Or Nexttool = 3 Or Nexttool = 4 Or Nexttool = 5) Then
    ActivateSignal(Output5)
    setuserled(1001,1)

    Else
    DeActivateSignal(Output5) 'ATC rotate CCW
    setuserled(1001,0)

    End If 'end rotate direction
    Sleep(35)
    ActivateSignal(OUTPUT6) 'ATC rotate


    Select Case NextTool
    Case 1'Tool#5 >1
    While Not(IsActive(OEMTRIG1) And Not IsActive(OEMTRIG2) And IsActive(OEMTRIG3) And Not IsActive(OEMTRIG4) And IsActive(OEMTRIG5))
    Wend
    Case 2'Tool#6 >2
    While Not(Not IsActive(OEMTRIG1) And IsActive(OEMTRIG2) And IsActive(OEMTRIG3) And Not IsActive(OEMTRIG4) And IsActive(OEMTRIG5))
    Wend
    Case 3'Tool#7 >3
    While Not(IsActive(OEMTRIG1) And IsActive(OEMTRIG2) And IsActive(OEMTRIG3) And Not IsActive(OEMTRIG4) And IsActive(OEMTRIG5))
    Wend
    Case 4'Tool#8 >4
    While Not(Not IsActive(OEMTRIG1) And Not IsActive(OEMTRIG2) And Not IsActive(OEMTRIG3) And IsActive(OEMTRIG4) And IsActive(OEMTRIG5))
    Wend
    Case 5'Tool#9 >5
    While Not(IsActive(OEMTRIG1) And Not IsActive(OEMTRIG2) And Not IsActive(OEMTRIG3) And IsActive(OEMTRIG4) And IsActive(OEMTRIG5))
    Wend
    Case 6'Tool#10 >6
    While Not(Not IsActive(OEMTRIG1) And IsActive(OEMTRIG2) And Not IsActive(OEMTRIG3) And IsActive(OEMTRIG4) And IsActive(OEMTRIG5))
    Wend
    Case 7'Tool#1 >7
    While Not(IsActive(OEMTRIG1) And Not IsActive(OEMTRIG2) And Not IsActive(OEMTRIG3) And Not IsActive(OEMTRIG4) And IsActive(OEMTRIG5))
    Wend
    Case 8'Tool#2 >8
    While Not(Not IsActive(OEMTRIG1) And IsActive(OEMTRIG2) And Not IsActive(OEMTRIG3) And Not IsActive(OEMTRIG4) And IsActive(OEMTRIG5))
    Wend
    Case 9'Tool#3 >9
    While Not(IsActive(OEMTRIG1) And IsActive(OEMTRIG2) And Not IsActive(OEMTRIG3) And Not IsActive(OEMTRIG4) And IsActive(OEMTRIG5))
    Wend
    Case 10'Tool#4 >10
    While Not(Not IsActive(OEMTRIG1) And Not IsActive(OEMTRIG2) And IsActive(OEMTRIG3) And Not IsActive(OEMTRIG4) And IsActive(OEMTRIG5))
    Wend
    End Select



    If getuserled(1001) Then 'REVERSE MOTOR TO STOP ATC IMMEDIAELY
    DeActivateSignal(OUTPUT5)
    Sleep(A)


    Else
    ActivateSignal(OUTPUT5)
    Sleep(B)



    End If 'end reverse

    DeActivateSignal(OUTPUT6) 'stop ATC
    DeActivateSignal(OUTPUT5)

    Select Case NextTool
    Case 1'Tool#5 >1 'safe check, does it safe to take the tool
    While Not(IsActive(OEMTRIG1) And Not IsActive(OEMTRIG2) And IsActive(OEMTRIG3) And Not IsActive(OEMTRIG4))
    Wend
    Case 2'Tool#6 >2
    While Not(Not IsActive(OEMTRIG1) And IsActive(OEMTRIG2) And IsActive(OEMTRIG3) And Not IsActive(OEMTRIG4))
    Wend
    Case 3'Tool#7 >3
    While Not(IsActive(OEMTRIG1) And IsActive(OEMTRIG2) And IsActive(OEMTRIG3) And Not IsActive(OEMTRIG4))
    Wend
    Case 4'Tool#8 >4
    While Not(Not IsActive(OEMTRIG1) And Not IsActive(OEMTRIG2) And Not IsActive(OEMTRIG3) And IsActive(OEMTRIG4))
    Wend
    Case 5'Tool#9 >5
    While Not(IsActive(OEMTRIG1) And Not IsActive(OEMTRIG2) And Not IsActive(OEMTRIG3) And IsActive(OEMTRIG4))
    Wend
    Case 6'Tool#10 >6
    While Not(Not IsActive(OEMTRIG1) And IsActive(OEMTRIG2) And Not IsActive(OEMTRIG3) And IsActive(OEMTRIG4))
    Wend
    Case 7'Tool#1 >7
    While Not(IsActive(OEMTRIG1) And Not IsActive(OEMTRIG2) And Not IsActive(OEMTRIG3) And Not IsActive(OEMTRIG4))
    Wend
    Case 8'Tool#2 >8
    While Not(Not IsActive(OEMTRIG1) And IsActive(OEMTRIG2) And Not IsActive(OEMTRIG3) And Not IsActive(OEMTRIG4))
    Wend
    Case 9'Tool#3 >9
    While Not(IsActive(OEMTRIG1) And IsActive(OEMTRIG2) And Not IsActive(OEMTRIG3) And Not IsActive(OEMTRIG4))
    Wend
    Case 10'Tool#4 >10
    While Not(Not IsActive(OEMTRIG1) And Not IsActive(OEMTRIG2) And IsActive(OEMTRIG3) And Not IsActive(OEMTRIG4))
    Wend
    End Select


    '=====end index=====
    'Sleep(1200) 'TEST
    '=====end m19=====
    Code"G91 G28 Z0." 'Take the tool
    While IsMoving ()
    Wend

    End If 'if same tool skip index
    Sleep(100)
    DeActivateSignal(OUTPUT1) 'son
    deactivatesignal(output3) 'analog
    DeActivateSignal(OUTPUT8) 'home RELAY


    Message("Tool "& NextTool &" loaded ")
    SetCurrentTool(NextTool)
    '====== complete toolchange======






    '=restore parameter===


    Code "F" & CurrentFeed


    ' check user led
    If getuserled(1000) Then
    'coolant was on
    Code "M8"
    End If


    ' go to old tool position
    'Code("G00 G90 G53 X" & CurrentPosX & "Y" & CurrentPosY)
    While IsMoving ()
    Wend
    'Code("G00 G90 G53 Z" & CurrentPosZ)
    While IsMoving ()
    Wend


    ' Reset coordinate mode to original value
    If oldCoordinateMode = 0 Then
    Code("G91")
    End If

    '===end restore parameter======

    End Sub
    Thu mua vệ tinh, tàu vũ trụ, robot thăm dò... cũ giá cao

  2. Thành viên đã cám ơn vusvus cho bài viết hữu ích này:


Các Chủ đề tương tự

  1. Dự án Thay điện ,khôi phục phay CNC OKUMA
    Bởi thucncvt trong diễn đàn Máy phay CNC
    Trả lời: 1
    Bài viết cuối: 27-07-2019, 12:26:28 AM
  2. xin hỏi về lệnh m3 điều khiển mach mach 3
    Bởi cuong trong diễn đàn Board điều khiển khác
    Trả lời: 3
    Bài viết cuối: 31-05-2018, 05:48:06 PM
  3. Đài thay dao máy Brother TC 321N giá ve chai
    Bởi clickmefunny trong diễn đàn Gian hàng hết hiệu lực
    Trả lời: 7
    Bài viết cuối: 24-08-2016, 05:27:23 PM
  4. Trả lời: 11
    Bài viết cuối: 05-06-2015, 01:02:20 PM

Quyền viết bài

  • Bạn Không thể gửi Chủ đề mới
  • Bạn Không thể Gửi trả lời
  • Bạn Không thể Gửi file đính kèm
  • Bạn Không thể Sửa bài viết của mình
  •