If notice there's nothing in there which actually moves the turret etc. Still needs code adding. Better example is to look at this link and download the file.
http://centroidcncforum.com/viewtopi...lit=turret+atc
Printable View
If notice there's nothing in there which actually moves the turret etc. Still needs code adding. Better example is to look at this link and download the file.
http://centroidcncforum.com/viewtopi...lit=turret+atc
Copied:-
TurretMotor is an output. It turns on if currentPosition_W != RequestedLocation_W.
;If current position != requested position, rotate turret
IF DoingTurretIndex_M && RequestedLocation_W != CurrentTurretPosition_W THEN SET TurretMotor
Not sure where or how this TurretMotor is defined. On my Triac, that was just an output for a relay, so that's easy. This is different as its actually the A Axis and not an 'outside' device.
I'll just put this here for now, but it's a work in progress. I need to go and do something, but will try and get it finished later.
Original code-
Code:;=============================================================================
MainStage
;=============================================================================
;Do gather if commanded (uncomment and recompile for debugging purposes)
;IF Aux11Key || ((SV_MPU11_ABS_POS_2 < SV_MACHINE_PARAMETER_45) && (SV_MACHINE_PARAMETER_45 < -1000)) THEN (Aux11KeyPD)
;IF Aux11KeyPD THEN (SV_TRIGGER_PLOT_DUMP), SET SV_STOP
;IF Aux11Key || OUT25 THEN (SV_TRIGGER_PLOT_DUMP)
IF TRUE THEN CurrentTurretPosition_W = 0
IF ToolBit1 && ToolBit2 && !ToolBit3 THEN CurrentTurretPosition_W = 1
IF !ToolBit1 && ToolBit2 && !ToolBit3 THEN CurrentTurretPosition_W = 2
IF !ToolBit1 && !ToolBit2 && !ToolBit3 THEN CurrentTurretPosition_W = 3
IF ToolBit1 && !ToolBit2 && !ToolBit3 THEN CurrentTurretPosition_W = 4
IF ToolBit1 && !ToolBit2 && ToolBit3 THEN CurrentTurretPosition_W = 5
IF !ToolBit1 && !ToolBit2 && ToolBit3 THEN CurrentTurretPosition_W = 6
IF !ToolBit1 && ToolBit2 && ToolBit3 THEN CurrentTurretPosition_W = 7
IF ToolBit1 && ToolBit2 && ToolBit3 THEN CurrentTurretPosition_W = 8
IF TRUE THEN SV_PLC_CAROUSEL_POSITION = CurrentTurretPosition_W
IF SV_PROGRAM_RUNNING THEN (ProgramRunning)
;cnctch.mac
IF OnAtPowerUp_M THEN RequestedLocation_W = CurrentTurretPosition_W
IF TRUE THEN TurretTimer = 700, ReversingTimer = 1500
IF M6 THEN (M6PD), SET DoingTurretIndex_M
IF M6PD THEN RequestedLocation_W = SV_TOOL_NUMBER
IF DoingTurretIndex_M && ((SV_TOOL_NUMBER < 1) || (SV_TOOL_NUMBER > 8))
THEN SET OtherFault_M, FaultMsg_W = INVALID_TOOL_NUMBER, RST DoingTurretIndex_M,
RequestedLocation_W = CurrentTurretPosition_W, SET ToolChangeComplete
IF DoingTurretIndex_M && RequestedLocation_W != CurrentTurretPosition_W THEN SET TurretMotor
IF RequestedLocation_W == CurrentTurretPosition_W THEN SET TurretTimer
IF TurretTimer THEN RST TurretMotor, SET ReversingTimer, RST TurretTimer
IF ReversingTimer THEN RST ReversingTimer, SET ToolChangeComplete
IF !SV_PROGRAM_RUNNING THEN RST M6, RST DoingTurretIndex_M, RequestedLocation_W = CurrentTurretPosition_W
IF !M6 THEN RST ToolChangeComplete, RST TurretTimer
IF SV_STOP THEN RST TurretMotor, RST TurretTimer, RST ReversingTimer, RST M6
Code in the process of being modified
RequestedLocation_WCode:;=============================================================================
MainStage
;=============================================================================
;Do gather if commanded (uncomment and recompile for debugging purposes)
;IF Aux11Key || ((SV_MPU11_ABS_POS_2 < SV_MACHINE_PARAMETER_45) && (SV_MACHINE_PARAMETER_45 < -1000)) THEN (Aux11KeyPD)
;IF Aux11KeyPD THEN (SV_TRIGGER_PLOT_DUMP), SET SV_STOP
;IF Aux11Key || OUT25 THEN (SV_TRIGGER_PLOT_DUMP)
IF SV_PROGRAM_RUNNING THEN (ProgramRunning)
;cnctch.mac
IF OnAtPowerUp_M THEN RequestedLocation_W = CurrentTurretPosition_W
IF TRUE THEN TurretTimer = 700, ReversingTimer = 1500
IF M6 THEN (M6PD), SET DoingTurretIndex_M
IF M6PD THEN RequestedLocation_W = SV_TOOL_NUMBER
IF DoingTurretIndex_M && ((SV_TOOL_NUMBER < 1) || (SV_TOOL_NUMBER > 8))
THEN SET OtherFault_M, FaultMsg_W = INVALID_TOOL_NUMBER, RST DoingTurretIndex_M,
RequestedLocation_W = CurrentTurretPosition_W, SET ToolChangeComplete
;code to calculate distance to move
If CurrentTurretPosition_W > RequestedLocations_W THEN DistanceToMove = ... (need to handle roll over)
;code to rotate A-axis require distance
;code to reverse A-axis
IF TRUE THEN SET ToolChangeComplete
IF !SV_PROGRAM_RUNNING THEN RST M6, RST DoingTurretIndex_M, RequestedLocation_W = CurrentTurretPosition_W
IF !M6 THEN RST ToolChangeComplete, RST TurretTimer
IF SV_STOP THEN RST TurretMotor, RST TurretTimer, RST ReversingTimer, RST M6
CurrentTurretPosition_W
Chaz, to save me looking it up, just to confirm, it's an 8-position turret (45 deg between tools)?
And does normal rotation increase or decrease tool position?
Just looked at a pic. It looks like the numbers decend.
This is the barebones of what should be needed I think.Code:;=============================================================================
MainStage
;=============================================================================
;Do gather if commanded (uncomment and recompile for debugging purposes)
;IF Aux11Key || ((SV_MPU11_ABS_POS_2 < SV_MACHINE_PARAMETER_45) && (SV_MACHINE_PARAMETER_45 < -1000)) THEN (Aux11KeyPD)
;IF Aux11KeyPD THEN (SV_TRIGGER_PLOT_DUMP), SET SV_STOP
;IF Aux11Key || OUT25 THEN (SV_TRIGGER_PLOT_DUMP)
IF SV_PROGRAM_RUNNING THEN (ProgramRunning)
;cnctch.mac
IF OnAtPowerUp_M THEN RequestedLocation_W = CurrentTurretPosition_W
IF TRUE THEN TurretTimer = 700, ReversingTimer = 1500
IF M6 THEN (M6PD), SET DoingTurretIndex_M
IF M6PD THEN RequestedLocation_W = SV_TOOL_NUMBER
IF DoingTurretIndex_M && ((SV_TOOL_NUMBER < 1) || (SV_TOOL_NUMBER > 8))
THEN SET OtherFault_M, FaultMsg_W = INVALID_TOOL_NUMBER, RST DoingTurretIndex_M,
RequestedLocation_W = CurrentTurretPosition_W, SET ToolChangeComplete
;code to calculate distance to move
IF CurrentTurretPosition_W > RequestedLocation_W THEN PositionsToMove_W = CurrentToolPosition_W - RequestedLocation_W
IF CurrentTurretPosition_W < RequestedLocation_W THEN PositionsToMove_W = (CurrentTurretPosition_W + 8) - RequestedLocation_W ;this assumes the PLC can handle ELSE..
IF TRUE THEN DistanceToMove_W = PositionsToMove_W * 45 ; This may need a further multiplication if we're not going to be moving in degrees (does this need extra movement to overshoot new position before reversing?)
;code to rotate A-axis require distance
;code to reverse A-axis
IF TRUE THEN SET ToolChangeComplete
IF !SV_PROGRAM_RUNNING THEN RST M6, RST DoingTurretIndex_M, RequestedLocation_W = CurrentTurretPosition_W
IF !M6 THEN RST ToolChangeComplete, RST TurretTimer
It still needs the required code to actually move the A-axis.
Also see the notes I've added.
Having scanned through the manual, I can't see how, or even if, you can move an axis via the PLC.
I've just realised, what you need to achieve may have to be via a combination of Macro and PLC.
The macro allows you to run normal G-codes, but I'm not sure if you can run calculations in a Macro.
What you may need to do, is run the Macro, which then moves to the PLC to calculate the rotation required, which is then stored in a variable the macro can access. The macro then carries out the required A axis movement.
So some response from the Centroid forum. Explained the logic to him. It looks like I need to buy the software to get access to the M107 command needed for the BCD Tool Changer Output. Happy to buy it but need to know I can get it to work.