public void Stop(DcMotorIndex motorIndex)
        {
            ConfigureChannels(motorIndex);

            pcaPwmDriver.SetChannelValue(channels.In1, PcaPwmDriver.FullyOff);
            pcaPwmDriver.SetChannelValue(channels.In2, PcaPwmDriver.FullyOff);
        }
Esempio n. 2
0
        private void ConfigureChannels(DcMotorIndex motorIndex)
        {
            switch (motorIndex)
            {
            case DcMotorIndex.DC1:
                channels.In1   = 10;
                channels.In2   = 9;
                channels.Speed = 8;
                break;

            case DcMotorIndex.DC2:
                channels.In1   = 11;
                channels.In2   = 12;
                channels.Speed = 13;
                break;

            case DcMotorIndex.DC3:
                channels.In1   = 4;
                channels.In2   = 3;
                channels.Speed = 2;
                break;

            case DcMotorIndex.DC4:
                channels.In1   = 5;
                channels.In2   = 6;
                channels.Speed = 7;
                break;
            }
        }
Esempio n. 3
0
        public void Stop(DcMotorIndex motorIndex)
        {
            ConfigureChannels(motorIndex);

            pwmControllerProvider.SetPulseParameters(channels.In1, dutyCycleFullyOff, true);
            pwmControllerProvider.SetPulseParameters(channels.In2, dutyCycleFullyOff, true);
        }
Esempio n. 4
0
        public void SetSpeed(DcMotorIndex motorIndex, ushort speed)
        {
            ConfigureChannels(motorIndex);

            var dutyCycle = PcaPwmDriver.PercentageScaler * speed / PcaPwmDriver.Range;

            dutyCycle = Math.Min(dutyCycle, PcaPwmDriver.PercentageScaler);

            pwmControllerProvider.SetPulseParameters(channels.Speed, dutyCycle, false);
        }
        public void SetSpeed(DcMotorIndex motorIndex, ushort speed)
        {
            Check.IsLengthInValidRange(speed, 0, PcaPwmDriver.Range - 1);

            ConfigureChannels(motorIndex);

            var speedRegisterValue = new PcaRegisterValue()
            {
                On = speed
            };

            pcaPwmDriver.SetChannelValue(channels.Speed, speedRegisterValue);
        }
Esempio n. 6
0
        public void Start(DcMotorIndex motorIndex, MotorDirection direction)
        {
            ConfigureChannels(motorIndex);

            if (direction == MotorDirection.Forward)
            {
                pwmControllerProvider.SetPulseParameters(channels.In1, dutyCycleFullyOn, false);
                pwmControllerProvider.SetPulseParameters(channels.In2, dutyCycleFullyOff, false);
            }
            else
            {
                pwmControllerProvider.SetPulseParameters(channels.In1, dutyCycleFullyOff, false);
                pwmControllerProvider.SetPulseParameters(channels.In2, dutyCycleFullyOn, false);
            }
        }
        public void Start(DcMotorIndex motorIndex, MotorDirection direction)
        {
            ConfigureChannels(motorIndex);

            if (direction == MotorDirection.Forward)
            {
                pcaPwmDriver.SetChannelValue(channels.In1, PcaPwmDriver.FullyOn);
                pcaPwmDriver.SetChannelValue(channels.In2, PcaPwmDriver.FullyOff);
            }
            else
            {
                pcaPwmDriver.SetChannelValue(channels.In1, PcaPwmDriver.FullyOff);
                pcaPwmDriver.SetChannelValue(channels.In2, PcaPwmDriver.FullyOn);
            }
        }
        private void DcMotorTest(DcMotorIndex motorIndex, MotorDirection direction, ushort speed)
        {
            if (dcMotor != null)
            {
                const int msDelay = 5000;

                // 속도 설정 및 모터 구동
                dcMotor.SetSpeed(motorIndex, speed);
                dcMotor.Start(motorIndex, direction);

                // 지정된 지연 대기
                Task.Delay(msDelay).Wait();

                // 모터 정지
                dcMotor.Stop(motorIndex);
            }
        }
        private void DcMotorTest(DcMotorIndex motorIndex, MotorDirection direction, ushort speed)
        {
            if (dcMotor.IsInitialized)
            {
                const int msDelay = 5000;

                // Set speed, and run motor
                dcMotor.SetSpeed(motorIndex, speed);
                dcMotor.Start(motorIndex, direction);

                // Wait a specified delay
                Task.Delay(msDelay).Wait();

                // Stop motor
                dcMotor.Stop(motorIndex);
            }
        }