Quote:
Originally Posted by Sparkyshires
Now, a couple things you may want to look at is decreasing the speed, so that you don't break the limit switch  or having maybe a time for it to slow down so that you don't burn out the motors by immediately flipping it in reverse.
|
Another thing to consider is a timeout so that if the limit switch is not reached in a reasonable time, the motor still turns off. In a competition or practice it is possible (perhaps even common) for a limit switch to become damaged or disconnected, or for mechanical parts to become bent or misaligned enough that the switch never gets activated. Ask yourself what will happen if that occurs.
If your motor drives a mechanism that will hit a hard stop if the motor keeps running, then bad things will most likely happen if the limit switch is not seen by your code. The mechanism might be damaged, or the motor may pull enough current to burn out. But if your code turns off the motor if it reaches a limit switch OR after running say 50% longer than it should have taken to reach the limit normally, disaster might be avoided.
By the way, if you want to do this one better, remember that the timeout should never occur if the mechanism and limit switch are working properly. If your code does see this timeout, you might want to display a message on the driver station that says the limit switch should be checked. This is one way to start implementing self diagnostic code. Our team has never gotten to that level of sophistication, but has considered it and is working to get there someday.