Raspberry Pi中PWM的频率调节 [英] Frequency regulation for PWM in Raspberry Pi
问题描述
我试图通过驱动程序控制步进电机,并修改电机的速度我需要改变PWM的频率,但是我的代码没有允许我对频率进行更改,换句话说,命令是定义固定的
频率值。有人可以帮我解决这个问题吗?
I am trying to control a stepper motor by means of a driver, and to modify the speed of the motor I need to change the frequency of the PWM, but my code does not allow me to make that change of frequency, in other words, the command is to define a fixed frequency value . Could someone help me solve that?
这是我正在使用的代码片段
This is the code snippet that i´m using
private async void SetupGPIO()
{
var gpioController = GpioController.GetDefault();
var pwmManager = new PwmProviderManager();
pwmManager.Providers.Add(new SoftPwm());
var pwmControllers = await pwmManager.GetControllersAsync();
//use the first available PWM controller an set refresh rate (Hz)
_pwmController = pwmControllers[0];
_pwmController.SetDesiredFrequency(240);
推荐答案
Hello Jose,
Hello Jose,
PwmProviderManager是否来自 Microsoft.IoT.DeviceCore.Pwm Nuget包?
Does the PwmProviderManager come from Microsoft.IoT.DeviceCore.Pwm Nuget package?
我测试以下命令来设置360之类的其他值,它设置成功。以下是测试结果:
I test the following command to set other value like 360, it set successfully. The following is test result:
那么你想设定什么价值?
So what value do you want to set?
祝你好运,
Rita
这篇关于Raspberry Pi中PWM的频率调节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!