覚え書きブログ

Raspberry PIの覚え書き(サーボモータ制御編)

Raspberry PIのGPIOを使ってサーボモータの制御をしたときのメモ。
f:id:hirotaka_hachiya:20141211015951j:plain
Richard Hirst氏が開発したServoBlasterというカーネルドライバを使う。
まず、Github repoからソースをダウンロードする。
1)git clone https://github.com/richardghirst/PiBits.git

2)ダウンロードしたディレクトリに移動し、コンパイルする。
$ cd PiBits/ServoBlaster
$ make install_autostart

ServoBlaster udev rules complete.
Enabling ServoBlaster autostart on boot.
ServoBlaster will now auto start on next boot.
The following commands will start and stop the driver:
modprobe servoblaster
modprobe -r servoblaster

3)servoblasterドライバを組み込む
modprobe servoblaster

4)コマンドで動作確認
echo 2=160 > /dev/servoblaster

サーボIDとピン番号との関係:
Servo number GPIO number Pin in P1 header
0 4 P1-7
1 17 P1-11
2 18 P1-12
3 21 P1-13
4 22 P1-15
5 23 P1-16
6 24 P1-18
7 25 P1-22