View Single Post
  #4   Spotlight this post!  
Unread 15-11-2014, 12:40
nickphowell nickphowell is offline
Registered User
FRC #4824
 
Join Date: Nov 2014
Location: Logansport, IN
Posts: 4
nickphowell is an unknown quantity at this point
Re: Limit Switch Help

Quote:
Originally Posted by Mark McLeod View Post
  1. You really don't want to be addressing one motor from two conflicting places at the same time. That's why they fight each other. Are you also setting the same motors in both False cases? That would be telling it to go and stop at the same time.
  2. You need a Wait (say 10ms) in your loops otherwise you threaten to overload and lock up your CPU.
Instead, make all your decisions about what you want the motor to do, then set the motor only once.
Here's an example for a Relay. Just replace the Relay with your motor in the sequence you want.
Since you are keying off two different limit switches you can also select and pass in the corresponding limit switch name or reference.
How do you wire and use a relay? We are a brand new programming team, so we do not know everything there is to know......yet.

We went ahead and tried a new chunk of code, and that is not working either. However, it worked better than previously. What went wrong is our "Up" case would not work properly. The motors would not work when this case was triggered, but the "Default" and the "Down" cases worked perfectly. The "Default" case just sets the motor output to 0.

Here are pictures of what the code looks like right now.
http://imgur.com/yLUmJ8J
http://imgur.com/f80i1KW
Reply With Quote