Motor Configuration

Template Project

This lesson applies to both Timed Robot and Command Robot templates. For Timed Robot, configure motors in robotInit(). For Command Robot, configure motors in subsystem constructors.

Overview

Proper configuration ensures motors operate safely and correctly. We'll configure three essential settings: inversion, idle mode, and current limits. Each setting serves a specific purpose for safe and predictable motor behavior.

Key Settings

Configure these for every motor:

  • Inversion: Ensure positive output moves the mechanism forward.
  • Idle Mode: Choose between Brake (hold position) or Coast (free spin).
  • Current Limit: Protect hardware from over-current damage.

Step 1: Create Configuration Object

Start by creating a configuration object. This object holds all the settings we'll apply to the motor. We create it, set properties, then apply it to the motor.
Create and apply a configuration object:
// In robotInit() or constructor
TalonFXConfiguration config = new TalonFXConfiguration();
// We'll add settings here
m_motor.getConfigurator().apply(config);

Step 2: Configure Inversion

Inversion controls which direction is "positive." Set this so that positive software values match the physical "forward" direction of your mechanism. Test by applying small positive power (0.2). If it moves backward, enable inversion.
Add inversion to the configuration:
TalonFXConfiguration config = new TalonFXConfiguration();
// Set motor direction (adjust based on your mechanism)
config.MotorOutput.Inverted = InvertedValue.CounterClockwise_Positive;
// Alternative: InvertedValue.Clockwise_Positive
m_motor.getConfigurator().apply(config);

Step 3: Configure Idle Mode

Idle mode determines motor behavior when output is zero. Brake mode makes the motor resist motion when stopped. Use this for elevators, arms, and drivetrains where you want to hold position. Coast mode allows free spinning when stopped. Use this for flywheels and intakes.
Add idle mode to the configuration:
TalonFXConfiguration config = new TalonFXConfiguration();
// Brake: Motor resists motion when stopped (good for elevators, arms)
config.MotorOutput.NeutralMode = NeutralModeValue.Brake;
// Coast: Motor spins freely when stopped (good for flywheels, intakes)
// Alternative: NeutralModeValue.Coast
m_motor.getConfigurator().apply(config);

Step 4: Configure Current Limits

Current limiting prevents motor burnout and system brownouts by capping the maximum amperage. Recommended values: 20-40A for small motors, 40-60A for drive motors. Adjust based on your motor specifications and mechanical load.
Add current limiting to the configuration:
TalonFXConfiguration config = new TalonFXConfiguration();
// Enable current limiting to protect motor from overheating
config.CurrentLimits.StatorCurrentLimitEnable = true;
// Set limit to 40A (adjust based on motor and application)
config.CurrentLimits.StatorCurrentLimit = 40.0;
m_motor.getConfigurator().apply(config);

Combining All Settings

In practice, you configure all three settings together in one configuration object. Here's how they work together to create a complete motor configuration.

Full Configuration Example

Complete configuration combining all settings:
// In robotInit() or constructor
TalonFXConfiguration config = new TalonFXConfiguration();

// Step 1: Set inversion (ensure positive = forward direction)
config.MotorOutput.Inverted = InvertedValue.CounterClockwise_Positive;

// Step 2: Set idle mode (Brake for elevators/arms, Coast for flywheels/intakes)
config.MotorOutput.NeutralMode = NeutralModeValue.Brake;

// Step 3: Enable current limiting
config.CurrentLimits.StatorCurrentLimitEnable = true;
config.CurrentLimits.StatorCurrentLimit = 40.0;

// Apply all settings at once
m_motor.getConfigurator().apply(config);

Configuration Order

The order of settings in the configuration object doesn't matter. All settings are applied together when you call apply() or configure(). However, always apply the configuration to the motor after setting all properties.

Testing Your Configuration

After configuring, test each setting: Inversion: Apply 0.2 power, verify direction. Idle Mode: Stop motor, check if it holds or spins freely. Current Limit: Monitor current draw during operation to ensure it's within limits.

Resources

Open full interactive app