Giter Club home page Giter Club logo

Comments (8)

teemuatlut avatar teemuatlut commented on July 29, 2024 1

If CS should be below 16, then set vsense to true.
If CS should be over 16, then vsense should be false, so we test and reset it if it was set. If vsense was not set, then there's no need to write it.

Sure a mere write is faster than a read and write and that's why it was removed in TMCStepper.

My first suggestion is to move on to the newer TMCStepper library that superseded this one.
If you want to stick with this library, after setting the current, read back the chopconf and ihold_irun registers.
The motor should react to step inputs if toff > 0, irun > 0 and en pin is low.
Vsense itself doesn't prevent the motor from spinning but when reading back the value with vsense(), the read operation will overwrite the cached register value which is then modified and pushed to the register. If the read fails and reads 0, then you'll be writing toff = 0 to the driver, effectively disabling it. When you removed the vsense() call, the cached register was no longer overwritten with an invalid value and it seemed to be fixing everything.
So the likely cause for now is an issue with read operations.

from tmc2130stepper.

dev-000 avatar dev-000 commented on July 29, 2024 1

Migrated to the new TMCStepper library. Got it working fine with my setup.
Good that you added the note to ReadMe to help anyone use the newer library from now.

Thanks again for all the help. 😃

from tmc2130stepper.

dev-000 avatar dev-000 commented on July 29, 2024

Thanks for the fast response.
I didn't know about the overwriting of the register on a failed read. I presume that's what is happening here. When I am reading vsense(), I was always getting a zero.

I had tried the newer TMCStepper library but couldn't get it working with my setup. But I didn't spend any time trying to figure out why it wasn't working. Let me try the new library once again and report back. If it works, I can get going with that. I presume the same initialization commands and functions should work for the new library as well?

from tmc2130stepper.

dev-000 avatar dev-000 commented on July 29, 2024

Seems the same issue of vsense persists in the newer library too.

For IRMS<=872mA(CS<16 limit for Rsense = 0.12Ω), driver.rms_current() still returns a wrong value. vsense seems to be stuck at zero.
But the motor runs in both cases though.

I just saw that someone else has opened an issue on this same problem in the new library too. I will post there from now on if there is a fix.

from tmc2130stepper.

teemuatlut avatar teemuatlut commented on July 29, 2024

Arduino Nano 33 IOT with TMCStepper@master

#include <TMCStepper.h>

#define EN_PIN            3 // Enable
#define STEP_PIN          2 // Step
#define CS_PIN           10 // Chip select
#define R_SENSE 0.11f // Match to your driver

// Select your stepper driver type
TMC2130Stepper driver(CS_PIN, R_SENSE);                           // Hardware SPI

void setup() {
  delay(2000);
  pinMode(EN_PIN, OUTPUT);
  pinMode(STEP_PIN, OUTPUT);
  digitalWrite(EN_PIN, HIGH);
  Serial.begin(9600);
  while(!Serial);
  Serial.println("########## " __TIME__ " ########");

  SPI.begin();
  driver.begin();

  driver.rms_current(600);        // Set motor RMS current
  Serial.print("vsense = ");
  Serial.print(driver.vsense());
  Serial.print("\trms_current = ");
  Serial.print(driver.rms_current());
  Serial.print("\tirun = ");
  Serial.println(driver.irun());

  driver.rms_current(1000);        // Set motor RMS current
  Serial.print("vsense = ");
  Serial.print(driver.vsense());
  Serial.print("\trms_current = ");
  Serial.print(driver.rms_current());
  Serial.print("\tirun = ");
  Serial.println(driver.irun());
}

void loop() {}

For me returns:

########## 23:44:04 ########
vsense = 1	rms_current = 581	irun = 18
vsense = 0	rms_current = 994	irun = 17

from tmc2130stepper.

dev-000 avatar dev-000 commented on July 29, 2024

Thanks for taking the time to check this.
I tried your same code on my first setup(Custom TMC2130 + Atsamd21 board) changing only the pin numbers. I got the following

vsense = 0 rms_current = 1077 irun = 20
vsense = 0 rms_current = 974 irun = 18

which corresponds to the fact that vsense is not getting set(or not getting read properly)

To explore why this was happening, I went back to a normal Atsamd21 M0 Adafruit feather board and original TMC SilentStepStick SPI board setup. Made wire connections between them. For the same connections and the same code, I get the output the same as you reported.

vsense = 1 rms_current = 581 irun = 18
vsense = 0 rms_current = 994 irun = 17

It seems then that the TMCStepper library is working and I am starting to suspect that it might be a hardware issue in my custom board. I don't think its an SPI connection issue as its soldered on. Now when I am rechecking the TMC SilentStepStick schematic and mine(Attached below), seems that I left AIN_IREF open. But I am unsure if that will cause this issue which we are discussing.

TMC

Any tips on debugging this issue on my custom board? It's a TQFP48 package. I am unclear why there might be a read/write issue (as the motor is configured and running).

from tmc2130stepper.

teemuatlut avatar teemuatlut commented on July 29, 2024

Hardware design is not really my strong suite. My first thought was the unconnected SPI_MODE pin but according to the datasheet that should have a pullup resistor and so should be fine. Maybe you can try pulling it to 3.3 none-the-less.

AIN_VREF is only used if I_scale_analog is enabled in gconf register.

Can you successfully read the IOIN register?

Also you may need to get into debugging with a logic analyzer or an oscope if there are no obvious issues.

from tmc2130stepper.

dev-000 avatar dev-000 commented on July 29, 2024

I tried reading IOIN register with driver.IOIN() but it keeps returning zero. So I am guessing it's not reading(It's reading fine in Feather M0 + TMCsilentstep setup).
I am unclear as to how a write( for configurations) is possible and yet read keeps failing.
Regarding the 3V3 pullups, I didn't give that for the same reasons you mentioned. I am unsure about AIN_VREF though as there is no pullup there. But I am using that in my code also.
I have to really dig deep into checking what's wrong.

from tmc2130stepper.

Related Issues (20)

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.