Class StepMotor

  • All Implemented Interfaces:
    Impc555, IntbMpc555HB, Ippc32

    public class StepMotor
    extends Object
    implements IntbMpc555HB
    Step motor driver on TPU-A or TPU-B.
    Full step and half step modes are possible.
    Full step requires 2 pins on the TPU. The pins deliver A and B signals. These signals have to be externally inverted to drive the coils of the motor (A, A', B, B'). Half step uses 4 pins on the TPU.
    When starting a motor the signals provide a ramping up to the final speed. When stopping they are ramping down to zero. A ramp will also be used when the stepping speed changes.
    • Field Detail

      • channel

        int channel
      • fullStep

        boolean fullStep
      • diff

        int diff
      • openSteps

        int openSteps
    • Constructor Detail

      • StepMotor

        public StepMotor​(boolean tpuA,
                         boolean fullStep,
                         int stepPeriod,
                         int channel)
        Creates a step motor driver.
        Parameters:
        tpuA - true uses TPU-A. false uses TPU-B.
        fullStep - true: full step mode. false: half step mode.
        stepPeriod - Maximum stepping speed in µs (stepPeriod <= 6553)
        channel - First pin on TPU. For full step channel and channel+1 pin will be used. For half step channel, channel+1, channel+2 and channel+3 will be used. Accordingly for full step channel is in the range of 0..14 while for half step the range is between 0..12.
    • Method Detail

      • move

        public void move​(int steps)
        Moves the motor for steps.
        Parameters:
        steps - Number of steps. A negative value moves the motor in the opposite direction.
      • start

        public void start()
        Starts the step motor.
        Use this method solely to start the motor after it has been stopped with stop(...).
      • stop

        public void stop()
        Stops the step motor.
        The motor can subsequently be restarted with start(...).
      • finished

        public boolean finished()
        Queries whether the motor has reached its required position.
        Returns:
        true if required position has been reached.
      • position

        public int position()
        Queries actual position of the motor.
        Returns:
        Actual position in steps.
      • reset

        public void reset()
        Resets the position.
        The final position is set to the actual position. This immediately stops the motor.