Go Down

Topic: Nano IOT 33 & TMC Stepper library (Read 76 times) previous topic - next topic

russell_roberts

I am trying to set up the nano and a Watterott Trinamic TMC2208

I can get the driver to work but I cannot compile the simple example that comes with the library to work.

I would appreciate some help direction

thanks

the error

Code: [Select]

Users/russellroberts/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/arm-none-eabi-g++ -mcpu=cortex-m0plus -mthumb -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD -DF_CPU=48000000L -DARDUINO=10810 -DARDUINO_SAMD_NANO_33_IOT -DARDUINO_ARCH_SAMD -DCRYSTALLESS -D__SAMD21G18A__ -DUSB_VID=0x2341 -DUSB_PID=0x8057 -DUSBCON "-DUSB_MANUFACTURER=\"Arduino LLC\"" "-DUSB_PRODUCT=\"Arduino NANO 33 IoT\"" -I/Users/russellroberts/Library/Arduino15/packages/arduino/tools/CMSIS/4.5.0/CMSIS/Include/ -I/Users/russellroberts/Library/Arduino15/packages/arduino/tools/CMSIS-Atmel/1.2.0/CMSIS/Device/ATMEL/ -I/Users/russellroberts/Library/Arduino15/packages/arduino/hardware/samd/1.8.4/cores/arduino -I/Users/russellroberts/Library/Arduino15/packages/arduino/hardware/samd/1.8.4/variants/nano_33_iot -I/Users/russellroberts/Documents/Arduino/libraries/TMCStepper/src -I/Users/russellroberts/Library/Arduino15/packages/arduino/hardware/samd/1.8.4/libraries/SPI /var/folders/z6/tcyclyq10676672qkq094blm0000gn/T/arduino_build_572909/sketch/tmc.ino.cpp -o /var/folders/z6/tcyclyq10676672qkq094blm0000gn/T/arduino_build_572909/sketch/tmc.ino.cpp.o
tmc:36:44: error: use of deleted function 'TMC2208Stepper::TMC2208Stepper(uint16_t, uint16_t, float)'
 TMC2208Stepper driver(SW_RX, SW_TX, R_SENSE);                     // Software serial
                                            ^
In file included from /Users/russellroberts/Desktop/tmc/tmc.ino:7:0:
/Users/russellroberts/Documents/Arduino/libraries/TMCStepper/src/TMCStepper.h:819:4: note: declared here
    TMC2208Stepper(uint16_t, uint16_t, float) = delete; // Your platform does not currently support Software Serial
    ^~~~~~~~~~~~~~
/Users/russellroberts/Desktop/tmc/tmc.ino: In function 'void setup()':
tmc:49:26: error: use of deleted function 'void TMC2208Stepper::beginSerial(uint32_t)'
 driver.beginSerial(115200);     // SW UART drivers
                          ^
In file included from /Users/russellroberts/Desktop/tmc/tmc.ino:7:0:
/Users/russellroberts/Documents/Arduino/libraries/TMCStepper/src/TMCStepper.h:827:9: note: declared here
    void beginSerial(uint32_t) = delete; // Your platform does not currently support Software Serial
         ^~~~~~~~~~~
Multiple libraries were found for "TMCStepper.h"
 Used: /Users/russellroberts/Documents/Arduino/libraries/TMCStepper
Multiple libraries were found for "SPI.h"
 Used: /Users/russellroberts/Library/Arduino15/packages/arduino/hardware/samd/1.8.4/libraries/SPI


here is my code

Code: [Select]

/**
   Author Teemu M√§ntykallio
   Initializes the library and runs the stepper
   motor in alternating directions.
*/

#include <TMCStepper.h>

//#define EN_PIN           4 // Enable
#define DIR_PIN          4 // Direction
#define STEP_PIN         5 // Step
//#define CS_PIN           42 // Chip select
//#define SW_MOSI          66 // Software Master Out Slave In (MOSI)
//#define SW_MISO          44 // Software Master In Slave Out (MISO)
//#define SW_SCK           64 // Software Slave Clock (SCK)
#define SW_RX            30 // TMC2208/TMC2224 SoftwareSerial receive pin
#define SW_TX            31 // TMC2208/TMC2224 SoftwareSerial transmit pin
//#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
// UltiMachine Einsy and Archim2 boards use 0.2
// Panucatt BSD2660 uses 0.1
// Watterott TMC5160 uses 0.075

// Select your stepper driver type
//TMC2130Stepper driver(CS_PIN, R_SENSE);                           // Hardware SPI
//TMC2130Stepper driver(CS_PIN, R_SENSE, SW_MOSI, SW_MISO, SW_SCK); // Software SPI
//TMC2660Stepper driver(CS_PIN, R_SENSE);                           // Hardware SPI
//TMC2660Stepper driver(CS_PIN, R_SENSE, SW_MOSI, SW_MISO, SW_SCK);
//TMC5160Stepper driver(CS_PIN, R_SENSE);
//TMC5160Stepper driver(CS_PIN, R_SENSE, SW_MOSI, SW_MISO, SW_SCK);

//TMC2208Stepper driver(&SERIAL_PORT, R_SENSE);                     // Hardware Serial
TMC2208Stepper driver(SW_RX, SW_TX, R_SENSE);                     // Software serial
//TMC2209Stepper driver(&SERIAL_PORT, R_SENSE, DRIVER_ADDRESS);
//TMC2209Stepper driver(SW_RX, SW_TX, R_SENSE, DRIVER_ADDRESS);

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_pwm_mode(true);       // Toggle stealthChop on TMC2130/2160/5130/5160
  //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);
}

matt_lee_smith

Hello russell_roberts,

I am not experienced with steppers, however, looking over the code I can see that for starters it is using a software serial communication. The Nano 33's don't have software serial capabilities as the hardware allows it to assign a serial to pins see: https://stackoverflow.com/questions/57175348/softwareserial-for-arduino-nano-33-iot for example for more details. Also if you are wiring the board to the driver from the TX/RX pins then those are pin numbers 16(TX) and 17(RX) and they run on Serial1, not Serial. Here is some of the Arduino statement on this:

Serial ports on the Arduino NANO 33 IoT

The USB connector of the board is directly connected to the USB host pins of the SAMD21. This routing enables you to use the Arduino NANO 33 IoT as a client USB peripheral (acting as a mouse or a keyboard connected to the computer) or as a USB host device so that devices like a mouse, keyboard, or an Android phone can be connected to the Arduino NANO 33 IoT. This port can also be used as a virtual serial port using the Serial object in the Arduino programming language. The RX0 and TX1 pins are a second serial port available as Serial1.


I would recommend changing the TX/RX code. This may help with the errors you are experiencing notably:
Quote
TMC2208Stepper(uint16_t, uint16_t, float) = delete; // Your platform does not currently support Software Serial

void beginSerial(uint32_t) = delete; // Your platform does not currently support Software Serial
I hope this helps.

Best regards,
Matt

Go Up