Automatic Tool Changer Logic

I have been working on adding Automatic Tool Changer (ATC) functions to Grbl (more on that soon).  First, I wanted to put in some basic safety logic that will not allow the ATC to open when the spindle is on or even spinning down. If that were to happen it could be dangerous and it would damage the ATC. By “logic” I mean logic gates outside of the firmware.  This would backup the firmware and prevent a bug or weird state from activating the ATC. This is quite easy with a custom component in PSoC.  This logic will still function if the firmware has a bug, the firmware locks up, of even while stopped during debugging.

Right now I have 2 signals I can work with. One is the enable signal going to the spindle. The other is the output that signals the ATC to open.  Eventually I would also like to incorporate a tachometer signal from the spindle, but I don’t have a spindle with a tachometer yet.  The logic is relatively simple.  If the component sees that both signals exist at the same time, it will disable both and raise a fault signal. To prevent any timing issues I will also incorporate a spindown delay with the spindle and a shorter ‘settling’ delay for the ATC air valve. Under normal conditions it simply passes the spindle or ATC signals to the outputs.

Here is what the component looks like in PSoC creator.

Inputs

  • Spindle_In: The spindle enable signal goes in here.
  • ATC_In: The signal to open the ATC goes here.
  • Clock: This is used to count down the spindle spindown and ATC settling time.
  • Reset: In a fault condition, this is used to reset the fault.
  • Parameters:
    • Spindown: How many clock cycles will be used for the spindown.
    • ATC Settle: How many clock cycles will be added after the ATC is closed before the spindle can turn on..

Outputs

  • Spindle Out: The spindle enable signal will come out here.
  • ATC Out: The ATC open signal will come from here and go to the pin for this.
  • Fault: If anything goes wrong, this will go high.  It would typically connect to an interrupt.  This must be cleared with a reset.

Test Circuit

I tested this out on a CY8CKIT-001 with a PSoC5 module installed. This made it easy to connect to switches to simulate the input signals and LEDs to easily view the output signals.

Note: In the test there is only one line of firmware. It initializes the PWM component. The rest is done in discrete logic.

  • There is a switch to to simulate the spindle output from the firmware.  This goes through a not because it switches to ground on this dev board.  It then splits to turn on the PWM and go to the ATC_logic component. This simulates Grbl’s Spindle enable and Spindle PWM signals. The PWM was set with a 10% duty cycle so the dimmer output is easily noticed.
  • There is a switch for the ATC signal.
  • There is a switch to reset the component if if latches with a fault.

 

Here is a picture of the setup.

Here is a video of the testing.

Here is the Verilog code for the component.


//`#start header` -- edit after this line, do not edit this line
// ========================================
//
// Open Source Creative Commons 4.0 Attribution, Share Alike. 
//
// ========================================
`include "cypress.v"
//`#end` -- edit above this line, do not edit this line
// Generated on 06/15/2017 at 18:36
// Component: atc_logic
module atc_logic (
	output  reg ATC_out,
	output  reg fault,
	output  reg spindle_out,
	input   ATC_in,
	input   clock,
	input   reset,
	input   spindle_in
);
	parameter atc_settle = 3;
	parameter spindown = 10;

//`#start body` -- edit after this line, do not edit this line

//reg spindle_enable;
    
    reg [15:0] atc_count;
    reg [15:0] spin_count;
    reg [1:0] latch;
    
    //assign spindle_out = spindle_in & spindle_enable;
    //assign spindle_out = spindle_in;
    
        
    always @(posedge clock or posedge reset)    
    begin
        if (reset)
            begin
                latch = 0;               
            end
        else if (   ((ATC_in  || (atc_count > 0))     &&     (spindle_in || (spin_count > 0))) || latch   )
            begin
                ATC_out = 0;
                spindle_out = 0;
                fault = 1;
                latch = 1;
            end
        else
            begin
                fault = 0;                
                
                if (spindle_in)
                    begin
                        spin_count = spindown;
                        spindle_out = 1;
                    end
                else if (spin_count > 0)
                    begin
                        spin_count = spin_count - 1;
                        spindle_out = 0;
                    end
                else
                    begin
                        spindle_out = 0;
                    end
                
                
                    
                if (ATC_in)
                    begin
                        atc_count = atc_settle;
                        ATC_out = 1;
                    end
                else if (atc_count > 0)
                    begin                
                        atc_count = atc_count - 1;
                        ATC_out = 0;
                    end    
                else
                    begin
                        ATC_out = 0;
                    end
                
                
            end
            
    end    

//`#end` -- edit above this line, do not edit this line
endmodule
//`#start footer` -- edit after this line, do not edit this line
//`#end` -- edit above this line, do not edit this line

 

 

Share and Enjoy:
  • Print
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Yahoo! Buzz
  • Twitter
  • Google Bookmarks

2 Responses to “Automatic Tool Changer Logic”


  1. Michael Seney

    What arc and spindle are you using.

  2. bdring

    I bought mine from CNCCat for a Kress Spindle.

*