AGHSEagleRobotics / frc1388-2024

0 stars 0 forks source link

Intake motor stutters #43

Closed jtechau closed 8 months ago

jtechau commented 8 months ago

The intake roller motor has been stuttering when in operation. It appears that this is due to turning off the motor in the subsystem's periodic() method: https://github.com/AGHSEagleRobotics/frc1388-2024/blob/d8b678322ebaeeda120680cbaf7de17bec0543c7/frc1388-2024/src/main/java/frc/robot/subsystems/IntakeSubsystem.java#L103

It's bad to set a motor power/speed in more than one place at the same point in time. In this case, the setRollerMotor() method is setting the desired power level, but periodic() is setting it back to zero. This conflict causes erratic motor power levels. In this case, the motor was bouncing between high power and zero power, which was the likely cause of motor stuttering. When the motor power fluctuates rapidly, it causes the motor to heat up. The motor in question smoked and can no longer be considered to be reliable.

Lessons to be learned:

jtechau commented 8 months ago

See pull request #44.

jtechau commented 8 months ago

Damage to motors and mechanisms can probably be reduced by using a ramp rate to avoid starting/stopping the motor too quickly. This is probably a good general practice when fast motor response isn't necessary.

For example, SparkMax and SparkFlex controllers have a method setOpenLoopRampRate() to limit motor output from changing too quickly.

calvinxp commented 8 months ago

done