Giter Club home page Giter Club logo

tmc2130stepper's Issues

Simple Sketch on Arduino Not Working

I've tried to use the Simple sketch for the SilentStepStick (TMC2130) using Arduino UNO and NANO and just cannot get it to work. I have successfully ran this sketch below so I know everything is connected fine. Are there any additional details I can provide to you? Thank you very much for your help.

#include "SPI.h"

// Note: You also have to connect GND, 5V/VIO and VM.
//       A connection diagram can be found in the schematics.
#define EN_PIN    7 //enable (CFG6)
#define DIR_PIN   8 //direction
#define STEP_PIN  9 //step

#define CS_PIN   10 //chip select
#define MOSI_PIN 11 //SDI/MOSI (ICSP: 4, Uno: 11, Mega: 51)
#define MISO_PIN 12 //SDO/MISO (ICSP: 1, Uno: 12, Mega: 50)
#define SCK_PIN  13 //CLK/SCK  (ICSP: 3, Uno: 13, Mega: 52)

//TMC2130 registers
#define WRITE_FLAG     (1<<7) //write flag
#define READ_FLAG      (0<<7) //read flag
#define REG_GCONF      0x00
#define REG_GSTAT      0x01
#define REG_IHOLD_IRUN 0x10
#define REG_CHOPCONF   0x6C
#define REG_COOLCONF   0x6D
#define REG_DCCTRL     0x6E
#define REG_DRVSTATUS  0x6F

uint8_t tmc_write(uint8_t cmd, uint32_t data)
{
  uint8_t s;

  digitalWrite(CS_PIN, LOW);

  s = SPI.transfer(cmd);
  SPI.transfer((data>>24UL)&0xFF)&0xFF;
  SPI.transfer((data>>16UL)&0xFF)&0xFF;
  SPI.transfer((data>> 8UL)&0xFF)&0xFF;
  SPI.transfer((data>> 0UL)&0xFF)&0xFF;

  digitalWrite(CS_PIN, HIGH);

  return s;
}

uint8_t tmc_read(uint8_t cmd, uint32_t *data)
{
  uint8_t s;

  tmc_write(cmd, 0UL); //set read address

  digitalWrite(CS_PIN, LOW);

  s = SPI.transfer(cmd);
  *data  = SPI.transfer(0x00)&0xFF;
  *data <<=8;
  *data |= SPI.transfer(0x00)&0xFF;
  *data <<=8;
  *data |= SPI.transfer(0x00)&0xFF;
  *data <<=8;
  *data |= SPI.transfer(0x00)&0xFF;

  digitalWrite(CS_PIN, HIGH);

  return s;
}

void setup()
{
  //set pins
  pinMode(EN_PIN, OUTPUT);
  digitalWrite(EN_PIN, HIGH); //deactivate driver (LOW active)
  pinMode(DIR_PIN, OUTPUT);
  digitalWrite(DIR_PIN, LOW); //LOW or HIGH
  pinMode(STEP_PIN, OUTPUT);
  digitalWrite(STEP_PIN, LOW);

  pinMode(CS_PIN, OUTPUT);
  digitalWrite(CS_PIN, HIGH);
  pinMode(MOSI_PIN, OUTPUT);
  digitalWrite(MOSI_PIN, LOW);
  pinMode(MISO_PIN, INPUT);
  digitalWrite(MISO_PIN, HIGH);
  pinMode(SCK_PIN, OUTPUT);
  digitalWrite(SCK_PIN, LOW);

  //init serial port
  Serial.begin(9600); //init serial port and set baudrate
  while(!Serial); //wait for serial port to connect (needed for Leonardo only)
  Serial.println("\nStart...");

  //init SPI
  SPI.begin();
  //SPI.setDataMode(SPI_MODE3); //SPI Mode 3
  //SPI.setBitOrder(MSBFIRST); //MSB first
  //SPI.setClockDivider(SPI_CLOCK_DIV128); //clk=Fcpu/128
  SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE3));

  //set TMC2130 config
  tmc_write(WRITE_FLAG|REG_GCONF,      0x00000001UL); //voltage on AIN is current reference
  tmc_write(WRITE_FLAG|REG_IHOLD_IRUN, 0x00001010UL); //IHOLD=0x10, IRUN=0x10
  tmc_write(WRITE_FLAG|REG_CHOPCONF,   0x00008008UL); //native 256 microsteps, MRES=0, TBL=1=24, TOFF=8
  //tmc_write(WRITE_FLAG|REG_CHOPCONF,   0x01008008UL); //128 microsteps, MRES=0, TBL=1=24, TOFF=8
  //tmc_write(WRITE_FLAG|REG_CHOPCONF,   0x02008008UL); // 64 microsteps, MRES=0, TBL=1=24, TOFF=8
  //tmc_write(WRITE_FLAG|REG_CHOPCONF,   0x03008008UL); // 32 microsteps, MRES=0, TBL=1=24, TOFF=8
  //tmc_write(WRITE_FLAG|REG_CHOPCONF,   0x04008008UL); // 16 microsteps, MRES=0, TBL=1=24, TOFF=8
  //tmc_write(WRITE_FLAG|REG_CHOPCONF,   0x05008008UL); //  8 microsteps, MRES=0, TBL=1=24, TOFF=8
  //tmc_write(WRITE_FLAG|REG_CHOPCONF,   0x06008008UL); //  4 microsteps, MRES=0, TBL=1=24, TOFF=8
  //tmc_write(WRITE_FLAG|REG_CHOPCONF,   0x07008008UL); //  2 microsteps, MRES=0, TBL=1=24, TOFF=8
  //tmc_write(WRITE_FLAG|REG_CHOPCONF,   0x08008008UL); //  1 microsteps, MRES=0, TBL=1=24, TOFF=8

  //TMC2130 outputs on (LOW active)
  digitalWrite(EN_PIN, LOW);
}

void loop()
{
  static uint32_t last_time=0;
  uint32_t ms = millis();
  uint32_t data;
  uint8_t s;
    
  if((ms-last_time) > 1000) //run every 1s
  {
    last_time = ms;

    //show REG_GSTAT
    s = tmc_read(REG_GSTAT, &data);
    Serial.print("GSTAT:     0x0");
    Serial.print(data, HEX);
    Serial.print("\t - ");
    Serial.print("Status: 0x");
    Serial.print(s, HEX);
    if(s & 0x01) Serial.print(" reset");
    if(s & 0x02) Serial.print(" error");
    if(s & 0x04) Serial.print(" sg2");
    if(s & 0x08) Serial.print(" standstill");
    Serial.println(" ");

    //show REG_DRVSTATUS
    s = tmc_read(REG_DRVSTATUS, &data);
    Serial.print("DRVSTATUS: 0x");
    Serial.print(data, HEX);
    Serial.print("\t - ");
    Serial.print("Status: 0x");
    Serial.print(s, HEX);
    if(s & 0x01) Serial.print(" reset");
    if(s & 0x02) Serial.print(" error");
    if(s & 0x04) Serial.print(" sg2");
    if(s & 0x08) Serial.print(" standstill");
    Serial.println(" ");
  }

  //make steps
  digitalWrite(STEP_PIN, HIGH);
  delayMicroseconds(10);
  digitalWrite(STEP_PIN, LOW);
  delayMicroseconds(10);
}

Question: Right use of the library

Hi guys,

hope you can help me. Since a week I´m tring to set up my tmc2130. I´ve the orginal (green) one from watterot.
My supply voltage for the driver is 3.3V, VRef is at 1.1V, VM was tested between 12-18V.
SPI Connection is open. My goal is the set the settings with SPI using the TMC2130Stepper library and controll the motor with the accelstepper library. I´m using a arduino uno. The stepper is a generic 1.8°/200 Steps stepper from adafruits.
I want to create a controller for a camera slieder. Frist only the slieder than pan tilt astro functionality.

Problem what I have, is that my stepper runs only in low speeds. I´ve read that the arduino with its 16 Mhz is the limiting factor. But with a TB503A1 driver are getting much higher speeds. I only want the higher speed for position the camera on the slider during operation timelapse and so on the speeds that i can get at the moment are fine. But reference drive to the end stop and back i don´t want to wait für 5 min.

Below is my code example. At this configuration i need 3.4 seconds for a full rotaion. Is this a problem of my configuration of the tmc or do i´m using the tmc library in a wrong way or is this a problem with the accelstepper library.

Sorry for missusing your issue section teemuatlut but i couldn´t find you in a forum to ask you there.

#define EN_PIN    7  
#define DIR_PIN   8  
#define STEP_PIN  9  
#define CS_PIN    10 


#include <AccelStepper.h>
AccelStepper stepper(1, STEP_PIN, DIR_PIN); // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5

#include <TMC2130Stepper.h>
TMC2130Stepper driver = TMC2130Stepper(EN_PIN, DIR_PIN, STEP_PIN, CS_PIN);

void setup()
{  
    Serial.begin(9600);
    while(!Serial);
    Serial.println("Start...");
    
    driver.microsteps(0);   // Fullstep Mode
    driver.interpolate(1);  // Interpolate Fullstep to 256 Steps

/*
23.1
Initialization Example
SPI  datagram  example  sequence  to  enable the driver  for  step  and direction  operation  and  initialize the chopper for spreadCycle operation and for stealthChop at <60 RPM: 
SPI send:0xEC000100C3;      // CHOPCONF: TOFF=3, HSTRT=4, HEND=1, TBL=2, CHM=0 (spreadCycle)
SPI send:0x9000061F0A;      // IHOLD_IRUN: IHOLD=10,IRUN=31 (max. current), IHOLDDELAY=6
SPI send:0x910000000A;      // TPOWERDOWN=10: Delay before power down in stand still
SPI send: 0x8000000004;     // EN_PWM_MODE=1 enables stealthChop (with default PWM_CONF)
SPI send: 0x93000001F4;     // TPWM_THRS=500 yields a switching velocity about 35000 = ca. 30RPM
SPI send: 0xF0000401C8;     // PWM_CONF: AUTO=1, 2/1024 Fclk, Switch amplitude limit=200, Grad=1
*/

/*-----Initialization Example-----*/
/*-----Start-----*/

    driver.begin();
    driver.rms_current(600);

    driver.microsteps(0);   // Fullstep Mode          --> stepper won´t move without microsteps=0
    driver.interpolate(1);  // Interpolate Fullstep to 256 Steps    --> for smooth motion
    
    driver.off_time(3);               //TOFF=3
    driver.hysteresis_start(4);       //HSTRT=4
    driver.hysteresis_end(1);         //HEND=1
    driver.blank_time(36);            //TBL=2
    driver.chopper_mode(1);           //CHM=0
    
    driver.hold_current(10);          //IHOLD=10
    driver.run_current(31);           //IRUN=31
    driver.hold_delay(6);             //IHOLDDELAY=6

    driver.power_down_delay(10);      //TPOWERDOWN=10

    driver.stealthChop(1);            //EN_PWM_MODE

    driver.stealth_max_speed(500);    //TPWM_THRS

//  driver.                           //PWM_CONF: AUTO=1
    driver.stealth_freq(0);           //2/1024 Fclk
    driver.stealth_amplitude(200);    //Switch amplitude limit=200
    driver.stealth_gradient(1);       //Grad

/*-----End-----*/
/*-----Initialization Example-----*/
 
    digitalWrite(EN_PIN, LOW);
    
    stepper.setMaxSpeed(3500.0);
    stepper.setAcceleration(500.0);

    
}
void loop()
{    
 
    Serial.println(stepper.speed());              // Serial Monitor für Kontrolle der Einstellungen
    Serial.println(stepper.currentPosition());    // ---
    Serial.println(stepper.isRunning());          // ---

    stepper.moveTo(1000);                         // Läuft 5 Runden bei 200 Steps --> runs 5 rounds at 200 steps need approx. 3.4sec per round
    stepper.run();                                // Run Befehl

/*
  digitalWrite(STEP_PIN, HIGH);
  delayMicroseconds(10);
  digitalWrite(STEP_PIN, LOW);
  delayMicroseconds(10);
*/    
}

Teensy

I'm trying to get my new TMC2130 drivers to work with the Teensy 3.6. I had the 2100 drivers working fine. I have the EN, DIR, STEP and CS pins connected to digital pins on the Teensy and no joy. The Simple example makes no reference to a SPI library, so I'm assuming I dont need to run those wires for this example? Or are they needed regardless...

Teensy pinout is here

Would love some fritzing diagrams of the wiring.. but from what I see, this looks to be a great library.. if I can get it work, it'd even better ;)

Got TMC2130Stepper library working after 'constexpr' compile errors with STM32 on Arduino IDE

Great library, thank you.

In Arduino 1.8.5 IDE, I tried to compile my code with TMC2130Stepper for my 'Blue Pill' STM32F103 (hardware support from stm32duino.com).

Ran into a load of compiler errors, pointing to the use of 'constexpr' in TMC2130Stepper_REGDEFS.h. I don't have the error log now, but it was something to do with compiler version not understading constexpr.

I replaced every instance of 'constexpr' with 'const' in TMC2130Stepper_REGDEFS.h, and it compiled fine and works fine.

I couldn't replicate this by installing the whole toolkit from fresh along with all the hardware definitions, boards, libraries on a new machine. This error doesn't show up. But it did on my older dev computer that's had incremental arduino updates for the last 5 years.

So just in case anyone's looking for this issue - it might help someone to get their prototype working.

Not sure about the actual implications of using const vs constexpr, maybe someone could explain?

Enable CoolStep - Digital current control

Sensorless homing is amazing but it just does not stop here as it can also be used for sensorless load-dependent current control that uses StallGuard2 as well. Why not bring this remarkable feature to life?

M122 - Understanding the readings.

M122 - I'm running a TMC2208 on X and a TMC2130 on E0. I can figure out some of the readings but am not sure on what all of the abbreviations mean. I have looked all over for a guide but everything I see just gives a general description of the M122 command in general. Any help would be appreciated. Also which reading will show skipped steps. Thanks

Here's what I'm reading.
SENT: M122
READ: X:159.63 Y:97.28 Z:12.68 E:0.00 Count X:12774 Y:8058 Z:5045
READ: X E0
READ: Enabled false true
READ: Set current 1200 400
READ: RMS current 1160 397
READ: MAX current 1636 560
READ: Run current 20/31 12/31
READ: Hold current 10/31 6/31
READ: CS actual 20/31 12/31
READ: PWM scale 55 33
READ: vsense 0=.325 1=.18
READ: stealthChop true true
READ: msteps 16 16
READ: tstep 637 2896
READ: pwm
READ: threshold 83 64
READ: [mm/s] 119.43 30.38
READ: OT prewarn true false
READ: OT prewarn has
READ: been triggered false false
READ: off time 5 5
READ: blank time 24 24
READ: hysteresis
READ: -end 2 2
READ: -start 3 3
READ: Stallguard thrs 0
READ: DRVSTATUS X E0
READ: stallguard
READ: sg_result 0
READ: fsactive
READ: stst
READ: olb X
READ: ola X
READ: s2gb
READ: s2ga
READ: otpw X
READ: ot
READ: 157C
READ: 150C
READ: 143C
READ: 120C X
READ: s2vsa
READ: s2vsb
READ: Driver registers: X = 0x40:14:01:01
READ: E0 = 0x20:0C:00:00

SEIMIN_bm is wrong

FYI.

The mask SEIMIN_bm (0x80000UL) is wrong. It is in the stallGuard2 threshold value.
It must be #define SEIMIN_bm 0x8000UL (bit 15).

StallGuard - 'PORTF' was not declared in this scope

image
First, thanks for your job, it amazing to control the tmc2130 as simple as that but I have a small issues. When I compile the example sketch StallGuard the debug said PORTF is not declared.
The library work just fine on the "simple" sketch and is apparently correctly installed.
Any on can help me to understand my error ?
Thanks for your time 👍
image

TPOWERDOWN / hend compile errors

/usr/local/share/arduino/libraries/TMC2130Stepper/src/source/TMC2130Stepper.cpp:193:10: error: prototype for 'uint32_t TMC2130Stepper::TPOWERDOWN()' does not match any in class 'TMC2130Stepper'
 uint32_t TMC2130Stepper::TPOWERDOWN() { return TPOWERDOWN_sr; }
.piolibdeps/TMC2130Stepper_ID1493/src/source/TMC2130Stepper_CHOPCONF.cpp:13:6: error: prototype for 'void TMC2130Stepper::hend(int8_t)' does not match any in class 'TMC2130Stepper'
void TMC2130Stepper::hend(  int8_t  B ) { TMC_MOD_REG(CHOPCONF, HEND);  }

Can't make simple example work

I know it's a horrible title. Feel free to change it.

Here is my setup:

  • Arduino Nano. Probably some clone.
  • Stepper- NEMA 17 - 48 mm LDO-42STH47-1684A
  • Chinese clone of watterott's stick
  • 12V 3A power supply
  • Protector board (with a bunch of diodes, I assume)

Initially, I didn't know about Chinese clones having this non-SPI soldered bridge thing. It didn't work and the motor was making high pitch noises. I've desoldered one resistor and connected two other bridges according to instructions in one of Merlin issues.

It still doesn't work 😢Simple example doesn't work as is. Nothing happens. I can turn rotator with my fingers. When I disabled stealthChop motor starting vibrating making sound, but not turning.

I am not sure if I was able to kill the driver or I am missing anything else =( Thought maybe you have some ideas on how to debug this thing. I don't have a good scope, though I have a simple logic analyser and a good multimeter.

img_20180526_110407
img_20180526_110533

img_20180526_110426
img_20180526_110452_hht

All Steppers not moving after a few simple pins resolder on TMC2130's

i need help with my TMC2130, I'm not sure if this is the right place, if not, please delete.

I'm doing a Standalone MOD on my CR-10s, I was running five TMC2130'S on a MKS Gen L gen 1.0 in SPI mode without any issues, when the board was just sitting on desk. After the wife got tired of all those exposed wires, I printed a custom case to neatly make all the component fit inside a fan cool enclosure.

To do that I needed to to resolder the 4 SPI pins on my drivers (SDI, SCK, CK & SDO). The factory pins were pointing straight up and I needed to have them horizontal to fit in the case.

So instead of just bending the pins, I removed the old pins and soldered new 90 deg pins, thinking is was much cleaner looking. While I had the soldering iron out I added a pin on the "DIAG" for when I'm ready to do sensorless homing.

After fixing a few bad crimps on the Dupont connectors that were giving my "Driver Errors Printer Halted" messages. I was finally ready to home that beauty. But to my horror, none of the axis moved. I resetted the printer many time, but no success. I tried moving just the individual axis manually, no go on that as well...

I've rechecked every solder points they all look good, nothing seems to be shorted out.

Could I have fried the drivers just by re-soldering pins ?

Can someone help me figure out what is wrong ?

This is how I've got them wired.

And here is the M122 report:

Send: M122
Recv: 		X	Y	Z	Z2	E0
Recv: Enabled		false	false	false	false	false
Recv: Set current	750	750	750	750	750
Recv: RMS current	1325	1325	1325	1325	1325
Recv: MAX current	1868	1868	1868	1868	1868
Recv: Run current	23/31	23/31	23/31	23/31	23/31
Recv: Hold current	4/31	4/31	4/31	4/31	4/31
Recv: CS actual		0/31	0/31	0/31	0/31	0/31
Recv: PWM scale		0	0	0	0	0
Recv: vsense		0=.325	0=.325	0=.325	0=.325	0=.325
Recv: stealthChop	false	false	false	false	false
Recv: msteps		256	256	256	256	256
Recv: tstep		0	0	0	0	0
Recv: pwm
Recv: threshold		0	0	0	0	0
Recv: [mm/s]		-	-	-	-	-
Recv: OT prewarn	false	false	false	false	false
Recv: OT prewarn has
Recv: been triggered	false	false	false	false	false
Recv: off time		0	0	0	0	0
Recv: blank time	16	16	16	16	16
Recv: hysteresis
Recv: -end		-3	-3	-3	-3	-3
Recv: -start		1	1	1	1	1
Recv: Stallguard thrs	0	0	0	0	0
Recv: DRVSTATUS	X	Y	Z	Z2	E0
Recv: stallguard
Recv: sg_result		0	0	0	0	0
Recv: fsactive
Recv: stst
Recv: olb
Recv: ola
Recv: s2gb
Recv: s2ga
Recv: otpw
Recv: ot
Recv: Driver registers:	X = 0x00:00:00:00
Recv: 	Y = 0x00:00:00:00
Recv: 	Z = 0x00:00:00:00
Recv: 	Z2 = 0x00:00:00:00
Recv: 	E0 = 0x00:00:00:00
Recv: 
Recv: 
Recv: ok

Question: TMC5130Stepper (TRAMS board)

Hi @teemuatlut,

thanks for updating the TRAMS board and all the work you do with the TMC2130/2208.
Wouldn't it be possible to use the TMC2130Stepper code also for the TMC5130 stepper drivers? As far i can see in the datasheets the TMC2130 uses quite the same architecture and registers as the TMC5130. The TMC5130 has more features and it looks like the TMC2130 is the smaller/cheaper sister/brother.
Wouldn't that help to get the TMC5130/TRAMS board more popular and easier to be supported? New code could be copied from the TMC2130 to the TMC5130 and just extra features had to be implemented to the TMC5130, or am I completely wrong?

Unable to compile with PlatformIO

Getting this string of errors:

.piolibdeps/TMC2130Stepper_ID1493/src/source/TMC2130Stepper.cpp:193:10: error: prototype for 'uint32_t T
MC2130Stepper::TPOWERDOWN()' does not match any in class 'TMC2130Stepper'
uint32_t TMC2130Stepper::TPOWERDOWN() { return TPOWERDOWN_sr; }
^
In file included from .piolibdeps/TMC2130Stepper_ID1493/src/source/TMC2130Stepper.cpp:1:0:
.piolibdeps/TMC2130Stepper_ID1493/src/TMC2130Stepper.h:91:8: error: candidates are: void TMC2130Stepper:
:TPOWERDOWN(uint8_t)
void TPOWERDOWN(     uint8_t input);
^
.piolibdeps/TMC2130Stepper_ID1493/src/TMC2130Stepper.h:90:11: error:                 uint8_t TMC2130Step
per::TPOWERDOWN()
uint8_t TPOWERDOWN();
^
.piolibdeps/TMC2130Stepper_ID1493/src/source/TMC2130Stepper.cpp:194:6: error: prototype for 'void TMC213
0Stepper::TPOWERDOWN(uint32_t)' does not match any in class 'TMC2130Stepper'
void TMC2130Stepper::TPOWERDOWN(uint32_t input) {
^
In file included from .piolibdeps/TMC2130Stepper_ID1493/src/source/TMC2130Stepper.cpp:1:0:
.piolibdeps/TMC2130Stepper_ID1493/src/TMC2130Stepper.h:91:8: error: candidates are: void TMC2130Stepper:
:TPOWERDOWN(uint8_t)
void TPOWERDOWN(     uint8_t input);
^
.piolibdeps/TMC2130Stepper_ID1493/src/TMC2130Stepper.h:90:11: error:                 uint8_t TMC2130Step
per::TPOWERDOWN()
uint8_t TPOWERDOWN();
^
.piolibdeps/TMC2130Stepper_ID1493/src/source/TMC2130Stepper_CHOPCONF.cpp:13:6: error: prototype for 'voi
d TMC2130Stepper::hend(int8_t)' does not match any in class 'TMC2130Stepper'
void TMC2130Stepper::hend(  int8_t  B ) { TMC_MOD_REG(CHOPCONF, HEND);  }
^
In file included from .piolibdeps/TMC2130Stepper_ID1493/src/source/TMC2130Stepper_CHOPCONF.cpp:1:0:

.piolibdeps/TMC2130Stepper_ID1493/src/TMC2130Stepper.h:140:12: error: candidates are: uint8_t TMC2130Ste
pper::hend()
uint8_t  hend();
^
.piolibdeps/TMC2130Stepper_ID1493/src/TMC2130Stepper.h:124:8: error:                 void TMC2130Stepper
::hend(uint8_t)
void hend(        uint8_t  B);
^
*** [.pioenvs/pro16MHzatmega328/lib26f/TMC2130Stepper_ID1493/source/TMC2130Stepper.cpp.o] Error 1
.piolibdeps/TMC2130Stepper_ID1493/src/source/TMC2130Stepper_CHOPCONF.cpp:30:9: error: prototype for 'int
8_t TMC2130Stepper::hend()' does not match any in class 'TMC2130Stepper'
int8_t  TMC2130Stepper::hend()  { TMC_GET_BYTE(CHOPCONF, HEND);  }
^
In file included from .piolibdeps/TMC2130Stepper_ID1493/src/source/TMC2130Stepper_CHOPCONF.cpp:1:0:
.piolibdeps/TMC2130Stepper_ID1493/src/TMC2130Stepper.h:140:12: error: candidates are: uint8_t TMC2130Ste
pper::hend()
uint8_t  hend();
^
.piolibdeps/TMC2130Stepper_ID1493/src/TMC2130Stepper.h:124:8: error:                 void TMC2130Stepper
::hend(uint8_t)
void hend(        uint8_t  B);
^
*** [.pioenvs/pro16MHzatmega328/lib26f/TMC2130Stepper_ID1493/source/TMC2130Stepper_CHOPCONF.cpp.o] Error
 1

Looking for Help With StallGuard

Good day. I've gotten the StallGuard example to work on my Arduino Mega, however, I am confused on how to properly read if the STALL flag has been triggered. I've been able to Jerry-Rig it with (drv_status & SG_RESULT_bm)>>SG_RESULT_bp <= 5 to disable the motor but I know there has to be a cleaner way to get this value. Is there a function I can call to get the STALL flag without that clunkiness?

Also, is there any better documentation on the timer interupt system that is running the motor in the StallGuard example? I'd like to implement it, but I have no idea how it works past TIMSK1 is the clock and OCR1A is the clock speed.

Thanks!

Software SPI doesn't read data

While using SoftSPI, there is no possibility to read any data from the driver, arduino sets all the options properly. The drivers are working properly, as using standard arduino SPI it's working OK.
Board used: Arduino Mega 2560 (chinese clone), tested with different boards, different tmc2130, and different pins for MISO MOSI SCK.

Stealtchop stops motor working

Hi,

I've got a 2130 connected to an adafruit arduino(bluefruit LE). I've changed the various pins(en, cs, dir, step) to ones on the board and have(it has dedicated pins) MOSI -> SDI, MISO -> SDO, SCK -> SCK.

I've tried getting the simple example to work but it doesn't work unless I comment out the line

driver.stealthChop(1);

Worked this out by trial and error. Without this line the motor turns and changes direction, though is noisy as if using a normal stepper driver. I've tried 3 different stepper motors and the same thing happenes for all of them.

Any ideas how I can resolve this ?

Thanks.

EDIT: Another thing I just noticed is that sometimes it doesn't change direction, it sort of stalls for a short time then continues in the same direction, then this behaviour either continues or it goes back to switching direction.

StallGuard example on nano

Hi,

thanks for your library and examples.
I'm trying to get your StallGuard example to work on a arduino nano
but (obviously) PORTF isn't defined. Actually, I'm only just learning about
port manipulation so I'm still a little unsure what your are trying to achieve
with

ISR(TIMER1_COMPA_vect){
PORTF |= 1 << 0;
PORTF &= ~(1 << 0);
}

is this setting the STEP pin?
Any help would be gratefully received.
Best regards,
Kevin

Calculations in rms_current()

This might be nitpicking, but wouldn't it be better to use round() or ceil() when converting from float to integer in TMC2130Stepper::rms_current((), and do the conversion as late as possible for the ihold() argument?
It currently is always floor() (implicitly), and the argument of ihold() gets floor()'ed even twice.
Along that line, is it useful to have getCurrent() return the value requested by the user rather than the value currently realized by the driver (as TMC2130Stepper::rms_current() does when called without argument)?

void TMC2130Stepper::rms_current(uint16_t mA, float multiplier, float RS) {
	Rsense = RS;
	uint8_t CS = 32.0*1.41421*mA/1000.0*(Rsense+0.02)/0.325 - 1;
	// If Current Scale is too low, turn on high sensitivity R_sense and calculate again
	if (CS < 16) {
		vsense(true);
		CS = 32.0*1.41421*mA/1000.0*(Rsense+0.02)/0.180 - 1;
	} else if(vsense()) { // If CS >= 16, turn off high_sense_r if it's currently ON
		vsense(false);
	}
	irun(CS);
	ihold(CS*multiplier);
	val_mA = mA;
}

no sg_result reading stealthChop mode

With

TMC2130.begin(); TMC2130.SilentStepStick2130(600); TMC2130.sg_stall_value(16); TMC2130.diag1_stall(1); TMC2130.diag1_active_high(1); TMC2130.sg_filter(0); TMC2130.microsteps(256); TMC2130.stealth_amplitude(64); TMC2130.stealth_gradient(15); TMC2130.stealth_freq(0); TMC2130.stealth_autoscale(0); TMC2130.stealth_symmetric(0); TMC2130.standstill_mode(0);

if
TMC2130.stealthChop(0);
then
Serial.println(TMC2130.sg_result(), DEC);
works

but if
TMC2130.stealthChop(1);
then
Serial.println(TMC2130.sg_result(), DEC);
gives 0 all the time, even if sg_stall_value is ajusted differently

v2.4.2 and Marlin Bugfix-2.0 Issue

@teemuatlut
I am having issues with v2.4.2 and Marlin Bugfix-2.0 (6/12/18) after loading the firmware I get the below errors. If I set the TMC2130 Library to version a80fb02 everything works with no errors. Please let me know if you need additional info and/or if I should also post the issue with Marlin

Connecting...
start
Printer is now online.
echo:Marlin bugfix-2.0.x
echo: Last Updated: 2018-01-20 | Author: (none, default config)
echo:Compiled: Jun 26 2018
echo: Free Memory: 2105 PlannerBufferBytes: 1664
echo:V55 stored settings retrieved (815 bytes; crc 365)
echo: G21 ; Units in mm (mm)
echo: M149 C ; Units in Celsius
echo:Filament settings: Disabled
echo: M200 D1.75
echo: M200 D0
echo:Steps per unit:
echo: M92 X100.34 Y100.34 Z400.00 E100.00
echo:Maximum feedrates (units/s):
echo: M203 X400.00 Y400.00 Z8.00 E50.00
echo:Maximum Acceleration (units/s2):
echo: M201 X400 Y400 Z100 E1000
echo:Acceleration (units/s2): P<print_accel> R<retract_accel> T<travel_accel>
echo: M204 P400.00 R1000.00 T400.00
echo:Advanced: B<min_segment_time_us> S<min_feedrate> T<min_travel_feedrate> J<junc_dev> E<max_e_jerk>
echo: M205 B20000 S0.00 T0.00 J0.02
echo:Home offset:
echo: M206 X0.00 Y0.00 Z0.00
echo:Auto Bed Leveling:
echo: M420 S0 Z0.00
echo:Material heatup parameters:
echo: M145 S0 H180 B70 F0
echo: M145 S1 H240 B110 F0
echo:PID settings:
echo: M301 P26.06 I1.80 D94.47
echo:Z-Probe Offset (mm): (mm):
echo: M851 Z-1.60
echo:Stepper driver current:
echo: M906 X575 Y575 Z740
M906 T0 E740
echo:Linear Advance:
echo: M900 K0.00
X driver error detected:
overtemperature
short to ground (coil A)
short to ground (coil B)
X Y Z E0
Enabled false false false false
Set current 575 575 740 740
RMS current 550 994 734 1325
MAX current 776 1402 1035 1868
Run current 17/31 17/31 23/31 23/31
Hold current 8/31 8/31 11/31 11/31
CS actual 31/31 0/31 31/31 0/31
PWM scale 255 0 255 0
vsense 1=.18 0=.325 1=.18 0=.325
stealthChop true false true false
msteps 0 256 0 256
tstep 4294967295 0 4294967295 0
pwm
threshold 0 0 0 0
[mm/s] - - - -
OT prewarn true false true false
OT prewarn has
been triggered false false false false
off time 15 0 15 0
blank time 54 16 54 16
hysteresis
-end 12 -3 12 -3
-start 8 1 8 1
Stallguard thrs 0 0 0 0
DRVSTATUS X Y Z E0
stallguard X X
sg_result 1023 0 1023 0
fsactive X X
stst X X
olb X X
ola X X
s2gb X X
s2ga X X
otpw X X
ot X X
Driver registers: X = 0xFF:FF:FF:FF
Y = 0x00:00:00:00
Z = 0xFF:FF:FF:FF
E0 = 0x00:00:00:00
Error:Printer halted. kill() called!
Error:Printer halted. kill() called!
img_0075

"Short to ground" errors in Marlin 1.1.7

Hey @teemuatlut, I really appreciate the work you have put into providing this library.

I'm having an issue with my authentic TMC2130's. They didn't perform all that well in stealthChop mode, and after turning hybrid mode off in Marlin and switching to SpreadCycle, it printed smooth as ever. Then I started getting the following error as soon as I turn on my power supply:

Y driver error detected:
overtemperature
short to ground (coil A)
short to ground (coil B)

I've checked the motor - nothing is shorted to ground. Each winding pair connects to each other, and none are shorted across windings. The resistance is low and equal among both windings (and match the X motor exactly). I've checked and redone the wiring, nothing is amiss.

It's not overheating as the heatsink is cool and the fan is on.

I've swapped the stepper drivers and gotten the same error message for Y. I then left them in the same places, but swapped the chip select between them - and still, "Y driver error detected...". If I unplug both chip select cables, I get:

X driver error detected:
overtemperature
short to ground (coil A)
short to ground (coil B)

This makes me wonder if SPI is getting interrupted partway through or something. Any ideas? Am I completely off base in thinking this is a software issue?

TMC2130 with Accelstepper Library

I'm trying to run a Stepper with TMC2130 in combination with the AccelStepper Library.
The Stepper is making the correct sound (i can hear the acceleration and velocity etc) but the shaft is not turning.
If I step it manually with digitalWrite() HIGH - LOW it is moving.

Temperature monitor?

I can't find any references to the possibility of reading the operating temperature of the TMC2130, is it possible to do it or does the library not tolerate this?
With Marlin i can read this with "M922":

16:01:48.012 : echo: X Y Z E0 E1
16:01:48.012 : echo:Enabled true true true true true
16:01:48.012 : echo:Set current 800 800 800 600 800
16:01:48.012 : echo:RMS current 795 795 795 581 795
16:01:48.012 : echo:MAX current 1121 1121 1121 819 1121
16:01:48.012 : echo:Run current 25/31 25/31 25/31 18/31 25/31
16:01:48.012 : echo:Hold current 12/31 12/31 12/31 9/31 12/31
16:01:48.012 : echo:CS actual 25/31 25/31 25/31 18/31 12/31
16:01:48.012 : echo:PWM scale 0 0 0 0 0
16:01:48.012 : echo:vsense 1=.18 1=.18 1=.18 1=.18 1=.18
16:01:48.012 : echo:stealthChop false false false false false
16:01:48.012 : echo:msteps 64 64 64 32 0
16:01:48.013 : echo:tstep 66 1646 70 1048575 1048575
16:01:48.013 : echo:pwm threshold 0 0 0 0 0
16:01:48.013 : echo:[mm/s] - - - - -
16:01:48.013 : echo:OT prewarn false false false false false
16:01:48.013 : echo:OT prewarn has
16:01:48.013 : echo:been triggered false false false false false
16:01:48.013 : echo:off time 3 3 3 3 3
16:01:48.013 : echo:blank time 24 24 24 24 24
16:01:48.013 : echo:hysteresis
16:01:48.013 : echo:-end 2 2 2 2 2
16:01:48.013 : echo:-start 3 3 3 3 3
16:01:48.013 : echo:Stallguard thrs 0 0 0 0 0
16:01:48.013 : echo:DRVSTATUS X Y Z E0 E1
16:01:48.013 : echo:stallguard X X
16:01:48.013 : echo:sg_result 95 0 106 175 194
16:01:48.013 : echo:fsactive
16:01:48.013 : echo:stst X X
16:01:48.013 : echo:olb X
16:01:48.013 : echo:ola X
16:01:48.013 : echo:s2gb
16:01:48.013 : echo:s2ga
16:01:48.013 : echo:otpw
16:01:48.013 : echo:ot
16:01:48.013 : echo:Driver registers: X 0x00:19:00:57
16:01:48.013 : Y 0x01:19:00:00
16:01:48.013 : Z 0x00:19:00:7D
16:01:48.013 : E0 0x81:12:00:9D
16:01:48.013 : E1 0xE0:0C:00:D1

Without any help -> Y driver error detected:

Hi,

today I got the error below, where is there error? No ground, no heat, just nothing that helps.
It worked for many weeks flawless

< 23:00:36.307: N238737 G1 X178.735 Y79.622 E15.5415
> 23:00:36.357: ok
< 23:00:36.357: N238738 G1 X180.470 Y80.700 E15.6409
> 23:00:36.407: ok
< 23:00:36.407: N238739 G1 X181.060 Y81.036 E15.6739
> 23:00:36.415: Y driver error detected:
> 23:00:36.418:   X Y E0
> 23:00:36.418: Enabled  true true true
> 23:00:36.419: Set current 800 800 500
> 23:00:36.422: RMS current 795 795 489
> 23:00:36.423: MAX current 1121 1121 689
> 23:00:36.425: Run current 25/31 25/31 15/31
> 23:00:36.426: Hold current 12/31 12/31 7/31
> 23:00:36.426: CS actual  25/31 25/31 15/31
> 23:00:36.429: PWM scale 53 82 29
> 23:00:36.430: vsense  1=.18 1=.18 1=.18
> 23:00:36.432: stealthChop true true true
> 23:00:36.432: msteps  16 16 16
> 23:00:36.433: tstep  265 2110 1617
> 23:00:36.433: pwm
> 23:00:36.436: threshold  98 98 95
> 23:00:36.436: [mm/s]  100.85 100.85 30.04
> 23:00:36.437: OT prewarn false false false
> 23:00:36.438: OT prewarn has
> 23:00:36.440: been triggered false false false
> 23:00:36.440: off time  5 5 5
> 23:00:36.441: blank time 24 24 24
> 23:00:36.441: hysterisis
> 23:00:36.442: -end  2 2 2
> 23:00:36.443: -start  3 3 3
> 23:00:36.444: Stallguard thrs 0 0 0
> 23:00:36.444: DRVSTATUS X Y E0
> 23:00:36.445: stallguard    
> 23:00:36.445: sg_result  0 0 0
> 23:00:36.448: fsactive    
> 23:00:36.448: stst    
> 23:00:36.448: olb    
> 23:00:36.449: ola    
> 23:00:36.449: s2gb    
> 23:00:36.449: s2ga    
> 23:00:36.450: otpw    
> 23:00:36.451: ot    
> 23:00:36.451: Driver registers:
> 23:00:36.452:  X = 0x00:19:00:00
> 23:00:36.452:  Y = 0x00:19:00:00
> 23:00:36.453:  E0 = 0x00:0F:00:00
> 23:00:36.456: Firmware was halted, trying to reconnect. Eventually running print is stopped.

Inconsistencies in stepper motor response when using stallGuard

I am working on a project in which a stepper motor moves a heavy load along the z-axis. There are bearings on each end that I use stallGuard to "detect" and have the code change the direction of the stepper motor. While I have used this library successfully for a simpler application (using stealthChop on a stepper with minimum load), I continue to experience inconsistencies in the motor's response when using stallGuard.

Setup:

  • 12V/5A power supply
  • 2.34V phase voltage
  • Teensy 3.2
  • TMC2130
  • 600mA rms current
  • heat sinks/fan used

For example, without coding any of the settings for dcStep, it will inconsistently "turn on" when moving in the negative z-direction. It will also slip-causing the load to slide down the shaft for one second-when changing direction from positive z to the negative z, but it only does this occasionally. (There is a clear difference in the slip and dcStep.) One other example is that each time I compile code or hit the reset button on the Teensy, the motor stalls briefly after one second before doing what I told it do. Is it possible it's calculating something during that time?

I can compile and upload the same code two times and it will behave differently. Do I need to reset the parameters each time I upload the code? Any thoughts?

Write only wiring for set up

Feature request: Is it possible to have an intermediate setup with the CS, CLK, and MOSI connected between all the drivers, and set them up exactly the same? Specifically enabling stallguard, setting them all to a certain current setting and enabling the mode? I'm really liking these, but I wonder if the number of pins required for two way comms is going to eliminate a lot of possible uses. I'm thinking specifically of Marlin, but wanted to bother you here instead, because I bet this library will need some edits.

Reading of stallguard-value

Hello,

I would like to read the stallguard-value like described in chapter "14 stallGuard2 Load Measurement" of the Trinamic-manual.

On youtube, I have found this, which is pretty much what I am looking for:
https://www.youtube.com/watch?v=ZAVRGcjJSv8

With your library it is possible to read DRV_STATUS. But in my tests, the value won't change if I apply load on the stepper motor. The value for DRV_STATUS only changes, when the stepper already stalled. But I want to prevent this and measure the load earlier.

Do you have already tested this feature or maybe have an idea how I can read this value properly? Are there any other settings which must be done before? I have already testet different SGT-values, but they seem not to make any difference.

Problem with Running for Certain Number of Steps

Hello,
I recently modified the Simple.ino example so that I could get my motor to step enough times to make one full revolution (200 in my case). However, I am having issues where I have to increment my step counter by some weird factor (1/250) just to get close to one revolution. I don't know what is causing this and the issue is not prevalent on my simpler stepper controllers. Any help would be appreciated.

Problems executing stallguard on esp32

I'm trying to execute stall guard example on esp32, the simple example is running fine but there are errors with stallguard. Please help

`Arduino: 1.8.5 (Windows 10), Board: "MH ET LIVE ESP32MiniKit, 80MHz, Default, 921600, None"

WARNING: library TMC2130Stepper claims to run on (avr, sam) architecture(s) and may be incompatible with your current board which runs on (esp32) architecture(s).
StallGuard:85: error: expected constructor, destructor, or type conversion before '(' token

ISR(TIMER1_COMPA_vect){

 ^

C:\Users\Prathamesh\Documents\Arduino\libraries\TMC2130Stepper\examples\StallGuard\StallGuard.ino: In function 'void setup()':

StallGuard:66: error: 'TCCR1A' was not declared in this scope

 TCCR1A = 0;// set entire TCCR1A register to 0

 ^

StallGuard:67: error: 'TCCR1B' was not declared in this scope

 TCCR1B = 0;// same for TCCR1B

 ^

StallGuard:68: error: 'TCNT1' was not declared in this scope

 TCNT1  = 0;//initialize counter value to 0

 ^

StallGuard:69: error: 'OCR1A' was not declared in this scope

 OCR1A = 256;// = (16*10^6) / (1*1024) - 1 (must be <65536)

 ^

StallGuard:71: error: 'WGM12' was not declared in this scope

 TCCR1B |= (1 << WGM12);

                 ^

StallGuard:73: error: 'CS11' was not declared in this scope

 TCCR1B |= (1 << CS11);// | (1 << CS10);  

                 ^

StallGuard:75: error: 'TIMSK1' was not declared in this scope

 TIMSK1 |= (1 << OCIE1A);

 ^

StallGuard:75: error: 'OCIE1A' was not declared in this scope

 TIMSK1 |= (1 << OCIE1A);

                 ^

C:\Users\Prathamesh\Documents\Arduino\libraries\TMC2130Stepper\examples\StallGuard\StallGuard.ino: At global scope:

StallGuard:85: error: expected constructor, destructor, or type conversion before '(' token

ISR(TIMER1_COMPA_vect){

^

C:\Users\Prathamesh\Documents\Arduino\libraries\TMC2130Stepper\examples\StallGuard\StallGuard.ino: In function 'void loop()':

StallGuard:97: error: 'TIMSK1' was not declared in this scope

 if (read_byte == '0')      { TIMSK1 &= ~(1 << OCIE1A); digitalWrite( EN_PIN, HIGH ); }

                              ^

StallGuard:97: error: 'OCIE1A' was not declared in this scope

 if (read_byte == '0')      { TIMSK1 &= ~(1 << OCIE1A); digitalWrite( EN_PIN, HIGH ); }

                                               ^

StallGuard:98: error: 'TIMSK1' was not declared in this scope

 else if (read_byte == '1') { TIMSK1 |=  (1 << OCIE1A); digitalWrite( EN_PIN,  LOW ); }

                              ^

StallGuard:98: error: 'OCIE1A' was not declared in this scope

 else if (read_byte == '1') { TIMSK1 |=  (1 << OCIE1A); digitalWrite( EN_PIN,  LOW ); }

                                               ^

StallGuard:99: error: 'OCR1A' was not declared in this scope

 else if (read_byte == '+') if (OCR1A > MAX_SPEED) OCR1A -= 20;

                                ^

exit status 1
expected constructor, destructor, or type conversion before '(' token

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
`

Direction issue

Hi,

Firstly, thanks for your work on this library, I'm excited to be using this new driver.

I'm hoping you can help with this odd situation. I've just switched from using a DRV8825 driver to the TMC2130. The simple example mostly works for me, except I can't seem to get it to change direction (I did need to change the microsecond delay from 10 to 100, otherwise the motor just stalls). I've double checked the DIR pin configuration and wiring, so I'm kind of at a loss. Any thoughts on next steps or things to consider?

Thank you.

Error while building https://github.com/p3p/Marlin/tree/32bit-bugfix-1.1.x-LPC1768

I have been building every update of the LPC1768 version of Marlin.
Today I built the version dated 18/07/2017 with the errors shown in the attached file. Something changed
between the 17/07/2017 and the above version. The Re-ARM also failed with the following error:

Compiling .pioenvs\Re-ARM\lib\TMC2130Stepper\source\TMC2130Stepper.o
.piolibdeps\TMC2130Stepper\src\source\TMC2130Stepper.cpp:1:17: fatal error: SPI.h: No such file or directory

#include <SPI.h>
^
compilation terminated.
*** [.pioenvs\Re-ARM\lib\TMC2130Stepper\source\TMC2130Stepper.o] Error 1
 [ERROR] Took 371.83 seconds
Environment Re-ARM              [ERROR]
 [ERROR] Took 371.83 seconds
 
 [SUMMARY]
Environment megaatmega2560      [SKIP]
Environment megaatmega1280      [SKIP]
Environment printrboard         [SKIP]
Environment brainwavepro        [SKIP]
Environment rambo               [SKIP]
Environment DUE                 [SKIP]
Environment teensy35            [SKIP]

Mega2560_failure_report.txt

stallGuard feature problem

Hi, when i try to compile your StallGuard.ino, I get some error messages.

'class TMC2130Stepper' has no member named 'rms_current'.

Cant find in your description that there would be such a command in your library, only setCurrent and run_current. I changed it to run_current, which fixed it but instead i got:

exit status 1
'class TMC2130Stepper' has no member named 'sg_result'

I deleted that line and got the code running, trying out different stall values bot to no avail. I only get 0 in the serial monitor.

I have tried both your and Moritz Walters library for the TMC2130 drivers, but have not gotten stallGuard to work at all. I have tried both the StallGuard.ino file aswell as the stallguard function in the Marlin fork, tried a variety of values for THIGH and TCOOLTHRS but with no luck. I have the diag1 pin wired to the endstop signal pin on a RAMPS 1.4

Let me know if i can supply any more information to help us out to get this to work :)

Need help integrating into Prusa Research firmware

Hello,

I am trying to integrate this library into the Prusa research fork of Marlin ([https://github.com/prusa3d/Prusa-Firmware]) and am running into weird issues.

I have basically copied over the TMC2130 declarations from Marlin 1.1.0 into the PR firmware and compilation fails with:
C:\Users\MADHU_~1\AppData\Local\Temp\build230ef159538de2d523fd9e0a48ac3ccf.tmp\sketch\ConfigurationStore.cpp.o: In function Config_StoreSettings()':

C:\Users\MADHU_~1\AppData\Local\Temp\build230ef159538de2d523fd9e0a48ac3ccf.tmp\sketch/ConfigurationStore.cpp:114: undefined reference to `stepperX'

C:\Users\MADHU_~1\AppData\Local\Temp\build230ef159538de2d523fd9e0a48ac3ccf.tmp\sketch/ConfigurationStore.cpp:114: undefined reference to `stepperX'

C:\Users\MADHU_~1\AppData\Local\Temp\build230ef159538de2d523fd9e0a48ac3ccf.tmp\sketch/ConfigurationStore.cpp:119: undefined reference to `stepperY'

C:\Users\MADHU_~1\AppData\Local\Temp\build230ef159538de2d523fd9e0a48ac3ccf.tmp\sketch/ConfigurationStore.cpp:119: undefined reference to `stepperY'

C:\Users\MADHU_~1\AppData\Local\Temp\build230ef159538de2d523fd9e0a48ac3ccf.tmp\sketch/ConfigurationStore.cpp:124: undefined reference to `stepperZ'

C:\Users\MADHU_~1\AppData\Local\Temp\build230ef159538de2d523fd9e0a48ac3ccf.tmp\sketch/ConfigurationStore.cpp:124: undefined reference to `stepperZ'

C:\Users\MADHU_~1\AppData\Local\Temp\build230ef159538de2d523fd9e0a48ac3ccf.tmp\sketch/ConfigurationStore.cpp:140: undefined reference to `stepperE0'

C:\Users\MADHU_~1\AppData\Local\Temp\build230ef159538de2d523fd9e0a48ac3ccf.tmp\sketch/ConfigurationStore.cpp:140: undefined reference to `stepperE0'

C:\Users\MADHU_~1\AppData\Local\Temp\build230ef159538de2d523fd9e0a48ac3ccf.tmp\sketch\stepper.cpp.o: In function `st_init()':

C:\Users\MADHU_~1\AppData\Local\Temp\build230ef159538de2d523fd9e0a48ac3ccf.tmp\sketch/stepper.cpp:662: undefined reference to `tmc2130_init()'

collect2.exe: error: ld returned 1 exit status`

Can you please help?

Thanks!

Live Tune example wont compile - Teensy 3.6

Trying to get my motor to work, loaded the live tune example and got this error...

`Arduino: 1.8.5 (Mac OS X), TD: 1.40, Board: "Teensy 3.6, Serial, 180 MHz, Faster, US English"

Live_tune:15: error: expected constructor, destructor, or type conversion before '(' token
ISR(TIMER1_COMPA_vect){//timer1 interrupt 1Hz toggles pin 13 (LED)
^
Live_tune:15: error: expected constructor, destructor, or type conversion before '(' token
ISR(TIMER1_COMPA_vect){//timer1 interrupt 1Hz toggles pin 13 (LED)
^
expected constructor, destructor, or type conversion before '(' token

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
`

Feedback on m122 for other axis than xyz

Hey everybody , I am curently gambeling arround with more TMC2130 Drivers, its only on the Bench but maybe you could follow me:
ich got TMC2130's including SPI and DIag0 on all 6axis (on my new printer this will be XYZ X2 E0 E1 XYZ are working fine, i know how to asign X2 etc thats not new,
but on TMC2130 Debug M122 I ony get status reports on XYZ never on X2 or any of the extruders,
If i set current via
SENDING:M906 X I1 500 // it always reports (like it would work) back current of all the other axis, but not of the "uncommen ones"
X driver current: 800
Y driver current: 900
Z driver current: 900
This is M122 output:
SENDING:M122
X Y Z
Enabled false false false
Set current 800 900 900
RMS current 795 887 887
MAX current 1121 1251 1251
Run current 25/31 28/31 28/31
Hold current 12/31 14/31 14/31
CS actual 12/31 14/31 14/31
PWM scale 128 128 6
vsense 1=.18 1=.18 1=.18
stealthChop true true true
msteps 16 16 16
tstep 1048575 1048575 1048575
pwm
threshold 0 0 0
[mm/s] - - -
OT prewarn false false false
OT prewarn has
been triggered false false false
off time 5 5 5
blank time 24 24 24
hysteresis
-end 2 2 2
-start 3 3 3
Stallguard thrs 8 8 8
DRVSTATUS X Y Z
stallguard
sg_result 0 0 0
fsactive
stst X X X
olb X X
ola X X
s2gb
s2ga
otpw
ot
Driver registers: X = 0xE0:0C:00:00
Y = 0xE0:0E:00:00
Z = 0x80:0E:00:00

could someone tell me if ther is just not feedback on this (X2 etc) or am I mistaking somwere?

btw hardware is completly custom build arround arduinomega and i checkt the pins for correct conection.

Use of TMC drivers in SPI cascade mode.

The current SPI support for the trinamic drivers requires all tmc chips to be connected to clk, miso and mosi of the processor and a separate chip select pin for each driver.

For many (3D printer) configurations however this is a pain in the ass because there are not enough pins available/accessible (many times forcing you to use the endstop-switch pins for cs and use tmc stallguard as endstop, which has its own problems).

The TMC chips however can be used in cascade where miso/mosi are connected from chip to chip and they all share one common chip select. This requires only 4 connections to the processor to control all connected TMC chips and this would also simplify the interconnection of the stepsticks tremendously !

TMC-SPI.pdf

(sorry: forgot clk in drawings... these are all connected together....)

Configuration chopper settings

Hey,

I am trying to find the right settings for a Pololu Stepper Motor NEMA 11 Bipolar 200 Steps Rev 28×45mm 4.5V 0.67 A Phase for chopper configuration but even though I calculated the parameters using your excel table and set the parameters in my arduino script using your library it did not work out... I measured the chopper cycle using an oscilloscope , measuring over the sense resistor and got a chopper frequency of round about 6kHz and a duration of the fast decay cycle much longer than tblank... I am not very familiar with the trinamic chip driver and do not know the appropriate configurations of all registers that need to be set as there are a lot.
I tried to follow the instructions given in the pdfs that I attached. Also see my Arduino script (for a Arduino Mega 2560) and the modified excel table for my Motor.
I would appreciate a little help a lot, as far as possible!

Thanks in advance!

AN001-spreadCycle.pdf
AN002-stallGuard2.pdf
TMC2130_Pulolu_Parameters.xlsx
Pololu Stepper Motor NEMA 11.pdf
TMC2130_CHopper_Settings_alternative.zip

fCLK - where to get this value

Hello, i have a question - how can i get information about fCLK of particular SilentStepStick? this value (fCLK) is used in many formulas, but i dont know whether it is set by some register or hardwired by oscillator on stepstick...? thank you very much for explanation.

marlin 1.1.8 and TMC2130 stepper library 2.2.0 get compilation error

Error code from Arduino IDE 1.8.5

Build options changed, rebuilding all
In file included from sketch/Marlin.h:46:0,
from sketch/Marlin_main.cpp:247:
sketch/Marlin_main.cpp: In instantiation of 'void tmc_status(TMC&, TMC_AxisEnum, TMC_debug_enum, float) [with TMC = TMC2130Stepper]':
sketch/Marlin_main.cpp:10391:73: required from here
serial.h:37: error: 'class TMC2130Stepper' has no member named 'hysterisis_end'
#define MYSERIAL customizedSerial
^
sketch/Marlin_main.cpp:10366:24: note: in expansion of macro 'MYSERIAL'
case TMC_HEND: MYSERIAL.print(st.hysterisis_end(), DEC); break;
^
serial.h:37: error: 'class TMC2130Stepper' has no member named 'hysterisis_start'
#define MYSERIAL customizedSerial
^
sketch/Marlin_main.cpp:10367:25: note: in expansion of macro 'MYSERIAL'
case TMC_HSTRT: MYSERIAL.print(st.hysterisis_start(), DEC); break;
^
exit status 1
'class TMC2130Stepper' has no member named 'hysterisis_end'

setup.zip

Einsy Rambo

Hi, I have an einsy rambo and the spreadCycle won't work with marlin and sensorless homming, I try a lots of thing but motor don't move in this mode.
So I try the spreadcycle example to see if it's marlin or the lib, and the same thing happen motor don't move in this mode.
I connect to X and changed the pin by this:
#define EN_PIN 29
#define DIR_PIN 49
#define STEP_PIN 37
#define CS_PIN 41
#define STEP_PORT PORTC // Register to match with STEP_PIN
#define STEP_BIT 0

Board from Prusa Shop, and the motor work fine with simple example, so it's not a bad connection or pin assignement.

Can you help me please?

Usage of _pinDIR, _pinSTEP, _pinEN

It seems, by searching the repository, that these attributes are not used anywhere.
Yet the constructor expects them as arguments which then get stored in the corresponding attributes.

If indeed unnecessary can these be removed and the constructor simplified?

Thank you!

TMC2130 Not Working/Powering Question 24V w/M80,M81

Ramps1.4/Mega2560
24V mod
POWER_SUPPLY 1 (M80,M81)
Marlin1.1.8
Octoprint
TMC2130 X,Y
DRV8825 Z,E

Sorry for lengthy story but I'm pulling my hair out and I've googlized a bunch. Thanks for your work.
I can't get any stepper, with a TMC2130 driving it, to move with "my setup". Installed with Tom's Instructions and rechecked wiring many times. Removed TMC2130s and re-connected DRV8825s and steppers work. Put TMC2130s back in and nothing. Uploaded the example provided, here, and realized I have no way to power Ramps using M80,M81 through the example sketch. Dug out 12V PSU and connected power to Ramps and no movement (previously uploaded the example sketch). With 12V PSU still on, uploaded example sketch and VOILA!! X axis movement. Very harsh vibrating, definitely not good. Commented out "stealthchop" in example then re-uploaded and movement was definitely worse. Played with motor current in example sketch and found 800mA to be best but still horrible vibrations. Easilly able to reverse x-direction by pushing carriage in opposite direction. Looks like all communication is functioning with the example sketch but not with Marlin. I've checked pins_Ramps.h and its correct. Changed _CS to 4 and 5 and rewired. Nothing. M122 S1 shows register/hex changes when I try to home but no movement.

24V vs 12V issues??
Do the TMC2130 drivers need power at the time of Mega2560 boot to function?
Any help at this time is appreciated. Thank you.

Can't compile in Arduino IDE, "Update TMC2130Stepper library to 2.2.1 or newer."

I configured my Marlin for my new TMC2130 v1.1 today and when I hit the verify button I received this error:

`
In file included from sketch\MarlinConfig.h:39:0,

             from sketch\G26_Mesh_Validation_Tool.cpp:27:

SanityCheck.h:1439: error: #error "Update TMC2130Stepper library to 2.2.1 or newer."

 #error "Update TMC2130Stepper library to 2.2.1 or newer."

  ^

exit status 1
#error "Update TMC2130Stepper library to 2.2.1 or newer."
`
**I have installed the library from Arduino 2.3.0 and tried downloading it from GitHub, I also tried version 2.2.1 but still no luck. I also tried different Arduino IDE versions but still no luck. Have anyone got any idea how to fix it.

If you need the TMC2130 part from the configuration_adv.h here it is:**
// @section tmc_smart

/**

  • Enable this for SilentStepStick Trinamic TMC2130 SPI-configurable stepper drivers.
  • You'll also need the TMC2130Stepper Arduino library
  • (https://github.com/teemuatlut/TMC2130Stepper).
  • To use TMC2130 stepper drivers in SPI mode connect your SPI pins to
  • the hardware SPI interface on your board and define the required CS pins
  • in your pins_MYBOARD.h file. (e.g., RAMPS 1.4 uses AUX3 pins X_CS_PIN 53, Y_CS_PIN 49, etc.).
  • You may also use software SPI if you wish to use general purpose IO pins.
    */
    #define HAVE_TMC2130
    #if ENABLED(HAVE_TMC2130) // Choose your axes here. This is mandatory!
    #define X_IS_TMC2130
    //#define X2_IS_TMC2130
    #define Y_IS_TMC2130
    //#define Y2_IS_TMC2130
    #define Z_IS_TMC2130
    //#define Z2_IS_TMC2130
    #define E0_IS_TMC2130
    #define E1_IS_TMC2130
    //#define E2_IS_TMC2130
    //#define E3_IS_TMC2130
    //#define E4_IS_TMC2130
    #endif

/**

  • Enable this for SilentStepStick Trinamic TMC2208 UART-configurable stepper drivers.
  • Connect #_SERIAL_TX_PIN to the driver side PDN_UART pin with a 1K resistor.
  • To use the reading capabilities, also connect #_SERIAL_RX_PIN
  • to PDN_UART without a resistor.
  • The drivers can also be used with hardware serial.
  • You'll also need the TMC2208Stepper Arduino library
  • (https://github.com/teemuatlut/TMC2208Stepper).
    */
    //#define HAVE_TMC2208
    #if ENABLED(HAVE_TMC2208) // Choose your axes here. This is mandatory!
    //#define X_IS_TMC2208
    //#define X2_IS_TMC2208
    //#define Y_IS_TMC2208
    //#define Y2_IS_TMC2208
    //#define Z_IS_TMC2208
    //#define Z2_IS_TMC2208
    //#define E0_IS_TMC2208
    //#define E1_IS_TMC2208
    //#define E2_IS_TMC2208
    //#define E3_IS_TMC2208
    //#define E4_IS_TMC2208
    #endif

#if ENABLED(HAVE_TMC2130) || ENABLED(HAVE_TMC2208)

#define R_SENSE 0.11 // R_sense resistor for SilentStepStick2130
#define HOLD_MULTIPLIER 0.5 // Scales down the holding current from run current
#define INTERPOLATE true // Interpolate X/Y/Z_MICROSTEPS to 256

#define X_CURRENT 600 // rms current in mA. Multiply by 1.41 for peak current.
#define X_MICROSTEPS 16 // 0..256

#define Y_CURRENT 600
#define Y_MICROSTEPS 16

#define Z_CURRENT 700
#define Z_MICROSTEPS 16

#define X2_CURRENT 800
#define X2_MICROSTEPS 16

#define Y2_CURRENT 800
#define Y2_MICROSTEPS 16

#define Z2_CURRENT 800
#define Z2_MICROSTEPS 16

#define E0_CURRENT 600
#define E0_MICROSTEPS 16

#define E1_CURRENT 600
#define E1_MICROSTEPS 16

#define E2_CURRENT 800
#define E2_MICROSTEPS 16

#define E3_CURRENT 800
#define E3_MICROSTEPS 16

#define E4_CURRENT 800
#define E4_MICROSTEPS 16

/**

  • Use software SPI for TMC2130.
  • The default SW SPI pins are defined the respective pins files,
  • but you can override or define them here.
    */
    //#define TMC_USE_SW_SPI
    //#define TMC_SW_MOSI -1
    //#define TMC_SW_MISO -1
    //#define TMC_SW_SCK -1

/**

  • Use Trinamic's ultra quiet stepping mode.
  • When disabled, Marlin will use spreadCycle stepping mode.
    */
    #define STEALTHCHOP

/**

  • Monitor Trinamic TMC2130 and TMC2208 drivers for error conditions,
  • like overtemperature and short to ground. TMC2208 requires hardware serial.
  • In the case of overtemperature Marlin can decrease the driver current until error condition clears.
  • Other detected conditions can be used to stop the current print.
  • Relevant g-codes:
  • M906 - Set or get motor current in milliamps using axis codes X, Y, Z, E. Report values if no axis codes given.
  • M911 - Report stepper driver overtemperature pre-warn condition.
  • M912 - Clear stepper driver overtemperature pre-warn condition flag.
  • M122 S0/1 - Report driver parameters (Requires TMC_DEBUG)
    */
    //#define MONITOR_DRIVER_STATUS

#if ENABLED(MONITOR_DRIVER_STATUS)
#define CURRENT_STEP_DOWN 50 // [mA]
#define REPORT_CURRENT_CHANGE
#define STOP_ON_ERROR
#endif

/**

  • The driver will switch to spreadCycle when stepper speed is over HYBRID_THRESHOLD.
  • This mode allows for faster movements at the expense of higher noise levels.
  • STEALTHCHOP needs to be enabled.
  • M913 X/Y/Z/E to live tune the setting
    */
    //#define HYBRID_THRESHOLD

#define X_HYBRID_THRESHOLD 100 // [mm/s]
#define X2_HYBRID_THRESHOLD 100
#define Y_HYBRID_THRESHOLD 100
#define Y2_HYBRID_THRESHOLD 100
#define Z_HYBRID_THRESHOLD 3
#define Z2_HYBRID_THRESHOLD 3
#define E0_HYBRID_THRESHOLD 30
#define E1_HYBRID_THRESHOLD 30
#define E2_HYBRID_THRESHOLD 30
#define E3_HYBRID_THRESHOLD 30
#define E4_HYBRID_THRESHOLD 30

/**

  • Use stallGuard2 to sense an obstacle and trigger an endstop.
  • You need to place a wire from the driver's DIAG1 pin to the X/Y endstop pin.
  • X, Y, and Z homing will always be done in spreadCycle mode.
  • X/Y/Z_HOMING_SENSITIVITY is used for tuning the trigger sensitivity.
  • Higher values make the system LESS sensitive.
  • Lower value make the system MORE sensitive.
  • Too low values can lead to false positives, while too high values will collide the axis without triggering.
  • It is advised to set X/Y/Z_HOME_BUMP_MM to 0.
  • M914 X/Y/Z to live tune the setting
    */
    //#define SENSORLESS_HOMING // TMC2130 only

#if ENABLED(SENSORLESS_HOMING)
#define X_HOMING_SENSITIVITY 8
#define Y_HOMING_SENSITIVITY 8
#define Z_HOMING_SENSITIVITY 8
#endif

/**

  • Enable M122 debugging command for TMC stepper drivers.
  • M122 S0/1 will enable continous reporting.
    */
    #define TMC_DEBUG

/**

  • M915 Z Axis Calibration
    • Adjust Z stepper current,
    • Drive the Z axis to its physical maximum, and
    • Home Z to account for the lost steps.
  • Use M915 Snn to specify the current.
  • Use M925 Znn to add extra Z height to Z_MAX_POS.
    */
    //#define TMC_Z_CALIBRATION
    #if ENABLED(TMC_Z_CALIBRATION)
    #define CALIBRATION_CURRENT 250
    #define CALIBRATION_EXTRA_HEIGHT 10
    #endif

/**

#endif // TMC2130 || TMC2208

ESP32 Compatibilty

First, thank you for spending the time to create this library. I appreciate it very much.

When compiling for an ESP32 device, I receive the following errors. I am assuming the library is not compatible with ESP32 correct?

WARNING: library TMC2130Stepper claims to run on (avr, sam) architecture(s) and may be incompatible with your current board which runs on (esp32) architecture(s).

StallGuardESP32:90: error: expected constructor, destructor, or type conversion before '(' token

 ISR(TIMER1_COMPA_vect){

     ^

In function 'void setup()':

StallGuardESP32:71: error: 'TCCR1A' was not declared in this scope

     TCCR1A = 0;// set entire TCCR1A register to 0

     ^

StallGuardESP32:72: error: 'TCCR1B' was not declared in this scope

     TCCR1B = 0;// same for TCCR1B

     ^

StallGuardESP32:73: error: 'TCNT1' was not declared in this scope

     TCNT1  = 0;//initialize counter value to 0

     ^

StallGuardESP32:74: error: 'OCR1A' was not declared in this scope

     OCR1A = 60;// = (16*10^6) / (1*1024) - 1 (must be <65536)

     ^

StallGuardESP32:76: error: 'WGM12' was not declared in this scope

     TCCR1B |= (1 << WGM12);

                     ^

StallGuardESP32:78: error: 'CS11' was not declared in this scope

     TCCR1B |= (1 << CS11);// | (1 << CS10);  

                     ^

StallGuardESP32:80: error: 'TIMSK1' was not declared in this scope

     TIMSK1 |= (1 << OCIE1A);

     ^

StallGuardESP32:80: error: 'OCIE1A' was not declared in this scope

     TIMSK1 |= (1 << OCIE1A);

                     ^

StallGuardESP32:90: error: expected constructor, destructor, or type conversion before '(' token

 ISR(TIMER1_COMPA_vect){

    ^

StallGuardESP32:102: error: 'TIMSK1' was not declared in this scope

     if (read_byte == '0')      { TIMSK1 &= ~(1 << OCIE1A); digitalWrite( EN_PIN, HIGH ); }

                                  ^

StallGuardESP32:102: error: 'OCIE1A' was not declared in this scope

     if (read_byte == '0')      { TIMSK1 &= ~(1 << OCIE1A); digitalWrite( EN_PIN, HIGH ); }

                                                   ^

StallGuardESP32:103: error: 'TIMSK1' was not declared in this scope

     else if (read_byte == '1') { TIMSK1 |=  (1 << OCIE1A); digitalWrite( EN_PIN,  LOW ); }

                                  ^

StallGuardESP32:103: error: 'OCIE1A' was not declared in this scope

     else if (read_byte == '1') { TIMSK1 |=  (1 << OCIE1A); digitalWrite( EN_PIN,  LOW ); }

                                                   ^

StallGuardESP32:104: error: 'OCR1A' was not declared in this scope

     else if (read_byte == '+') if (OCR1A > MAX_SPEED) OCR1A -= 20;

                                    ^

StallGuardESP32:104: error: suggest explicit braces to avoid ambiguous 'else' [-Werror=parentheses]

     else if (read_byte == '+') if (OCR1A > MAX_SPEED) OCR1A -= 20;

             ^

cc1plus.exe: some warnings being treated as errors

Using library SPI at version 1.0
Using library TMC2130Stepper at version 2.3.0

exit status 1

expected constructor, destructor, or type conversion before '(' token

TMC2130 only reading 0xFF:FF:FF:FF on all drivers

Uploaded my firmware today and tried moving an axis using G1 X10 it and nothing happened, so sent M122 and it sent back
SENDING:M122 X Y Z E0 Enabled true false false false Set current 800 800 800 800 RMS current 795 795 795 795 MAX current 1121 1121 1121 1121 Run current 25/31 25/31 25/31 25/31 Hold current 12/31 12/31 12/31 12/31 CS actual 31/31 31/31 31/31 31/31 PWM scale 255 255 255 255 vsense 1=.18 1=.18 1=.18 1=.18 stealthChop true true true true msteps 0 0 0 0 tstep 4294967295 4294967295 4294967295 4294967295 pwm threshold 0 0 0 0 [mm/s] - - - - OT prewarn true true true true OT prewarn has been triggered false false false false off time 15 15 15 15 blank time 54 54 54 54 hysteresis -end 12 12 12 12 -start 8 8 8 8 Stallguard thrs 8 8 0 0 DRVSTATUS X Y Z E0 stallguard X X X X sg_result 1023 1023 1023 1023 fsactive X X X X stst X X X X olb X X X X ola X X X X s2gb X X X X s2ga X X X X otpw X X X X ot X X X X Driver registers: X = 0xFF:FF:FF:FF Y = 0xFF:FF:FF:FF Z = 0xFF:FF:FF:FF E0 = 0xFF:FF:FF:FF

Here are my Config files (conf.h conf_adv.h):

Conf files.zip

I put everything together using:
MKS_Gen-L_TMC2130_SPI_Sensor-less_Homing_Wiring_Diagram.pdf

What should I do now to get it all working?

Double Stepping when combined with Marlin 1.1.8

Hi,

I'm using Marlin 1.1.8 and when combined with v2.0.2 I have no issues, everything works great.
However when updating to any version of TMC2130Stepper newer than this, all movements travel twice as far. No changes to Marlin.

I tried the latest bugfix branch of Marlin incase it was an interaction between the two libraries, however it still doesnt work.

Thanks
Matt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.