Motion Magic for elevator with motors on both sides (opposite direction)

So we have an elevator with a gearbox with 2 motors (using a VersaDM w/ Versaplanetary on each side of the elevator. We use the 775pro connect and mounted all of them so they face the same way. However, this reversed some of the directions so to go up, I need to invert one motor on the right side and invert one motor on the left side. Will this cause any issues with motion magic and setting the setpoint?

Thank You

Our robot last year had exactly the configuration you describe.
We had done problems inverting the motors and having them follow each other, so we eventually just swapped the wires on one motor, which worked great.

+1 on this working fine.

To be safe, we ran each motor individually first in a simple % out setup (all the others physically disconnected) to verify that invert was correct for each of them. Then we hooked all four back up and using those invert settings started tuning the arm. Seemed safest to make sure we didn’t have motors driving against each other.

1 Like

Yea, that is what we did with percent output. We have a master motor (talon doing the motion magic, and a slave motor following the talon). I just have to make sure the sensor is in line with the talon right? Also, set a positive setpoint for the positive side, and a negative setpoint on the negative side?

Elevator Left Side:
talonMasterL.setInverted(true);
victorSlaveL.setInverted(false);
talonMasterL.setSensorPhase(true);

Elevator Right Side:
talonMasterR.setInverted(false);
victorSlaveR.setInverted(true);
talonMasterR.setSensorPhase(false);


In teleop:
talonMasterR.set(ControlMode.MotionMagic, setpoint);
victorSlaveR.follow(talonMasterR)

talonMasterL.set(ControlMode.MotionMagic, -setpoint);
victorSlaveL.follow(talonMasterL);

Would the above code work fine with motion magic?

Is your victorSlave always following the talonMaster? If so, then you should perform all that configuration one time when the objects are instantiated and configured.

Regarding the negative set point, you don’t need to do that. The most important thing you can do is set your motors and sensors in phase with each other first.

Meaning, positive input to the talon produces green LEDs, and negative inputs produce red LEDs. Then, green LEDs produce positive encoder increments, and red LEDs produce negative encoder decrements.

Once you have the motors and sensors in phase with each other, then your setpoint is the same for both sides. If you have inverted the motor in the talon configuration such that both sides of the elevator are producing green LEDs to have the elevator go up, and red LEDs have the elevator go down (or vice versa is fine), then your setpoint is just a number relative to where you are.

We treat the zero position for our arm as 0, and have the other positions be positive set point values relative to 0. That way we can reset our relative encoder when the limit switch at the bottom is hit, as well as enforce soft limits in the talon itself to prevent over driving as a fall back if for some reason we have ended up in a weird state the robot subsystem wasn’t expecting.

Back to the original question, our drivetrain is setup with two sets of motors inverted relative to each other. Here is a link to our drivetrain that shows the configuration we use after we took the steps found at CTREs documentation to make sure the motors and sensors are in phase with each other.

If you peruse the rest of the code, you’ll see the DriveMM commands we use set the setpoints of both motors to be the same (i.e. not inverted from each other) because our motor controllers and sensors have been configured to be in phase with each other on both sides.

The victor always follows the talon. For the sensor phase, I need to make sure it is going in the same direction as the talonMaster right? The victor doesnt matter to that right?

Here is how we setup our talons (though victors should be similar I think) in our DriveTrain constructor:
NOTE: There is a lot more setup in the constructor, click the link above to see the entire thing, I’m only posting the stuff related to inversion and sensor phase, etc here.

        // Using the Phoenix Tuner we observed the left side motors need to be inverted
		// in order to be in phase
		left_motor_master.setInverted(true);
		
		// Set the followers to follow the inversion setting of their masters
		left_motor_slave.setInverted(InvertType.FollowMaster);
		right_motor_slave.setInverted(InvertType.FollowMaster);

		// Reverse the right side encoder to be in phase with the motors
		right_motor_master.setSensorPhase(true);

		// Setup the followers for each side
		left_motor_slave.follow(left_motor_master);
		right_motor_slave.follow(right_motor_master);

In our setup we only have encoders connected to our master Talons, one for each side (left and right).

I think you’ll be doing something similar from what I understood your setup to be.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.