View Single Post
  #2   Spotlight this post!  
Unread 26-01-2015, 15:59
Thad House Thad House is offline
Volunteer, WPILib Contributor
no team (Waiting for 2021)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2010
Location: Thousand Oaks, California
Posts: 1,094
Thad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond reputeThad House has a reputation beyond repute
Re: Programming US Digital Encoder

Quote:
Originally Posted by TimTheGreat View Post
So I am trying to get a motor to go to a certain position using the encoder provided by US Digital, and am having trouble.

Code:
self.talon = wpilib.CANTalon(15)
        self.talon.changeControlMode(CANTalon.ControlMode.Position)
        self.talon.setFeedbackDevice(CANTalon.FeedbackDevice.EncFalling) #Not sure if the encode is EncFalling or Quad
        self.talon.reverseSensor(True)
        self.talon.setP(1)
        self.talon.setPosition(0)
and in OperatorControl

Code:
  self.talon.set(270)
But when I enable the DS, the motor just keeps spinning, and the value goes past 270.
You do want to be using Quad for an encoder like that.

Remember that the encoder is always in 4x mode, which means that 1 rotation of the shaft is 1440 pulses is using a 360 CPR encoder. Moving from 0 to 270 is only moving the output shaft about 80 degrees. Is that what you want?

Also, the P gain needs to be a much smaller number then 1. With a P gain of one, your motor will always be moving at a full speed. I would recommend using a P gain of 0.01, if not 0.001 to start with, then start increasing from there if its not moving fast enough, or at all.
__________________
All statements made are my own and not the feelings of any of my affiliated teams.
Teams 1510 and 2898 - Student 2010-2012
Team 4488 - Mentor 2013-2016
Co-developer of RobotDotNet, a .NET port of the WPILib.