LoginSignup
2
2

More than 3 years have passed since last update.

RaspberryPi/Ubuntuで3相ブラシレスDCモーターを制御する

Posted at

DIY自動運転車用のインホイールモーターを動かすための練習で、まずは小型のブラシレスモーターを動かしてみる。

参考:
https://shizenkarasuzon.hatenablog.com/entry/2019/03/04/002326
ブラシレスモータをRaspberry PIやArduinoで制御してみる

物品

ブラシレスDCモーターはアマゾンで1000円くらい。
https://www.amazon.co.jp/gp/product/B01DBGY6OA/

ESCも700円くらい。30A。
https://www.amazon.co.jp/gp/product/B016MNN7EE/

配線

ラズパイのGPIO-4、GNDに接続。その他は適当にギボシ端子で結線。
IMG_5215.jpg
quad_motor.png

pigpioのインストール

ラズパイのGPIOでPWM制御をするためのライブラリ。
公式サイトに従ってインストール。
http://abyz.me.uk/rpi/pigpio/download.html

wget https://github.com/joan2937/pigpio/archive/master.zip
unzip master.zip
cd pigpio-master
make
sudo make install

デーモンも稼働させておく。

sudo pigpiod

Pythonコード

import time
import pigpio
motor_pin = 4

pi = pigpio.pi()

pi.set_servo_pulsewidth(motor_pin, 2000)
print("max")
time.sleep(2)
pi.set_servo_pulsewidth(motor_pin, 1000)
print("min")
time.sleep(3)

for i in range(3):
        pi.set_servo_pulsewidth(motor_pin, 2000)
        time.sleep(2)
        pi.set_servo_pulsewidth(motor_pin, 1200)
        print("1200")
        time.sleep(2)

pi.set_servo_pulsewidth(motor_pin, 0)
pi.stop()

モーターが無事回った。もっと低速で回したいが、モータースペックのためか、1000以下だとうまく回らず。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2