ROBOTC.net forums
http://robotc.net/forums/

Programming an Emergency Shutdown
http://robotc.net/forums/viewtopic.php?f=11&t=9268
Page 1 of 1

Author:  Houdyschell_lab [ Mon Aug 25, 2014 10:59 pm ]
Post subject:  Programming an Emergency Shutdown

I need to program a conveyor belt that can be shut down while it is going through the code. From what I understand, I can't use a while loop or an if-else statement because both of these only check for a change in their condition once each time the robot performs its program. I need to use a code that will continuously check for a change in the conditions as it performs the main code. How would I go about doing this?

Author:  CARBOT [ Tue Aug 26, 2014 8:39 pm ]
Post subject:  Re: Programming an Emergency Shutdown

Try something like this...

conveyor_motor = ON
WHILE conveyor_motor = ON
IF stop_button = true
conveyor_motor = OFF
ENDIF
ENDWHILE
do stuff with conveyor stopped

Author:  JohnWatson [ Wed Aug 27, 2014 9:38 am ]
Post subject:  Re: Programming an Emergency Shutdown

This is one of those rare instances (at least in this level of programming) where multitasking is a valid, efficient option. You can see a brief overview of ROBOTC's multitasking implementation here (along with a rough psuedocode of the emergency stop button implementation) and an overview of all of the ROBOTC for Cortex multitasking commands here.

You can also find an overview of the Task Status debugger window here (useful to keep track of which tasks are being run any at any point in your program).

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/