|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
We are having problems with the encoder. The Code is as follows.
public class Shooter extends Subsystem { public CANTalon shooterMotorOne = new CANTalon(RobotMap.shooterMotorOne); CANTalon shooterMotorTwo = new CANTalon(RobotMap.shooterMotorTwo); CANTalon shooterMotorThree = new CANTalon(RobotMap.shooterMotorThree); CANTalon shooterMotorFour = new CANTalon(RobotMap.shooterMotorFour); public void updateDashboard() { double leftShootSpeed = shooterMotorOne.getSpeed(); SmartDashboard.putNumber("Speed",shooterMotorOne.g etSpeed()); System.out.println("Left Shoot Speed: " + leftShootSpeed); SmartDashboard.putNumber("Error: ", shooterMotorOne.getClosedLoopError()); } protected void initDefaultCommand() { setDefaultCommand (new Shoot(0)); } public void shoot(double speed) { shooterMotorOne.setFeedbackDevice(FeedbackDevice.C treMagEncoder_Relative); shooterMotorTwo.setFeedbackDevice(FeedbackDevice.C treMagEncoder_Relative); shooterMotorThree.setFeedbackDevice(FeedbackDevice .CtreMagEncoder_Relative); shooterMotorFour.setFeedbackDevice(FeedbackDevice. CtreMagEncoder_Relative); shooterMotorOne.reverseSensor(false); shooterMotorTwo.reverseSensor(false); shooterMotorThree.reverseSensor(true); shooterMotorFour.reverseSensor(true); shooterMotorOne.changeControlMode(TalonControlMode .Speed); shooterMotorTwo.changeControlMode(TalonControlMode .PercentVbus); shooterMotorThree.changeControlMode(TalonControlMo de.PercentVbus); shooterMotorFour.changeControlMode(TalonControlMod e.PercentVbus); double shooterP = Robot.prefs.getDouble("shooterP", 0.4); double shooterI = Robot.prefs.getDouble("shooterI", 0); double shooterD = Robot.prefs.getDouble("shooterD", 0); double shooterF = Robot.prefs.getDouble("shooterF", 0); double prefspeed = Robot.prefs.getDouble("prefspeed", 100); shooterMotorOne.setPID(shooterP, shooterI, shooterD, shooterF, 0, 0, 0); shooterMotorTwo.setPID(shooterP, shooterI, shooterD, shooterF, 0, 0, 0); shooterMotorThree.setPID(shooterP, shooterI, shooterD, shooterF, 0, 0, 0); shooterMotorFour.setPID(shooterP, shooterI, shooterD, shooterF, 0, 0, 0); shooterMotorOne.set(speed); shooterMotorTwo.set(speed); shooterMotorThree.set(speed); shooterMotorFour.set(speed); } The code provides no errors. When we run the robot everything functions correctly, and we get an error value yet we do not receive anything for speedL. We tried 2 old encoders, and even built a new encoder. |
|
#2
|
||||
|
||||
|
Re: VersaPlanetary Integrated Encoder
Quote:
Post the output from RioLog when you run your code. |
|
#3
|
|||||
|
|||||
|
Re: VersaPlanetary Integrated Encoder
First off debugging. Is the status light on your SRX encoder green or yellow? If not, you don't have power or you've assembled it wrong and it can't see the magnet. If you spin the wheel by hand, do you see a change in feedback or error? If not, there may be a problem with your cable or encoder.
Secondly, you should have a non-zero value for F. For initial tuning, you want PID = 0, F = number. Then tweak F up until you have 0 error at your target speed. Thirdly, if all these are tied together in one system, it's better to have a single feedback and PID, and slave the other talons to the one that's doing PID. You have to do that anyways if you only have one. Check the Talon Software Reference Manual for info on that. Thirdly, I'd rather you weren't setting ALL that in the Shoot function. It's fine for debugging, but the final code should have most of that in an initialize function and the Set calls only in Shoot. Lastly, let me know if you haven't figured this out by Saturday and I can swing by your shop and see if I can help. |
|
#4
|
|||
|
|||
|
Re: VersaPlanetary Integrated Encoder
Quote:
|
|
#5
|
|||||
|
|||||
|
Re: VersaPlanetary Integrated Encoder
No light means no power. Check your cables and connections.
|
|
#6
|
|||
|
|||
|
Re: VersaPlanetary Integrated Encoder
We fixed it!!! They didn't see the broken cable at first! Thank you
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|