[FIXED] Bug in EMF Calculator

• I found a bug in the EMF calculator with the gear ratio on a lead screw.

Steps to reproduce

1. Enter motor details (or select preset, exact values don't matter)
2. In section "Drive" select Leadscrew (exact lead does not matter)
3. Change the gearing from 1:1 to 2:1

Expected Behavior

Because the motor now needs to turn double the speed I would expect the steps/mm to double.

Actual Behavior

steps/mm will be halved and this leads to wrong results for "Step pulse frequency" and "Speed at which torque starts to drop" (both).

Fix

The error is in calcStepsPerMm(). The if-Block that calculates steps/mm for leadscrews needs to be changed from

var ratio = \$("#gear_ratio_2").val() / \$("#gear_ratio_1").val();
fullStepsPerMm = (360.0 * ratio) / (leadscrewLead * stepAngle);
stepsPerMm = (360.0 * microstepping * ratio) / (leadscrewLead * stepAngle);

to

var ratio = \$("#gear_ratio_2").val() / \$("#gear_ratio_1").val();
fullStepsPerMm = (360.0) / (distancePerRevolution * stepAngle);
stepsPerMm = (360.0 * microstepping) / (distancePerRevolution * stepAngle);

The last two lines are the ones modified here. This will correct steps/mm calculation and thus fix the above issues.

• Can you link to the EMF calculator you're speaking about? I can't find it after several attempts.

But also, is it possible that the gear ratio is just being interpreted opposite to how you think it is? If you replace 2:1 with 1:2, are the results "as expected" from the original scenario?

• @bot I mean the one that can be found on http://reprapfirmware.org/.

Yes, I can reverse the gearing ratio and this will "fix" the steps/mm bug - but then the back EMF due to rotation is wrong and will be halved instead of doubled. • @wilriker Thanks for the link. I had never seen these before!

I see what you mean. I do not know enough about back-EMF, or steppers in general to know if this is correct or an error, like you say. Is it possible that by gearing down the motor, it produces less back EMF due to a lower load? Or is the back-emf dependent only on speed?

• @bot The back EMF due to rotation is exactly what the name implies - and as you guessed - dependent on speed. And a geared down motor will turn faster, so higher back EMF. • Cool, thanks for the clarification. Hopefully they get the bugs worked out of these calculators, as they seem quite useful.

• @bot The issue only occurs with a gear ratio other than 1:1. And I already included the fix in my first post, so it is only a matter of using the sources. • @wilriker Yes, I see that you've fixed the code -- I'm just hoping they get to implementing the fix before anybody makes some incorrect conclusions.

• @wilriker said in Bug in EMF Calculator:

var ratio = \$("#gear_ratio_2").val() / \$("#gear_ratio_1").val();
• @t3p3tony Thanks! 