Go to Post There are no rules specifically prohibiting the use of cryogenically preserved legumes on the robot. - dtengineering [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 29-03-2016, 21:43
Jeringo Jeringo is offline
Registered User
FRC #4749
 
Join Date: Jan 2016
Location: Atlanta
Posts: 10
Jeringo is an unknown quantity at this point
TalonSRX encoder confusion java

I am getting a little confused on encoders for the TalonSRX.
i am trying to do three things, first thing is the software limit. How exactly does it work. we have a shooter that tilts the upmost position it -1000 and all the way to the floor is 3500 i've tried swapping the values but it only lets me tilt the shooter down. the second thing is how to i reset the encoder or set it to 0? and the third thing is how to i tell the motor to go to a certain position?


Code:
Tilt.setFeedbackDevice(FeedbackDevice.AnalogEncoder);
Tilt.setForwardSoftLimit(-1000.00);
Tilt.enableForwardSoftLimit(true);
Tilt.setReverseSoftLimit(3501.00);
Tilt.enableReverseSoftLimit(true);

int pulseWidthPos = Tilt.getPulseWidthPosition();
int pulseWidthUs = Tilt.getPulseWidthRiseToFallUs();
int PeriodUs = Tilt.getPulseWidthRiseToRiseUs();
int pulseWidthVel = Tilt.getPulseWidthVelocity();
FeedbackDeviceStatus sensorStatus = Tilt.isSensorPresent(FeedbackDevice.CtreMagEncoder_Absolute);
boolean sensorPluggedIn = (FeedbackDeviceStatus.FeedbackStatusPresent == sensorStatus);
  #2   Spotlight this post!  
Unread 29-03-2016, 22:25
GRSICP GRSICP is offline
Greta Rauch
FRC #5822 (WolfByte)
Team Role: Programmer
 
Join Date: Oct 2015
Rookie Year: 2010
Location: Chicago
Posts: 18
GRSICP is an unknown quantity at this point
Re: TalonSRX encoder confusion java

I don't know the answer to the questions about the limits as I have not used them yet. However, I can help with getting the Talon to a certain position.

Here is an example of initialization of a Talon:
Code:
armR = new CANTalon(1); 
armR.setFeedbackDevice(FeedbackDevice.QuadEncoder); //Set the feedback device that is hooked up to the talon
armR.setPID(0.2, 0.001, 100, 0.00, 360, 12, 0); //Set the PID constants (p, i, d), you will need to do some tweaking to get these right
Here is the code needed to get the arm to a certain location:
Code:
armR.changeControlMode(TalonControlMode.Position); //Change control mode of talon, default is PercentVbus (-1.0 to 1.0)
armR.set(height); //height is the value you are looking to move to
armR.reverseSensor(true); 
armR.enableControl(); //Enable PID control on the talon
A note on the reverse sensor line: in our case, the reading from the QuadEncoder was negative so we needed to both feed .set a negative value and use the reverseSensor method.

In terms of setting it to 0, here is the code we use:
Code:
talonName.setPosition(0);
I hope this helps!
  #3   Spotlight this post!  
Unread 29-03-2016, 23:05
Jeringo Jeringo is offline
Registered User
FRC #4749
 
Join Date: Jan 2016
Location: Atlanta
Posts: 10
Jeringo is an unknown quantity at this point
Re: TalonSRX encoder confusion java

Quote:
Originally Posted by GRSICP View Post
I don't know the answer to the questions about the limits as I have not used them yet. However, I can help with getting the Talon to a certain position.

Here is an example of initialization of a Talon:
Code:
armR = new CANTalon(1); 
armR.setFeedbackDevice(FeedbackDevice.QuadEncoder); //Set the feedback device that is hooked up to the talon
armR.setPID(0.2, 0.001, 100, 0.00, 360, 12, 0); //Set the PID constants (p, i, d), you will need to do some tweaking to get these right
Here is the code needed to get the arm to a certain location:
Code:
armR.changeControlMode(TalonControlMode.Position); //Change control mode of talon, default is PercentVbus (-1.0 to 1.0)
armR.set(height); //height is the value you are looking to move to
armR.reverseSensor(true); 
armR.enableControl(); //Enable PID control on the talon
A note on the reverse sensor line: in our case, the reading from the QuadEncoder was negative so we needed to both feed .set a negative value and use the reverseSensor method.

In terms of setting it to 0, here is the code we use:
Code:
talonName.setPosition(0);
I hope this helps!
how could i use a joystick for this?
  #4   Spotlight this post!  
Unread 30-03-2016, 08:55
Camilo86's Avatar
Camilo86 Camilo86 is offline
Registered User
AKA: camilo
FRC #0125 (Nutrons)
Team Role: Programmer
 
Join Date: Jun 2013
Rookie Year: 2012
Location: Boston
Posts: 21
Camilo86 is a glorious beacon of lightCamilo86 is a glorious beacon of lightCamilo86 is a glorious beacon of lightCamilo86 is a glorious beacon of lightCamilo86 is a glorious beacon of lightCamilo86 is a glorious beacon of light
Re: TalonSRX encoder confusion java

Quote:
Originally Posted by Jeringo View Post
how could i use a joystick for this?
You can make a variable to hold your arm distance setPoint, and add/subtract from this value using the joystick's output value. Notice that joysticks have a range of -1 to 1, so you might have to multiply some constant > 1 to your joystick output so that your joystick can have a fast effect on the setpoint. This will all the depend on the distancePerPulse you currently have.
__________________
Hopper finalist 2015
Dean's List winner 2015
  #5   Spotlight this post!  
Unread 30-03-2016, 11:20
ozrien's Avatar
ozrien ozrien is offline
Omar Zrien
AKA: Omar
no team
Team Role: Mentor
 
Join Date: Sep 2006
Rookie Year: 2003
Location: Sterling Heights, MI
Posts: 521
ozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant future
Re: TalonSRX encoder confusion java

Jerigo,
Have you tried looking at the Talon SRX Software Reference Manual? See the manufacturer's website.
  #6   Spotlight this post!  
Unread 30-03-2016, 14:20
GRSICP GRSICP is offline
Greta Rauch
FRC #5822 (WolfByte)
Team Role: Programmer
 
Join Date: Oct 2015
Rookie Year: 2010
Location: Chicago
Posts: 18
GRSICP is an unknown quantity at this point
Re: TalonSRX encoder confusion java

Quote:
Originally Posted by ozrien View Post
Jerigo,
Have you tried looking at the Talon SRX Software Reference Manual? See the manufacturer's website.
Here is the link:
https://www.ctr-electronics.com/Talo...e%20Manual.pdf
Closed Thread


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 10:02.

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