View Single Post
  #8   Spotlight this post!  
Unread 15-07-2008, 11:16
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,801
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: 2002 FRC Controller...

You want to create a software "latch" that remembers the emergency stop button was pushed.

Up at the top declare a variable that will be your latch.
Code:
emergency_stop VAR byte ' Stop until power cycle
Make sure you initialize it BEFORE your MainLoop:
Code:
emergency_stop = 0
Inside your main loop check p2_sw_aux1 to see if you should stop.
Code:
If p2_sw_aux1 = 1 then emergency_stop = 1
emergency_stop will only get set to 1. It never resets to 0 anywhere unless you power cycle.

Then immediately before your Serout, test emergency_stop and turn everything off.
Code:
If emergency_stop = 0 then nevermind:
    PWM1 = 0
    PWM2 = 0
 'and so on (also decide how you want your relays set)
nevermind:
You could also put an alternate Serout command inside the If with 127's hardcoded in place of the PWM variables.

Another way to do it would be to prevent the regular Serout from being called at all by wrapping it with your emergency_stop check and the Master controller will shut everything down for you. This'll force the "Basic Run Err" light to come on in about a tenth of a second.
Code:
If emergency_stop = 1 then nevermind:
    Serout(...
nevermind:
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 15-07-2008 at 14:33.