JHS-Viking-Robotics / FRC-2021

Code for the FRC 2021 season.
GNU General Public License v3.0
0 stars 1 forks source link

Change Hopper lift control PID to use quad encoding #11

Open derickson2402 opened 3 years ago

derickson2402 commented 3 years ago

Currently the hopper lift controller uses a CTRE mag encoder set to quad encoding mode (note that this code is not present in 2021 code as of writing, but is in 2020 code) in order to do closed loop control. This is necessary in order to get an absolute position of the hopper lift "arm" upon boot without some sort of calibration function or hardware limit switches or other solution which would allow the robot to "feel around" for the limits of movement.

This works great, but at high speed and in situations where greater precision is necessary it is best practice to "seed" the initial position of the hopper arm upon boot using PWM's exact position, but then switching over to quad encoding and applying an offset based upon the initial value. This way, the robot gets the speed/precision of quad encoding mode and the absolute position from PWM mode.

derickson2402 commented 3 years ago

Check out this section in the Phoenix documentation