View Single Post
  #12   Spotlight this post!  
Unread 21-10-2010, 21:47
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,880
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: How do I use interrupts?

Adding to Ether's idea, you might encapsulate the Motor speed command in a subvi all by itself that everyone calls to set that motor speed. With an optional input for the emergency stop flag.

Then the interrupt handler calls it to set the emergency stop flag (& speed to zero), while the state machine calls it for normal operation. The subvi only allows one caller at a time, so you avoid the race condition of setting the speed in two different places near-simultaneously.
In the subvi if the emergency stop flag is set, only an explicit reset allows non-zero motor speeds.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
Reply With Quote