jruben4
February 14, 2022, 5:07pm
#1
Trying to reduce how much CAN messaging the CTR CanCoders are doing. I really only use them at robot init once, so the refresh rate could be very slow ideally. I understand they are at 10ms by default?
Can anyone provide a java example of how to set this?
I can’t tell from the documentation if I should be using
_canCoder.velocityMeasurementPeriod = SensorVelocityMeasPeriod.Period_25Ms;
or
setStatusFramePeriod()
1 Like
setStatusFramePeriod is what you’re looking for.
Keep in mind by reducing the status frame period you are reducing the rate at which you get encoder data updates.
The velocity measurement period is the period over which velocity samples are averaged to filter out noise.
jruben4
February 14, 2022, 5:23pm
#3
Do you have any example java code how you set that?
1 Like
jruben4
February 14, 2022, 6:33pm
#5
I don’t see CanCoders at all in that code example
Jacob_C
February 14, 2022, 9:36pm
#6
Joe is referring to lines like this that showcase the setStatusFramePeriod function:
_rightConfig.remoteFilter0.remoteSensorSource = RemoteSensorSource.Pigeon_Yaw;
_rightConfig.remoteFilter0.remoteSensorDeviceID = _pidgey.getDeviceID();
/* Configure the Remote Sensor to be the Selected Sensor of the right Talon */
_rightConfig.auxiliaryPID.selectedFeedbackSensor = TalonFXFeedbackDevice.RemoteSensor0.toFeedbackDevice();
/* Scale the Selected Sensor using a coefficient (Values explained in Constants.java */
_rightConfig.auxiliaryPID.selectedFeedbackCoefficient = Constants.kTurnTravelUnitsPerRotation / Constants.kPigeonUnitsPerRotation;
/* Set status frame periods */
_rightMaster.setStatusFramePeriod(StatusFrameEnhanced.Status_12_Feedback1, 20, Constants.kTimeoutMs);
_rightMaster.setStatusFramePeriod(StatusFrameEnhanced.Status_13_Base_PIDF0, 20, Constants.kTimeoutMs);
_rightMaster.setStatusFramePeriod(StatusFrameEnhanced.Status_14_Turn_PIDF1, 20, Constants.kTimeoutMs);
_pidgey.setStatusFramePeriod(PigeonIMU_StatusFrame.CondStatus_9_SixDeg_YPR , 5, Constants.kTimeoutMs);
/* Configure neutral deadband */
_rightConfig.neutralDeadband = Constants.kNeutralDeadband;
_leftConfig.neutralDeadband = Constants.kNeutralDeadband;
/* max out the peak output (for all modes). However you can
* limit the output of a given PID object with configClosedLoopPeakOutput().
That function is being called on a motor controller in the example but it’s a common API function that exists on all Phoenix CAN classes.
CANcoder Status Information:
jruben4
February 14, 2022, 9:52pm
#7
So something like this would hit the can bus every 100ms instead of the usual 10ms?
CANCoder rot_encoder_bl = init(new CANCoder(CAN.DT_BL_CANCODER));
rot_encoder_bl.setStatusFramePeriod(CANCoderStatusFrame.SensorData, 100, 100);
The Messaging rate caused an issue (we were unaware of at the time) with our current 2022 robot where our max Falcon motor usage was 15. Our robot uses 17. Changing it to 100ms fixed the problem for us.
2 Likes
To clarify for talonFXs, if most of our PID loops are running on integrated sensors, the onboard PIDs don’t need the canbus for the feedback loop, is that correct?
Most of these status frames, are IN FACT (stupid question coming up), status frames for GETTING, and I don’t need them for SETTING.
I can turn all of these status groups off?
Yes, status frames continuously report data on the can bus. If you don’t need to get the data in your program, you can increase the period.
1 Like
good to know. I’m gonna be wiping almost all of this stuff out!
I’m guessing this makes phoenix tuner a little harder to use the plotting function?