# Time Constant and Step Response in a Motor Test

> Run a motor step test, read the 63.2 percent point and calculate the time constant, with Arduino logging code.

Canonical: https://roboticsengineering.in/step-response-time-constant-motor-test/ | Published: 2026-11-14 | Updated: 2026-11-20 | Author: Jignesh S Panchal

**To find a motor’s time constant, apply a fixed voltage from rest, log the speed, and note how long it takes to reach 63.2 percent of its final value. That single number, together with the final speed per volt, gives you a usable first-order model for tuning a speed loop.**

## Key takeaways

- A step test applies a constant voltage from rest and records speed against time.
- For a first-order system, speed reaches 63.2 percent of its final value after one time constant tau.
- After about four time constants the speed is within roughly 2 percent of final, and after five within about 1 percent.
- Log at a steady interval, at least ten samples per time constant, using millis() timing.

## Running a Step Test

A step test means switching the input from zero to a fixed value in one go and watching how the output responds. For a motor, hold the robot with the wheels off the ground, make sure the battery is charged, and apply one fixed PWM duty from rest. Keep the supply the same one you will use in the finished robot, because a battery that sags changes the result.

Run the motor for long enough to reach steady speed, which for small gearmotors is often a fraction of a second to a second or more. Check this on your own motor rather than assuming. Use a speed sensor that you trust: an encoder counted over short intervals, or an IR tachometer such as the one in the [digital tachometer project](https://roboticsengineering.in/projects/digital-tachometer-ir-sensor-lcd-arduino/). Avoid a very small step, because the motor’s dead zone from static friction will distort it, and avoid the full-power step if it risks saturating your driver.

## Reading 63 Percent

The 63.2 percent figure comes from the first-order step response `y(t) = yf x (1 - e^(-t / tau))`, where `yf` is the final value. At `t = tau` the exponent is `-1`, and `e^-1 = 0.368`, so `y = yf x (1 - 0.368) = 0.632 x yf`.

The table shows an assumed motor with final speed 150 rpm and `tau = 0.12 s`. Each speed is calculated from the formula, not measured.

| Time (s) | t / tau | e^(-t/tau) | Speed (rpm) | Percent of final |
| --- | --- | --- | --- | --- |
| 0.06 | 0.5 | 0.607 | 59.0 | 39.3 |
| 0.12 | 1 | 0.368 | 94.8 | 63.2 |
| 0.24 | 2 | 0.135 | 129.7 | 86.5 |
| 0.36 | 3 | 0.050 | 142.5 | 95.0 |
| 0.48 | 4 | 0.018 | 147.3 | 98.2 |
| 0.60 | 5 | 0.007 | 149.0 | 99.3 |

Check one row: at 0.24 s, `e^-2 = 0.1353`, so speed is `150 x (1 - 0.1353) = 150 x 0.8647 = 129.7 rpm`. Real data will not match perfectly, because gearboxes have backlash and friction, and the encoder adds noise. A visible lag at the very start, or a final creep, means the motor is not exactly first order.

## Calculating the Time Constant

You have two ways to get tau from your log. The direct way is to compute 63.2 percent of the final speed and read the time at which the log crosses it. For a final speed of 150 rpm that level is `0.632 x 150 = 94.8 rpm`.

The second way uses any single point on the curve. Rearranging the formula gives `tau = -t / ln(1 - y / yf)`. Example: the log shows 85 rpm at `t = 0.10 s`. Then `y / yf = 85 / 150 = 0.5667`, `1 - 0.5667 = 0.4333`, and `ln(0.4333) = -0.836`. So `tau = 0.10 / 0.836 = 0.120 s`. Using several points and averaging reduces the effect of noise in any single reading.

The steady-state gain is `K = yf / V`, so a 150 rpm result with a 6 V step gives `K = 25 rpm per volt`. The theory behind K and tau is in the first-order DC motor transfer function. For the choice of the motor itself, see [motor selection for robots](https://roboticsengineering.in/motor-selection-for-robots/).

## Logging Data with Arduino

Log at a fixed interval, using `millis()` and no `delay()`, as in [a non-blocking millis state machine](https://roboticsengineering.in/arduino-millis-non-blocking-robot-state-machine/). An interval of 10 ms gives 12 samples per time constant for `tau = 0.12 s`, which is enough. This sketch is untested and assumes an encoder counted by an interrupt elsewhere in the code.

```
// Untested example. Assumes encoderCount is updated by an ISR.
volatile long encoderCount = 0;
const int PWM_PIN = 5;
const int COUNTS_PER_REV = 1320;      // set for your encoder and gearbox
unsigned long t0, lastLog;
long lastCount = 0;
void setup() {
  Serial.begin(115200);
  pinMode(PWM_PIN, OUTPUT);
  Serial.println("ms,rpm");
  t0 = lastLog = millis();
  analogWrite(PWM_PIN, 150);          // the step, applied once
}
void loop() {
  unsigned long now = millis();
  if (now - lastLog >= 10) {          // 10 ms sample
    noInterrupts(); long c = encoderCount; interrupts();
    float rev = (c - lastCount) / (float)COUNTS_PER_REV;
    float rpm = rev * 60.0 / 0.010;   // revs per 10 ms to rpm
    Serial.print(now - t0); Serial.print(',');
    Serial.println(rpm);
    lastCount = c; lastLog = now;
  }
  if (now - t0 > 1500) analogWrite(PWM_PIN, 0);   // stop after 1.5 s
}
```

Copy the Serial output into a spreadsheet to plot it. A single 10 ms window at low speed holds only a few counts, so the rpm will look stepped; smooth it with a short average if needed.

## Using the Result for Tuning

With `K` and `tau` you can sanity-check a loop before running it. A closed loop that is much faster than the motor demands large voltage swings and saturates, while one that is much slower wastes performance. A common starting aim is a closed-loop response comparable to or a little faster than the open-loop tau. Start with a modest `Kp`, add `Ki` to remove steady error, and check the result against the logged response. The full procedure is in [PID tuning for robot motion](https://roboticsengineering.in/pid-tuning-robot-motion/), and a ready loop to try it on is in [PID motor speed control with an encoder](https://roboticsengineering.in/projects/pid-motor-speed-control-encoder-arduino/). If your driver is the common [L298N module](https://roboticsengineering.in/components/l298n-motor-driver/), remember it drops some voltage, so check the motor voltage with a multimeter.

## Common Test Errors

Most bad results come from the setup, not the maths. A sagging battery makes the final speed drift lower during the test. A step that is too small sits in the dead zone. A sample interval that jitters because of `delay()` or slow Serial prints spreads the time axis. Counting encoder pulses without interrupts misses counts at higher speed.

## How to check this yourself

1. Run the same step three times and compare the 63.2 percent time; large differences point to battery sag or a loose setup.
2. Plot your log and overlay the formula with your tau; it should follow the curve closely after the first few samples.
3. Repeat at a different duty and check that K is roughly unchanged; if not, the motor is not behaving linearly.
4. Repeat with the real wheel load fitted and see how tau changes.

## Common mistakes

- Starting the clock before the step is actually applied.
- Reading the time at 50 percent instead of 63.2 percent.
- Using a log that stopped before the speed settled, so the final value is wrong.
- Printing to Serial too slowly and distorting the sample interval.

## Quick checklist

- Use a charged battery and the real supply.
- Log every 10 ms with millis().
- Record until about five time constants have passed.
- Take tau at 63.2 percent and K as final speed over voltage.
- Repeat three times and with the real load.

## Frequently asked questions

### What is the time constant of a motor?

The time constant is the time a motor takes to reach 63.2 percent of its final speed after a voltage step. It is a measure of how quickly the motor responds. A smaller value means a faster response. For a first-order system, about four time constants bring the speed within roughly 2 percent of final.

### Why 63 percent and not 50 percent?

For a first-order response y = yf (1 – e^(-t/tau)), putting t equal to tau gives 1 – e^-1, which is 0.632. The number comes straight from the exponential, so tau is defined at that level. Half the final value is reached earlier, at about 0.69 time constants.

### How many samples do I need for a step test?

Aim for at least ten samples per time constant and a log that lasts about five time constants. For a time constant of 0.12 s, a 10 ms interval over 0.6 s or more gives 60 samples. A steady interval matters more than a very fast one.

## Related reading

- [Learn hub](https://roboticsengineering.in/learn/): more control and motor explainers.
- [Robot Cycle Time Calculation: Worked Example](https://roboticsengineering.in/robot-cycle-time-calculation/)

## About the author and how this is kept accurate

Written, checked and maintained by [Jignesh Panchal](https://www.linkedin.com/in/jignesh-s-panchal/) of [Jaadu Digital](https://jaadudigital.com/). Figures in worked examples come from the stated assumptions, not from a bench test of our own. Read the [editorial standard](https://roboticsengineering.in/editorial-standard/), follow the author on [LinkedIn](https://www.linkedin.com/in/jignesh-s-panchal/), or [send a correction](https://roboticsengineering.in/contact/). Last reviewed: November 2026.
