質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Arduino

Arduinoは、AVRマイコン、単純なI/O(入出力)ポートを備えた基板、C言語を元としたArduinoのプログラム言語と、それを実装した統合開発環境から構成されたシステムです。

Q&A

解決済

1回答

2347閲覧

ステッピングモーターが動きません

退会済みユーザー

退会済みユーザー

総合スコア0

Arduino

Arduinoは、AVRマイコン、単純なI/O(入出力)ポートを備えた基板、C言語を元としたArduinoのプログラム言語と、それを実装した統合開発環境から構成されたシステムです。

0グッド

0クリップ

投稿2019/09/07 13:25

編集2019/09/07 22:33

前提・実現したいこと

ステッピングモーターをArduinoで動かそうとしたのですが動かない、というかコードにエラーが出てしまいます。ユニポーラ型のステッピングモーターを秋月のL6470モータードライバで動かそうとしてArduino IDEにサイトから拾ってきたコードを貼ったのですがエラーが出てしまいうまく動きません。
該当のサイトです。
https://deviceplus.jp/hobby/entry037/

発生している問題・エラーメッセージ

Arduino:1.8.9 (Windows Store 1.8.21.0) (Windows 10), ボード:"Arduino/Genuino Uno" C:\Users\eisuk\OneDrive\ドキュメント\Arduino\sketch_sep07a\sketch_sep07a.ino:4:0: warning: "PIN_SPI_MOSI" redefined In file included from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:257:0, from sketch\sketch_sep07a.ino.cpp:1: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\variants\standard/pins_arduino.h:39:0: note: this is the location of the previous definition #define PIN_SPI_MOSI (11) ^ C:\Users\eisuk\OneDrive\ドキュメント\Arduino\sketch_sep07a\sketch_sep07a.ino:5:0: warning: "PIN_SPI_MISO" redefined In file included from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:257:0, from sketch\sketch_sep07a.ino.cpp:1: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\variants\standard/pins_arduino.h:40:0: note: this is the location of the previous definition #define PIN_SPI_MISO (12) ^ C:\Users\eisuk\OneDrive\ドキュメント\Arduino\sketch_sep07a\sketch_sep07a.ino:6:0: warning: "PIN_SPI_SCK" redefined In file included from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:257:0, from sketch\sketch_sep07a.ino.cpp:1: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\variants\standard/pins_arduino.h:41:0: note: this is the location of the previous definition #define PIN_SPI_SCK (13) ^ C:\Users\eisuk\OneDrive\ドキュメント\Arduino\sketch_sep07a\sketch_sep07a.ino:7:0: warning: "PIN_SPI_SS" redefined In file included from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:257:0, from sketch\sketch_sep07a.ino.cpp:1: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\variants\standard/pins_arduino.h:38:0: note: this is the location of the previous definition #define PIN_SPI_SS (10) ^ C:\Users\eisuk\OneDrive\ドキュメント\Arduino\sketch_sep07a\sketch_sep07a.ino: In function 'void setup()': sketch_sep07a:24:21: error: 'L6470_resetdevice' was not declared in this scope C:\Users\eisuk\OneDrive\ドキュメント\Arduino\sketch_sep07a\sketch_sep07a.ino: In function 'void loop()': sketch_sep07a:30:1: error: expected primary-expression before '<' token sketch_sep07a:30:2: error: 'span' was not declared in this scope sketch_sep07a:31:22: error: 'L6470_busydelay' was not declared in this scope sketch_sep07a:31:24: error: expected primary-expression before '<' token sketch_sep07a:31:25: error: expected primary-expression before '/' token sketch_sep07a:32:1: error: expected primary-expression before '}' token C:\Users\eisuk\OneDrive\ドキュメント\Arduino\sketch_sep07a\sketch_sep07a.ino: In function 'void L6470_setup()': sketch_sep07a:35:24: error: 'L6470_setparam_acc' was not declared in this scope sketch_sep07a:36:24: error: 'L6470_setparam_dec' was not declared in this scope sketch_sep07a:37:29: error: 'L6470_setparam_maxspeed' was not declared in this scope sketch_sep07a:38:29: error: 'L6470_setparam_minspeed' was not declared in this scope sketch_sep07a:39:27: error: 'L6470_setparam_fsspd' was not declared in this scope sketch_sep07a:40:29: error: 'L6470_setparam_kvalhold' was not declared in this scope sketch_sep07a:41:28: error: 'L6470_setparam_kvalrun' was not declared in this scope sketch_sep07a:42:28: error: 'L6470_setparam_kvalacc' was not declared in this scope sketch_sep07a:43:28: error: 'L6470_setparam_kvaldec' was not declared in this scope sketch_sep07a:45:29: error: 'L6470_setparam_stepmood' was not declared in this scope C:\Users\eisuk\OneDrive\ドキュメント\Arduino\sketch_sep07a\sketch_sep07a.ino: In function 'void fulash()': sketch_sep07a:50:39: error: 'L6470_getparam_abspos' was not declared in this scope sketch_sep07a:53:40: error: 'L6470_getparam_speed' was not declared in this scope exit status 1 'L6470_resetdevice' was not declared in this scope 「ファイル」メニューの「環境設定」から 「より詳細な情報を表示する:コンパイル」を有効にすると より詳しい情報が表示されます。

