두 개의 PWM 신호 (예 : PWM 입력)의 주파수 및 듀티 사이클을 얻고 입력에 따라 다른 PWM 신호 (즉 PWM 출력)를 설정하려고합니다. 이 PWM 신호의 듀티 사이클은 50 %이며 주파수 범위는 1kHz ~ 20kHz입니다.MS-IoT Lightning을 사용하여 Raspberry Pi2로 PWM을 설정/가져 오는 방법?
웹을 조금 확인했는데 Windows 10 IoT Core에서 Microsoft IoT Lightning 라이브러리 (예 : 버스 제공 업체)를 찾았습니다. 이 라이브러리는 PWM 소비자 예제에서도 필자가 필요로하는 것 같다.
그러나 PWM Consumer에 기초한 첫 번째 예제를 테스트하는 동안 PWM 컨트롤러 주파수 범위가 40Hz에서 1kHz로 제한된다는 것을 알았습니다. 따라서 첫 번째 문제는 주파수 범위가 지원되지 않는 것 같습니다.
또한 PWM 컨트롤러 속성 "ActualFrequency"는 "SetDesiredFrequencyMethod"를 통해 설정된 주파수를 반환하지만 PWMPin 개체는 현재 듀티 사이클에 대한 정보 만 제공합니다.
따라서 나는 몇 가지 대답을 찾기 위해 인터넷 검색을했고, 나는 이전의 두 가지 문제보다 훨씬 혼란 스럽다 this question을 발견했습니다.
가능하면 MS-IoT Lightning Library를 사용하여 Raspberry Pi2에서 1kHz ~ 20kHz의 PWM 신호를 설정/가져 오는 방법을 알고 있습니까? 여기
, 예제에서 코드의 몇 행 :
public async void Run(IBackgroundTaskInstance taskInstance)
{
if (!LightningProvider.IsLightningEnabled)
{
// Lightning provider is required for this sample
return;
}
var deferral = taskInstance.GetDeferral();
// Use the PAC9685 PWM provider, LightningPCA9685PwmControllerProvider
pwmController = (await PwmController.GetControllersAsync(LightningPwmProvider.GetPwmProvider()))[0];
motorPin = pwmController.OpenPin(0);
secondMotorPin = pwmController.OpenPin(1);
//// To use the software PWM provider, LightningSoftwarePwmControllerProvider, with GPIO pins 5 and 6,
//// uncomment the following lines and comment the ones above
//pwmController = (await PwmController.GetControllersAsync(LightningPwmProvider.GetPwmProvider()))[1];
//motorPin = pwmController.OpenPin(5);
//secondMotorPin = pwmController.OpenPin(6);
pwmController.SetDesiredFrequency(50);
motorPin.SetActiveDutyCyclePercentage(RestingPulseLegnth);
motorPin.Start();
secondMotorPin.SetActiveDutyCyclePercentage(RestingPulseLegnth);
secondMotorPin.Start();
timer = ThreadPoolTimer.CreatePeriodicTimer(Timer_Tick, TimeSpan.FromMilliseconds(500));
}
private void Timer_Tick(ThreadPoolTimer timer)
{
iteration++;
if (iteration % 3 == 0)
{
currentPulseLength = ClockwisePulseLength;
secondPulseLength = CounterClockwisePulseLegnth;
}
else if (iteration % 3 == 1)
{
currentPulseLength = CounterClockwisePulseLegnth;
secondPulseLength = ClockwisePulseLength;
}
else
{
currentPulseLength = 0;
secondPulseLength = 0;
}
double desiredPercentage = currentPulseLength/(1000.0/pwmController.ActualFrequency);
motorPin.SetActiveDutyCyclePercentage(desiredPercentage);
double secondDesiredPercentage = secondPulseLength/(1000.0/pwmController.ActualFrequency);
secondMotorPin.SetActiveDutyCyclePercentage(secondDesiredPercentage);
}
모든 최고의, 로렌조
Ok @ Servé, RPi (즉, Raspberry Pi)는 실시간 시스템이 아닙니다. 그런 다음 MS-IoT (Microsoft IoT Lightning) 번개를 어떻게 사용합니까? 그 목적은 무엇입니까? –
나는 그 도서관에 대해 잘 모른다. 소스를 보면 Arduino를 위해 제작 된 것 같습니다. 어쩌면 다른 사람이 도울 수 있습니다 – Laurijssen
누군가가 도울 수 있는지 보자;) –