Hello all, I'm new to the forum but not cnc or mach3(have several machines running it) recently retrofitted a mill (denford triac) and i'm stumped with the atc macro. Any help will be appreciated at this point. The part i'm having an issue with is, i want to activate output 7(while input 1 is active)and have output 7 remain on until input 1 goes inactive and returns active again then deactivate output 7.
some info..
The input is a proximity sensor on the geneva gear drive thats shaped like 3/4 of a circle and is active on the missing 1/4 section
tool charger is 8 position
relays ect are setup
its a reversible ac gear motor driving a geneva gear
1 relay is motor power 1 for reversing
has proximity sensor which i have wired to a relay that grounds a pin to activate (input1)
ive started with a macro i found and edited (for better or worse...)the section below between the "#######" is the main issue but any help is welcome this is v1.0 after all...
Sub Main()
'Global variables declaration
NewTool = GetSelectedTool()
OldTool = GetCurrentTool()
While NewTool > 8
NewTool = Question ("Enter New Tool Number up to " & MaxToolNum)
Wend
If NewTool = OldTool Then'Compare between actual tool and requested tool
Else
End If
If NewTool > 8 Then'requested tool higher then tool numbers
Else
End If
If NewTool < 1 Then'tool number to low
Else
End If
code("m05")
Call ZatcPosition
Call AtcIn'Activate air cylinder valve to put old tool back to carrousel
Call Unclamp'Spindle: Tool Unclamp
Call AtcDown'lowers atc
Call LeastTravel'determine the least travel to move and Turns CW or CCW
Call AtcUp'raises atc
Call Clamp'Spindle: Tool Clamp
Call AtcOut'retracts atc
Call SetUserDRO (1200,NewTool)'Store new tool as actual tool value
SetCurrentTool( NewTool )
End Sub
Function ZatcPosition()'Move to Z tool position and wait until position reached
code("G53")'Move in Absolute Machine coordinates
code("G00 Z-1") 'Z value as to be checked for exact match with carrousel height
While(IsMoving())
Sleep(100)'temporisation entre while++
Wend
End Function
Function AtcIn()'Put old tool back to carrousel
ActivateSignal(OUTPUT4)'Move carrousel air cylinder to the tool change position adjust output# to match atc slide
code("g04 p01")
End Function
Function Unclamp()'Spindle: Tool Unclamp
ActivateSignal(OUTPUT6)'Release the tool, adjust output number for drawbar output
code("g04 p01")'pause
End Function
Function AtcDown()'lowers atc to rotate
ActivateSignal(OUTPUT5)'solonoid to lower atc
code("G04 p01")'pause
End Function
'Sequence to determine the least travel to move for TC, CW or CCW
Function LeastTravel()
NewTool = GetSelectedTool()
OldTool = GetCurrentTool()
NTool = 8 ' Number of tools changer holds
CWPos = GetSelectedTool() - GetCurrentTool() ' Assume a CW move
If CWPos < 0 Then ' CWPos < 0 ==> rtp < atp
CWPos = CWPos + NTools
End If
CCWPos = NTools - CWPos
If CWPos < CCWPos Then
Call CW()
Else
Call CCW()
End If
End Function
############################################################################################
Function CW()'Rotation CW
Dim x As Integer
Dim CTPos As Integer 'Carrousel Tool Position Relative to OldTool Position
CTPos=0
ActivateSignal(OUTPUT7)'Turns the AC Motor On
code"g04 p05"
Do Until IsActive(input1)
ActivateSignal(OUTPUT7)'Turns the AC Motor On
deactivatesignal(output7)
sleep(0)
Loop
For x=0 To CWPos
If IsActive(input1) Then
x=x+1
While IsActive(input1)'Wait for OEMTrig to de-assert
Wend
End If
Next x
CTPos=x
DeactivateSignal(OUTPUT7)
End Function
Function CCW()'Rotation CCW
Dim y As Integer
Dim CTPos As Integer 'Carrousel Tool Position Relative to OldTool Position
CTPos=0
ActivateSignal(OUTPUT7)'Turns the AC Motor On
activatesignal(output8)'atc motor revirsing relay
code"g04 p05"
Do Until IsActive(input1)
ActivateSignal(OUTPUT7)'Turns the AC Motor On
activatesignal(output8)'atc motor revirsing relay
sleep(0)
Loop
For y=0 To CCWPos
If IsActive(input1) Then
y=y+1
While IsActive(input1)'Wait for OEMTrig to de-assert
Wend
End If
Next y
CTPos=y
DeactivateSignal(OUTPUT7)
deactivatesignal(output8)
End Function
############################################################################################
Function AtcUp()'lifts atc
deActivateSignal(OUTPUT5)'relay for solonoid to lower/lift atc
code("G04 p01")'pause
End Function
Function Clamp()'power drawbar unactivated
DeactivateSignal(OUTPUT6)'unactivating drawbar relay
End Function
Function AtcOut()'retracts atc
deActivateSignal(OUTPUT4)'atc retract cylinder relay
code("g04 p01")
End Function
Main