After analyzing my problem with the Tool Changer Macro, I suspect that my electronic circuit that converts the 4 decimal positions to 2-bit binary is not latching fast enough for the Input2 & Input3 to correctly monitor the tool position. This is partly due to its being on a breadboard and I decided to temporarily shelf it.
Instead, I connected directly the 4 sensor/switches to the BOB and used "Input1, Input2, Input3, & Input4" in Mach3 that correspond to the parallel port's Input Pins 11, 12, 13, & 15. My weakest in VB scripting and not enough knowledge of electronics took me some time to realize that the sensors are sinking current (I am not even sure if this is the correct term
) and thus, the one that is not lighting up in the BOB as well as in the Active signals in the diagnostic page is the active position.
Eventually, I got it to work nice and easy. The turret takes less than a second to a max of 2 seconds to rotate the requested tool into position. It never takes more than 1 complete revolution of the turret to put the requested tool into position.
Here is the working Toolchanger Macro:
'This Macro was based on the 4 position sensors being fed directly into 4 INPUTs
'to the parallel port.
'Input1 is Tool1 (Pin11, Active High), Input2 is Tool2 (Pin12, Active High),
'Input3 is Tool3 (Pin13, Active High), Input4 is Tool4 (Pin15, Active High).
'Since Sensors are sinking current, hence all set to Active High.
'Output2 triggers 1st relay that raises and rotates the turret CW,
'Output3 triggers 2nd relay that rotates turret CCW and lower the turret to lock tool in position.
'OEMDRO(1200) is utilized to store the last used tool (OldTool) and is updated
'upon final execution of the macro. This is resorted to as the Txxyy will overwrite
'the "CurrentTool" DRO.
'M6Start.m1s
OldTool = GetOEMDRO (1200)
Tool = GetSelectedTool()
MaxToolNum = 4 'Max number of tools for the changer
If OldTool = Tool Then
Message ("Selected Tool already loaded")
Exit Sub
End If
While Tool > MaxToolNum
Tool = Question ("Enter New Tool Number up to " & MaxToolNum)
Wend
Call StartTool
While NewTool <> Tool
Call CheckPins
While IsMoving()
Wend
Wend
Call StopTool
Call SetUserDRO (1200, NewTool)
SetCurrentTool(NewTool)
'//// Subroutines /////////
Sub StartTool
ActivateSignal(Output2)
'Code "G4 P4.0" 'Wait for the tool to rotate past the sensor
While IsMoving()
Wend
End Sub
Sub CheckPins
If Not IsActive(Input1) Then
NewTool = 1
End If
If Not IsActive(Input2) Then
NewTool = 2
End If
If Not IsActive(Input3) Then
NewTool = 3
End If
If Not IsActive(Input4) Then
NewTool = 4
End If
End Sub
Sub Stoptool
DeActivateSignal(Output2)
While IsMoving()
Wend
ActivateSignal(Output3)
Code "G4 P1.0" 'Wait for the tool to rotate onto ratchet stop
While IsMoving()
Wend
DeActivateSignal(Output3)
While IsMoving()
Wend
End Sub