TDEB Top Bar

Trending
Semiconductor Industry News — The Digital Electronics Blog
Follow Us

TDEB Masthead

The Semiconductor Hub

Semiconductors.  Chips and Systems.  Innovation.

Indexed by leading Search Engines, AI and referenced by Engineers worldwide 500+ Articles 10M+ Pageviews 30+ Reports 50+ Citations

Interview Question on Digital Motor Speed Control: Average RPM

Murugavel Ganesan
by
0
Share Facebook X LinkedIn WhatsApp Email

The average RPM for the whole trip is 48 RPM, not 50. The motor turns the same number of revolutions in each direction, but it spends longer on the slow reverse leg, so the average must be weighted by time. Divide the total revolutions by the total time and you get the harmonic mean of 60 and 40, which is 48 RPM.

Digital logic puzzle illustration for the motor speed control interview question

Key takeaways

  • Average speed is always total quantity divided by total time, never the plain average of two speeds.
  • When equal amounts of work (here, equal revolutions) are done at two speeds, the average is the harmonic mean: 2 x 60 x 40 / (60 + 40) = 48 RPM.
  • The plain average, 50 RPM, is only correct when the motor spends equal time at each speed.
  • A digital speed meter gets this right automatically if it counts revolutions and time over the whole trip and divides once at the end.

The question

A person designs a digital circuit to control a motor's speed. The motor runs at 60 RPM (revolutions per minute) when moving forward and at 40 RPM when reversing. The motor operates forward for a distance and then reverses the same distance. How would you calculate the average RPM of the motor for the entire trip?

Try it before reading on. Most people answer 50 RPM in a few seconds, and that is the trap.

Why 50 RPM is wrong

The plain (arithmetic) mean, (60 + 40) / 2 = 50, gives each speed equal weight. That would be right only if the motor ran for the same time at each speed, for example one minute forward and one minute in reverse. In this question the distance (revolutions) is equal, not the time, so the slow leg lasts longer and pulls the average down.

What is held equalCorrect averageResult for 60 and 40 RPM
Equal time at each speedArithmetic mean (a + b) / 250 RPM
Equal revolutions at each speedHarmonic mean 2ab / (a + b)48 RPM

The harmonic mean is always less than or equal to the arithmetic mean, and they are equal only when both speeds are the same.

The idea in one picture

Imagine walking to a shop at a brisk pace and walking home slowly. You spend more minutes on the slow walk, so over the whole trip you were moving slowly for most of the time. Any honest average has to reflect that. The motor is the same: equal revolutions each way, but more minutes in reverse at 40 RPM, so the trip average sits below the midpoint of 50.

Deep dive: the numbers and details

This part holds the algebra, a worked example, a Verilog speed meter and the follow-up questions. Skip it if the overview is all you need.

Answer: total revolutions divided by total time

To calculate the average RPM of the motor for the entire trip, consider the total revolutions and the total time taken for the entire operation.

Because the motor covers the same distance in each direction, it turns the same number of revolutions each way (assuming the same wheel or gear ratio both ways). Let that number be d revolutions.

Forward leg

  • Speed = 60 RPM
  • Time taken = d / 60 minutes

Reverse leg

  • Speed = 40 RPM
  • Time taken = d / 40 minutes

Whole trip

  • Total revolutions = 2d
  • Total time = d/60 + d/40 = 2d/120 + 3d/120 = 5d/120 = d/24 minutes
  • Average speed = total revolutions / total time = 2d / (5d/120) = (2d x 120) / 5d = 240 / 5 = 48 RPM

Note that d cancels out, so the answer does not depend on how far the motor travels.

Worked example with numbers

Take d = 60 revolutions in each direction (an illustrative figure; any value gives the same result).

LegRevolutionsSpeed (RPM)Time (minutes)
Forward60601.0
Reverse60401.5
Whole trip12048 (average)2.5

120 revolutions in 2.5 minutes is 48 RPM. The motor spends 60 percent of the trip at the slower speed, which is why the average sits closer to 40 than to 60.

How a digital circuit would measure it

Since the question is framed around a digital motor controller, it is worth showing how the hardware gets the right answer. A typical speed measurement block counts one pulse per revolution (from an encoder index or a Hall sensor) and counts a fixed timebase, such as a 1 ms tick. The average over the trip is the revolution count scaled to minutes and divided by the elapsed time. The important design point is to accumulate both counts over the whole trip and divide once, rather than averaging the two per-leg speeds.

