|
Page 1 of 1
|
[ 5 posts ] |
|
| Author |
Message |
|
maths222
Rookie
Joined: Wed Dec 01, 2010 5:15 pm Posts: 22
|
 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 |
|
 |
|
mattallen37
Expert
Joined: Thu Sep 29, 2011 11:09 pm Posts: 158 Location: Michigan USA
|
 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 |
|
 |
|
DiMastero
Expert
Joined: Wed Jun 30, 2010 7:15 am Posts: 179
|
 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 |
|
 |
|
magicode
Moderator
Joined: Tue Sep 14, 2010 9:19 pm Posts: 496
|
 Re: End-of-program Routine
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 |
|
 |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2905 Location: Rotterdam, The Netherlands
|
 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
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Wed Mar 28, 2012 1:39 am |
|
|
|
Page 1 of 1
|
[ 5 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 8 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
|
|