简体   繁体   English

raspberry pi B +硬件PWM

[英]raspberry pi B+ hardware PWM

Raspberry pi B+ has four hardware PWM. Raspberry pi B +有四个硬件PWM。 How to use them in C/C++. 如何在C / C ++中使用它们。 The less complicated solution - the better. 解决方案越简单越好。

I found one working solution with WiringPi 我找到了一个使用WiringPi的工作解决方案

gpio mode 1 pwm  
gpio pwm-bal  
gpio pwmr 1024  
gpio pwm 1 500  

This solution works only for one PWM output (GPIO18). 该解决方案仅适用于一个PWM输出(GPIO18)。 I thinks it is because WiringPi is designed for previous version of raspberry pi (Model B+ has new PWMs on GPIO12, GPIO13 and GPIO19). 我认为这是因为WiringPi是为先前版本的raspberry pi设计的(Model B +在GPIO12,GPIO13和GPIO19上有新的PWM)。

For controlling regular GPIO I found solution: 为了控制常规GPIO我找到了解决方案:

pi@auto:~$ sudo -i  
root@auto:~# echo "16" > /sys/class/gpio/export  
root@auto:~# echo "out" > /sys/class/gpio/gpio16/direction  
root@auto:~# echo "1" > /sys/class/gpio/gpio16/value  
root@auto:~# echo "0" > /sys/class/gpio/gpio16/value  

But there is no way how to control hardware PWM. 但是如何控制硬件PWM是没有办法的。

Product https://www.pololu.com/product/2753 has reference to python library - that do exactly what I want. 产品https://www.pololu.com/product/2753引用了python库 - 这正是我想要的。

Please no software PWM suggestions. 请不要软件PWM建议。

Thanks 谢谢

Vlado 弗拉多

Here is aa distro that can hopefully fit your need. 是一个有希望满足您需求的发行版。 It provides PWM and Servo kernel modules. 它提供PWM和伺服内核模块。 You can simply modify the kernel files under /sys/class/rpi-pwm/ to create custom PWM output. 您只需修改/ sys / class / rpi-pwm /下的内核文件即可创建自定义PWM输出。
Here is the download link. 是下载链接。

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

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