`timescale 1us/1us
// Average RPM over a whole trip: total revolutions / total time.
// tick_ms is a 1 ms timebase; rev_pulse is one pulse per revolution.
module avg_rpm (
  input  wire        clk,
  input  wire        rst,
  input  wire        tick_ms,
  input  wire        rev_pulse,
  output reg  [31:0] revs,
  output reg  [31:0] ms,
  output wire [31:0] rpm_avg
);
  always @(posedge clk) begin
    if (rst) begin
      revs <= 0;
      ms   <= 0;
    end else begin
      if (rev_pulse) revs <= revs + 1;
      if (tick_ms)   ms   <= ms + 1;
    end
  end
  // revs per minute = revs * 60000 / ms (guard against divide by zero)
  assign rpm_avg = (ms == 0) ? 32'd0 : (revs * 32'd60000) / ms;
endmodule

A testbench that drives 60 revolutions at 60 RPM and then 60 revolutions at 40 RPM prints:

forward only : revs=60 ms=60000 avg=60 RPM
whole trip   : revs=120 ms=150000 avg=48 RPM

The divider is written as a combinational expression to keep the example short. In a real controller you would usually compute it once at the end of a measurement window with a sequential divider, or work with the period (time per revolution) directly and avoid division in hardware altogether. Also size the counters so that revs x 60000 cannot overflow over the longest trip you expect.

Common mistakes

  • Averaging the two speeds. This gives 50 RPM and ignores that the slow leg takes longer.
  • Arithmetic slips with the fractions. d/60 + d/40 is 5d/120 (that is, d/24), not 2d/120. Using the wrong common denominator gives an average of 60 RPM, which is clearly impossible for a trip that includes a 40 RPM leg.
  • Treating direction as negative speed. If you count reverse revolutions as negative, the net revolutions are zero and the "average" is zero. The question asks about speed (how fast the shaft turns), so use magnitudes.
  • Averaging per-leg readings in hardware. A controller that averages its last two speed readings has the same flaw as the 50 RPM answer.

How interviewers probe this question

  • They ask for an instant answer to see whether you say 50, then ask you to justify it.
  • They change the condition to "equal time in each direction" and expect you to switch to 50 RPM.
  • They ask for the general formula, 2ab / (a + b), and when it equals the plain average.
  • For hardware roles they ask how you would measure speed in logic: pulse counting over a fixed window versus timing the period between pulses, and which is more accurate at low speed (period timing usually is).

Frequently asked questions

Does the distance d matter?

No. It cancels in the calculation. Any equal distance in each direction gives 48 RPM.

What if the motor reversed for twice the distance?

Then the total is 3d revolutions in d/60 + 2d/40 = 2d/120 + 6d/120 = 8d/120 minutes, so the average is 3d x 120 / 8d = 45 RPM. The slow leg now takes an even larger share of the time, so the average falls further toward 40. A quick sanity check for any answer: it must lie between the slowest and fastest speeds.

Is this the same as the classic average speed of a car problem?

Yes. A car that goes somewhere at 60 km/h and returns at 40 km/h averages 48 km/h for the same reason.

Where else does the harmonic mean show up in hardware?

Whenever equal amounts of work are done at different rates, for example average throughput when a fixed number of transactions is processed at two different clock rates or bus speeds.

Murugavel Ganesan
About the Author
Murugavel Ganesan
Product Director | SerDes · IVN · Edge AI · Compute | Ex Intel · Infineon

A semiconductor product leader working across product architecture, definition, strategy, and silicon and software execution, from concept through volume production. He has worked with teams across Asia, Europe and the USA, including at Intel, Infineon and ArrayComm.

His work covers ASICs, SoCs, FPGAs and chiplets for wireless, wireline, automotive, IoT and AI, including PCIe, CXL and DDR interfaces alongside RF and mixed-signal design.

Share Facebook X LinkedIn WhatsApp Email

Post a Comment

0 Comments

Your comments will be moderated before it appears here.

Post a Comment (0)

#buttons=(Ok, Go it!) #days=(20)

Our website uses cookies to enhance your experience. Learn more
Ok, Go it!