![]() |
Programming US Digital Encoder
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)Code:
self.talon.set(270) |
Re: Programming US Digital Encoder
Quote:
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. |
Re: Programming US Digital Encoder
Put some sort of mechanical load on the motor when you're trying out closed-loop position control. If you don't, it's going to overshoot. A lot.
|
Re: Programming US Digital Encoder
You're sensor is not single-direction (not a tachometer). So you want to select Quad-encoder. That's part of the problem.
So you're initial closedloopErr is +270 ( target - currentPos), such that currentPos is about '0'. 270 times a pgain of '1' will yield '270'. That's about 26% positive throttle (1023 is full, see Duty-Cycle Section 17.5 in software reference manual). So I think that's ok. Also I see that you reversed the sensor. I'm guessing you followed the procedure in section 7.4 (or similar) to ensure that positive throttle makes "Sensor Position" move in the positive direction. Just curious how did you hookup the encoder to the motor mechanically. I mean what's the gear ratio between the two? |
Re: Programming US Digital Encoder
Quote:
Quote:
|
Re: Programming US Digital Encoder
Quote:
|
Re: Programming US Digital Encoder
Cool. You should be able closed loop position with that. I've tested closed-looping a quad encoder right to the output shaft of a CIM (>5000 rpm) using the S4 encoder (360 cpr) so that'll work.
My math says : 360cpr = 1440 position units per rotation. 270 / 1440 = 0.1875 rotations or 67.5 deg. Also checkout section 11.2 for checking on the closed-loop err and the applied throttle to sanity check your closed-loop. |
| All times are GMT -5. The time now is 01:40. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi