简体   繁体   English

Raspberry Pi 4 控制伺服而不晃动

[英]Raspberry Pi 4 controlling a Servo without shaking

I've been trying to control a mg995 Servo by changing the duty Cycle with the RPi.GPIO library, but the Servo ended up shaking a lot.我一直在尝试通过使用 RPi.GPIO 库更改占空比来控制 mg995 伺服,但伺服最终摇晃了很多。 I've been reading a lot of Threads about this issue and I know, that using the RPi.GPIO library is causing the issue.我已经阅读了很多关于这个问题的线程,我知道,使用 RPi.GPIO 库会导致问题。 I then tried to use the pigpio library but it's unfortunately not available for the RP4.然后我尝试使用 pigpio 库,但遗憾的是它不适用于 RP4。 I know that buying a specific hardware could help out but I want to try it with software first.我知道购买特定的硬件可能会有所帮助,但我想先用软件尝试一下。 Is there another way to controll a Servo without the shaking?有没有其他方法可以控制伺服而不晃动? I want to run the Servo through python code btw我想通过 python 代码运行伺服

If the driving is not done at a too high PWM frequency then you can create a solution by using SYSFS driver, if you need high frequency the problem is maybe hardware and not software to control at the oscilloscope.如果驱动不是在太高的 PWM 频率下完成,那么您可以使用 SYSFS 驱动程序创建解决方案,如果您需要高频率,问题可能是硬件而不是软件在示波器上进行控制。 If you are able and want to do without any lib then you can write directly the gpio registers of the SOC through memory-map with mmap如果您能够并且想要不使用任何库,那么您可以使用mmap通过 memory-map 直接写入 SOC 的 gpio 寄存器

As I tested before, software PWM is unstable and the servos can shake a lot, hardward PWM is quite acurrate, but the pi has only 2 hardware PWM channels.正如我之前测试过的,软件 PWM 不稳定,舵机抖动很大,硬件 PWM 相当准确,但 pi 只有 2 个硬件 PWM 通道。 The best way may be add an external PWM module (PCA9685 for example).最好的方法可能是添加一个外部 PWM 模块(例如 PCA9685)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM