Grove Motor Driver TB6612FNG

I hate magic numbers.

I’m trying to port the driver software to Python and buried in the cpp file is a magic number:

ms_per_step = (uint16_t)(3000.0 / (float)rpm);

I have no idea what this 3000.0 means but through trial and error, I figured out I need to change it to 7000.0 to get my stepper motor working correctly .

Anyone know what this magic number is supposed to be.


Take (e.g.) motor running at 1 rpm. Then the variable ms_per_step will take the value of 3000. 1 rpm corresponds to 1 minute per revolution. So 3000 milliseconds per step will be 1 minute per revolution. In other words: 3 seconds per step == 60 seconds per revolution. For this equation to be valid, evidently a motor with 20 steps per revolution is assumed. There exist tiny stepper motors with this stator configuration.