Git Product home page Git Product logo

m5_ddtmotor_m15m06's Introduction

M5Stack DDT Motor M06/M15 Library

**Direct Drive Tech社製ダイレクトドライブモーターのArduinoライブラリです。

販売ページ(スイッチサイエンス): https://www.switch-science.com/catalog/7646/

M5Stack,M5SickC等のM5シリーズでの使用を想定していますが、送受信部分のコードを一部可変すれば他のArduinoボードでも動作するかと思います。

Hardware

結線に関してはデータシート参照

Installing

  1. githubで本リポジトリを.zipでダウンロード
  2. ArduinoIDEからスケッチ -> ライブラリをインクルード -> .zip形式のライブラリをインストール

Usage

ファイル -> スケッチ例 -> DDT_Motor_M15M06 よりサンプルスケッチがあるのでそちらを参照してください。

  • spin_the_motor.ino

    モーターの正転逆転を行いつつ、シリアルモニタに現在速度を出力

Description

Initialize

auto motor_handler = MotorHandler(33, 32); // RX,TX

RX,TXはM5Stackの種類や使用しているモジュール・Hatによって異なります。

Spin the motor

 Control_Motor(uint16_t Speed, uint8_t ID, uint8_t Acce, uint8_t Brake_P, Receiver *Receiver);

いずれのモードにおいても、第一引数のSpeedに値を入れます。

Acceleration:Valid in velocity loop. unity: RPM/0.1ms. When set to 0, it wouldbethe default value

Brake:Valid in velocity loop when the value is 0xFF. Brake won’t work at other values.

Receiverオブジェクトにモーターの状態が格納されます

  • Receiv.ID ID
  • Receiv.BMode モード(mode)
  • Receiv.ECurru 電流(Current)
  • Receiv.BSpeed 速度(Velocity)
  • Receiv.Position 位置(Angle)
  • Receiv.ErrCode エラーコード(Fault value)

Obtain other feedback

Get_Motor(uint8_t ID, Receiver *Receiver);

Receiverオブジェクトにモーターの状態が格納されます

  • Receiv.ID ID
  • Receiv.BMode モード(mode)
  • Receiv.ECurru 電流(Current)
  • Receiv.BSpeed 速度(Velocity)
  • Receiv.Temp 温度(Stator tempe rature)
  • Receiv.Position 位置(Angle)
  • Receiv.ErrCode エラーコード(Fault value)

Angle in 8 bits:0 ~ 256 corresponds to 0 ~ 360° Stator

temperature :unity : ℃

Mode switching

Set_MotorMode(uint8_t Mode, uint8_t ID);
Mode Value
Current Mode 0x01 -32767 ~ 32767 correspond to 0 ~ 8A,INT16
Velocity Mode 0x02 -330~330 rpm,INT16
Angle Mode 0x03 0 ~ 32767correspond to 0° ~ 360°,UNT16

Only when the velocity is lower than 10 rpm that switching to angle loopisavailable. モード変更はフラッシュには保存されません。

ID setting

Set_MotorID(uint8_t ID);

Note:When setting the ID, please make sure that the bus has only one motor.

ID setting is allowed once every power reset. The ID will be changed after 5 times repeating the ID setting command.

ID check

Check_Motor(Receiver *Receiver);

Note: When checking the ID, please make sure that the bus has only one motor

Error Code

Fault value BIT7 BIT6 BIT5 BIT4 BIT3 BIT2 BIT1 BIT0
Description Reserved Reserved Reserved Overheat Stall Phase Over current Bus over current Sensor Fault

Sensor Fault E.g.:0x02 or 0b00000010 corresponds to Bus over current.

Trouble Shooting

  • コマンドを送っているのにモーターが回らない/値が取得できない
    • 一度モーターの電源を切り、再度電源投入すると値が取れる場合がある
    • モーターのケーブル黒線はGNDではないので注意
    • デフォルトIDは0ではなく0x01, Velocity Mode

Author

ゆうもや

Reference

m5_ddtmotor_m15m06's People

Contributors

takex5g avatar sato-susumu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.