Detect Spindle RPM Drop and ESTOP

More
07 Aug 2014 08:02 #49571 by russtuff
Hello friends. LinuxCNC does not currently control my spindle, however, I am in the process of getting it to read the spindle RPM via CNC4PC C3 board to my C11 BOB.

To avoid crashes and/or losing steps, I would like LinuxCNC to monitor RPM and ESTOP if the RPM drops below some threshhold (like % drop of RMS, or maybe a set RPM below whatever S defines in the Gcode (which would be included only for this purpose since S isn't actually telling the motor what to do)).

I'm sure this is possible, and am hoping someone can point me in the right direction. While I've been using LinuxCNC for a couple of years, I've never tried anything like this before.

Please Log in or Create an account to join the conversation.

More
07 Aug 2014 14:46 #49573 by ArcEye
Hi

Have a look at the lathe sim under sim > axis > lathe.hal in the sample configs

That has an 'at speed' section and shows the connections to compare actual speed to commanded speed

regards

Please Log in or Create an account to join the conversation.

More
08 Aug 2014 03:47 #49586 by russtuff
Thanks!
I'll check it out.

Please Log in or Create an account to join the conversation.

More
10 Aug 2014 18:54 #49652 by andypugh

To avoid crashes and/or losing steps, I would like LinuxCNC to monitor RPM and ESTOP if the RPM drops below some threshhold (like % drop of RMS, or maybe a set RPM below whatever S defines in the Gcode (which would be included only for this purpose since S isn't actually telling the motor what to do)).


This is a little harder than it might appear. The difficulty is that the E-stop will be tripped every time that the spindle it turned on, as it will be below speed until it accelerates.

This means that you need to store the spindle state in HAL in some way (off, not-at-speed, has-been-at-speed, underspeed-so-estop)

This can probably be done with a chain of mux-blocks, flip-flops and logic. But it seems neater to use a custom HAL component. (arguably we should have a generic spindle-at-speed component)

Here is an off-the-cuff untested example of how the component might look, to be compiled and installed with "halcompile"
component spindle-monitor "spindle at-speed and underspeed detection";
pin in bit spindle-is-on;
pin in float spindle-command;
pin in float spindle-feedback;

pin out bit spindle-at-speed;
pin out bit spindle-underspeed;

param rw level "state machine state";
param rw threshold;

function _;
license "gpl v2 or higher"

;;

FUNCTION(_){

switch (level){
case 0:  // idle
    spindle_at_speed = 0;
    spindle_underspeed = 0;
    if (spindle_is_on) level = 1;
    break;
case 1: // waiting for spindle-at-speed
    if ( ! spindle_is_on ) {
        level = 0;
        return; }
    if (absf(spindle_command - spindle_feedback) < threshold) {
        level = 2;
        spindle_at_speed = 1;
        return; }
    break;
case 2: // monitoring speed
    if ( ! spindle_is_on ) {
        level = 0;
        return; }
    if  (spindle_command - spindle_feedback) > threshold) {
        spindle_underspeed = 1; }
    break;

Please Log in or Create an account to join the conversation.

More
12 Aug 2014 02:36 #49718 by russtuff

This is a little harder than it might appear. The difficulty is that the E-stop will be tripped every time that the spindle it turned on, as it will be below speed until it accelerates.

This means that you need to store the spindle state in HAL in some way (off, not-at-speed, has-been-at-speed, underspeed-so-estop)

This can probably be done with a chain of mux-blocks, flip-flops and logic. But it seems neater to use a custom HAL component. (arguably we should have a generic spindle-at-speed component)

Here is an off-the-cuff untested example of how the component might look, to be compiled and installed with "halcompile"
component spindle-monitor "spindle at-speed and underspeed detection";
pin in bit spindle-is-on;
pin in float spindle-command;
pin in float spindle-feedback;

pin out bit spindle-at-speed;
pin out bit spindle-underspeed;

param rw level "state machine state";
param rw threshold;

function _;
license "gpl v2 or higher"

;;

FUNCTION(_){

switch (level){
case 0:  // idle
    spindle_at_speed = 0;
    spindle_underspeed = 0;
    if (spindle_is_on) level = 1;
    break;
case 1: // waiting for spindle-at-speed
    if ( ! spindle_is_on ) {
        level = 0;
        return; }
    if (absf(spindle_command - spindle_feedback) < threshold) {
        level = 2;
        spindle_at_speed = 1;
        return; }
    break;
case 2: // monitoring speed
    if ( ! spindle_is_on ) {
        level = 0;
        return; }
    if  (spindle_command - spindle_feedback) > threshold) {
        spindle_underspeed = 1; }
    break;

That is super helpful,and I appreciate the start. I should have my mill back together in few days and will start doing some tests.

I wonder if it would work to just delay the test for however many seconds it takes for the motor to hit max RPM. Say wait 3 seconds, then start checking for drops in RPM.

I'll keep at it :)

Please Log in or Create an account to join the conversation.

Time to create page: 0.433 seconds
Powered by Kunena Forum