Go to Post I'm so conflicted right now. On one hand, you made the same page as a celebrity. On the other hand.... Justin Bieber. - Akash Rastogi [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
  #9   Spotlight this post!  
Unread 24-11-2015, 00:13
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 - so I got my hardware setup. I have 2 talon srx's setup with 2 of the optical encoders from andymark. I created a test button and added the following to the execute on the command for the button. It starts and stops the motor but I'm not sure it is really doing what I want. Basically I'm working towards a command that will cause the robot to travel forward x inches to be used in autonomous mode. The code below is what I used...the position on the encoder doesn't seem to wind up anywhere close to where I expect it to be also I think I'd have better results if it was running slower or there was a load on the wheel. The output from the print statements is before the code for ease of following. Obviously I'm totally overlooking something so any guidance is appreciated.


Start of Execute
-264
-264


Code:
    	System.out.println("Start of Execute");
    	RobotDrive drive = RobotMap.driveSystemdrive;
    	CANTalon talon =  RobotMap.driveSystemCANTalon1;
    	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.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.set(5000); //Tells the talon to go to 5000 encoder counts, using the preset PID parameters.
    	System.out.println(talon.getEncPosition());
    	finished = true;
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:51.

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