ameyer / arduino-l6470 Goto Github PK
View Code? Open in Web Editor NEWL6470 Stepper Motor Driver library for Arduino
L6470 Stepper Motor Driver library for Arduino
Hello!
The Marlin Firmware now supports the L6470 Stepperdriver and needs this Library to support it.
I think it is a very interesting driver and so I ordered 2 Drivermodules.
Now i try to get it to work. I downloaded and installed the 'Arduino-L6470' library in the Arduino Ide 1.8.2.
It looks OK an I can select in Examples the example code. But if i try to compile it it exits with errors. If it activate the L6470 support the errors are the same. I tried it to compile in Arduino 1.0.1 (if it is an version problem). But it is the same. Unfortunately I am not an experienced arduino programmer. I don´t know whats the problem. I wonder that this library is necessary for Marlin but there is now further information...
Perhaps it is a stupid mistake from me. Thanks a lot.
Underneath the compiling errors of the L6470 example code
Arduino: 1.8.2 (Windows 7), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"
C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\TK_T530\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\TK_T530\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\TK_T530\Documents\Arduino\libraries -fqbn=arduino:avr:mega:cpu=atmega2560 -ide-version=10802 -build-path C:\Users\TK_T530\AppData\Local\Temp\arduino_build_426690 -warnings=none -build-cache C:\Users\TK_T530\AppData\Local\Temp\arduino_cache_859426 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.1.1 -prefs=runtime.tools.avrdude.path=C:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino9 -prefs=runtime.tools.avr-gcc.path=C:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2 -verbose C:\Users\TK_T530\Documents\Arduino\libraries\L6470\examples\L6470\L6470.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\TK_T530\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\TK_T530\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\TK_T530\Documents\Arduino\libraries -fqbn=arduino:avr:mega:cpu=atmega2560 -ide-version=10802 -build-path C:\Users\TK_T530\AppData\Local\Temp\arduino_build_426690 -warnings=none -build-cache C:\Users\TK_T530\AppData\Local\Temp\arduino_cache_859426 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.1.1 -prefs=runtime.tools.avrdude.path=C:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino9 -prefs=runtime.tools.avr-gcc.path=C:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2 -verbose C:\Users\TK_T530\Documents\Arduino\libraries\L6470\examples\L6470\L6470.ino
Using board 'mega' from platform in folder: C:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21
Using core 'arduino' from platform in folder: C:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21
Build-Optionen wurden verändert, alles wird neu kompiliert
Detecting libraries used...
"C:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10802 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\cores\arduino" "-IC:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\variants\mega" "C:\Users\TK_T530\AppData\Local\Temp\arduino_build_426690\sketch\L6470.ino.cpp" -o "nul"
"C:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10802 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\cores\arduino" "-IC:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\variants\mega" "-IC:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\libraries\SPI\src" "C:\Users\TK_T530\AppData\Local\Temp\arduino_build_426690\sketch\L6470.ino.cpp" -o "nul"
"C:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10802 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\cores\arduino" "-IC:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\variants\mega" "-IC:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\libraries\SPI\src" "-IC:\Users\TK_T530\Documents\Arduino\libraries\L6470" "C:\Users\TK_T530\AppData\Local\Temp\arduino_build_426690\sketch\L6470.ino.cpp" -o "nul"
"C:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10802 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\cores\arduino" "-IC:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\variants\mega" "-IC:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\libraries\SPI\src" "-IC:\Users\TK_T530\Documents\Arduino\libraries\L6470" "C:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\libraries\SPI\src\SPI.cpp" -o "nul"
"C:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10802 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\cores\arduino" "-IC:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\variants\mega" "-IC:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\libraries\SPI\src" "-IC:\Users\TK_T530\Documents\Arduino\libraries\L6470" "C:\Users\TK_T530\Documents\Arduino\libraries\L6470\L6470.cpp" -o "nul"
Generating function prototypes...
"C:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10802 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\cores\arduino" "-IC:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\variants\mega" "-IC:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\libraries\SPI\src" "-IC:\Users\TK_T530\Documents\Arduino\libraries\L6470" "C:\Users\TK_T530\AppData\Local\Temp\arduino_build_426690\sketch\L6470.ino.cpp" -o "C:\Users\TK_T530\AppData\Local\Temp\arduino_build_426690\preproc\ctags_target_for_gcc_minus_e.cpp"
"C:\Program Files (x86)\Arduino\tools-builder\ctags\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\Users\TK_T530\AppData\Local\Temp\arduino_build_426690\preproc\ctags_target_for_gcc_minus_e.cpp"
Sketch wird kompiliert...
"C:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10802 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\cores\arduino" "-IC:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\variants\mega" "-IC:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\libraries\SPI\src" "-IC:\Users\TK_T530\Documents\Arduino\libraries\L6470" "C:\Users\TK_T530\AppData\Local\Temp\arduino_build_426690\sketch\L6470.ino.cpp" -o "C:\Users\TK_T530\AppData\Local\Temp\arduino_build_426690\sketch\L6470.ino.cpp.o"
Compiling libraries...
Compiling library "SPI"
"C:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10802 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\cores\arduino" "-IC:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\variants\mega" "-IC:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\libraries\SPI\src" "-IC:\Users\TK_T530\Documents\Arduino\libraries\L6470" "C:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\libraries\SPI\src\SPI.cpp" -o "C:\Users\TK_T530\AppData\Local\Temp\arduino_build_426690\libraries\SPI\SPI.cpp.o"
Compiling library "L6470"
"C:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10802 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\cores\arduino" "-IC:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\variants\mega" "-IC:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\libraries\SPI\src" "-IC:\Users\TK_T530\Documents\Arduino\libraries\L6470" "C:\Users\TK_T530\Documents\Arduino\libraries\L6470\L6470.cpp" -o "C:\Users\TK_T530\AppData\Local\Temp\arduino_build_426690\libraries\L6470\L6470.cpp.o"
C:\Users\TK_T530\Documents\Arduino\libraries\L6470\L6470.cpp: In member function 'int L6470::getStatus()':
C:\Users\TK_T530\Documents\Arduino\libraries\L6470\L6470.cpp:316:10: error: expected primary-expression before '=' token
return = Xfer(0) << 8 | Xfer(0);
^
C:\Users\TK_T530\Documents\Arduino\libraries\L6470\L6470.cpp: In member function 'long unsigned int L6470::AccCalc(float)':
C:\Users\TK_T530\Documents\Arduino\libraries\L6470\L6470.cpp:325:28: error: expected ';' before ':' token
return temp < 0x00000FFF : temp : 0x00000FFF;
^
C:\Users\TK_T530\Documents\Arduino\libraries\L6470\L6470.cpp:325:28: error: expected primary-expression before ':' token
C:\Users\TK_T530\Documents\Arduino\libraries\L6470\L6470.cpp: In member function 'long unsigned int L6470::DecCalc(float)':
C:\Users\TK_T530\Documents\Arduino\libraries\L6470\L6470.cpp:332:28: error: expected ';' before ':' token
return temp < 0x00000FFF : temp : 0x00000FFF;
^
C:\Users\TK_T530\Documents\Arduino\libraries\L6470\L6470.cpp:332:28: error: expected primary-expression before ':' token
C:\Users\TK_T530\Documents\Arduino\libraries\L6470\L6470.cpp: In member function 'long unsigned int L6470::MaxSpdCalc(float)':
C:\Users\TK_T530\Documents\Arduino\libraries\L6470\L6470.cpp:341:28: error: expected ';' before ':' token
return temp < 0x000003FF : temp : 0x000003FF;
^
C:\Users\TK_T530\Documents\Arduino\libraries\L6470\L6470.cpp:341:28: error: expected primary-expression before ':' token
C:\Users\TK_T530\Documents\Arduino\libraries\L6470\L6470.cpp: In member function 'long unsigned int L6470::MinSpdCalc(float)':
C:\Users\TK_T530\Documents\Arduino\libraries\L6470\L6470.cpp:350:28: error: expected ';' before ':' token
return temp < 0x00000FFF : temp : 0x00000FFF;
^
C:\Users\TK_T530\Documents\Arduino\libraries\L6470\L6470.cpp:350:28: error: expected primary-expression before ':' token
C:\Users\TK_T530\Documents\Arduino\libraries\L6470\L6470.cpp: In member function 'long unsigned int L6470::FSCalc(float)':
C:\Users\TK_T530\Documents\Arduino\libraries\L6470\L6470.cpp:359:28: error: expected ';' before ':' token
return temp < 0x000003FF : temp : 0x000003FF;
^
C:\Users\TK_T530\Documents\Arduino\libraries\L6470\L6470.cpp:359:28: error: expected primary-expression before ':' token
C:\Users\TK_T530\Documents\Arduino\libraries\L6470\L6470.cpp: In member function 'long unsigned int L6470::IntSpdCalc(float)':
C:\Users\TK_T530\Documents\Arduino\libraries\L6470\L6470.cpp:368:28: error: expected ';' before ':' token
return temp < 0x00003FFF : temp : 0x00003FFF;
^
C:\Users\TK_T530\Documents\Arduino\libraries\L6470\L6470.cpp:368:28: error: expected primary-expression before ':' token
C:\Users\TK_T530\Documents\Arduino\libraries\L6470\L6470.cpp: In member function 'long unsigned int L6470::SpdCalc(float)':
C:\Users\TK_T530\Documents\Arduino\libraries\L6470\L6470.cpp:377:28: error: expected ';' before ':' token
return temp < 0x000FFFFF : temp : 0x000FFFFF;
^
C:\Users\TK_T530\Documents\Arduino\libraries\L6470\L6470.cpp:377:28: error: expected primary-expression before ':' token
Bibliothek SPI in Version 1.0 im Ordner: C:\Users\TK_T530\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\libraries\SPI wird verwendet
Bibliothek L6470 im Ordner: C:\Users\TK_T530\Documents\Arduino\libraries\L6470 (legacy) wird verwendet
exit status 1
Fehler beim Kompilieren für das Board Arduino/Genuino Mega or Mega 2560.
Hi, while this compiles fine for the esp8266 it doesn't actually work.
What would be required for it to work on ESPs?
There are currently no available library's for the L6470 and yours looks like the closest to be able to get working.
Thanks
i want read Mark Position with easy command like stepper.getMark();
Thanks
.piolibdeps/3cd0993/L6470.h:189:0: warning: "DEC" redefined
#define DEC 0x06
This name is defined by arduino/Print.h
as a flag to print in base 10.
Serial.println('good to go');
Serial.println('Comm issue');
These strings should be double-quoted. A PR for that is pending.
I realized quickly that run time utilities to return status and set various parameters would be very useful. The biggest problem I had was accessing specific drivers with statements like:
LOOPXYZE(I) {
get status(I)
set parameter(I)
}
The solution I came up with was:
extern uint8_t L6470_chain[L6470_driver(20 + 1]; // 0 - number of drivers in chain, 1... axis
uint8_t L6470_chain[L6470_driver(MAX_L6470) + 1]; // 0 - number of drivers in chain, 1... axis
L6470::L6470(const int SSPin, const byte axis, const byte position) {
// _SSPin = SSPin;
_SSPin = L6470_SS_PIN;
// Serial.begin(9600);
Axis = axis;
_Position = position;
L6470_chain[0]++;
L6470_chain[position] = axis
I'd be surprised if there wasn't a much better method. Suggestions?
In L6470.h line 203 to 206, the status register of MOT_STATUS is bit 6 and bit 5, so I think the code should be modified from
STATUS_MOT_STATUS_STOPPED (0x0000<<13)
to
STATUS_MOT_STATUS_STOPPED (0x0000<<5)
Because if you left shift 13 bits, it would be bit 14 and bit 13.
One of the things I did to implement the SPI chain for the Nucleo boards was to hardwire in a new SPI routine.
I'd appreciate suggestions on how to setup the library so that it can be directed to an optional L6470 specific SPI channel.
The only way I know is to test for a build flag, NOT compile the library's transfer function and depend of the project to provide it.
Something like this
PlatformIO.ini
build_flags = -DL6470_EXT_SPI
L6470.cpp
#ifndef L6470_EXT_SPI
byte L6470::Xfer(byte data) {
…
#endif
project file
#ifdef L6470_EXT_SPI
byte L6470::Xfer(byte data) {
…
#endif
The problem with this approach is the Arduino IDE doesn't have a way of creating the build flag. This would be Marlin specific.
I'd rather do something like #ifdef "file in project" but I don't think the C preprocessor can do that.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.