Independent but synchronous mechanisms?

I have two mechanisms that are independent of each other, not mechanically linked, and they both have a CTRE Mag encoder on them. I’m wondering how I would go about synchronizing these mechanisms in software so that they would always be in the same place relative to each other, and their encoder positions are always the same.


If they’re run by Talons just put one of them in follower mode. It looks something like this. frontLeft.set(ControlMode.Follower, rearLeft.getDeviceID());

There could be more load on one mechanism than the other though. Would that make a difference?

Can you give me a specific example of what you’re trying to do? That may help. The main reason I’ve used this is for the drive train. We use a 4 CIM drive train, and by putting the front talons in follower mode they’ll always work in sync and you only need one encoder per half of the drive train.

Follower mode definitely would not work in the case of different loads. Follower mode sets the input on the follower motor to be the same as the leader, but in this case you’d want different inputs to achieve the same output.

You can try to take the value of one encoder of a TalonSRX and feed it to the other one as a PID input. It would take a lot of try to fine tune the PID but I think it would work

You can use TalonSRX closed-loop for differential. We added this last season (for diff-swerve, diff-drive-train, and other similar mechanisms).

Basically you make one master talon calculate PID[0] + PID[1], and PID[0] - PID[1].
The former is applied to the motor. The latter is sent to your AuxFollower (talon set to follow with FollowType.AuxOutput1).

You could even run a primary PID to servo the difference/sum of the two sensors to maintain level, while open looping the overall up/down of the mechanism.

Similar post here manipulating two sensors to produce a sum/difference to servo/maintain.

MotionMagic with Aux PID[1] would be useful since your target mechanism is profiled along your single-axis, meaning Aux PID[1] maintains the sensor difference just like a turn-closed-loop during an arc.

Whatever you do, start by configuring the peak outputs to be very weak or disconnect motors entirely while you work out direction/phases/etc during hardware-bringup.

Makes sense?

Yes, it does, thank you very much!