![]() | |
| Home Page | Mark Forums Read | Today's Posts | My Replies | Classifieds | Reviews | Photo Gallery | Web Links | Share Files | Advertise With Us | Ad List |
| |||||||
| This forum is sponsored by: |
![]() |
| | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
| |||
| |||
| 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
| ||||
| ||||
| 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
| |||
| |||
| Thanks a lot!!! I will try this tomorrow morning |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
| |