예제 #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
        private void HandleAccelerationTimerTick(object ignored)
        {
            int    num = Math.Sign(_targetVelocity - CurrentVelocity);
            double acceleratedVelocity = ComputeAcceleratedVelocity(Acceleration * num);
            double duty = num >= 0 ? Accelerate(acceleratedVelocity) : Decelerate(acceleratedVelocity);

            Debug.Print("Velocity " + duty.ToString("F4"));
            _motorWinding.SetOutputPowerAndPolarity(duty);
            CurrentVelocity = duty;
        }