Class StepMapper

  • All Implemented Interfaces:

    
    public final class StepMapper
    
                        

    Calculates a "physical" angle to steps mapping for a geared stepper motor. This is used to translate desired physical angles into the corresponding number of steps the stepper motor must take, considering the gear ratio. This is obviously an approximation since stepper motors move in discrete steps and do not have the concept of "state".

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Integer degreesToSteps(Integer degrees) Convert degrees to steps.
      final List<Integer> stepsToDegrees(Integer steps) Convert steps to degrees.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • StepMapper

        StepMapper(Integer stepsPerRotation, Float gearRatio)
    • Method Detail

      • degreesToSteps

         final Integer degreesToSteps(Integer degrees)

        Convert degrees to steps. Compensates for negative degrees and degrees over 360.

      • stepsToDegrees

         final List<Integer> stepsToDegrees(Integer steps)

        Convert steps to degrees. Returns the range of possible degrees for the given number of steps. Note that not all steps will have a corresponding degree (due to rounding), so this uses the "closest" minimum or last.