該当のソースコード

Arduino

1#include <SPI.h> 2 3// ピン定義。 4#define PIN_SPI_MOSI 11 5#define PIN_SPI_MISO 12 6#define PIN_SPI_SCK 13 7#define PIN_SPI_SS 10 8#define PIN_BUSY 9 9 10void setup() 11{ 12 delay(1000); 13 pinMode(PIN_SPI_MOSI, OUTPUT); 14 pinMode(PIN_SPI_MISO, INPUT); 15 pinMode(PIN_SPI_SCK, OUTPUT); 16 pinMode(PIN_SPI_SS, OUTPUT); 17 pinMode(PIN_BUSY, INPUT); 18 SPI.begin(); 19 SPI.setDataMode(SPI_MODE3); 20 SPI.setBitOrder(MSBFIRST); 21 Serial.begin(9600); 22 digitalWrite(PIN_SPI_SS, HIGH); 23 24 L6470_resetdevice(); //ここで問題が起こっています 25 L6470_setup(); 26 delay(4000); 27} 28 29void loop(){ 30<span style="color: #ff0000;"> L6470_move(1,500); 31 L6470_busydelay(500);</span> 32} 33 34void L6470_setup(){ 35L6470_setparam_acc(0x40); 36L6470_setparam_dec(0x40); 37L6470_setparam_maxspeed(0x40); 38L6470_setparam_minspeed(0x01); 39L6470_setparam_fsspd(0x3ff); 40L6470_setparam_kvalhold(0x20); 41L6470_setparam_kvalrun(0x20); 42L6470_setparam_kvalacc(0x20); 43L6470_setparam_kvaldec(0x20); 44 45L6470_setparam_stepmood(0x03); 46} 47 48void fulash(){ 49 Serial.print("0x"); 50 Serial.print( L6470_getparam_abspos(),HEX); 51 Serial.print(" "); 52 Serial.print("0x"); 53 Serial.println( L6470_getparam_speed(),HEX); 54}

試したこと

MsTimer2ライブラリを導入していなかったため該当のコードは削除しました。

補足情報(FW/ツールのバージョンなど)

L6470_resetdevice関数が無いことが理由だと思うのですがどうやって書けばいいんでしょうか。
回答よろしくお願いします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

ozwk

2019/09/07 14:35

参考にしたリンクをちゃんと読んでください そのコードだけでは動かないと書いてあります
退会済みユーザー

退会済みユーザー

2019/09/08 00:10

ご指摘ありがとうございます 改善しました
guest

回答1

0

ベストアンサー

参考先サイトさまからさらにリンク先であるここ からL6470_commands.inoを入手し、導入する必要があるのではないかと思います。

投稿2019/09/07 13:35

nomuken

総合スコア1627

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

退会済みユーザー

退会済みユーザー

2019/09/07 13:57

ありがとうございます 明日やってみます
退会済みユーザー

退会済みユーザー

2019/09/08 08:11

解決しました!動きました!
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問