E-Stop switch kills threads 2 and 3


Results 1 to 3 of 3

Thread: E-Stop switch kills threads 2 and 3

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

    Default 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

    Similar Threads:


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

    Default 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

    Regards
    TK http://dynomotion.com


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

    Default 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



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

E-Stop switch kills threads 2 and 3

E-Stop switch kills threads 2 and 3