View Single Post
  #2   Spotlight this post!  
Unread 18-02-2008, 00:53
Jon Stratis's Avatar
Jon Stratis Jon Stratis is offline
Electrical/Programming Mentor
FRC #2177 (The Robettes)
Team Role: Mentor
 
Join Date: Feb 2007
Rookie Year: 2006
Location: Minnesota
Posts: 3,747
Jon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond repute
Re: Using Limit Switches with the Arm

We've had similar problems with understanding what certain parts are supposed to do - it can get very confusing. Just tonight i tried a different tactic with one of the students and it seemed to make everything a LOT clearer. Set everything up in a big truth table, and then build your conditionals from that. I'm not sure i understand your situation well enough to help with a truth table for you specifically, but here's the situation that we have:

two buttons on the controller: B1 spins a wheel in to suck up a ball, while B2 spins it out to spit out a ball. In both cases, we only want the wheel spinning as long as the button is pressed. If both buttons are pressed at once, we don't care what is happening.

a limit switch: When the ball hits the limit switch, we know the ball is in our traveling position, so we don't want the motors to be able to spin inwards anymore (but they CAN spin outwards).

so the truth table would be:
Code:
 B1 | B2 | S1 | wheels
----------------------
  T |  T |  T |  (not in)
  T |  T |  F |  (don't care)
  T |  F |  T |  stop
  T |  F |  F |  in
  F |  T |  T |  out
  F |  T |  F |  out
  F |  F |  T |  stop
  F |  F |  F |  stop
Which we can turn into psudocode with:
Code:
if (B1 is pressed and S1 is not pressed) 
    spin the wheels in   				 //this happens for lines 2 and 4
else if (B2 is pressed)					 
    spin the wheels out					 //this happens for lines 1, 5, and 6
else									 
    stop the wheels					 //this happens for lines 3, 7, and 8
I think if you did something similar, it might help you think about the situation a little easier. The key is finding the rows that have a similar output, and grouping those together into if statements.