Now I understand what was wrong with my code. Hey, so, I managed to get my turret to operate. Pretty stoked it worked right off the bat for a new coder. Although I didnt want to spend too much time on VB I also have a router with Mach 4 so LUA is my focus. Cool.
My M6Start Macro is attached. It is specific to my machine in the fact I have very little outputs and have used up all inputs. So this macro is only going to work with hardware configuration like mine. Also, be very selective when you purchase your SSRs as they need to work with low voltages directly off a BOB. The wiring diagram is in this forum post. The turret is a LD6B Chinese one. Does the job.
But can someone help me finish this please I am not sure what to do I think its now my post that needs to be edited. I have seen something about options for Turret, QCTP on front, QCTP on rear with options to change but I don't know exactly what I am editing. Currently, instead of a tool change, my machine pauses with "CHANGE TO T3 ON REAR TOOL POST". I need to hit the cycle button and then it will change tools. There is a line in my machining file that does this - how do I edit my post so it removes that line. Its line N14.
Really hoping someone can hop in and help. Also, is my macro ok or do I need to look at more safety locks? I will always home the machine on startup and always have tooling set correct prior to a job. Second question is I have a 4 post turret. Many more tools that will number 1-4 with several with the same tool number but different offsets. Wondering how I program into the tool library tool #1 for example with offset #6 for example. Ie T0106 - that must be in Fusion 360.
Anyways. Sample code attached.
Macro Below
Sub Main()
OldTool = GetCurrentTool() 'Sets old tool variable
NewTool = GetSelectedTool() 'Sets the new tool variable
MaxToolNum = 4 'Max tools on the turret
If MaxToolNum < 1 Or MaxToolNum > 4 Then
Message "Incorrect Tool Selected"
ElseIf OldTool = NewTool Then
' No toolchange required, exit sub
Exit Sub
End If
'If GetOEMLED(87) Or GetOEMLED(809) Then
'Message "Machine not homed Dork"
'Code "M30"
'End If
If NewTool = OldTool Then
Message "No Change"
End If
Code "G53 F1800 X-10" 'Move to change position
While IsMoving() 'Wait for movement to complete
Wend
' Tool Change Time
If NewTool = 1 Then
ActivateSignal(OUTPUT3) 'Open Tool #1 Relay for selection input to BOB
Sleep(500)
ActivateSignal(OUTPUT7) 'Begin rotating turret'
While Not IsActive(INPUT2) 'Turret is rotating until the selected tool is in position'
Wend
DeactivateSignal(OUTPUT7) 'Stop turret from spinning
Sleep(100)
ActivateSignal(OUTPUT8) 'Reverse Turret
Sleep(1400)
DeactivateSignal(OUTPUT3)
DeactivateSignal(OUTPUT8)
ElseIf NewTool = 2 Then
ActivateSignal(OUTPUT4) 'Open Tool #1 Relay for selection input to BOB
Sleep(500)
ActivateSignal(OUTPUT7) 'Begin rotating turret'
While Not IsActive(INPUT2) 'Turret is rotating until the selected tool is in position'
Wend
DeactivateSignal(OUTPUT7) 'Stop turret from spinning
Sleep(100)
ActivateSignal(OUTPUT8) 'Reverse Turret
Sleep(1400)
DeactivateSignal(OUTPUT4)
DeactivateSignal(OUTPUT8)
ElseIf NewTool = 3 Then
ActivateSignal(OUTPUT5) 'Open Tool #1 Relay for selection input to BOB
Sleep(500)
ActivateSignal(OUTPUT7) 'Begin rotating turret'
While Not IsActive(INPUT2) 'Turret is rotating until the selected tool is in position'
Wend
DeactivateSignal(OUTPUT7) 'Stop turret from spinning
Sleep(100)
ActivateSignal(OUTPUT8) 'Reverse Turret
Sleep(1400)
DeactivateSignal(OUTPUT5)
DeactivateSignal(OUTPUT8)
ElseIf NewTool = 4 Then
ActivateSignal(OUTPUT6) 'Open Tool #1 Relay for selection input to BOB
Sleep(500)
ActivateSignal(OUTPUT7) 'Begin rotating turret'
While Not IsActive(INPUT2) 'Turret is rotating until the selected tool is in position'
Wend
DeactivateSignal(OUTPUT7) 'Stop turret from spinning
Sleep(100)
ActivateSignal(OUTPUT8) 'Reverse Turret
Sleep(1400)
DeactivateSignal(OUTPUT6)
DeactivateSignal(OUTPUT8)
SetCurrentTool(NewTool) 'Set the new tool to current
End If
End Sub