I am helping rebuild a small lathe with an 8 position tool changer. This is my first script in Mach3. We converted the tool changer from a pure pnuematic with a proprietary control board to a stepper with encoder driven rotary motion with a pnuematic lock. The cylinder has sensors to read locked and unlocked position. We have been trouble shooting the code and think it is tied to line two of the code not seeing the value of the variable "Tool". I can put a number 1 through 8 into the SetCurrentTool function and the toolchanger unlocks, moves and locks as it should. We also have the inputs rem'd out at this point in the trouble shooting. One step at the time. what is the best way to see if the function getting the current tool number and what is the best way to see that the variable, "Tool" changes? Right now the code is loaded into M06 start and we are to the point that we are running it from the mdi.
Tool = GetSelectedTool()
SetCurrentTool(Tool)
Code"G53 X-0.2 Z-0.2" 'Move to tool change location
While Ismoving()
Wend
ActivateSignal(OUTPUT4) 'unlock the turrent
While not Isactive(INPUT2) 'wait for the switch to signal end of stroke
Sleep(1000) 'Give it time for the motion to fully stop
Wend
If GetCurrentTool() = 1 then ' Check for the Tool #
Code"G0 A2.3486" ' Move to position
While Ismoving() 'wait for the movement to stop
Wend
End If
If GetCurrentTool() = 2 then
Code"G0 A4.6972"
While Ismoving()
Wend
End If
If GetCurrentTool() = 3 then
Code"G0 A7.0458"
While Ismoving()
Wend
End If
If GetCurrentTool() = 4 then
Code"G0 A9.3944"
While Ismoving()
Wend
End If
If GetCurrentTool() = 5 then
Code"G0 A11.743"
While Ismoving()
Wend
End If
If GetCurrentTool() = 6 then
Code"G0 A14.0916"
While Ismoving()
Wend
End If
If GetCurrentTool() = 7 then
Code"G0 A16.4402"
While Ismoving()
Wend
End If
If GetCurrentTool() = 8 then
Code"G0 A18.7888"
While Ismoving()
Wend
End If
DeactivateSignal(OUTPUT4) 'Release air cylinder
While NOT Isactive(INPUT3)
Wend
Sleep(1000) 'Give it time to complete end of stroke
End