teemuatlut / TMCStepper

MIT License
479 stars 188 forks source link

TMC2208Stepper::VACTUAL is uint32_t, but must be signed datatype #281

Open RalfR68 opened 10 months ago

RalfR68 commented 10 months ago

VACTUAL is a signed 24 bit value (sign=motor run direction) and therefore needs to be declared as signed long, not unsigned. Currently, only positive values are returned, even if the motor runs in "negative" direction. This put me to trouble when using VACTUAL to run the motor, and using an interrupt routine to count INDEX pulses and checking VACTUAL sign to determine current direction.

File TMC2208Stepper.cpp (lines 328ff): void TMC2208Stepper::VACTUAL(uint32_t input) // change to int32_t uint32_t TMC2208Stepper::VACTUAL() // change to int32_t

Proof: When I typecast the return value of VACTUAL to (signed long), everything works fine.

PS: Great library, saved me loads of work! Great work!