You can control DC motor speed by applying a PWM signal to the controller inputs. PWM controls the speed by rapidly switching the motor on and off with different periods for on and off. The number of on/off cycles per second is known as the PWM frequency. The percentage of on time during each cycle is known as the duty cycle.
Some of the popular inexpensive L298N motor driver boards allow for two methods of providing the PWM - either via the enable pin or the input pins.
The advantages/disadvantages of using one method or the other is not clear (at least as far as my googling ability goes).
Anyhow I set up a test consisting of a Pi, L298N motor driver board, and a DC motor.
A plastic gear wheel was attached to the motor shaft. Two magnets were inserted in the gear wheel. Two were used simply for balance. A pair of digital Hall effect sensors were mounted to align with the magnets. One would have been enough but two allowed misalignments to be easily spotted.
In this arrangement each Hall sensor is pulsed twice per shaft revolution (once each time a magnet passes over the sensor).
The tests consisted of cycling through PWM update frequencies then driving the motor for 3 seconds at 100%, 95%, ..., 5% duty cycles. The number of pulses for each Hall sensor was recorded at the end of each 3 second period. Each test was carried out using enable PWM and then using input PWM. The whole series of tests were repeated 5 times.
A comparison of RPM achieved at PWM frequencies 50, 400, 800Hz using enable (ENA) or input (IN1) pins.
The chart shows pulses per 3 second interval on the vertical axis and duty cycle percentage on the horizontal axis.
Whether any conclusions can be drawn or not for practical motor usage I'm not so sure. Certainly using the enable pin for PWM performed better for a range of frequencies and duty cycles. But in effect these were extremely light load tests.
At peak the motor RPM was around 9000 (10 times the pulse rate, times 20 to go from 3 second to minutes and then divide by two pulses per revolution).
If you do anything similar make sure your magnets are secure. One of mine spun off and hasn't been seen since. I expect it's lodged in my brain like Homer Simpson's crayon.
software, results, plots