mirror of
https://github.com/m5stack/m5-docs.git
synced 2026-05-20 10:23:01 -07:00
88 lines
3.2 KiB
Markdown
88 lines
3.2 KiB
Markdown
# STEPMOTOR モジュール {docsify-ignore-all}
|
|
|
|
<img src="assets/img/product_pics/module/module_stepmotor_01.png" width="30%" height="30%"> <img src="assets/img/product_pics/module/module_stepmotor_02.png" width="30%" height="30%"> <img src="assets/img/product_pics/module/module_stepmotor_03.png" width="30%" height="30%">
|
|
|
|
<!-- <img src="assets/img/product_pics/module/module_stepmotor_04.png" width="30%" height="30%"> -->
|
|
|
|
***
|
|
|
|
:memo:**[概要](#概要)** :octocat:**[サンプルコード](#サンプルコード)** :electric_plug:**[回路図](#回路図)** 🛒**[購入リンク](https://www.aliexpress.com/store/product/M5Stack-New-Arrival-Stepmotor-Module-for-Arduino-ESP32-GRBL-12C-Step-Motor-MEGA328P-similar-as-12V/3226069_32889109142.html?spm=2114.12010612.8148356.17.50511b9b5ViNuz)**
|
|
|
|
## 概要
|
|
|
|
**<mark>STEPMOTOR</mark>**モジュールはATmega328Pを内蔵しており、GRBLファームウェアによってモータをコントロールすることが可能です。M5StackのCoreとの通信にはI2Cを利用しています。I2Cアドレスは**<mark>0x70</mark>**です。
|
|
|
|
## 特徴
|
|
|
|
- 電源入力 9-24V
|
|
- 3-Way STEPMOTOR<mark>(X, Y, Z)</mark>
|
|
- リチウムバッテリー用インターフェース内蔵
|
|
|
|
## パッケージ内容
|
|
|
|
- 1x STEPMOTOR モジュール
|
|
- 1x 12V 電源 (オプション)
|
|
- 1x 5V ファンモジュール (オプション)
|
|
|
|
## アプリケーション
|
|
|
|
- 自作3Dプリンタ
|
|
- シンプルロボットアーム
|
|
|
|
## 関連リンク
|
|
|
|
- **[公式ビデオ](https://www.youtube.com/channel/UCozgFVglWYQXbvTmGyS739w)**
|
|
|
|
- **[フォーラム](http://forum.m5stack.com/)**
|
|
|
|
- **[モジュール内のMEGA328ファームウェア](https://github.com/m5stack/stepmotor_module/tree/master/Firmware%20for%20stepmotor%20module/GRBL-Arduino-Library)**
|
|
|
|
## サンプルコード
|
|
|
|
### 1. Arduino IDE
|
|
|
|
*以下のコードは不完全です(説明のためだけに). 完全なコードが必要な場合は、ここをクリックしてください[サンプルコード](https://github.com/m5stack/stepmotor_module/tree/master/Example/Arduino)。*
|
|
|
|
```adrduino
|
|
/*
|
|
If Button A was pressed,
|
|
stepmotor will rotate back and forth at a time
|
|
*/
|
|
|
|
#include <M5Stack.h>
|
|
#include <Wire.h>
|
|
|
|
#define STEPMOTOR_I2C_ADDR 0x70
|
|
|
|
// initialization
|
|
M5.begin();
|
|
Wire.begin();
|
|
|
|
// Controlling Protocol:
|
|
// G<n> X<distance>Y<distance>Z<distance> F<speed>
|
|
SendCommand(STEPMOTOR_I2C_ADDR, "G1 X20Y20Z20 F500");
|
|
SendCommand(STEPMOTOR_I2C_ADDR, "G1 X0Y0Z0 F400");
|
|
|
|
// Get Data from Module.
|
|
Wire.requestFrom(STEPMOTOR_I2C_ADDR, 1);
|
|
if (Wire.available() > 0) {
|
|
int u = Wire.read();
|
|
if (u != 0) Serial.write(u);
|
|
}
|
|
|
|
// Send Data to Module.
|
|
while (Serial.available() > 0) {
|
|
int inByte = Serial.read();
|
|
SendByte(STEPMOTOR_I2C_ADDR, inByte);
|
|
}
|
|
```
|
|
|
|
### 2. UIFlow
|
|
|
|
*特定のルーチンをクリックしてください[ルーチン](https://github.com/m5stack/M5-ProductExampleCodes/blob/master/Module/STEPMOTOR/UIFlow)。*
|
|
|
|
<img src="assets/img/product_pics/module/module_example/STEPMOTOR/example_module_stepmotor_01.png">
|
|
|
|
## 回路図
|
|
|
|
<img src="assets/img/product_pics/module/stepmotor_sch.png"> |