component turret "This component controls the turret hardware for Kirk Wallace's Hardinge HNC turret. M6 calls this (via .hal file link - linkpp iocontrol.0.tool-change turret.0.ToolChange) to move the turret to the last T word value entered. Only position 1 through 8 are considered valid."; pin in bit position_change "A .hal file should connect this to iocontrol.X.tool-change."; pin in s32 position_requested "A .hal file should connect this pin to iocontrol.X.tool-prep-number. Only position 1 through 8 will be considered valid. Multiple tools at a position may be acomodated in the tool table."; pin in s32 position_current "A .hal file should connect this pin to a wsum.X.sum pin. wsum.X.bit.0.in through wsum.X.bit.3.in should be connected to A through C from the turret encoder board. The HNC turret encoder board will output a 0 (zero) between valid positions."; pin out bit position_changed "A .hal file should connect this to iocontrol.X.tool-changed to indicate to EMC when the position change is complete."; pin out bit seek "Connect this pin via .hal file to the turret rotate solenoid signal."; pin out bit stop "Connect this pin via .hal file to the turret stop solenoid signal."; param rw s32 state_turret "This parameter holds the value of the current state of the turret change process; idle, seeking, stopping, parking."; param rw s32 settle "This parameter holds the initial value and then the count down of servo periods to allow settling of the turret mechanism before invoking next state proceedure."; param rw s32 settle_stop "This is the initial settle time in servo periods between activating the stop solenoid and when the turret comes to rest."; param rw s32 settle_park "This is the initial settle time in servo periods between deactivating the turret rotate solenoid and when the turret descends to the park position."; function _ nofp; license "GPL"; ;; FUNCTION(_) { if (position_change) { switch (state_turret) { case 0: if (position_requested != position_current && position_requested>0 && position_requested<9) { seek=1; state_turret=1; } else { position_changed=1; } break; case 1: if (position_requested == position_current) { stop=1; settle=settle_stop; state_turret=2; } break; case 2: --settle; if (settle<=0) { seek=0; settle=settle_park; state_turret=3; } break; case 3: --settle; if (settle<=0) { stop=0; state_turret=0; position_changed=1; } break; default: state_turret=0; break; } } else { seek=0; stop=0; position_changed=0; } }