![]() |
Issues with LimitSwitch
Hey guys!
I'm having troubles with programming limit switches. We're using a limit switch to stop our arms from going too low. The problem I'm having, is that the limit switch stops the motor, but then the entire robot stops working. Obviously that's a problem with the code. I'm not sure what to do though. I'll paste all of our robot code. Code:
package org.usfirst.frc.team6077.robot;Code:
while (counter.get() > 0) { |
Re: Issues with LimitSwitch
Quote:
You'd be right. What does a while loop do? Yours will continuously be true so it will never break the loop. What is the point of the counter by the way? There's probably a way to do what you want without this. |
help im new to this
I was researching how to program xbox controller to arcade and use one analog stick. Im using talons so what is speed control? and how do i program the xbox controller
public void teleopPeriodic() { while (isOperatorControl() && isEnabled()) { drive.setSafetyEnabled(true); double speedControl = 1; double joystickLeftY = mXboxController.getRawAxis(1)*speedControl; double joystickLeftX = mXboxController.getRawAxis(0)*-1*speedControl; drive.arcadeDrive(joystickLeftY, joystickLeftX); |
Re: Issues with LimitSwitch
It shouldn't. When the lever isn't pressed the value is supposed to be 0, correct?
|
Re: Issues with LimitSwitch
Quote:
|
Re: Issues with LimitSwitch
> while (counter.get() > 0)
You never initialize the counter. While that may be ok, I suggest doing that in RobotInit, just in case. At a minimum, I think you have to tell it which DIO channel to watch. However, it doesn't really do anything in your code. It counts the number of presses, so it should always be >0 after the first press. You either want to see if it is pressed, or not. It doesn't do you much good to count the number of times it is pressed. |
Re: Issues with LimitSwitch
Quote:
|
Re: Issues with LimitSwitch
Quote:
Code:
switch = DigitalInput(0) |
Re: Issues with LimitSwitch
Quote:
|
Re: Issues with LimitSwitch
Quote:
Errors? Doesn't execute the code? Which DIO port is it on? |
Re: Issues with LimitSwitch
Quote:
Code:
package org.usfirst.frc.team6077.robot; |
Re: Issues with LimitSwitch
At the beginning of OperatorControl, you check the limit switch, and stop slidemotor if it the switch is true.
So, make sure the limit switch returns 1 (true) when it is reached, and 0 (false) when it is not. However, you code continues to execute, and at: Quote:
|
Re: Issues with LimitSwitch
Quote:
Code:
if (limit1.get() == true) { |
Re: Issues with LimitSwitch
That would work better. I didn't look at your code in detail, so check that your code will move the arm away from the limit switch, or else your arm will permenantly stop when the limit switch is hit.
|
| All times are GMT -5. The time now is 08:04 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi