Dear all,
This is my first post, I hope I’m not doing too many mistakes
I have an Arduino Nano 33 BLE and I want to control (among many other things) a Trinamic TMC2209 Stepper Driver Board. I am trying to make one of the examples coming with the TMCStepper library called “Simple”.
After fighting against several compilations errors due to Serial specificities of the Nano 33 BLE board, I finaly made it to the (hopefully) last error. It’s the following :
In file included from C:\Users\XXX\AppData\Local\Arduino15\packages\arduino\hardware\mbed\1.3.2\cores\arduino/Arduino.h:90:0,
from sketch\TMC2209-working.ish.ino.cpp:1:
C:\Users\XXX\AppData\Local\Arduino15\packages\arduino\hardware\mbed\1.3.2\variants\ARDUINO_NANO33BLE/pins_arduino.h:82:14: error: expected unqualified-id before numeric constant
#define D1 1
^
C:\Users\XXX\Documents\Arduino\libraries\TMCStepper-master\src/TMCStepper.h:608:12: note: in expansion of macro 'D1'
uint16_t D1();
^
C:\Users\XXX\AppData\Local\Arduino15\packages\arduino\hardware\mbed\1.3.2\variants\ARDUINO_NANO33BLE/pins_arduino.h:82:14: error: expected unqualified-id before numeric constant
#define D1 1
^
C:\Users\XXX\Documents\Arduino\libraries\TMCStepper-master\src/TMCStepper.h:609:8: note: in expansion of macro 'D1'
void D1(uint16_t input);
^
exit status 1
Error compiling for board Arduino Nano 33 BLE.
I am coming to you because, to my surprise (well not so much of a surprise after roaming the web for answers) **my code compiles just fine and executes on an Arduino UNO! **To the exception to this adaptation:
#define SERIAL_PORT Serial1 // for Nano 33 BLE
changed to :
#define SERIAL_PORT Serial // for UNO
Here is my code : (again working just fine on the Arduino UNO and not compiling on the Nano 33 BLE)
#include <TMCStepper.h>
#define EN_PIN 6 // Enable
#define DIR_PIN 2 // Direction
#define STEP_PIN 3 // Step
#define SERIAL_PORT Serial1 // TMC2208/TMC2224 HardwareSerial port
#define DRIVER_ADDRESS 0b00 // TMC2209 Driver address according to MS1 and MS2
#define R_SENSE 0.11f // Match to your driver
// SilentStepStick series use 0.11
// Select your stepper driver type
TMC2209Stepper driver(&SERIAL_PORT, R_SENSE, DRIVER_ADDRESS); // Hardware Serial
void setup() {
pinMode(EN_PIN, OUTPUT);
pinMode(STEP_PIN, OUTPUT);
pinMode(DIR_PIN, OUTPUT);
digitalWrite(EN_PIN, LOW); // Enable driver in hardware
// Enable one according to your setup
//SPI.begin(); // SPI drivers
SERIAL_PORT.begin(115200); // HW UART drivers
//driver.beginSerial(115200); // SW UART drivers
driver.begin(); // SPI: Init CS pins and possible SW SPI pins
// UART: Init SW UART (if selected) with default 115200 baudrate
driver.toff(5); // Enables driver in software
driver.rms_current(600); // Set motor RMS current
driver.microsteps(16); // Set microsteps to 1/16th
//driver.en_spreadCycle(false); // Toggle spreadCycle on TMC2208/2209/2224
driver.pwm_autoscale(true); // Needed for stealthChop
}
bool shaft = false;
void loop() {
// Run 5000 steps and switch direction in software
for (uint16_t i = 5000; i>0; i--) {
digitalWrite(STEP_PIN, HIGH);
delayMicroseconds(160);
digitalWrite(STEP_PIN, LOW);
delayMicroseconds(160);
}
shaft = !shaft;
driver.shaft(shaft);
}
I have been stuck with this error for over a week now, and I can’t move on. Feels to me like some incompatibility between said TMCStepper.h library and the Nano 33 BLE pins_arduino.h library …
Hopefully you can help!
Thanks in advance
Raztou3D