11
VB and the development of wizards / Please Review! VB Script for 4-position toolchanger.
« on: April 04, 2014, 11:55:24 AM »
So, I finally finished terminating all the wires and tried the code. I am not seeing action when I call for a tool change in MDI.
I've checked the signal out to trigger the changer works (Output2), signal in from the changer is set to 'active' when it is moving (Input2), all verified in Mach diagnostics.
I did a stepthru of the code in the VB editor, and it actually triggered the toolpost once!!! But then never again Sooooo close.....When I open Mach, I've set the tool mdi to '1' as the starting spot. Then I was doing a T202 M06 to call for tool two. I have the config set to 'auto' on toolchange options. PS - I took out the 'then' pieces, I was getting a compile error - I looked at the Mach guides and they didn't seem to be needed for a 'While' command set.
I would really appreciate if someone could take a look at the code and verify if it all looks good, here is the exact code that is in the macros/Lathe/M6start file:
'M6Start.m1s
Sub Main()
selectedTool = GetSelectedTool()
currentFace = (GetCurrentTool() - 1) Mod 4
targetFace = (selectedTool - 1) Mod 4
'rotate turret required number of "clicks"
For click = 1 To (targetFace - currentFace + 4) Mod 4 'rotate accounting for rollover
ActivateSignal(Output2) 'activate momentary command to rotate
Sleep (100)
DeActivateSignal(Output2) 'deactivate momentary command
While IsActive(Input2) 'wait for turret to stop
Sleep (100)
Wend
Next
SetCurrentTool selectedTool 'not forgetting to update to the new tool
End Sub
I've checked the signal out to trigger the changer works (Output2), signal in from the changer is set to 'active' when it is moving (Input2), all verified in Mach diagnostics.
I did a stepthru of the code in the VB editor, and it actually triggered the toolpost once!!! But then never again Sooooo close.....When I open Mach, I've set the tool mdi to '1' as the starting spot. Then I was doing a T202 M06 to call for tool two. I have the config set to 'auto' on toolchange options. PS - I took out the 'then' pieces, I was getting a compile error - I looked at the Mach guides and they didn't seem to be needed for a 'While' command set.
I would really appreciate if someone could take a look at the code and verify if it all looks good, here is the exact code that is in the macros/Lathe/M6start file:
'M6Start.m1s
Sub Main()
selectedTool = GetSelectedTool()
currentFace = (GetCurrentTool() - 1) Mod 4
targetFace = (selectedTool - 1) Mod 4
'rotate turret required number of "clicks"
For click = 1 To (targetFace - currentFace + 4) Mod 4 'rotate accounting for rollover
ActivateSignal(Output2) 'activate momentary command to rotate
Sleep (100)
DeActivateSignal(Output2) 'deactivate momentary command
While IsActive(Input2) 'wait for turret to stop
Sleep (100)
Wend
Next
SetCurrentTool selectedTool 'not forgetting to update to the new tool
End Sub