private void ServoTest() { if (pwmDriver.IsInitialized) { const byte channel = 0; const int msSleepTime = 1000; const double minPulseDuration = 0.7; const double maxPulseDuration = 2.3; const double step = 0.1; for (var pulseDuration = maxPulseDuration; pulseDuration >= minPulseDuration - step; pulseDuration -= step) { var registerValue = PcaPwmDriver.PulseDurationToRegisterValue(pulseDuration, hzFrequency); pwmDriver.SetChannelValue(channel, registerValue); Task.Delay(msSleepTime).Wait(); } // PWM 채널 비활성화 pwmDriver.SetChannelValue(pwmChannel, PcaPwmDriver.FullyOff); } }
private async Task InitializePwmDriver() { pwmDriver = new PcaPwmDriver(); await pwmDriver.Init(); if (pwmDriver.IsInitialized) { // Enable oscillator pwmDriver.SetSleepMode(SleepMode.Normal); } }
private async Task InitializePwmDriver() { pwmDriver = new PcaPwmDriver(); await pwmDriver.Init(pwmAddress); if (pwmDriver.IsInitialized) { // 오실레이터 활성화 pwmDriver.SetSleepMode(SleepMode.Normal); // 주파수 설정 pwmDriver.SetFrequency(hzFrequency); } }
public StepperMotor(PcaPwmDriver pcaPwmDriver, uint steps = 200) { Check.IsNull(pcaPwmDriver); this.pcaPwmDriver = pcaPwmDriver; Steps = steps * MicroStepCount; SetSpeed(Rpm); fullStepControlPhases = ControlPhaseHelper.GetFullStepSequence(); // 마이크로 스테핑 제어 단계 및 선형 램프 microStepControlPhases = ControlPhaseHelper.GetMicroStepSequence(); microStepCurve = MicrosteppingHelper.GetLinearRamp(MicroStepCount); }
public DcMotor(PcaPwmDriver pcaPwmDriver) { Check.IsNull(pcaPwmDriver); this.pcaPwmDriver = pcaPwmDriver; }
public void SetPulseParameters(int pin, double dutyCycle, bool invertPolarity) { var pcaRegisterValue = PcaPwmDriver.DutyCycleToRegisterValue(dutyCycle, invertPolarity); pcaPwmDriver.SetChannelValue(Convert.ToByte(pin), pcaRegisterValue); }