# SMARTDAMP Algorithm

More content soon. TLDR: if you have the kV and kA feedforward values. we can use that as a model for our system.

Then, we solve for the poles of the system. After some math, we arrive at the following:

$$
K\_D=2\sqrt{K\_aK\_P}-K\_v
$$

This will guarantee a critically damped PID response for a PD controller, given an arbitrary choice of Kp

It is recommended that the following inequality is true:

$$
K\_p \geq \frac{K\_v^2}{4K\_a}
$$

Otherwise, Kd will be negative and you get a scary non-minimum phase system.

### Specifying percent overshoot

A Critically damped system is not necessarily the fastest possible response, sometimes you are okay with a bit of overshoot. This modified version of the SMARTDAMP algorithm allows you to specify a percent overshoot in addition to your proportional gain to give you your optimal choice for Kd

$$
K\_d = 2 \zeta \sqrt{K\_a K\_p} - K\_v
$$

where Zeta is our [dampening ratio](https://en.wikipedia.org/wiki/Damping#Damping_ratio_definition).

We can find zeta using the following equation given *PO* (Percent overshoot)

$$
\zeta =\frac{-\ln{\frac{PO}{100}}}{\sqrt{\pi^2 + \ln^2{\frac{PO}{100}}}}
$$


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.ctrlaltftc.com/advanced/smartdamp-algorithm.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
