Spindle stops during a job


Results 1 to 8 of 8

Thread: Spindle stops during a job

  1. #1
    Member
    Join Date
    Feb 2011
    Location
    USA
    Posts
    48
    Downloads
    0
    Uploads
    0

    Default Spindle stops during a job

    Gentlemen,

    Once again I request your expertise...

    I was running several jobs today and I noticed that several times during the job, the spindle would stop.

    1. This problem happens at different places in the job, or most times not at all.
    2. The spindle drive does not report any errors.
    3. I put an analog voltmeter on the DAC output of KANALOG, and the DAC voltage drops out when the spindle does. The spindle enable signal stays ON. Cycling Estop allows it to restart correctly.
    4. If I don't cycle Estop and run the job again, the spindle never starts. The DAC remains at 0V.

    So it looks like this issue is coming from the controller, and is not a spindle drive issue.
    Something is causing the spindle DAC output to drop to 0 during the job.
    I may have something in the C code causing this...

    I have attached my C code files for the CW Spindle and for the Feedrate / Spindle override pots.

    Suggestions?
    Thanks,
    Rick

    *** Spindle CW Code ***
    Code:
    #include "KMotionDef.h"
    
    
    // Spindle CW Jog function with +/- voltage used for direction
    
    
    #define SPINDLEAXIS 4            // Axis Channel to Jog to rotate Spindle
    #define FACTOR (1.0/6090.0)          // to convert RPM to counts/sec (counts/rev / 60.0sec)
    #define SPEEDVAR 99            // global persistant variable to store latest speed
    #define STATEVAR 98            // global persistant variable to store latest state (-1=CCW,0=off,1=CW)
    #define KMVAR 1                 // variable KMotionCNC will pass speed parameter (113)
    #define SPINDLE_CHANGING_SPEED 140    // Bit goes low when spindle is at command speed, 1 when changing
    #define SPINDLE_0_SPEED 139        // Bit goes high when spindle is at 0 speed
    #define SPINDLE_ENABLE    153        // Bit to enable spindle drive
    
    
    int splast=0,splastsolid=-1,spcount=0;
    int result;
    
    
    // M03 command passes no arguments
    // desired speed is read from user variable SPEEDVAR
    // save in user variable STATEVAR whether it was off, CW, or CCW (0,1,-1)
    // save in user variable SPEEDVAR the last desired speed
    
    
    
    
    main()
    {
        float speed = *(float *)&persist.UserData[SPEEDVAR];    // get speed setting 
        float LastState = persist.UserData[STATEVAR];          // get last state 
        
        if (LastState==-1)  
        {
            // spindle was CCW now we want CW 
            // spin down
    
    
            Jog(SPINDLEAXIS,0);
            while (!CheckDone(SPINDLEAXIS));
    
    
            // Wait for spindle to stop
            while (ReadBit(SPINDLE_0_SPEED) == 0);
        }
    
    
        // Set the new state
        LastState = 1;
    
    
        // Turn on Spindle
        SetBit (SPINDLE_ENABLE);
        
        // Set spindle to new speed and direction
        Jog(SPINDLEAXIS, speed * FACTOR * LastState);
    
    
        // Wait for spindle to reach set speed
        // SPINDLE_CHANGING_SPEED bit only goes low at speed
        result = 1;
        while (result != 0)
        {
            result = ReadBit(SPINDLE_CHANGING_SPEED)==1;
            //printf ("%d,",result);
        }
        //Delay_sec(2);
    
    
        // Save the new state
        persist.UserData[STATEVAR] = 1;
    
    
        // Print status
        printf("M3 Spindle CW, Spindle speed %f, FACTOR %f, State %f\n", speed, FACTOR, LastState);
    }
    *** Feedrate / Spindle override code ***

    Code:
    #include "KMotionDef.h"
    
    
    #define TMP 10 // which spare persist to use to transfer data
    #include "KflopToKMotionCNCFunctions.c"
    
    
    #define CHANGE_TOL 0.02  // only update if change is more than this
    #define CHANGE_TIME 0.05  // don't update more often than this time
    #define FROADC    0    // A/D converter for FRO
    #define SSOADC    1    // A/D converter for SSO
    
    
    double LastSSO=-1;
    double LastSSOTime=0;
    double LastFRO=-1;
    double LastFROTime=0;
    
    
    main()
    {
        double SSOPot,FROPot,FRO,SSO,T;
    
    
        while (1)
        {
            T = WaitNextTimeSlice();
            
            // Update Feed Rate Override value from POT
    
    
            // assume 5V range where 2.5V is nominal FRO, result is 0-2.5
            FROPot=KANALOG_CONVERT_ADC_TO_VOLTS(ADC(FROADC)) - 2.5;
            
            // fROPot ranges from 0 to 2.5
            // FRO ranges from 1 to 2.25
            FRO = FROPot*0.5+1.0;
    
    
            // send message to KMotionCNC if the pot changed significantly
            // and it has been a while since the last message
            if ((FRO > LastFRO+CHANGE_TOL || FRO < LastFRO-CHANGE_TOL) && 
                T > LastFROTime+CHANGE_TIME)
            {
                printf("FRO = %f\n",FRO);
                DoPCFloat(PC_COMM_SET_FRO,FRO);
                LastFRO=FRO;
                LastFROTime=T;
            }
    
    
            // Update Spindle Speed Override value from POT
    
    
            // assume 5V range where 2.5V is nominal SSO
            SSOPot=KANALOG_CONVERT_ADC_TO_VOLTS(ADC(SSOADC)) - 2.5;
            
            SSO = SSOPot*0.5+1.0;
    
    
            // send message to KMotionCNC if the pot changed significantly
            // and it has been a while since the last message
            if ((SSO > LastSSO+CHANGE_TOL || SSO < LastSSO-CHANGE_TOL) && 
                T > LastSSOTime+CHANGE_TIME)
            {
                printf("SSO = %f\n",SSO);
                DoPCFloat(PC_COMM_SET_SSO,SSO);
                LastSSO=SSO;
                LastSSOTime=T;
            }
        }
    }


    Similar Threads:


  2. #2
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4045
    Downloads
    0
    Uploads
    0

    Default Re: Spindle stops during a job

    Hi rbickle,

    I don't see anything obvious.

    What does the SSO on the KMotionCNC Screen do when the problem happens?

    If you have KMotion.exe running what is displayed on the Console and what displays on the Axis Screen when the problem happens?

    How are you running the Feedrate / Spindle Override code? What Thread? Normally that code would be added to your Initialization Program. Does it fail without this code running?

    How are M3, S and other M Codes configured in KMotionCNC | Tool Setup?

    Please post your Initialization Program.

    Regards

    Regards
    TK http://dynomotion.com


  3. #3
    Member
    Join Date
    Jun 2004
    Location
    Scotland
    Posts
    355
    Downloads
    0
    Uploads
    0

    Default Re: Spindle stops during a job

    Looking at the code, I'm going to guess the spindle has an encoder, and feedhold is activating due to hitting the softlimit for the spindle axis.
    I had the same problem with my mill doing it's first long job recently, as I'd left the softlimit setting in my init file set to the default setting.

    To confirm, as Tom says, keep KMotion running the in background with the console open. If it is, you'll get a message telling you about the softlimit and that a feedhold has been triggered.



  4. #4
    Member
    Join Date
    Feb 2011
    Location
    USA
    Posts
    48
    Downloads
    0
    Uploads
    0

    Default Re: Spindle stops during a job

    Tom,

    I updated the user area in flash memory to be sure that I had the correct code, and now I can't get it to fail again. Murphy's law. I'll try more later...

    I have the button handler in thread1, the FRO/SSO in thread2, and the MPG code in thread3

    I don't think there was anything different about the FRO/SSO when the spindle stopped. I did not look at the console or the axis screen, but I can tell that the spindle axis (4) was still enabled, as it drifts around some even when s=0. Also I checked the spindle relay during that problem and it was still engaged.

    I have modified code for M3, M4, S, and M5 which waits for the spindle to get to speed, or to stop. This has been working fine. I'll post them if you like.

    The initialization code:

    Code:
    #include "KMotionDef.h"
    
    /*
    Initialization and button handler functions
    for the J325 Milling Machine. 
    This file executes in Thread 1
    R. Bickle, ICS, 12/2016
    x and y axes have 20,000 encoder counts per inch
    z axis has 25,000 encoder counts per inch
    spindle has 5600 encoder counts per revolution
    */
    
    // Input Bits
    #define FEEDHOLDBIT 	19
    #define CYCLESTARTBIT 	16
    #define ESTOP 			136
    #define HALTBIT 		18
    #define RESTARTBIT 		17
    #define CLAMP 			142
    #define UNCLAMP 		141
    //#define ZEROALLBIT 		29
    #define OVERTRAVEL 		137
    #define OVERLOAD 		138
    #define SPINDLE0SPEED	139
    #define SPINDLEATSPEED	140
    #define AIRPRESSOK		143
    
    // Output Bits
    #define DRIVE_ENABLE	152
    #define SPINDLE_ENABLE	153
    #define DRAWBAR_OPEN	154
    
    // Set initial output state
    ClearBit (DRIVE_ENABLE);
    ClearBit (SPINDLE_ENABLE);
    ClearBit (DRAWBAR_OPEN);
    
    // function prototypes for compiler
    int  DoPC(int cmd);
    int  DoPCFloat(int cmd, float f);
    int  Debounce(int n, int *cnt, int *last, int *lastsolid);
    void ButtonService (void);
    
    // global state variables for switch debouncing
    int flast=0,flastsolid=-1,fcount=0;
    int clast=0,clastsolid=-1,ccount=0;
    int elast=0,elastsolid=-1,ecount=0;
    int elast2=0,elastsolid2=-1,ecount2=0;
    int hlast=0,hlastsolid=-1,hcount=0;
    int rlast=0,rlastsolid=-1,rcount=0;
    int zlast=0,zlastsolid=-1,zcount=0;
    int clamplast=0,clamplastsolid=-1,clampcount=0;
    int unclamplast=0,unclamplastsolid=-1,unclampcount=0;
    int Estop = 0;
    
    main()
    {
    
    	ch0->InputMode=ENCODER_MODE;
    	ch0->OutputMode=DAC_SERVO_MODE;
    	ch0->Vel=60000;
    	ch0->Accel=250000;
    	ch0->Jerk=5e+006;
    	ch0->P=8;
    	ch0->I=1e-006;
    	ch0->D=100;
    	ch0->FFAccel=0.00025;
    	ch0->FFVel=0.034;
    	ch0->MaxI=2000;
    	ch0->MaxErr=3500;
    	ch0->MaxOutput=2000;
    	ch0->DeadBandGain=1;
    	ch0->DeadBandRange=0;
    	ch0->InputChan0=0;
    	ch0->InputChan1=1;
    	ch0->OutputChan0=0;
    	ch0->OutputChan1=1;
    	ch0->MasterAxis=-1;
    	ch0->LimitSwitchOptions=0x12c;
    	ch0->LimitSwitchNegBit=137;
    	ch0->LimitSwitchPosBit=137;
    	ch0->SoftLimitPos=1e+009;
    	ch0->SoftLimitNeg=-1e+009;
    	ch0->InputGain0=-1;
    	ch0->InputGain1=1;
    	ch0->InputOffset0=0;
    	ch0->InputOffset1=0;
    	ch0->OutputGain=-1;
    	ch0->OutputOffset=0;
    	ch0->SlaveGain=1;
    	ch0->BacklashMode=BACKLASH_OFF;
    	ch0->BacklashAmount=0;
    	ch0->BacklashRate=0;
    	ch0->invDistPerCycle=1;
    	ch0->Lead=0;
    	ch0->MaxFollowingError=10000000;
    	ch0->StepperAmplitude=250;
    
    	ch0->iir[0].B0=1;
    	ch0->iir[0].B1=0;
    	ch0->iir[0].B2=0;
    	ch0->iir[0].A1=0;
    	ch0->iir[0].A2=0;
    
    	ch0->iir[1].B0=1;
    	ch0->iir[1].B1=0;
    	ch0->iir[1].B2=0;
    	ch0->iir[1].A1=0;
    	ch0->iir[1].A2=0;
    
    	ch0->iir[2].B0=0.0166094;
    	ch0->iir[2].B1=0.0332189;
    	ch0->iir[2].B2=0.0166094;
    	ch0->iir[2].A1=1.60679;
    	ch0->iir[2].A2=-0.673229;
    
    	ch1->InputMode=ENCODER_MODE;
    	ch1->OutputMode=DAC_SERVO_MODE;
    	ch1->Vel=60000;
    	ch1->Accel=250000;
    	ch1->Jerk=4e+006;
    	ch1->P=7;
    	ch1->I=1e-005;
    	ch1->D=72;
    	ch1->FFAccel=0.00023;
    	ch1->FFVel=0.0311;
    	ch1->MaxI=2000;
    	ch1->MaxErr=3500;
    	ch1->MaxOutput=2000;
    	ch1->DeadBandGain=1;
    	ch1->DeadBandRange=0;
    	ch1->InputChan0=1;
    	ch1->InputChan1=1;
    	ch1->OutputChan0=1;
    	ch1->OutputChan1=1;
    	ch1->MasterAxis=-1;
    	ch1->LimitSwitchOptions=0x12c;
    	ch1->LimitSwitchNegBit=137;
    	ch1->LimitSwitchPosBit=137;
    	ch1->SoftLimitPos=1e+009;
    	ch1->SoftLimitNeg=-1e+009;
    	ch1->InputGain0=-1;
    	ch1->InputGain1=1;
    	ch1->InputOffset0=0;
    	ch1->InputOffset1=0;
    	ch1->OutputGain=-1;
    	ch1->OutputOffset=0;
    	ch1->SlaveGain=1;
    	ch1->BacklashMode=BACKLASH_OFF;
    	ch1->BacklashAmount=0;
    	ch1->BacklashRate=0;
    	ch1->invDistPerCycle=1;
    	ch1->Lead=0;
    	ch1->MaxFollowingError=10000000;
    	ch1->StepperAmplitude=250;
    
    	ch1->iir[0].B0=1;
    	ch1->iir[0].B1=0;
    	ch1->iir[0].B2=0;
    	ch1->iir[0].A1=0;
    	ch1->iir[0].A2=0;
    
    	ch1->iir[1].B0=1;
    	ch1->iir[1].B1=0;
    	ch1->iir[1].B2=0;
    	ch1->iir[1].A1=0;
    	ch1->iir[1].A2=0;
    
    	ch1->iir[2].B0=0.016609;
    	ch1->iir[2].B1=0.033219;
    	ch1->iir[2].B2=0.016609;
    	ch1->iir[2].A1=1.60679;
    	ch1->iir[2].A2=-0.673229;
    	
    	ch2->InputMode=ENCODER_MODE;
    	ch2->OutputMode=DAC_SERVO_MODE;
    	ch2->Vel=60000;
    	ch2->Accel=600000;
    	ch2->Jerk=1e+006;
    	ch2->P=0.8;
    	ch2->I=1e-005;
    	ch2->D=125;
    	ch2->FFAccel=0.000125;
    	ch2->FFVel=0.0294;
    	ch2->MaxI=2000;
    	ch2->MaxErr=3500;
    	ch2->MaxOutput=2000;
    	ch2->DeadBandGain=1;
    	ch2->DeadBandRange=0;
    	ch2->InputChan0=2;
    	ch2->InputChan1=1;
    	ch2->OutputChan0=2;
    	ch2->OutputChan1=1;
    	ch2->MasterAxis=-1;
    	ch2->LimitSwitchOptions=0x12c;
    	ch2->LimitSwitchNegBit=137;
    	ch2->LimitSwitchPosBit=137;
    	ch2->SoftLimitPos=1e+009;
    	ch2->SoftLimitNeg=-1e+009;
    	ch2->InputGain0=-1;
    	ch2->InputGain1=1;
    	ch2->InputOffset0=0;
    	ch2->InputOffset1=0;
    	ch2->OutputGain=-1;
    	ch2->OutputOffset=0;
    	ch2->SlaveGain=1;
    	ch2->BacklashMode=BACKLASH_OFF;
    	ch2->BacklashAmount=0;
    	ch2->BacklashRate=0;
    	ch2->invDistPerCycle=1;
    	ch2->Lead=0;
    	ch2->MaxFollowingError=10000000;
    	ch2->StepperAmplitude=250;
    
    	ch2->iir[0].B0=1;
    	ch2->iir[0].B1=0;
    	ch2->iir[0].B2=0;
    	ch2->iir[0].A1=0;
    	ch2->iir[0].A2=0;
    
    	ch2->iir[1].B0=1;
    	ch2->iir[1].B1=0;
    	ch2->iir[1].B2=0;
    	ch2->iir[1].A1=0;
    	ch2->iir[1].A2=0;
    
    	ch2->iir[2].B0=0.016609;
    	ch2->iir[2].B1=0.033219;
    	ch2->iir[2].B2=0.016609;
    	ch2->iir[2].A1=1.60679;
    	ch2->iir[2].A2=-0.673229;
    
    	ch4->InputMode=NO_INPUT_MODE;
    	ch4->OutputMode=DAC_SERVO_MODE;
    	ch4->Vel=0.5;
    	ch4->Accel=1;
    	ch4->Jerk=5;
    	ch4->P=0;
    	ch4->I=0;
    	ch4->D=0;
    	ch4->FFAccel=0;
    	ch4->FFVel=2047;
    	ch4->MaxI=2047;
    	ch4->MaxErr=1e+010;
    	ch4->MaxOutput=2047;
    	ch4->DeadBandGain=1;
    	ch4->DeadBandRange=0;
    	ch4->InputChan0=4;
    	ch4->InputChan1=1;
    	ch4->OutputChan0=4;
    	ch4->OutputChan1=1;
    	ch4->MasterAxis=-1;
    	ch4->LimitSwitchOptions=0x100;
    	ch4->LimitSwitchNegBit=0;
    	ch4->LimitSwitchPosBit=0;
    	ch4->SoftLimitPos=1e+009;
    	ch4->SoftLimitNeg=-1e+009;
    	ch4->InputGain0=1;
    	ch4->InputGain1=1;
    	ch4->InputOffset0=0;
    	ch4->InputOffset1=0;
    	ch4->OutputGain=-1;
    	ch4->OutputOffset=0;
    	ch4->SlaveGain=1;
    	ch4->BacklashMode=BACKLASH_OFF;
    	ch4->BacklashAmount=0;
    	ch4->BacklashRate=0;
    	ch4->invDistPerCycle=1;
    	ch4->Lead=0;
    	ch4->MaxFollowingError=10000000;
    	ch4->StepperAmplitude=250;
    
    	ch4->iir[0].B0=1;
    	ch4->iir[0].B1=0;
    	ch4->iir[0].B2=0;
    	ch4->iir[0].A1=0;
    	ch4->iir[0].A2=0;
    
    	ch4->iir[1].B0=1;
    	ch4->iir[1].B1=0;
    	ch4->iir[1].B2=0;
    	ch4->iir[1].A1=0;
    	ch4->iir[1].A2=0;
    
    	ch4->iir[2].B0=1;
    	ch4->iir[2].B1=0;
    	ch4->iir[2].B2=0;
    	ch4->iir[2].A1=0;
    	ch4->iir[2].A2=0;
    
    
    	// Enable the axes and set the destination
    	//EnableAxisDest(0,0);
    	//EnableAxisDest(1,0);
    	//EnableAxisDest(2,0);
    
    	EnableAxis (0);
    	EnableAxis (1);
    	EnableAxis (2);
    	EnableAxis (4);
    
    	// Set coordinates to x, y, z and a. A is disabled
    	DefineCoordSystem(0,1,2,-1);
    
    	// Configure input bits
    	//SetBitDirection (FEEDHOLDBIT, 0);
    	//SetBitDirection (CYCLESTARTBIT, 0);
    	//SetBitDirection (ESTOP, 0);
    	//SetBitDirection (HALTBIT, 0);
    	//SetBitDirection (RESTARTBIT, 0);
    	//SetBitDirection (CLAMP, 0);
    	//SetBitDirection (UNCLAMP, 0);
    	//SetBitDirection (ZEROALLBIT, 0);
    	//SetBitDirection (OVERTRAVEL, 0);
    	//SetBitDirection (OVERLOAD, 0);
    	//SetBitDirection (SPINDLE0SPEED, 0);
    	//SetBitDirection (SPINDLEATSPEED, 0);
    	//SetBitDirection (AIRPRESSOK, 0);
    
    	// Configure output bits
    	//SetBitDirection (DRAWBAR_OPEN, 1);
    	//SetBitDirection (DRIVE_ENABLE, 1);
    	//SetBitDirection (SPINDLE_ENABLE, 1);
    
    	// Print startup message to console
    	printf("Button Handler Start\n");
    
    	// Enable the axis drive
    	SetBit (DRIVE_ENABLE);
    	//Delay_sec (1);
    	//SetBit (SPINDLE_ENABLE);
    
    	// Continuous loop
    	while (1)
    	{
    		WaitNextTimeSlice();	// Delay until time slice
    		ButtonService ();		// Handle Button Presses
    	}
    }
    
    // ************************************************************************
    
    // Handle Buttons
    void ButtonService ()
    {
    	int result;
    
    	// Handle Drawbar Clamp
    	result = Debounce(ReadBit(CLAMP),&clampcount,&clamplast,&clamplastsolid);
    	if  (result == 1)
    	{
    		// Clamp drawbar if job is not running, spindle at 0 speed
    		if (!JOB_ACTIVE && ReadBit(SPINDLE0SPEED))
    		{
    			ClearBit (DRAWBAR_OPEN);
    			printf("Drawbar Closed\n");
    		}
    	}
    
    	// Handle Drawbar Unclamp
    	result = Debounce(ReadBit(UNCLAMP),&unclampcount,&unclamplast,&unclamplastsolid);
    	if  (result == 1)
    	{
    		// Clamp drawbar if job is not running, spindle at 0 speed
    		if (!JOB_ACTIVE && ReadBit(SPINDLE0SPEED))
    		{
    			SetBit (DRAWBAR_OPEN);
    			printf("Drawbar Open\n");
    		}
    	}
    	
    	// Handle FeedHold/Resume
    	result = Debounce(ReadBit(FEEDHOLDBIT),&fcount,&flast,&flastsolid);
    	if  (result == 1)
    	{
    		if (CS0_StoppingState == 0)
    		{
    			StopCoordinatedMotion();
    			printf("Feed Hold ON\n");
    		}
    		else
    		{
    			ResumeCoordinatedMotion();
    			printf("Feed Hold OFF\n");
    		}
    	}
    
    	// Handle Cycle Start
    	result = Debounce(ReadBit(CYCLESTARTBIT),&ccount,&clast,&clastsolid);
    	if  (result == 1)
    	{
    		DoPC(PC_COMM_EXECUTE);
    		printf("Execute\n");
    	}
    
    	// Handle ESTOP pressed
    	result = Debounce(ReadBit(ESTOP),&ecount,&elast,&elastsolid);
    	if  (result == 0)
    	{
    		printf("Emergency Stop ON\n");		
    		DoPC(PC_COMM_ESTOP);
    		ClearBit (DRIVE_ENABLE);
    		ClearBit (SPINDLE_ENABLE);
    		Estop = 1;	// Set a flag so that the release code only happens once
    	}
    	
    	// Handle ESTOP released
    
    	result = Debounce(ReadBit(ESTOP),&ecount2,&elast2,&elastsolid2);
    	if (result == 1)
    	{
    		if (Estop == 1)	// Check for flag
    		{
    			//DoPC(PC_COMM_IDLE);
    			printf("Emergency Stop OFF\n");
    			Estop = 0;
    			SetBit (DRIVE_ENABLE);
    			EnableAxis (0);
    			EnableAxis (1);
    			EnableAxis (2);
    			EnableAxis (4);
    			
    		}
    	}
    
    	
    	// Handle HALT
    	result = Debounce(ReadBit(HALTBIT),&hcount,&hlast,&hlastsolid);
    	if  (result == 1)
    	{
    		DoPC(PC_COMM_HALT);
    		printf("Job Halt\n");
    	}
    	
    	// Handle RESTART
    	result = Debounce(ReadBit(RESTARTBIT),&rcount,&rlast,&rlastsolid);
    	if  (result == 1)
    	{
    		DoPC(PC_COMM_RESTART);
    		printf("Job Restart\n");
    	}
    	
    	// Handle ZERO ALL
    	/*
    	result = Debounce(ReadBit(ZEROALLBIT),&zcount,&zlast,&zlastsolid);
    	if  (result == 1)
    	{
    		DoPCFloat(PC_COMM_SET_X,0.0);
    		DoPCFloat(PC_COMM_SET_Y,0.0);
    		DoPCFloat(PC_COMM_SET_Z,0.0);
    		printf("Zero All Axes\n");
    	}
    	*/
    }
    
    // ************************************************************************
    
    // Put a Float as a parameter and pass the command to the App
    int DoPCFloat(int cmd, float f)
    {
    	int result;
    	persist.UserData[PC_COMM_PERSIST+1] = *(int*)&f;
    	return DoPC(cmd);
    }
    
    
    // ************************************************************************
    
    // Pass a command to the PC and wait for it to handshake
    // that it was received by either clearing the command
    // or changing it to a negative error code
    int DoPC(int cmd)
    {
    	int result;
    	
    	persist.UserData[PC_COMM_PERSIST]=cmd;
    	
    	do
    	{
    		WaitNextTimeSlice();	
    	}while (result=persist.UserData[PC_COMM_PERSIST]>0);
    	
    	printf("Result = %d\n",result);
    
    	return result;
    }
    
    
    // ************************************************************************
    
    // Debounce a bit
    //
    // return 1 one time when first debounced high 
    // return 0 one time when first debounced low 
    // return -1 otherwise 
    #define DBTIME 300
    
    int Debounce(int n, int *cnt, int *last, int *lastsolid)
    {
    	int v = -1;
    	
    	if (n == *last)  // same as last time?
    	{
    		if (*cnt == DBTIME-1)
    		{
    			if (n != *lastsolid)
    			{
    				v = *lastsolid = n;  // return debounced value
    			}
    		}
    		if (*cnt < DBTIME)	(*cnt)++;
    	}
    	else
    	{
    		*cnt = 0;  // reset count
    	}
    	*last = n;
    	return v;
    }

    Quote Originally Posted by TomKerekes View Post
    Hi rbickle,

    I don't see anything obvious.

    What does the SSO on the KMotionCNC Screen do when the problem happens?

    If you have KMotion.exe running what is displayed on the Console and what displays on the Axis Screen when the problem happens?

    How are you running the Feedrate / Spindle Override code? What Thread? Normally that code would be added to your Initialization Program. Does it fail without this code running?

    How are M3, S and other M Codes configured in KMotionCNC | Tool Setup?

    Please post your Initialization Program.

    Regards




  5. #5
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4045
    Downloads
    0
    Uploads
    0

    Default Re: Spindle stops during a job

    Hi rbickle,

    As m_c pointed out the Soft Limits are only set to 1 billion. At 5600 counts/rev that would only be 178000 revs. I don't know what RPM you run at but at 3000RPM that would only be about an hour. Change to -1e30 and +1e30.

    Although I wouldn't normally expect a SoftLimit Feedhold to stop the Spindle so there still may be some other issue.

    Regards

    Regards
    TK http://dynomotion.com


  6. #6
    Member
    Join Date
    Jun 2004
    Location
    Scotland
    Posts
    355
    Downloads
    0
    Uploads
    0

    Default Re: Spindle stops during a job

    Quote Originally Posted by rbickle View Post
    Tom,
    I don't think there was anything different about the FRO/SSO when the spindle stopped. I did not look at the console or the axis screen, but I can tell that the spindle axis (4) was still enabled, as it drifts around some even when s=0. Also I checked the spindle relay during that problem and it was still engaged.
    Just because the spindle relay is still active, doesn't mean the spindle axis is still enabled. If the KFlop decides the axis needs disabled, it will disable the axis servo loop (IIRC this also sets any DAC to 0), display a message via the console telling you why, and if you check the Axis screen in KMotion, the tick will of disappeared from the enable box for that axis.

    Unless you have code to detect the axis disable, everything else will stay how it was prior to the disable, which would include your spindle enable relay.

    But as Tom says, a feedhold caused by soft limits shouldn't stop the spindle. Now I think about it, my mill just activated a feedhold, and the spindle kept running.

    Unfortunately, unless you can recreate the fault with the console window open, it's a bit of guessing game, as everything else looks OK.



  7. #7
    Member
    Join Date
    Feb 2011
    Location
    USA
    Posts
    48
    Downloads
    0
    Uploads
    0

    Default Re: Spindle stops during a job

    Ah, I understand. I'll make the change.
    I'll have to run some more parts while watching carefully and see if it happens again.
    Thanks for the info.

    Rick



  8. #8
    Member
    Join Date
    Feb 2011
    Location
    USA
    Posts
    48
    Downloads
    0
    Uploads
    0

    Default Re: Spindle stops during a job

    One other question. I notice that I keep having to restart threads 2 and 3, which are code for the FRO/SSO and MPG respectively. Thread 1 remains on, but 2 and 3 stop executing if the Estop is pressed and if KmotionCNC is running. If KmotionCNC is not running, this does not happen.

    Thanks,
    Rick



Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


About CNCzone.com

    We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

Follow us on


Our Brands

Spindle stops during a job

Spindle stops during a job