View Single Post
  #10   Spotlight this post!  
Unread 22-02-2011, 11:16
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: SPIKEs malfunctioning in "Reverse"

Quote:
Originally Posted by smcmahon View Post
What's the proper way to program the Spike relays to accomplish what I described above?
I can think of three "proper" ways to do it. One is conceptually simple but has nested case statements that are hard to read at a glance. One is elegant but unobvious, using boolean arrays to derive a single number that selects from four cases. My favorite isn't exactly pretty, but it's small and easy to explain.

Place two Select functions (you'll find them in the Comparison palette). Wire button 1 to the s input (labeled with a question mark) of the first one. The f (bottom) input should have a relay "Off" constant, and the t (top) input should have a relay "Forward". The second Select's s input should be wired from button 2, the f input from the output of the first Select, and the the t input should have a relay "Reverse". The output of the second Select goes to the input of a Relay Set.

When neither button is pressed, the Off is selected through to the relay. When button 1 is pressed (and button 2 is not), the relay sees the Forward. When button 2 is pressed, the relay is set Reverse.

Does that make sense?