585,753 active members*
4,020 visitors online*
Register for free
Login
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2011
    Posts
    48

    E-Stop switch kills threads 2 and 3

    Quick questions for the gurus...

    I notice that my machine now kills threads 2 and 3, which are my MPG and SSO,DRO programs, whenever the E-stop switch is pressed. In thread 1, the program detects the pressing and releasing of the E-stop. I have code in the release of the E-stop switch that starts threads 2 and 3, but this does not seem to work. If I go into the C program tab and start them manually, then everything is fine. Its a bit of a pain to do this though, every time you hit the switch.

    This wasn't happening previously. I may have made a program change that is causing it.
    Any suggestions?

    Code:
    	// 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);
    			StartThread(2);
    			StartThread(3);
    			
    		}
    	}
    Thanks,
    Rick

  2. #2
    Join Date
    May 2006
    Posts
    4045

    Re: E-Stop switch kills threads 2 and 3

    Hi Rick,

    Off hand I can't see why that wouldn't restart Threads 2 and 3 if it is being called. Does the message print?

    btw A single Debounce of ESTOP can be used to indicate pressed and released.

    I think a better approach would be to eliminate the need for Threads 2 and 3 altogether by handling everything in a forever loop in your Init Progam in Thread #1

    Regards
    TK
    http://dynomotion.com

  3. #3
    Join Date
    Feb 2011
    Posts
    48

    Re: E-Stop switch kills threads 2 and 3

    Quote Originally Posted by TomKerekes View Post
    Hi Rick,

    Off hand I can't see why that wouldn't restart Threads 2 and 3 if it is being called. Does the message print?

    btw A single Debounce of ESTOP can be used to indicate pressed and released.

    I think a better approach would be to eliminate the need for Threads 2 and 3 altogether by handling everything in a forever loop in your Init Progam in Thread #1

    Regards
    Yes, the message prints to the console when the Estop is pressed and released.
    I also noticed when I cut and pasted the code that I could have simplified.

    I'll see what I can do to combine the programs.

    Thanks,
    Rick

Similar Threads

  1. Replies: 1
    Last Post: 01-09-2018, 10:40 PM
  2. Do I need an E-Stop switch?
    By Mike_Walls in forum CNC Machine Related Electronics
    Replies: 21
    Last Post: 05-31-2017, 09:48 PM
  3. Help me stop cutting fuzzy threads!
    By mioduz in forum MetalWork Discussion
    Replies: 12
    Last Post: 06-17-2012, 04:58 PM
  4. Adding E-Stop Switch
    By JohnLucas in forum Taig Mills / Lathes
    Replies: 10
    Last Post: 09-21-2011, 10:19 AM
  5. E-Stop Switch
    By crocky in forum Automation Technology Products
    Replies: 3
    Last Post: 10-10-2008, 04:34 PM

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
  •