> For the complete documentation index, see [llms.txt](https://yams.yassrobotics.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yams.yassrobotics.com/documentation/how-to-motor-controllers-and-sensors/how-do-i-use-exponential-profiles.md).

# How do I use exponential profiles?

An exponential profile plans a move the way a DC motor actually moves: hard acceleration at first, then less as it nears top speed. Every `SmartMotorController` in YAMS supports them. This is the short version: [Exponential profiles](https://yams.yassrobotics.com/documentation/understanding/exponential-profiles.md) has the full explanation and the tuning steps.

<figure><img src="https://1354553280-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZM0CFmYiQzcrY4zDcTtZ%2Fuploads%2Fgit-blob-cd805259e0788a8a85c06cc806a53802c26af5ab%2Fexponential-profile-compare.png?alt=media" alt="Two graphs. Setpoint velocity over time: a trapezoidal profile ramps in a straight line to a flat top, an exponential profile rises quickly and curves over near top speed. Acceleration against speed: the motor&#x27;s available acceleration falls to zero at top speed, the exponential profile follows it, and the trapezoidal profile asks for a constant acceleration the motor cannot give at high speed"><figcaption><p>The two profiles, and why the motor can follow one more easily than the other.</p></figcaption></figure>

## Use one

Add `withExponentialProfile(...)` instead of `withTrapezoidalProfile(...)`. For an elevator, YAMS works out starting values from the motor, the carriage and the drum. This is a fragment of an elevator subsystem's fields; the rest of the config (feedforward, limits, telemetry) is as in the [Elevator tutorial](https://yams.yassrobotics.com/documentation/tutorials/elevator.md).

{% code title="ElevatorSubsystem.java (fragment)" %}

```java
private final Distance drumRadius = Inches.of(0.25).times(22).div(2 * Math.PI); // 22 tooth sprocket, #25 chain
private final Mass     weight = Pounds.of(16);
private final DCMotor  motors = DCMotor.getNEO(1);
private final MechanismGearing gearing = new MechanismGearing(GearBox.fromReductionStages(3, 4));

private final SmartMotorControllerConfig motorConfig = new SmartMotorControllerConfig(this)
    .withControlMode(ControlMode.CLOSED_LOOP)
    // Gearing first: withExponentialProfile reads it to build the profile.
    .withGearing(gearing)
    .withDrumRadius(drumRadius)
    // PLACEHOLDER kP, in volts per meter. Tune it after the profile.
    .withClosedLoopController(10, 0, 0)
    // Maximum voltage during the profile, the motor, the carriage weight and the drum radius.
    .withExponentialProfile(Volts.of(12), motors, weight, drumRadius);
```

{% endcode %}

`withGearing` must come **before** `withExponentialProfile`, because the profile is calculated from the gearing at that moment. This form also makes the closed loop work in meters (see [How do I tune my elevator in rotations instead of meters?](https://yams.yassrobotics.com/documentation/how-to-motor-controllers-and-sensors/how-to-disable-linear-closed-loop-control.md)).

There are helpers for arms, flywheels and custom limits too: see [creating constraints](https://yams.yassrobotics.com/documentation/understanding/exponential-profiles.md#creating-constraints).

## When should I use one?

<figure><img src="https://1354553280-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZM0CFmYiQzcrY4zDcTtZ%2Fuploads%2Fgit-blob-7d94af6bc3483cc22c0e4118b164f3b956505187%2Fexponential-profile-tracking.gif?alt=media" alt="Animation of a 12 volt motor following each profile. With the trapezoidal profile the measured velocity falls behind the setpoint as the speed rises and the motor saturates at 12 volts. With the exponential profile the measured velocity stays on the setpoint"><figcaption><p>A simulated 12 V motor following each profile. The trapezoidal profile asks for more than the motor has left at speed.</p></figcaption></figure>

* **Use one** when a trapezoidal profile is hard to tune, or the mechanism falls behind it and then overshoots.
* **Keep the trapezoidal profile** if it already works well, or the motor is always current limited.
* **It cannot fix an underpowered mechanism.**

See [when to use each profile type](https://yams.yassrobotics.com/documentation/understanding/exponential-profiles.md#when-to-use-each-profile-type).

## Tune it

Start from the helper's values and [refine the profile live](https://yams.yassrobotics.com/documentation/understanding/exponential-profiles.md#refining-the-profile-live). The profile only plans the move, so it still needs a feedforward, and the profile's `kV` and `kA` are [not the feedforward's](https://yams.yassrobotics.com/documentation/reference/editor/config/feedforward.md#these-are-not-an-exponential-profiles-kv-and-ka).

## Check it

Start the simulation, command a new height, and graph the motor's `closedloop/setpoint/position` against `measurement/position` under **NetworkTables > Mechanisms**. The setpoint should curve smoothly to the target, and the measurement should stay close behind it the whole way.

## If it did not work

* **The setpoint jumps straight to the target, or the elevator does not move.** The profile is missing or empty: check that `withGearing` comes before `withExponentialProfile`, and that the drum radius and carriage weight are right.
* **The elevator falls behind the setpoint and then overshoots.** The feedforward is missing or `kG` is 0. See [Feedforward](https://yams.yassrobotics.com/documentation/reference/editor/config/feedforward.md).

## Code reference

{% @github-files/github-code-block url="<https://github.com/Yet-Another-Software-Suite/YAMS/blob/master/examples/commands2/simple_robot-2027/src/main/java/first/robot/subsystems/ExponentiallyProfiledElevatorSubsystem.java>" %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://yams.yassrobotics.com/documentation/how-to-motor-controllers-and-sensors/how-do-i-use-exponential-profiles.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
