# Protecting Rev 10 V5 Smart Motors (11W) with Code

This only applies to Rev 10 of the V5 Smart Motor (11W).  To learn more go to rev10rma.vex.com

## What commands need protection

We have identified an issue that can cause these motors to fail. The issue presents itself when the motor is commanded to run at a voltage higher than 11 volts and then another command is sent to the motor to turn in the opposite direction. This sequence of commands causes a voltage spike that damages components on the motor’s PC board.

Most motor commands use the motor’s internal control logic which does not allow the motor to reach 11 volts of output power. Motor commands like “motor.spinto(...)” and “motor.spinfor(...)” use PID to maintain velocities and do not allow the motor to run above 11 volts. The only command that can be used to send a specific voltage command to the motor is “motor.spin(...)”. There are several version of motor.spin():

## Examples of voltage mode commands

The specific version of motor.spin() that sets the motors voltage is:

C++:

motor m1 = motor(PORT1, ratio18_1, false);

m1.spin(forward, commandedVolts, volt);

Python:

m1 = Motor(Ports.PORT1, GearSetting.RATIO_18_1, False)

m1.spin(FORWARD, commandedVolts, VOLT)

## Protecting voltage mode commands

The version of motor.spin() that takes voltage units is the only command that can cause the motor to run at or above 11 volts. You will need to make sure you only pass values that are less than 11.0 to this function. Example:

C++
if( commandedVolts >= 11.0) {
commandedVolts = 10.9;
}
else if( commandedVolts <= -11.0) {
commandedVolts = -10.9;
}
m1.spin(forward, commandedVolts, volt);

Python
if( commandedVolts >= 11.0 ):
commandedVolts = 10.9
elif( commandedVolts <= -11.0 ):
commandedVolts = -10.9
m1.spin(FORWARD, commandedVolts, VOLT)

If you are using any units other than voltage units in the spin command you do not need to perform this commanded value check. Make sure that you never drive your Rev 10 motors over 11 or more volts should keep your motors from faulting.

## C++ Command Reference

`     /**      * @brief Turns the motor on, and spins it in the specified direction.      * @paramdir The direction to spin the motor.      */void      spin( directionTypedir );     /**      * @brief Turns on the motor and spins it in a specified direction and a       * specified velocity.      * @paramdir The direction to spin the motor.      * @paramvelocity Sets the amount of velocity.      * @paramunits The measurement unit for the velocity value.      */void      spin( directionTypedir, doublevelocity, velocityUnitsunits );void      spin( directionTypedir, doublevelocity, percentUnitsunits ){      spin( dir, velocity, static_cast<velocityUnits>(units) );     }     /**      * @brief Turns on the motor and spins it in a specified direction and a       * specified voltage.      * @paramdir The direction to spin the motor.      * @paramvoltage Sets the amount of volts.      * @paramunits The measurement unit for the voltage value.      */void      spin( directionTypedir, doublevoltage, voltageUnitsunits );`

## Python Command Reference

`defspin(self, direction: DirectionType.DirectionType, *args, **kwargs):       '''### Spin the motor using the provided arguments       #### Arguments:           direction : The direction to spin the motor, FORWARD or REVERSE           velocity (optional) : spin the motor using this velocity, the default            velocity set by set_velocity will be used if not provided.           units (optional) : The units of the provided velocity, default is RPM       #### Returns:           None       #### Examples:           # spin motor forward at velocity set with set_velocity\\           motor1.spin(FORWARD)\n           # spin motor forward at 50 rpm\\           motor1.spin(FORWARD, 50)\n           # spin with negative velocity, ie. backwards\\           motor1.spin(FORWARD, -20)\n           # spin motor forwards with 100% velocity\\           motor1.spin(FORWARD, 100, PERCENT)\n           # spin motor forwards at 50 rpm\\           motor1.spin(FORWARD, 50, RPM)\n           # spin motor forwards at 360 dps\\           motor1.spin(FORWARD, 360.0, VelocityUnits.DPS)       '''`

For more information, help, and tips, check out the many resources at VEX Professional Development Plus

Last Updated: