Results 1 to 3 of 3

Thread: M6 - ?

  1. #1
    Registered
    Join Date
    Sep 2007
    Location
    Poland
    Posts
    6
    Downloads
    0
    Uploads
    0

    M6 - ?

    Hello. I attempt to write simple macro M6 to turn on some outputs. For example if M6 T1 then output 6, fi M6 T2 output 7 and so on. Does any body could help mi with this? I have old lathe and there is turret connected to PLC. This controller works: if signal is active on input 1 then turret goes to position 1. In the same way works with input 2,3 and 4. It seems to be rather easy task, but I have no luck

    Regards, Marek.


  2. #2
    Registered PoppaBear10's Avatar
    Join Date
    Feb 2005
    Location
    usa
    Posts
    488
    Downloads
    0
    Uploads
    0
    Marek,

    Ok, here you go. You will need to Enable "Outputs" 1-4 in mach3, if you are already
    using those, just pick other outputs and change them below. there are 20 outputs for
    your use.


    '==========================================================
    'M6Start.m1s

    Sub Main()

    NewTool = GetSelectedTool()
    OldTool = GetCurrentTool()
    MaxToolNum = 4 'Max number of tools for the changer

    While NewTool > MaxToolNum
    NewTool = Question ("Enter New Tool Number up to " & MaxToolNum)
    Wend

    If NewTool = OldTool Or NewTool = 0 Then
    Exit Sub
    End If

    If OldTool <> NewTool Then

    'This section of code will turn on the correct tool number output to the input
    'you need on the PLC.

    If (NewTool = 1) Then
    ActivateSignal(OUTPUT1) 'this output goes from Mach to your PLC input 1
    End If

    If (NewTool = 2) Then
    ActivateSignal(OUTPUT2) 'this output goes from Mach to your PLC input 2
    End If

    If (NewTool = 3) Then
    ActivateSignal(OUTPUT3) 'this output goes from Mach to your PLC input 3
    End If

    If (NewTool = 4) Then
    ActivateSignal(OUTPUT4) 'this output goes from Mach to your PLC input 4
    End If
    End If

    SetOEMDRO(824,NewTool)
    Code "G4 P4" 'A pause time of 4 seconds to give your turret time to index
    While IsMoving
    Wend

    'This section of code Turns the Output from Mach off after your turret
    'has indexed to the new position.

    If (NewTool = 1) Then
    DeActivateSignal(OUTPUT1) 'this output goes from Mach to your PLC input 1
    End If

    If (NewTool = 2) Then
    DeActivateSignal(OUTPUT2) 'this output goes from Mach to your PLC input 2
    End If

    If (NewTool = 3) Then
    DeActivateSignal(OUTPUT3) 'this output goes from Mach to your PLC input 3
    End If

    If (NewTool = 4) Then
    DeActivateSignal(OUTPUT4) 'this output goes from Mach to your PLC input 4
    End If

    End Sub
    Main

    'have fun,
    'Scott
    Commercial Mach3: Screens, Wizards, Plugins, Brains,PLCs, Macros, ATC's, machine design/build, retrofit, EMC2, Prototyping. http://sites.google.com/site/volunteerfablab/


  3. #3
    Registered
    Join Date
    Sep 2007
    Location
    Poland
    Posts
    6
    Downloads
    0
    Uploads
    0
    Thanks a lot!!! I will try this tomorrow morning


Posting Permissions


 


About CNCzone.com

    We are the largest and most active discussion forum from DIY CNC Machines to the Cad/Cam software to run them. The site is 100% free to join and use, so join today!

Follow us on

Facebook Dribbble RSS Feed


Search Engine Friendly URLs by vBSEO ©2011, Crawlability, Inc.