他有兩個 版本
1. kernel space 版本
2. user space 版本
kernel 版本 compile 起來有問題....然後作者也推薦使用 user space 版本
原文如下:
There are two implementations of ServoBlaster; a kernel module based one, and a user space daemon. The kernel module based one is the original, but is more of a pain to build because you need a matching kernel build. The user space daemon implementation is much more convenient to use and now has rather more features than the kernel based one. I would strongly recommend you use the user space implementation.
進到 user folder....
編譯指令:
sudo make
或是
sudo make install
其實兩個只差在如果你打 install... 就是開機的時候就會去load 去執行
執行指令:
$ sudo ./servod
結果如下:
Board revision: 1 Using hardware: PWM Using DMA channel: 14 Idle timeout: Disabled Number of servos: 8 Servo cycle time: 20000us Pulse increment step size: 10us Minimum width value: 50 (500us) Maximum width value: 250 (2500us) Output levels: Normal Using P1 pins: 7,11,12,13,15,16,18,22 Servo mapping: 0 on P1-7 GPIO-4 1 on P1-11 GPIO-17 2 on P1-12 GPIO-18 3 on P1-13 GPIO-27 4 on P1-15 GPIO-22 5 on P1-16 GPIO-23 6 on P1-18 GPIO-24 7 on P1-22 GPIO-25
它總共有八個PWM 輸出....
If you want to stop servod, the easiest way is to run: $ sudo killall servod
The default option is the equivalent of specifying --p1pins=7,11,12,13,15,16,18,22
可以修改的地方
Q1 : 如果只要四個輸出...要怎改?
A1 :
修改 servod.c
把static char *default_p1_pins = "7,11,12,13,15,16,18,22";
改成static char *default_p1_pins = "7,11,12,13";
就可以了
Q2 : 如何改pulse width 的最小值(1000us)...最大值(2000us)
A2 :
#define DEFAULT_SERVO_MIN_US 500
#define DEFAULT_SERVO_MAX_US 2500
改成
單位是 1 us
#define DEFAULT_SERVO_MIN_US 1000
#define DEFAULT_SERVO_MAX_US 2000
Q3 : 如何更改 cycle time, 改成 490Hz -> (1000000/490 = 2040):
#define DEFAULT_CYCLE_TIME_US 20000
改成#define DEFAULT_CYCLE_TIME_US 2040
Q4 : 如何更改 step_size , 從 10us 改成 2us...
#define DEFAULT_STEP_TIME_US 10
改成#define DEFAULT_STEP_TIME_US 2
Q5 : 如何動態更改pulse寬度
指定us 的方式
echo P1-7=1500us > /dev/servoblaster
指定 step 的方式
echo P1-7=150 > /dev/servoblaster # Using P1 pin number rather
Reference : https://github.com/richardghirst/PiBits/tree/master/ServoBlaster
沒有留言:
張貼留言