Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   VersaPlanetary Integrated Encoder (http://www.chiefdelphi.com/forums/showthread.php?t=153934)

Kram.Niestmaub 19-01-2017 18:24

VersaPlanetary Integrated Encoder
 
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.

granjef3 19-01-2017 18:39

Re: VersaPlanetary Integrated Encoder
 
Quote:

Originally Posted by Kram.Niestmaub (Post 1633650)
We are having problems with the encoder. The Code is as follows.
...snip...

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.

What is the error value you are getting, and where are you seeing it?
Post the output from RioLog when you run your code.

Kevin Sevcik 19-01-2017 18:47

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.

Kram.Niestmaub 19-01-2017 18:56

Re: VersaPlanetary Integrated Encoder
 
Quote:

Originally Posted by Kevin Sevcik (Post 1633656)
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.

It turns out the encoder has no lights, our mechanical is rebuilding them as we speak. As for PID and other points this is simple prototype code thank you for the suggestions.

Kevin Sevcik 19-01-2017 19:04

Re: VersaPlanetary Integrated Encoder
 
No light means no power. Check your cables and connections.

Kram.Niestmaub 19-01-2017 19:52

Re: VersaPlanetary Integrated Encoder
 
Quote:

Originally Posted by Kevin Sevcik (Post 1633664)
No light means no power. Check your cables and connections.

We fixed it!!! They didn't see the broken cable at first! Thank you


All times are GMT -5. The time now is 15:32.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi