Go to Post No one has ever said 'my intake can collect [game element] too quickly.' - JamesCH95 [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #17   Spotlight this post!  
Unread 24-11-2015, 22:27
riftware riftware is offline
Parent Mentor
AKA: Andrew Chandler
FRC #0031
Team Role: Mentor
 
Join Date: Dec 2013
Rookie Year: 2011
Location: Tulsa
Posts: 27
riftware is an unknown quantity at this point
Re: Using encoder with talon SRX

Ok - I seem to have gotten it working. Understanding is coming slowly. By calling set or setPosition (either seems to work?) I am basically telling the system the encoder current position is 9158 away from a 0 error state, at which point the PID system works to try and correct that. These values seem to work for me, not really sure why (placebo effect maybe?) but the longer version of setPid really seemed to cut down on the overshoot issue. The following code isn't pretty and I'm definitely cleaning it up but it gives me repeatable results. If anyone has any comments or wants to help me know why the values I've chosen seem to work well I'll be happy but I'm no longer banging my head against the wall. Thank you to everyone who patiently helped out. I'm excited that we may have a more intelligent autonomous mode than previous years (drive forward 4 seconds to get into next zone).
Code:
    protected void execute() {
    	if(busy) {return;}
    	busy = true;
    	finished = false;
    	System.out.println("Start of Execute");
    	RobotDrive drive = RobotMap.driveSystemdrive;
    	CANTalon talon =  RobotMap.driveSystemCANTalon2;
    	talon.changeControlMode(ControlMode.Position); //Change control mode of talon, default is PercentVbus (-1.0 to 1.0)
    	talon.setFeedbackDevice(FeedbackDevice.QuadEncoder); //Set the feedback device that is hooked up to the talon
    
    	talon.setPID(0.5, 0.001, 0.00, 0.00, 360, 36, 0); //Set the PID constants (p, i, d)
    	
    	talon.enableControl(); //Enable PID control on the talon
    	int currentPosition = talon.getEncPosition();
    	System.out.println(currentPosition);
    	talon.setPosition( 9158); 
    }

// Make this return true when this Command no longer needs to run execute()
    protected boolean isFinished() {
    	if(RobotMap.driveSystemCANTalon2.getPosition() < 80){
    		finished = true;
    		busy = false;
    	}
        return finished;
    }
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 11:52.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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