示例#1
0
 public void PerformStep(int direction)
 {
     phaseIndex += direction;
     if (phaseIndex > maxIndex)
     {
         phaseIndex = 0;
     }
     if (phaseIndex < 0)
     {
         phaseIndex = maxIndex;
     }
     phase1.SetOutputPowerAndPolarity(inPhaseDutyCycle[phaseIndex]);
     phase2.SetOutputPowerAndPolarity(outOfPhaseDutyCycle[phaseIndex]);
 }
示例#2
0
        void HandleAccelerationTimerTick(object ignored)
        {
            var accelerationSign    = Math.Sign(targetVelocity - CurrentVelocity);
            var acceleratedVelocity = ComputeAcceleratedVelocity(Acceleration * accelerationSign);
            var newVelocity         = accelerationSign >= 0 ? Accelerate(acceleratedVelocity) : Decelerate(acceleratedVelocity);

            Debug.Print("Velocity " + newVelocity.ToString("F4"));
            motorWinding.SetOutputPowerAndPolarity(newVelocity);
            CurrentVelocity = newVelocity;
        }