前提・実現したいこと
ステッピングモーターを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関数が無いことが理由だと思うのですがどうやって書けばいいんでしょうか。
回答よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー