Go to Post The terror level was lowered to MOE green for this event. - AdamHeard [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 23-01-2016, 11:40
ToMoPAnae's Avatar
ToMoPAnae ToMoPAnae is offline
Registered User
AKA: Patrick Fischer
FRC #3620 (Average Joes)
Team Role: Driver
 
Join Date: Jan 2015
Rookie Year: 2015
Location: St. Joseph
Posts: 8
ToMoPAnae is a glorious beacon of lightToMoPAnae is a glorious beacon of lightToMoPAnae is a glorious beacon of lightToMoPAnae is a glorious beacon of lightToMoPAnae is a glorious beacon of light
CAN Talon Speed Control Mode Trouble with Encoder Feedback

My team is having trouble getting the speed control setting to work with our CAN Talon. We cannot get the Talon to respond to changes in the error or the set point of desired speed. We know that our encoder is working correctly because we can see changes in encoder position and velocity through both the RoboRio and our program. We have firmware version 2.0 on the CAN Talons and the Talon is connected to a Quad encoder. We cannot even get the Talon to tell the motor to spin regardless of the set point. The LEDs on the Talon stay solid orange while this program is running, regardless of the set point. If we are in vBus mode the Talon works correctly. We are using a 775 Pro motor. The encoder is an Armabot RS7.

This is the code that we are running. We used the code from the software reference guide for how to use the speed mode of control with java. We removed parts of their code that were unnecessary. Any help or suggestions would be greatly appreciated.

Code:
public class Robot extends IterativeRobot {
    
    CANTalon _talon = new CANTalon(2);
    Joystick joy = new Joystick(0);
    StringBuilder sb = new StringBuilder();
    int _loops = 0;
    double target_Speed = 0;
	
    public void robotInit() {
    	_talon.changeControlMode(TalonControlMode.Speed);
    	_talon.setFeedbackDevice(FeedbackDevice.QuadEncoder);
    	_talon.reverseSensor(false);
    	_talon.configEncoderCodesPerRev(12);
    	_talon.configNominalOutputVoltage(+0.0f, -0.0f);
    	_talon.configPeakOutputVoltage(+12.0f, -12.0f);
    	_talon.setProfile(0);
    	_talon.setP(0);
    	_talon.setI(0);
    	_talon.setD(0);
    	_talon.setF(0);
    	
    }
    
    public void teleopPeriodic() {
    	double leftYStick = joy.getAxis(AxisType.kY);
    	double motorOutput = _talon.getOutputVoltage() / _talon.getBusVoltage();
    	sb.append("\tout");
    	sb.append(motorOutput);
    	sb.append("\tspd");
    	sb.append(_talon.getSpeed());
    	sb.append("\tjoy");
    	sb.append(leftYStick);
    		
    		target_Speed = 1000;
    		_talon.set(target_Speed);
    		sb.append("\terr");
    		sb.append(_talon.getClosedLoopError());
    		sb.append("\ttrg");
    		sb.append(target_Speed);
    		sb.append("\tencV");
    		sb.append(_talon.getEncVelocity());
    	
    	if(++_loops >= 10)
    	{
    		_loops = 0;
    		System.out.println(sb.toString());
    	}
    	sb.setLength(0);
    
    }
}
Attached Files
File Type: java Robot.java (2.2 KB, 5 views)

Last edited by ToMoPAnae : 23-01-2016 at 11:42. Reason: Attached Robot.java file
  #2   Spotlight this post!  
Unread 23-01-2016, 11:56
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: 522
ozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond repute
Re: CAN Talon Speed Control Mode Trouble with Encoder Feedback

All of your gains are zero. So error X zero => zero throttle.
Here's the relevant part...
Code:
	_talon.setP(0);
    	_talon.setI(0);
    	_talon.setD(0);
    	_talon.setF(0);
Can you look at section 12.4 for a walkthrough on speed servo.
Start with calculating feedforward so you can get "close" to your target speed. Then start with a soft p-gain and increment until the closed-loop response meets your requirements.
http://www.ctr-electronics.com/talon...ical_resources
  #3   Spotlight this post!  
Unread 23-01-2016, 11:57
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: 522
ozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond repute
Re: CAN Talon Speed Control Mode Trouble with Encoder Feedback

Since you are setting your gains once in robotInit, you could use the web-based config to modifying your gain values on the fly. And then once your happy with them you can modify the java code to assign those values. That way you don't have to rebuild => redeploy every time you want to try a new value.
  #4   Spotlight this post!  
Unread 23-01-2016, 12:30
ToMoPAnae's Avatar
ToMoPAnae ToMoPAnae is offline
Registered User
AKA: Patrick Fischer
FRC #3620 (Average Joes)
Team Role: Driver
 
Join Date: Jan 2015
Rookie Year: 2015
Location: St. Joseph
Posts: 8
ToMoPAnae is a glorious beacon of lightToMoPAnae is a glorious beacon of lightToMoPAnae is a glorious beacon of lightToMoPAnae is a glorious beacon of lightToMoPAnae is a glorious beacon of light
Re: CAN Talon Speed Control Mode Trouble with Encoder Feedback

Ok thanks for the help! We will let you know if this fixes the problem.
  #5   Spotlight this post!  
Unread 23-01-2016, 14:18
ToMoPAnae's Avatar
ToMoPAnae ToMoPAnae is offline
Registered User
AKA: Patrick Fischer
FRC #3620 (Average Joes)
Team Role: Driver
 
Join Date: Jan 2015
Rookie Year: 2015
Location: St. Joseph
Posts: 8
ToMoPAnae is a glorious beacon of lightToMoPAnae is a glorious beacon of lightToMoPAnae is a glorious beacon of lightToMoPAnae is a glorious beacon of lightToMoPAnae is a glorious beacon of light
Re: CAN Talon Speed Control Mode Trouble with Encoder Feedback

Changing the P-value fixed our problem. Thank for the help!
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 02:58.

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