Quote:
Originally Posted by TimTheGreat
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.