Skip to content

Commit bb93316

Browse files
committed
Rounding Problem
Showed up when using a stepper with only 48 steps per revolution
1 parent b9644e1 commit bb93316

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

StepperModel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ StepperModel::StepperModel(int inDirPin, int inStepPin, int inEnablePin, int inE
4949
currentStepcount=0;
5050
targetStepcount=0;
5151

52-
steps_per_mm = (int)(kStepsPerRevolution/(45.*M_PI))*kMicroStepping; // default value for a "normal" egg (45 mm diameter)
52+
steps_per_mm = (int)((kStepsPerRevolution/(45.*M_PI))*kMicroStepping+0.5); // default value for a "normal" egg (45 mm diameter)
5353
enableStepper(false);
5454
}
5555

5656
void StepperModel::resetSteppersForObjectDiameter(double diameter)
5757
{
5858
// Calculate the motor steps required to move per mm.
59-
steps_per_mm = (int)(kStepsPerRevolution/(diameter*M_PI))*kMicroStepping;
59+
steps_per_mm = (int)((kStepsPerRevolution/(diameter*M_PI))*kMicroStepping+0.5);
6060
if(endStopPin>=0)
6161
{
6262
#ifdef AUTO_HOMING

0 commit comments

Comments
 (0)