TMCStepper icon indicating copy to clipboard operation
TMCStepper copied to clipboard

Counting steps

Open jmaruska opened this issue 4 years ago • 1 comments

I am driving a motor via UART and a TMC2208.

VACTUAL sets a velocity, and the example uses delay to timeout that call. However, I would like to run the motor for X-number of steps, then do something else. Should I be able to read the steps with something like:

  uint16_t _step = driver.MSCNT();
  Serial.print ("step: ");
  Serial.println(_step);

~All I get are zeroes.~

EDIT: I changed the pins I was using for my soft serial (from 9, 10 to 10, 11 on a Leonardo) and I get data back. Not sure what to make of it. With VACTUAL(1600); I get this output:

step: 0 step: 814 step: 0 step: 837 step: 846 step: 0 step: 874 step: 883 step: 892 step: 901 step: 910 step: 919 step: 928 step: 942 step: 951 step: 960 step: 969 step: 978 step: 987 step: 996 step: 1005 step: 1014 step: 1023 step: 14 step: 23 step: 32 step: 41 step: 50 step: 59

I would have thought it would have been more incremental?

Thanks, J.

jmaruska avatar Jul 31 '21 19:07 jmaruska

The MSCNT is a the microstep count from 0-1023 in between fullsteps. It's theoretically possible to do this IF you can manage to read the counter value multiple times within one fullstep. This will limit to you to low speeds. If for example you reserve 20ms for a single read and do two read operations per full step, you can only do 25 fullsteps per second or 7.5rpm. I suggest using step and dir signals. The TMC5130 and TMC5160 are also options as they have an internal ramp generator.

teemuatlut avatar Aug 18 '21 18:08 teemuatlut