I appreciate all help!!!
Hello everyone! I am retrofitting my CHNC4, I am working on the lathe portion now. Currently there are 4 wires coming off the lathe encoder.
Here is the output states of each wire to what tool it is at.
Output 6 is the output to start and stop the turret.
Tool pin 2 pin 3 pin 4 pin 5
1 1 0 0 0
2 0 1 0 0
3 1 1 0 0
4 0 0 1 0
5 1 0 1 0
6 0 1 1 0
7 1 1 1 0
8 0 0 0 1
Here is the script I started. However I have 2 questions:
Question #1: What do I need to add to the script to update the current tool and tool offset to reflect selected tool?
Question #2: How would I be able to compare the signals for example when I get to tool 7 when pin 2,3, and 4 are HI? To tell mach, yes you are at tool 7 because all states are HI? I tried to put Active1 & active2 etc etc when the 2 or more signals need to be compared. However when I emulate an active state on those inputs, mach does not activate output6 or stop when I hit the emulated key (it shows on the diagnostic screen that it is active when I hit the key)
If GetSelectedTool() = GetCurrentTool() Then
message("Tool is the same NO tool change needed")
END
End If
If GetSelectedTool = 1 Then
Message "Moving to Tool# " &GetselectedTool()
Do
ActivateSignal(OutPut6)
If IsActive(Active1) Then Exit Do
Loop
DeActivateSignal(Active1)
Message("Tool#1 Loaded")
End If
If GetSelectedTool = 2 Then
Message "Moving to Tool# " &GetselectedTool()
Do
ActivateSignal(OutPut6)
If IsActive(Active2) Then Exit Do
Loop
DeActivateSignal(OutPut6)
Message("Tool#1 Loaded")
End If
If GetSelectedTool = 3 Then
Message "Moving to Tool# " &GetselectedTool()
Do
ActivateSignal(OutPut6)
If IsActive(Active1) & IsActive(Active2) Then Exit Do
Loop
DeActivateSignal(OutPut6)
Message("Tool#1 Loaded")
End If
If GetSelectedTool = 4 Then
Message "Moving to Tool# " &GetselectedTool()
Do
ActivateSignal(OutPut6)
If IsActive(Active3) Then Exit Do
Loop
DeActivateSignal(OutPut6)
Message("Tool#1 Loaded")
End If
If GetSelectedTool = 5 Then
Message "Moving to Tool# " &GetselectedTool()
Do
ActivateSignal(OutPut6)
If IsActive(Active1) & IsActive(Active3) Then Exit Do
Loop
DeActivateSignal(OutPut6)
Message("Tool#1 Loaded")
End If
If GetSelectedTool = 6 Then
Message "Moving to Tool# " &GetselectedTool()
Do
ActivateSignal(OutPut6)
If IsActive(Active2) & IsActive(Active3) Then Exit Do
Loop
DeActivateSignal(OutPut6)
Message("Tool#1 Loaded")
End If
If GetSelectedTool = 7 Then
Message "Moving to Tool# " &GetselectedTool()
Do
ActivateSignal(OutPut6)
If IsActive(Active1) & IsActive(Active2) & IsActive(Active3) Then Exit Do
Loop
DeActivateSignal(OutPut6)
Message("Tool#1 Loaded")
End If
If GetSelectedTool = 8 Then
Message "Moving to Tool# " &GetselectedTool()
Do
ActivateSignal(OutPut6)
If IsActive(Active4) Then Exit Do
Loop
DeActivateSignal(OutPut6)
Message("Tool#1 Loaded")
End If
End