;Eriks first real try December 2018 o sub ; Check to make sure z axis is homed M66 P8 L3 Q3 o025 if [#5399 LT 0] (abort, z axis is not homed) o025 endif M64 P7 ;Activate TC Arm move slow solenoid M64 P10 ;Activate TC Carousel rotate slowly command M64 P6 ;Orient the spindle ;Note the next three entries are to make up for spindle orient = true not working ;Check to see if spindle is in alarm (and therefore not homed) M66 P9 L3 Q5 ; wait for spindle = stopped o030 if [#5399 LT 0] (abort, spindle not stopped) o030 endif M66 P10 L2 Q5 ; wait for spindle = speed arrival o040 if [#5399 GT 0] (abort, spindle speed arrival true -> not in orient) o040 endif M66 P11 L2 Q3 ; Check to see if spindle is in alarm state o045 if [#5399 GT 0] (abort, Spindle is in alarm state) o045 endif ; Comment out until orient true works. This will replace the three above when working ;M66 P6 L3 Q5 ; wait orient = true ; o050 if [#5399 LT 0] ; (abort, failed to orient) ; o050 endif G53 G0 Z 1.78 ;Move Z to high load position ; only unload the tool if there is a tool in the spindle ; This assumes that the carousel is already aligned correctly. ; It is important to unload the tool before shutting down the machine. o100 IF [# GT 0] o103 if [# NE #] (abort, tool changer in wrong position) o103 endif G53 G0 Z -2.32 ;Move Z to low load position M64 P2 ; Extend tool changer arm G4 P3 ; Wait 3 seconds M66 P2 L3 Q5 ; wait for carousel-extended = true o104 if [#5399 LT 0] (abort, carousel not extended) o104 endif M66 P1 L2 Q5 ; wait for carousel-retracted = false o105 if [#5399 GT 0] (abort, carousel still retracted) o105 endif M64 P3 ;Release tool M66 P3 L3 Q5 ; wait for tool-released = true o106 if [#5399 LT 0] (abort, tool not released) o106 endif M65 P1 ;Turn off arm extend solenoid G53 G0 Z 1.78 ;Move Z to high load position o100 ENDIF ; Move carousel section o200 IF [# GT 0] M64 P4 ;Unlock Carousel M66 P4 L3 Q5 ; wait for carousel-unlocked = true o201 if [#5399 LT 0] (abort, carousel not unlocked) o201 endif M66 P5 L2 Q5 ; wait for carousel-locked = false o202 if [#5399 GT 0] (abort, carousel still locked) o202 endif M65 P4 ;Turn off carousel unlock solenoid M68 E0 Q# ;set the carousel to move to the right pocket M64 P0 ;Enable Carousel G4 P2 ; Wait 2 seconds M66 P0 L3 Q5 ; wait for carousel-ready = true o203 if [#5399 LT 0] (abort, carousel not finished) o203 endif M65 P0 ;Disable carousel enable M64 P5 ;Lock carousel G4 P1 ; Wait 1 second M66 P4 L2 Q3 ; wait for carousel-unlocked = false o204 if [#5399 GT 0] (abort, carousel unlocked) o204 endif M66 P5 L3 Q3 ; wait for carousel-locked = true o205 if [#5399 LT 0] (abort, carousel not locked) o205 endif M65 P5 ;Disable lock carousel M64 P2 ;Extend carousel, might already be extended G4 P2 ; Wait 2 seconds M66 P2 L3 Q8 ; wait for carousel-extended = true o206 if [#5399 LT 0] (abort, carousel not extended) o206 endif M66 P1 L2 Q5 ; wait for carousel-retracted = false o207 if [#5399 GT 0] (abort, carousel still retracted) o207 endif M64 P3 ;Release tool M66 P3 L3 Q5 ; wait for tool-released = true o208 if [#5399 LT 0] (abort, tool not released) o208 endif M66 P7 L3 Q5 ;Verify that tool is seen in carousel o209 if [#5399 LT 0] (abort, no tool in target carousel slot) o209 endif M64 P9 ;Turn on air blast G4 P2 ;Wait 2 seconds M65 P9 ;Turn off air blast G53 G0 Z -2.32 ;Move Z to low load position O200 ENDIF M65 P3 ;Clamp tool (turn unclamp off) G4 P2 ; Wait 2 seconds M66 P3 L2 Q5 ;Verify that tool is clamped o300 if [#5399 GT 0] (abort, tool not clamped) o300 endif M65 P2 ;Disable extend carousel solenoid M64 P1 ; Retract tool changer arm G4 P5 ; Wait 5 seconds M66 P1 L3 Q5 ; wait for carousel-retracted = true o400 if [#5399 LT 0] (abort, carousel not retracted) o400 endif M66 P2 L2 Q5 ; wait for carousel-extended = false o500 if [#5399 GT 0] (abort, carousel still extended) o500 endif M65 P1 ; Disable retract tool changer arm solenoid M65 P7 ;De-activate TC Arm move slow solenoid M65 P10 ;De-activate TC Carousel rotate slowly command M65 P6 ;turn off spindle orient M66 P9 L3 Q5 ; wait for spindle = stopped o600 if [#5399 LT 0] (abort, spindle not stopped) o600 endif M66 P10 L3 Q5 ; wait for spindle = speed arrival o700 if [#5399 LT 0] (abort, spindle speed arrival false -> still in orient) o700 endif G53 G0 Z -1.8 ;Move Z to low load position o endsub [1]