View unanswered posts | View active topics It is currently Sat Aug 02, 2014 4:35 am






Reply to topic  [ 5 posts ] 
End-of-program Routine 
Author Message
Rookie
User avatar

Joined: Wed Dec 01, 2010 5:15 pm
Posts: 30
Post End-of-program Routine
Is there any way to edit the built-in routine when the program ends--it kills motors, etc. It would allow the ability to kill a motor being run through a separate motor controller.


Tue Mar 27, 2012 5:01 pm
Profile
Expert

Joined: Thu Sep 29, 2011 11:09 pm
Posts: 184
Location: Michigan USA
Post Re: End-of-program Routine
I haven't used ROBOTC enough to know if this applies, but in NXC I set the abort flag to false (disable exiting a program when the dark gray button is pressed), and then periodically poll the button. If it is pressed, then I make it run my own "shutdown" function, and then finally terminate the program. This allows me to do anything I want before the program ends. Of course, this only applies to the instances where I opt to terminate the program through the button user interface instead of from the computer through USB, or some other way.

_________________
Matt


Tue Mar 27, 2012 9:21 pm
Profile WWW
Expert

Joined: Wed Jun 30, 2010 7:15 am
Posts: 181
Post Re: End-of-program Routine
yup RobotC has something similar: you can change how many times you have to click the gray button for the program to turn off. So you could have an extra task that you start at the beginning of your program that continuously checks for the gray button to be pressed and can then run a shutdown sequence.

I don't have access to RobotC right now but most of the stuff you'll need be in the help menu (F1), under NXT Functions --> buttons, methinks.

_________________
leonoverweel.com


Tue Mar 27, 2012 11:06 pm
Profile WWW
Moderator
Moderator
User avatar

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Post Re: End-of-program Routine
DiMastero wrote:
yup RobotC has something similar: you can change how many times you have to click the gray button for the program to turn off. So you could have an extra task that you start at the beginning of your program that continuously checks for the gray button to be pressed and can then run a shutdown sequence.

I don't have access to RobotC right now but most of the stuff you'll need be in the help menu (F1), under NXT Functions --> buttons, methinks.

I don't think that was the question he was asking. I think he's looking for something similar to a destructor. But I don't know how to code for that functionality.

_________________
sudo rm -rf /


Tue Mar 27, 2012 11:34 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3170
Location: Rotterdam, The Netherlands
Post Re: End-of-program Routine
There is no "hook" available to you in userspace to handle a program exit. The firmware does have one, which it attaches to your program. This turns off your motors when your program exits and perhaps does some other cleanups, too.

- Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Wed Mar 28, 2012 1:39 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.